feat: add API versioning , translate swagger, remove rate limiter
This commit is contained in:
+98
-78
@@ -15,9 +15,9 @@ const docTemplate = `{
|
||||
"host": "{{.Host}}",
|
||||
"basePath": "{{.BasePath}}",
|
||||
"paths": {
|
||||
"/api/auth/login": {
|
||||
"/api/v1/auth/login": {
|
||||
"post": {
|
||||
"description": "Authenticate user with email and password, returns JWT token",
|
||||
"description": "Аутентификация по email и паролю. Возвращает access_token (JWT) и refresh_token.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -27,10 +27,10 @@ const docTemplate = `{
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Login",
|
||||
"summary": "Вход",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Login credentials",
|
||||
"description": "Email и пароль",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
@@ -41,19 +41,19 @@ const docTemplate = `{
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"description": "Успешный вход, токены в ответе",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.AuthResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"description": "Ошибка валидации полей",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"description": "Неверный email или пароль",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ErrorResponse"
|
||||
}
|
||||
@@ -61,9 +61,9 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/auth/logout": {
|
||||
"/api/v1/auth/logout": {
|
||||
"post": {
|
||||
"description": "Invalidate a refresh token (logout)",
|
||||
"description": "Аннулирование refresh_token. После выхода повторное использование того же refresh_token вернёт 401.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -73,10 +73,10 @@ const docTemplate = `{
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Logout",
|
||||
"summary": "Выход",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Refresh token to invalidate",
|
||||
"description": "Refresh_token для аннулирования",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
@@ -87,7 +87,7 @@ const docTemplate = `{
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"description": "{\"message\": \"logged out successfully\"}",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
@@ -96,13 +96,13 @@ const docTemplate = `{
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"description": "Не указан refresh_token",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"description": "Refresh_token не найден или уже аннулирован",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ErrorResponse"
|
||||
}
|
||||
@@ -110,14 +110,14 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/auth/me": {
|
||||
"/api/v1/auth/me": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Get authenticated user's profile",
|
||||
"description": "Получение профиля текущего авторизованного пользователя.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -127,16 +127,16 @@ const docTemplate = `{
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Get current user",
|
||||
"summary": "Профиль пользователя",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"description": "Данные пользователя",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.UserResponse"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"description": "Токен не указан или недействителен",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ErrorResponse"
|
||||
}
|
||||
@@ -149,7 +149,7 @@ const docTemplate = `{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Update current user's username",
|
||||
"description": "Обновление username текущего пользователя.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -159,10 +159,10 @@ const docTemplate = `{
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Update profile",
|
||||
"summary": "Обновление профиля",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Profile update",
|
||||
"description": "Новый username",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
@@ -173,19 +173,19 @@ const docTemplate = `{
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"description": "Обновлённый профиль",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.UserResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"description": "Ошибка валидации: username от 3 до 30 символов",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"description": "Токен не указан или недействителен",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ErrorResponse"
|
||||
}
|
||||
@@ -193,14 +193,14 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/auth/password": {
|
||||
"/api/v1/auth/password": {
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Change current user's password",
|
||||
"description": "Изменение пароля текущего пользователя. Требуется указать старый и новый пароль.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.\nПароль должен содержать минимум 8 символов, заглавную букву, строчную букву и цифру.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -210,10 +210,10 @@ const docTemplate = `{
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Change password",
|
||||
"summary": "Смена пароля",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Password change details",
|
||||
"description": "Старый и новый пароль",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
@@ -224,7 +224,7 @@ const docTemplate = `{
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"description": "{\"message\": \"password changed successfully\"}",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
@@ -233,13 +233,13 @@ const docTemplate = `{
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"description": "Ошибка валидации: неверный старый пароль, слабый новый или совпадают",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"description": "Токен не указан или недействителен",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ErrorResponse"
|
||||
}
|
||||
@@ -247,9 +247,9 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/auth/refresh": {
|
||||
"/api/v1/auth/refresh": {
|
||||
"post": {
|
||||
"description": "Get a new access token using a refresh token",
|
||||
"description": "Получение новой пары токенов по refresh_token. Старый refresh_token становится недействительным (ротация).\nЕсли refresh_token истёк или уже был использован — придёт 401.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -259,10 +259,10 @@ const docTemplate = `{
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Refresh token",
|
||||
"summary": "Обновление токенов",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Refresh token",
|
||||
"description": "Действительный refresh_token",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
@@ -273,19 +273,19 @@ const docTemplate = `{
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"description": "Новая пара токенов",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.AuthResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"description": "Не указан refresh_token",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"description": "Refresh_token недействителен или истёк",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ErrorResponse"
|
||||
}
|
||||
@@ -293,9 +293,9 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/auth/register": {
|
||||
"/api/v1/auth/register": {
|
||||
"post": {
|
||||
"description": "Create user account with username, email, password",
|
||||
"description": "Создание новой учётной записи. После успешной регистрации сразу возвращается access_token и refresh_token.\nПароль должен содержать минимум 8 символов, заглавную букву, строчную букву и цифру.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -305,10 +305,10 @@ const docTemplate = `{
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Register",
|
||||
"summary": "Регистрация",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Registration details",
|
||||
"description": "Данные для регистрации",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
@@ -319,19 +319,19 @@ const docTemplate = `{
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"description": "Пользователь создан, токены в ответе",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.AuthResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"description": "Ошибка валидации полей (некорректный email, слабый пароль)",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"409": {
|
||||
"description": "Conflict",
|
||||
"description": "Email уже зарегистрирован",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ErrorResponse"
|
||||
}
|
||||
@@ -339,14 +339,14 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/organizations": {
|
||||
"/api/v1/organizations": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Get all organizations",
|
||||
"description": "Получение списка всех организаций с пагинацией.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -356,16 +356,30 @@ const docTemplate = `{
|
||||
"tags": [
|
||||
"organizations"
|
||||
],
|
||||
"summary": "List organizations",
|
||||
"summary": "Список организаций",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Количество записей на странице (по умолчанию 20)",
|
||||
"name": "limit",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Смещение от начала списка (по умолчанию 0)",
|
||||
"name": "offset",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"description": "Список организаций",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/org.OrgListResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"description": "Внутренняя ошибка сервера",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/org.ErrorResponse"
|
||||
}
|
||||
@@ -378,7 +392,7 @@ const docTemplate = `{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Create a new organization",
|
||||
"description": "Создание новой организации. slug используется в URL и должен быть уникальным.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -388,10 +402,10 @@ const docTemplate = `{
|
||||
"tags": [
|
||||
"organizations"
|
||||
],
|
||||
"summary": "Create organization",
|
||||
"summary": "Создание организации",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Organization details",
|
||||
"description": "Название и slug организации",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
@@ -402,19 +416,19 @@ const docTemplate = `{
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"description": "Организация создана",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/org.OrgResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"description": "Ошибка валидации полей",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/org.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"409": {
|
||||
"description": "Conflict",
|
||||
"description": "Slug уже занят",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/org.ErrorResponse"
|
||||
}
|
||||
@@ -422,14 +436,14 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/organizations/{id}": {
|
||||
"/api/v1/organizations/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Get organization details",
|
||||
"description": "Получение информации об организации по её ID.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -439,11 +453,11 @@ const docTemplate = `{
|
||||
"tags": [
|
||||
"organizations"
|
||||
],
|
||||
"summary": "Get organization by ID",
|
||||
"summary": "Получить организацию",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Organization ID",
|
||||
"description": "UUID организации",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
@@ -451,13 +465,13 @@ const docTemplate = `{
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"description": "Данные организации",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/org.OrgResponse"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"description": "Организация не найдена",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/org.ErrorResponse"
|
||||
}
|
||||
@@ -470,7 +484,7 @@ const docTemplate = `{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Update organization name",
|
||||
"description": "Обновление названия организации. slug изменить нельзя.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -480,17 +494,17 @@ const docTemplate = `{
|
||||
"tags": [
|
||||
"organizations"
|
||||
],
|
||||
"summary": "Update organization",
|
||||
"summary": "Обновление организации",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Organization ID",
|
||||
"description": "UUID организации",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "New organization details",
|
||||
"description": "Новое название организации",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
@@ -501,19 +515,19 @@ const docTemplate = `{
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"description": "Обновлённая организация",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/org.OrgResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"description": "Ошибка валидации полей",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/org.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"description": "Организация не найдена",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/org.ErrorResponse"
|
||||
}
|
||||
@@ -526,7 +540,7 @@ const docTemplate = `{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "Delete an organization",
|
||||
"description": "Безвозвратное удаление организации по её ID.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -536,11 +550,11 @@ const docTemplate = `{
|
||||
"tags": [
|
||||
"organizations"
|
||||
],
|
||||
"summary": "Delete organization",
|
||||
"summary": "Удаление организации",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Organization ID",
|
||||
"description": "UUID организации",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
@@ -548,7 +562,7 @@ const docTemplate = `{
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"description": "{\"message\": \"organization deleted\"}",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
@@ -557,7 +571,7 @@ const docTemplate = `{
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"description": "Организация не найдена",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/org.ErrorResponse"
|
||||
}
|
||||
@@ -747,6 +761,12 @@ const docTemplate = `{
|
||||
"org.OrgListResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"limit": {
|
||||
"type": "integer"
|
||||
},
|
||||
"offset": {
|
||||
"type": "integer"
|
||||
},
|
||||
"organizations": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
@@ -803,7 +823,7 @@ const docTemplate = `{
|
||||
},
|
||||
"securityDefinitions": {
|
||||
"Bearer": {
|
||||
"description": "Type \"Bearer\" followed by a space and the JWT token.",
|
||||
"description": "Введите ` + "`" + `Bearer \u003ctoken\u003e` + "`" + `, где token — access_token из ответа /auth/login или /auth/register",
|
||||
"type": "apiKey",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
@@ -815,10 +835,10 @@ const docTemplate = `{
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "1.0",
|
||||
Host: "",
|
||||
BasePath: "",
|
||||
BasePath: "/api/v1",
|
||||
Schemes: []string{"http"},
|
||||
Title: "AegisGuard API",
|
||||
Description: "API for AegisGuard control plane",
|
||||
Description: "API системы управления AegisGuard. Позволяет управлять пользователями и организациями.\nВсе защищённые эндпоинты требуют заголовок `Authorization: Bearer <token>`.\nТокен получается при регистрации или входе.",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
LeftDelim: "{{",
|
||||
|
||||
Reference in New Issue
Block a user