From 1e1cd261dd9c944f595c9023c8aa3e76aae751af Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Thu, 5 Jan 2023 21:10:26 -0500 Subject: Start on swagger docs --- docs/docs.go | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ docs/swagger.json | 158 +++++++++++++++++++++++++++++++++++++++++++++++ docs/swagger.yaml | 108 ++++++++++++++++++++++++++++++++ 3 files changed, 448 insertions(+) create mode 100644 docs/docs.go create mode 100644 docs/swagger.json create mode 100644 docs/swagger.yaml (limited to 'docs') diff --git a/docs/docs.go b/docs/docs.go new file mode 100644 index 0000000..95e9128 --- /dev/null +++ b/docs/docs.go @@ -0,0 +1,182 @@ +// Package docs GENERATED BY SWAG; DO NOT EDIT +// This file was generated by swaggo/swag +package docs + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": { + "name": "Mitchell Riedstra", + "url": "https://riedstra.dev", + "email": "mitch@riedstra.dev" + }, + "license": { + "name": "ISC" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/v0/del/{id}": { + "delete": { + "description": "Remove a paste from the filesystem", + "produces": [ + "text/plain" + ], + "tags": [ + "v0" + ], + "summary": "Deletes a paste for a given ID", + "parameters": [ + { + "type": "string", + "description": "Paste ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/v0/view/{id}": { + "get": { + "description": "Fetches the contents of a paste if given an ID", + "produces": [ + "text/plain" + ], + "tags": [ + "v0" + ], + "summary": "View a paste for a given ID", + "parameters": [ + { + "type": "string", + "description": "Paste ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/v1/del/{id}": { + "delete": { + "description": "Remove a paste from the filesystem", + "produces": [ + "application/json" + ], + "tags": [ + "v1" + ], + "summary": "Deletes a paste for a given ID", + "parameters": [ + { + "type": "string", + "description": "Paste ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/v1/getToken": { + "post": { + "description": "Returns an API key that's valid for a pre-determined amount of hours", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "v1" + ], + "summary": "Get an API key with valid credentials", + "parameters": [ + { + "description": "User Credentials", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/main.Credentials" + } + } + ], + "responses": {} + } + }, + "/v1/view/{id}": { + "get": { + "description": "Fetches the contents of a paste if given an ID", + "produces": [ + "application/json" + ], + "tags": [ + "v1" + ], + "summary": "View a paste for a given ID", + "parameters": [ + { + "type": "string", + "description": "Paste ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + } + }, + "definitions": { + "main.Credentials": { + "description": "User's credentials", + "type": "object", + "properties": { + "Password": { + "type": "string" + }, + "Username": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + }, + "BasicAuth": { + "type": "basic" + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0", + Host: "", + BasePath: "/api", + Schemes: []string{}, + Title: "Simple Pastebin API", + Description: "User's credentials", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/docs/swagger.json b/docs/swagger.json new file mode 100644 index 0000000..27c60a0 --- /dev/null +++ b/docs/swagger.json @@ -0,0 +1,158 @@ +{ + "swagger": "2.0", + "info": { + "description": "User's credentials", + "title": "Simple Pastebin API", + "contact": { + "name": "Mitchell Riedstra", + "url": "https://riedstra.dev", + "email": "mitch@riedstra.dev" + }, + "license": { + "name": "ISC" + }, + "version": "1.0" + }, + "basePath": "/api", + "paths": { + "/v0/del/{id}": { + "delete": { + "description": "Remove a paste from the filesystem", + "produces": [ + "text/plain" + ], + "tags": [ + "v0" + ], + "summary": "Deletes a paste for a given ID", + "parameters": [ + { + "type": "string", + "description": "Paste ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/v0/view/{id}": { + "get": { + "description": "Fetches the contents of a paste if given an ID", + "produces": [ + "text/plain" + ], + "tags": [ + "v0" + ], + "summary": "View a paste for a given ID", + "parameters": [ + { + "type": "string", + "description": "Paste ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/v1/del/{id}": { + "delete": { + "description": "Remove a paste from the filesystem", + "produces": [ + "application/json" + ], + "tags": [ + "v1" + ], + "summary": "Deletes a paste for a given ID", + "parameters": [ + { + "type": "string", + "description": "Paste ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + }, + "/v1/getToken": { + "post": { + "description": "Returns an API key that's valid for a pre-determined amount of hours", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "v1" + ], + "summary": "Get an API key with valid credentials", + "parameters": [ + { + "description": "User Credentials", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/main.Credentials" + } + } + ], + "responses": {} + } + }, + "/v1/view/{id}": { + "get": { + "description": "Fetches the contents of a paste if given an ID", + "produces": [ + "application/json" + ], + "tags": [ + "v1" + ], + "summary": "View a paste for a given ID", + "parameters": [ + { + "type": "string", + "description": "Paste ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": {} + } + } + }, + "definitions": { + "main.Credentials": { + "description": "User's credentials", + "type": "object", + "properties": { + "Password": { + "type": "string" + }, + "Username": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + }, + "BasicAuth": { + "type": "basic" + } + } +} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml new file mode 100644 index 0000000..bcff994 --- /dev/null +++ b/docs/swagger.yaml @@ -0,0 +1,108 @@ +basePath: /api +definitions: + main.Credentials: + description: User's credentials + properties: + Password: + type: string + Username: + type: string + type: object +info: + contact: + email: mitch@riedstra.dev + name: Mitchell Riedstra + url: https://riedstra.dev + description: User's credentials + license: + name: ISC + title: Simple Pastebin API + version: "1.0" +paths: + /v0/del/{id}: + delete: + description: Remove a paste from the filesystem + parameters: + - description: Paste ID + in: path + name: id + required: true + type: string + produces: + - text/plain + responses: {} + summary: Deletes a paste for a given ID + tags: + - v0 + /v0/view/{id}: + get: + description: Fetches the contents of a paste if given an ID + parameters: + - description: Paste ID + in: path + name: id + required: true + type: string + produces: + - text/plain + responses: {} + summary: View a paste for a given ID + tags: + - v0 + /v1/del/{id}: + delete: + description: Remove a paste from the filesystem + parameters: + - description: Paste ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: {} + summary: Deletes a paste for a given ID + tags: + - v1 + /v1/getToken: + post: + consumes: + - application/json + description: Returns an API key that's valid for a pre-determined amount of + hours + parameters: + - description: User Credentials + in: body + name: request + required: true + schema: + $ref: '#/definitions/main.Credentials' + produces: + - application/json + responses: {} + summary: Get an API key with valid credentials + tags: + - v1 + /v1/view/{id}: + get: + description: Fetches the contents of a paste if given an ID + parameters: + - description: Paste ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: {} + summary: View a paste for a given ID + tags: + - v1 +securityDefinitions: + "": + in: header + name: Authorization + type: apiKey + BasicAuth: + type: basic +swagger: "2.0" -- cgit v1.2.3