From 00bd014cdd0082b1e75aab0f69c0d47869cfd908 Mon Sep 17 00:00:00 2001 From: Bastien Riviere Date: Mon, 29 Jan 2024 19:19:50 +0100 Subject: [PATCH] chore: create openapi document --- README.md | 4 +++ openapi.yaml | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 openapi.yaml diff --git a/README.md b/README.md index b11546d..db6d54d 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,10 @@ URL Shortener written in Go. > [!NOTE] > If you are using [Nix](https://nixos.org/), you can just run `nix develop .` or `direnv allow` if you use Direnv. +## Dev dependencies + +- [ogen](https://github.com/ogen-go/ogen#install) to generate OpenAPI server + # Running the app Once you have installed all requirements, you can simply do: diff --git a/openapi.yaml b/openapi.yaml new file mode 100644 index 0000000..b7bebb8 --- /dev/null +++ b/openapi.yaml @@ -0,0 +1,69 @@ +openapi: 3.0.3 +info: + title: URL shortener + version: 0.1.0 + description: An URL shortener service. +paths: + "/{hash}": + get: + responses: + "307": + description: Redirect client to long URL. + headers: + Location: + schema: + type: string + description: Long URL + "404": + description: Not Found + description: Redirect client to long URL. + parameters: + - schema: + type: string + name: hash + in: path + required: true + description: Hash of shorten URL. + /create: + post: + requestBody: + description: Create a shorten URL + required: true + content: + application/json: + schema: + type: object + properties: + url: + type: string + description: URL to shorten + example: "https://example.com" + required: + - url + responses: + "201": + description: Succesfully created shorten URL. + content: + application/json: + schema: + type: object + properties: + shorten: + type: string + description: Created shorten URL. Going to this URL should redirect to URL from request body. + examples: {} + "400": + description: Bad Request + content: + application/json: + schema: + type: object + properties: + message: + type: string + examples: + Example 1: + value: + message: URL already exist. +components: + schemas: {}