From 1aebe89e334d587b6ef35d98fb302e89eabb82f3 Mon Sep 17 00:00:00 2001 From: nquidox Date: Sun, 6 Jul 2025 22:29:48 +0300 Subject: [PATCH] swagger docs --- docs/docs.go | 280 ++++++++++++++++++++++++++++++++++++++++++++++ docs/swagger.json | 254 +++++++++++++++++++++++++++++++++++++++++ docs/swagger.yaml | 162 +++++++++++++++++++++++++++ gen-swag.sh | 3 + 4 files changed, 699 insertions(+) create mode 100644 docs/docs.go create mode 100644 docs/swagger.json create mode 100644 docs/swagger.yaml create mode 100755 gen-swag.sh diff --git a/docs/docs.go b/docs/docs.go new file mode 100644 index 0000000..ba60ef2 --- /dev/null +++ b/docs/docs.go @@ -0,0 +1,280 @@ +// Package docs Code generated by swaggo/swag. DO NOT EDIT +package docs + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": {}, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/user": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Получает информацию о пользователе по его uuid из токена", + "tags": [ + "Users" + ], + "summary": "Получить информацию о пользователе", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.Info" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse400" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse401" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse500" + } + } + } + }, + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Обновить информацию о пользователе по его uuid из токена", + "consumes": [ + "application/json" + ], + "tags": [ + "Users" + ], + "summary": "Обновить информацию о пользователе", + "parameters": [ + { + "description": "изменения", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user.Update" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse400" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse401" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse500" + } + } + } + }, + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Регистрация нового пользователя", + "consumes": [ + "application/json" + ], + "tags": [ + "Users" + ], + "summary": "Регистрация нового пользователя", + "parameters": [ + { + "description": "новый пользователь", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user.Register" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse400" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse500" + } + } + } + }, + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Помечает пользователя как удаленного по его uuid из токена", + "tags": [ + "Users" + ], + "summary": "Удалить пользователя", + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse400" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse401" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse500" + } + } + } + } + } + }, + "definitions": { + "responses.ErrorResponse400": { + "type": "object", + "properties": { + "error": { + "type": "string", + "example": "Bad Request" + } + } + }, + "responses.ErrorResponse401": { + "type": "object", + "properties": { + "error": { + "type": "string", + "example": "Unauthorized" + } + } + }, + "responses.ErrorResponse500": { + "type": "object", + "properties": { + "error": { + "type": "string", + "example": "Internal Server Error" + } + } + }, + "user.Info": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "email": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "user.Register": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "user.Update": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "username": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "BearerAuth": { + "description": "Введите \"Bearer {your_token}\" для аутентификации", + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "2.0.0-alpha", + Host: "", + BasePath: "/api/v2", + Schemes: []string{}, + Title: "Merch Parser", + Description: "", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/docs/swagger.json b/docs/swagger.json new file mode 100644 index 0000000..9b69fc8 --- /dev/null +++ b/docs/swagger.json @@ -0,0 +1,254 @@ +{ + "swagger": "2.0", + "info": { + "title": "Merch Parser", + "contact": {}, + "version": "2.0.0-alpha" + }, + "basePath": "/api/v2", + "paths": { + "/user": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Получает информацию о пользователе по его uuid из токена", + "tags": [ + "Users" + ], + "summary": "Получить информацию о пользователе", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.Info" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse400" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse401" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse500" + } + } + } + }, + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Обновить информацию о пользователе по его uuid из токена", + "consumes": [ + "application/json" + ], + "tags": [ + "Users" + ], + "summary": "Обновить информацию о пользователе", + "parameters": [ + { + "description": "изменения", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user.Update" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse400" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse401" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse500" + } + } + } + }, + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Регистрация нового пользователя", + "consumes": [ + "application/json" + ], + "tags": [ + "Users" + ], + "summary": "Регистрация нового пользователя", + "parameters": [ + { + "description": "новый пользователь", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user.Register" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse400" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse500" + } + } + } + }, + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Помечает пользователя как удаленного по его uuid из токена", + "tags": [ + "Users" + ], + "summary": "Удалить пользователя", + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse400" + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse401" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/responses.ErrorResponse500" + } + } + } + } + } + }, + "definitions": { + "responses.ErrorResponse400": { + "type": "object", + "properties": { + "error": { + "type": "string", + "example": "Bad Request" + } + } + }, + "responses.ErrorResponse401": { + "type": "object", + "properties": { + "error": { + "type": "string", + "example": "Unauthorized" + } + } + }, + "responses.ErrorResponse500": { + "type": "object", + "properties": { + "error": { + "type": "string", + "example": "Internal Server Error" + } + } + }, + "user.Info": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "email": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "user.Register": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "user.Update": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "username": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "BearerAuth": { + "description": "Введите \"Bearer {your_token}\" для аутентификации", + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + } +} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml new file mode 100644 index 0000000..932ec30 --- /dev/null +++ b/docs/swagger.yaml @@ -0,0 +1,162 @@ +basePath: /api/v2 +definitions: + responses.ErrorResponse400: + properties: + error: + example: Bad Request + type: string + type: object + responses.ErrorResponse401: + properties: + error: + example: Unauthorized + type: string + type: object + responses.ErrorResponse500: + properties: + error: + example: Internal Server Error + type: string + type: object + user.Info: + properties: + created_at: + type: string + email: + type: string + username: + type: string + type: object + user.Register: + properties: + email: + type: string + password: + type: string + username: + type: string + type: object + user.Update: + properties: + email: + type: string + username: + type: string + type: object +info: + contact: {} + title: Merch Parser + version: 2.0.0-alpha +paths: + /user: + delete: + description: Помечает пользователя как удаленного по его uuid из токена + responses: + "200": + description: OK + "400": + description: Bad Request + schema: + $ref: '#/definitions/responses.ErrorResponse400' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/responses.ErrorResponse401' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/responses.ErrorResponse500' + security: + - BearerAuth: [] + summary: Удалить пользователя + tags: + - Users + get: + description: Получает информацию о пользователе по его uuid из токена + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.Info' + "400": + description: Bad Request + schema: + $ref: '#/definitions/responses.ErrorResponse400' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/responses.ErrorResponse401' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/responses.ErrorResponse500' + security: + - BearerAuth: [] + summary: Получить информацию о пользователе + tags: + - Users + post: + consumes: + - application/json + description: Регистрация нового пользователя + parameters: + - description: новый пользователь + in: body + name: body + required: true + schema: + $ref: '#/definitions/user.Register' + responses: + "200": + description: OK + "400": + description: Bad Request + schema: + $ref: '#/definitions/responses.ErrorResponse400' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/responses.ErrorResponse500' + security: + - BearerAuth: [] + summary: Регистрация нового пользователя + tags: + - Users + put: + consumes: + - application/json + description: Обновить информацию о пользователе по его uuid из токена + parameters: + - description: изменения + in: body + name: body + required: true + schema: + $ref: '#/definitions/user.Update' + responses: + "200": + description: OK + "400": + description: Bad Request + schema: + $ref: '#/definitions/responses.ErrorResponse400' + "401": + description: Unauthorized + schema: + $ref: '#/definitions/responses.ErrorResponse401' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/responses.ErrorResponse500' + security: + - BearerAuth: [] + summary: Обновить информацию о пользователе + tags: + - Users +securityDefinitions: + BearerAuth: + description: Введите "Bearer {your_token}" для аутентификации + in: header + name: Authorization + type: apiKey +swagger: "2.0" diff --git a/gen-swag.sh b/gen-swag.sh new file mode 100755 index 0000000..7f9f5fc --- /dev/null +++ b/gen-swag.sh @@ -0,0 +1,3 @@ +#!/bin/bash +swag f +swag init -g cmd/main.go