/
nsstnc
/
lab1-api
Обзор
Документация
Войти
/
nsstnc
/
lab1-api
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
services/api-gateway/docs/docs.go
895 строк
31 KB
nsstnc
Поправил аннотации к ручкам авторизации
18 ноя 2025, 22:11
18 ноя 2025, 22:11
0edae89
Код
Авторство
О чём код?
// 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": { "name": "Dev" }, "version": "{{.Version}}" }, "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { "/internal/v1/books/count": { "get": { "description": "Возвращает общее количество книг в системе. Доступно только для внутренних сервисов по API-ключу.", "produces": [ "application/json" ], "tags": [ "internal" ], "summary": "Get total count of books (internal)", "parameters": [ { "type": "string", "description": "Токен для внутренних запросов", "name": "X-API-KEY", "in": "header" } ], "responses": { "200": { "description": "Total number of books", "schema": { "type": "object", "properties": { "count": { "type": "integer" } } } }, "401": { "description": "Unauthorized", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } } }, "/v1/auth/login": { "post": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "auth" ], "parameters": [ { "description": "credentials", "name": "login", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.LoginRequest" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.TokenPair" } }, "401": { "description": "Unauthorized", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } } }, "/v1/auth/logout": { "post": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "auth" ], "responses": { "200": { "description": "OK" }, "401": { "description": "Unauthorized", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } } }, "/v1/auth/refresh": { "post": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "auth" ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.TokenPair" } }, "401": { "description": "Unauthorized", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } } }, "/v1/books": { "get": { "description": "Получить список книг. В версии v1 поле 'rating' отсутствует.", "produces": [ "application/json" ], "tags": [ "books" ], "summary": "List books (v1)", "parameters": [ { "type": "integer", "default": 10, "description": "Number of books to return", "name": "limit", "in": "query" }, { "type": "integer", "default": 0, "description": "Offset for pagination", "name": "offset", "in": "query" }, { "type": "string", "description": "Comma-separated list of fields to include (e.g., title,author,price)", "name": "fields", "in": "query" } ], "responses": { "200": { "description": "List of books (v1 shape)", "schema": { "type": "array", "items": { "type": "object" } } }, "500": { "description": "internal error", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } }, "post": { "security": [ { "BearerAuth": [] } ], "description": "Создать книгу. Поддерживает заголовок Idempotency-Key: повторные запросы с тем же ключом вернут кешированный ответ.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "books" ], "summary": "Create a book (v1)", "parameters": [ { "type": "string", "description": "Idempotency key (optional) — повторные запросы с тем же ключом не создадут дубликат", "name": "Idempotency-Key", "in": "header" }, { "description": "Book create payload", "name": "payload", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.CreateBookRequestV1" } } ], "responses": { "201": { "description": "Created book (v1 shape)", "schema": { "$ref": "#/definitions/models.Book" } }, "400": { "description": "bad request (validation)", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "401": { "description": "unauthorized\" // если включить auth middleware", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "409": { "description": "conflict (idempotency or duplicate)", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } } }, "/v1/books/{id}": { "get": { "description": "Получить книгу по идентификатору. Возвращает 404 если не найдено.", "produces": [ "application/json" ], "tags": [ "books" ], "summary": "Get book by ID (v1)", "parameters": [ { "type": "integer", "description": "Book ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "Book (v1 shape)", "schema": { "$ref": "#/definitions/models.Book" } }, "400": { "description": "bad request (invalid id)", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "404": { "description": "not found", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } }, "put": { "security": [ { "BearerAuth": [] } ], "description": "Обновить поля книги. Частичные обновления поддерживаются (PATCH-like behavior через PUT body с опциональными полями).", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "books" ], "summary": "Update book (v1)", "parameters": [ { "type": "integer", "description": "Book ID", "name": "id", "in": "path", "required": true }, { "description": "Fields to update", "name": "payload", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.UpdateBookRequest" } } ], "responses": { "200": { "description": "Updated book", "schema": { "$ref": "#/definitions/models.Book" } }, "400": { "description": "bad request (validation)", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "401": { "description": "unauthorized", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "404": { "description": "not found", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } }, "delete": { "security": [ { "BearerAuth": [] } ], "description": "Удалить книгу по ID. Возвращает 204 No Content при успешном удалении.", "tags": [ "books" ], "summary": "Delete book (v1)", "parameters": [ { "type": "integer", "description": "Book ID", "name": "id", "in": "path", "required": true } ], "responses": { "204": { "description": "No Content" }, "400": { "description": "bad request (invalid id)", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "401": { "description": "unauthorized", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "404": { "description": "not found", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } } }, "/v2/books": { "get": { "description": "Получить список книг. В версии v2 есть поле 'rating'.", "produces": [ "application/json" ], "tags": [ "books" ], "summary": "List books (v2)", "parameters": [ { "type": "integer", "default": 10, "description": "Number of books to return", "name": "limit", "in": "query" }, { "type": "integer", "default": 0, "description": "Offset for pagination", "name": "offset", "in": "query" }, { "type": "string", "description": "Comma-separated list of fields to include (e.g., title,author,price,rating)", "name": "fields", "in": "query" } ], "responses": { "200": { "description": "List of books (v2 shape)", "schema": { "type": "array", "items": { "type": "object" } } }, "500": { "description": "internal error", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } }, "post": { "security": [ { "BearerAuth": [] } ], "description": "Создать книгу. Поддерживает заголовок Idempotency-Key: повторные запросы с тем же ключом вернут кешированный ответ.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "books" ], "summary": "Create a book (v2)", "parameters": [ { "type": "string", "description": "Idempotency key (optional) — повторные запросы с тем же ключом не создадут дубликат", "name": "Idempotency-Key", "in": "header" }, { "description": "Book create payload", "name": "payload", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.CreateBookRequestV2" } } ], "responses": { "201": { "description": "Created book (v2 shape)", "schema": { "$ref": "#/definitions/models.Book" } }, "400": { "description": "bad request (validation)", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "401": { "description": "unauthorized", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "409": { "description": "conflict (idempotency or duplicate)", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } } }, "/v2/books/{id}": { "get": { "description": "Получить книгу по идентификатору. Возвращает 404 если не найдено.", "produces": [ "application/json" ], "tags": [ "books" ], "summary": "Get book by ID (v2)", "parameters": [ { "type": "integer", "description": "Book ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "Book (v2 shape)", "schema": { "$ref": "#/definitions/models.Book" } }, "400": { "description": "bad request (invalid id)", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "404": { "description": "not found", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } }, "put": { "security": [ { "BearerAuth": [] } ], "description": "Обновить поля книги. Частичные обновления поддерживаются (PATCH-like behavior через PUT body с опциональными полями).", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "books" ], "summary": "Update book (v2)", "parameters": [ { "type": "integer", "description": "Book ID", "name": "id", "in": "path", "required": true }, { "description": "Fields to update", "name": "payload", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.UpdateBookRequest" } } ], "responses": { "200": { "description": "Updated book", "schema": { "$ref": "#/definitions/models.Book" } }, "400": { "description": "bad request (validation)", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "401": { "description": "unauthorized", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "404": { "description": "not found", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } }, "delete": { "security": [ { "BearerAuth": [] } ], "description": "Удалить книгу по ID. Возвращает 204 No Content при успешном удалении.", "tags": [ "books" ], "summary": "Delete book (v2)", "parameters": [ { "type": "integer", "description": "Book ID", "name": "id", "in": "path", "required": true } ], "responses": { "204": { "description": "No Content" }, "400": { "description": "bad request (invalid id)", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "401": { "description": "unauthorized", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "404": { "description": "not found", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } } } }, "definitions": { "models.Book": { "type": "object", "properties": { "author": { "type": "string" }, "description": { "type": "string" }, "id": { "type": "integer" }, "price": { "type": "number" }, "rating": { "type": "number" }, "title": { "type": "string" } } }, "models.CreateBookRequestV1": { "type": "object", "required": [ "author", "price", "title" ], "properties": { "author": { "type": "string" }, "description": { "type": "string" }, "price": { "type": "number" }, "title": { "type": "string" } } }, "models.CreateBookRequestV2": { "type": "object", "required": [ "author", "price", "title" ], "properties": { "author": { "type": "string" }, "description": { "type": "string" }, "price": { "type": "number" }, "rating": { "type": "number" }, "title": { "type": "string" } } }, "models.LoginRequest": { "type": "object", "required": [ "password", "username" ], "properties": { "password": { "type": "string" }, "username": { "type": "string" } } }, "models.TokenPair": { "type": "object", "properties": { "access_token": { "type": "string" }, "expires_in": { "type": "integer" } } }, "models.UpdateBookRequest": { "type": "object", "properties": { "author": { "type": "string" }, "description": { "type": "string" }, "price": { "type": "number" }, "rating": { "type": "number" }, "title": { "type": "string" } } } }, "securityDefinitions": { "BearerAuth": { "description": "\"Type ` + "`" + `Bearer {token}` + "`" + ` to authenticate.\"", "type": "apiKey", "name": "Authorization", "in": "header" } } }` // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = &swag.Spec{ Version: "1.0", Host: "localhost:8080", BasePath: "/api/v1", Schemes: []string{}, Title: "Bookstore API", Description: "REST API for Bookstore (examples).", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, LeftDelim: "{{", RightDelim: "}}", } func init() { swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) }