851 lines
31 KiB
Go
851 lines
31 KiB
Go
// 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": {
|
|
"/api/v1/auth/login": {
|
|
"post": {
|
|
"description": "Аутентификация по email и паролю. Возвращает access_token (JWT) и refresh_token.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"summary": "Вход",
|
|
"parameters": [
|
|
{
|
|
"description": "Email и пароль",
|
|
"name": "request",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.LoginRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Успешный вход, токены в ответе",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.AuthResponse"
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Ошибка валидации полей",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.ErrorResponse"
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Неверный email или пароль",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/api/v1/auth/logout": {
|
|
"post": {
|
|
"description": "Аннулирование refresh_token. После выхода повторное использование того же refresh_token вернёт 401.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"summary": "Выход",
|
|
"parameters": [
|
|
{
|
|
"description": "Refresh_token для аннулирования",
|
|
"name": "request",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.LogoutRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "{\"message\": \"logged out successfully\"}",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Не указан refresh_token",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.ErrorResponse"
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Refresh_token не найден или уже аннулирован",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/api/v1/auth/me": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Получение профиля текущего авторизованного пользователя.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"summary": "Профиль пользователя",
|
|
"responses": {
|
|
"200": {
|
|
"description": "Данные пользователя",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.UserResponse"
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Токен не указан или недействителен",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"put": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Обновление username текущего пользователя.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"summary": "Обновление профиля",
|
|
"parameters": [
|
|
{
|
|
"description": "Новый username",
|
|
"name": "request",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.UpdateProfileRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Обновлённый профиль",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.UserResponse"
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Ошибка валидации: username от 3 до 30 символов",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.ErrorResponse"
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Токен не указан или недействителен",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/api/v1/auth/password": {
|
|
"put": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Изменение пароля текущего пользователя. Требуется указать старый и новый пароль.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.\nПароль должен содержать минимум 8 символов, заглавную букву, строчную букву и цифру.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"summary": "Смена пароля",
|
|
"parameters": [
|
|
{
|
|
"description": "Старый и новый пароль",
|
|
"name": "request",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.PasswordChangeRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "{\"message\": \"password changed successfully\"}",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Ошибка валидации: неверный старый пароль, слабый новый или совпадают",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.ErrorResponse"
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Токен не указан или недействителен",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/api/v1/auth/refresh": {
|
|
"post": {
|
|
"description": "Получение новой пары токенов по refresh_token. Старый refresh_token становится недействительным (ротация).\nЕсли refresh_token истёк или уже был использован — придёт 401.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"summary": "Обновление токенов",
|
|
"parameters": [
|
|
{
|
|
"description": "Действительный refresh_token",
|
|
"name": "request",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.RefreshRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Новая пара токенов",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.AuthResponse"
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Не указан refresh_token",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.ErrorResponse"
|
|
}
|
|
},
|
|
"401": {
|
|
"description": "Refresh_token недействителен или истёк",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/api/v1/auth/register": {
|
|
"post": {
|
|
"description": "Создание новой учётной записи. После успешной регистрации сразу возвращается access_token и refresh_token.\nПароль должен содержать минимум 8 символов, заглавную букву, строчную букву и цифру.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"auth"
|
|
],
|
|
"summary": "Регистрация",
|
|
"parameters": [
|
|
{
|
|
"description": "Данные для регистрации",
|
|
"name": "request",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.RegisterRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"201": {
|
|
"description": "Пользователь создан, токены в ответе",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.AuthResponse"
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Ошибка валидации полей (некорректный email, слабый пароль)",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.ErrorResponse"
|
|
}
|
|
},
|
|
"409": {
|
|
"description": "Email уже зарегистрирован",
|
|
"schema": {
|
|
"$ref": "#/definitions/auth.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/api/v1/organizations": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Получение списка всех организаций с пагинацией.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"organizations"
|
|
],
|
|
"summary": "Список организаций",
|
|
"parameters": [
|
|
{
|
|
"type": "integer",
|
|
"description": "Количество записей на странице (по умолчанию 20)",
|
|
"name": "limit",
|
|
"in": "query"
|
|
},
|
|
{
|
|
"type": "integer",
|
|
"description": "Смещение от начала списка (по умолчанию 0)",
|
|
"name": "offset",
|
|
"in": "query"
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Список организаций",
|
|
"schema": {
|
|
"$ref": "#/definitions/org.OrgListResponse"
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Внутренняя ошибка сервера",
|
|
"schema": {
|
|
"$ref": "#/definitions/org.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"post": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Создание новой организации. slug используется в URL и должен быть уникальным.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"organizations"
|
|
],
|
|
"summary": "Создание организации",
|
|
"parameters": [
|
|
{
|
|
"description": "Название и slug организации",
|
|
"name": "request",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/org.CreateOrgRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"201": {
|
|
"description": "Организация создана",
|
|
"schema": {
|
|
"$ref": "#/definitions/org.OrgResponse"
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Ошибка валидации полей",
|
|
"schema": {
|
|
"$ref": "#/definitions/org.ErrorResponse"
|
|
}
|
|
},
|
|
"409": {
|
|
"description": "Slug уже занят",
|
|
"schema": {
|
|
"$ref": "#/definitions/org.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/api/v1/organizations/{id}": {
|
|
"get": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Получение информации об организации по её ID.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"organizations"
|
|
],
|
|
"summary": "Получить организацию",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "UUID организации",
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Данные организации",
|
|
"schema": {
|
|
"$ref": "#/definitions/org.OrgResponse"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Организация не найдена",
|
|
"schema": {
|
|
"$ref": "#/definitions/org.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"put": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Обновление названия организации. slug изменить нельзя.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"organizations"
|
|
],
|
|
"summary": "Обновление организации",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "UUID организации",
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true
|
|
},
|
|
{
|
|
"description": "Новое название организации",
|
|
"name": "request",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/org.UpdateOrgRequest"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Обновлённая организация",
|
|
"schema": {
|
|
"$ref": "#/definitions/org.OrgResponse"
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Ошибка валидации полей",
|
|
"schema": {
|
|
"$ref": "#/definitions/org.ErrorResponse"
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Организация не найдена",
|
|
"schema": {
|
|
"$ref": "#/definitions/org.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"delete": {
|
|
"security": [
|
|
{
|
|
"Bearer": []
|
|
}
|
|
],
|
|
"description": "Безвозвратное удаление организации по её ID.\n**Требуется:** заголовок ` + "`" + `Authorization: Bearer \u003ctoken\u003e` + "`" + `.",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"organizations"
|
|
],
|
|
"summary": "Удаление организации",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "UUID организации",
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "{\"message\": \"organization deleted\"}",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"404": {
|
|
"description": "Организация не найдена",
|
|
"schema": {
|
|
"$ref": "#/definitions/org.ErrorResponse"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"definitions": {
|
|
"auth.AuthResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"refresh_token": {
|
|
"type": "string",
|
|
"example": "dGhpcyBpcyBhIHJlZnJlc2ggdG9rZW4="
|
|
},
|
|
"token": {
|
|
"type": "string",
|
|
"example": "eyJhbGciOiJIUzI1NiIs..."
|
|
},
|
|
"user": {
|
|
"$ref": "#/definitions/auth.UserPublic"
|
|
}
|
|
}
|
|
},
|
|
"auth.ErrorResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"error": {
|
|
"type": "string",
|
|
"example": "invalid email or password"
|
|
}
|
|
}
|
|
},
|
|
"auth.LoginRequest": {
|
|
"type": "object",
|
|
"required": [
|
|
"email",
|
|
"password"
|
|
],
|
|
"properties": {
|
|
"email": {
|
|
"type": "string",
|
|
"example": "john@example.com"
|
|
},
|
|
"password": {
|
|
"type": "string",
|
|
"example": "secret123"
|
|
}
|
|
}
|
|
},
|
|
"auth.LogoutRequest": {
|
|
"type": "object",
|
|
"required": [
|
|
"refresh_token"
|
|
],
|
|
"properties": {
|
|
"refresh_token": {
|
|
"type": "string",
|
|
"example": "dGhpcyBpcyBhIHJlZnJlc2ggdG9rZW4="
|
|
}
|
|
}
|
|
},
|
|
"auth.PasswordChangeRequest": {
|
|
"type": "object",
|
|
"required": [
|
|
"new_password",
|
|
"old_password"
|
|
],
|
|
"properties": {
|
|
"new_password": {
|
|
"type": "string",
|
|
"minLength": 8,
|
|
"example": "NewSecret456!"
|
|
},
|
|
"old_password": {
|
|
"type": "string",
|
|
"example": "Secret123!"
|
|
}
|
|
}
|
|
},
|
|
"auth.RefreshRequest": {
|
|
"type": "object",
|
|
"required": [
|
|
"refresh_token"
|
|
],
|
|
"properties": {
|
|
"refresh_token": {
|
|
"type": "string",
|
|
"example": "dGhpcyBpcyBhIHJlZnJlc2ggdG9rZW4="
|
|
}
|
|
}
|
|
},
|
|
"auth.RegisterRequest": {
|
|
"type": "object",
|
|
"required": [
|
|
"email",
|
|
"password",
|
|
"username"
|
|
],
|
|
"properties": {
|
|
"email": {
|
|
"type": "string",
|
|
"example": "john@example.com"
|
|
},
|
|
"password": {
|
|
"type": "string",
|
|
"minLength": 8,
|
|
"example": "Secret123!"
|
|
},
|
|
"username": {
|
|
"type": "string",
|
|
"maxLength": 30,
|
|
"minLength": 3,
|
|
"example": "john"
|
|
}
|
|
}
|
|
},
|
|
"auth.UpdateProfileRequest": {
|
|
"type": "object",
|
|
"required": [
|
|
"username"
|
|
],
|
|
"properties": {
|
|
"username": {
|
|
"type": "string",
|
|
"maxLength": 30,
|
|
"minLength": 3,
|
|
"example": "john_updated"
|
|
}
|
|
}
|
|
},
|
|
"auth.UserPublic": {
|
|
"type": "object",
|
|
"properties": {
|
|
"created_at": {
|
|
"type": "string"
|
|
},
|
|
"email": {
|
|
"type": "string"
|
|
},
|
|
"id": {
|
|
"type": "string"
|
|
},
|
|
"username": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"auth.UserResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"user": {
|
|
"$ref": "#/definitions/auth.UserPublic"
|
|
}
|
|
}
|
|
},
|
|
"org.CreateOrgRequest": {
|
|
"type": "object",
|
|
"required": [
|
|
"name",
|
|
"slug"
|
|
],
|
|
"properties": {
|
|
"name": {
|
|
"type": "string",
|
|
"maxLength": 100,
|
|
"minLength": 2,
|
|
"example": "My Corp"
|
|
},
|
|
"slug": {
|
|
"type": "string",
|
|
"maxLength": 50,
|
|
"minLength": 2,
|
|
"example": "my-corp"
|
|
}
|
|
}
|
|
},
|
|
"org.ErrorResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"error": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"org.OrgListResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"limit": {
|
|
"type": "integer"
|
|
},
|
|
"offset": {
|
|
"type": "integer"
|
|
},
|
|
"organizations": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/org.Organization"
|
|
}
|
|
},
|
|
"total": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
},
|
|
"org.OrgResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"organization": {
|
|
"$ref": "#/definitions/org.Organization"
|
|
}
|
|
}
|
|
},
|
|
"org.Organization": {
|
|
"type": "object",
|
|
"properties": {
|
|
"created_at": {
|
|
"type": "string"
|
|
},
|
|
"id": {
|
|
"type": "string"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"slug": {
|
|
"type": "string"
|
|
},
|
|
"updated_at": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"org.UpdateOrgRequest": {
|
|
"type": "object",
|
|
"required": [
|
|
"name"
|
|
],
|
|
"properties": {
|
|
"name": {
|
|
"type": "string",
|
|
"maxLength": 100,
|
|
"minLength": 2,
|
|
"example": "My Corp Updated"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"securityDefinitions": {
|
|
"Bearer": {
|
|
"description": "Введите ` + "`" + `Bearer \u003ctoken\u003e` + "`" + `, где token — access_token из ответа /auth/login или /auth/register",
|
|
"type": "apiKey",
|
|
"name": "Authorization",
|
|
"in": "header"
|
|
}
|
|
}
|
|
}`
|
|
|
|
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
|
var SwaggerInfo = &swag.Spec{
|
|
Version: "1.0",
|
|
Host: "",
|
|
BasePath: "/api/v1",
|
|
Schemes: []string{"http"},
|
|
Title: "AegisGuard API",
|
|
Description: "API системы управления AegisGuard. Позволяет управлять пользователями и организациями.\nВсе защищённые эндпоинты требуют заголовок `Authorization: Bearer <token>`.\nТокен получается при регистрации или входе.",
|
|
InfoInstanceName: "swagger",
|
|
SwaggerTemplate: docTemplate,
|
|
LeftDelim: "{{",
|
|
RightDelim: "}}",
|
|
}
|
|
|
|
func init() {
|
|
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
|
|
}
|