{ "schemes": [ "http" ], "swagger": "2.0", "info": { "description": "API шлюз для доступа к сервисам системы", "title": "API Gateway Service", "contact": {}, "version": "1.0" }, "host": "localhost:8080", "basePath": "/api", "paths": { "/login": { "post": { "description": "Выполняет вход пользователя в систему", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Authentication" ], "summary": "Аутентификация пользователя", "parameters": [ { "description": "Данные для входа", "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.LoginRequest" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.LoginResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/posts": { "get": { "security": [ { "sessionAuth": [] } ], "description": "Возвращает пагинированный список постов", "produces": [ "application/json" ], "tags": [ "Posts" ], "summary": "Получение списка постов", "parameters": [ { "type": "integer", "description": "Номер страницы (по умолчанию 1)", "name": "page", "in": "query" }, { "type": "integer", "description": "Размер страницы (по умолчанию 20)", "name": "page_size", "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.PostListResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } }, "post": { "security": [ { "sessionAuth": [] } ], "description": "Создает новый пост от имени текущего пользователя", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Posts" ], "summary": "Создание нового поста", "parameters": [ { "description": "Данные для создания поста", "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.CreatePostRequest" } } ], "responses": { "201": { "description": "Created", "schema": { "$ref": "#/definitions/models.PostResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/posts/{id}": { "get": { "security": [ { "sessionAuth": [] } ], "description": "Возвращает пост по его ID", "produces": [ "application/json" ], "tags": [ "Posts" ], "summary": "Получение поста по ID", "parameters": [ { "type": "string", "description": "ID поста", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.PostResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } }, "put": { "security": [ { "sessionAuth": [] } ], "description": "Обновляет данные поста", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Posts" ], "summary": "Обновление поста", "parameters": [ { "type": "string", "description": "ID поста", "name": "id", "in": "path", "required": true }, { "description": "Новые данные для поста", "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.UpdatePostRequest" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.PostResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } }, "delete": { "security": [ { "sessionAuth": [] } ], "description": "Удаляет пост по его ID", "tags": [ "Posts" ], "summary": "Удаление поста", "parameters": [ { "type": "string", "description": "ID поста", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.DeletePostResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/posts/{id}/comments": { "get": { "security": [ { "sessionAuth": [] } ], "description": "Возвращает список комментариев к посту с пагинацией", "produces": [ "application/json" ], "tags": [ "Comments" ], "summary": "Получение комментариев к посту", "parameters": [ { "type": "string", "description": "ID поста", "name": "id", "in": "path", "required": true }, { "type": "integer", "description": "Номер страницы (по умолчанию 1)", "name": "page", "in": "query" }, { "type": "integer", "description": "Размер страницы (по умолчанию 20)", "name": "page_size", "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.CommentListResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } }, "post": { "security": [ { "sessionAuth": [] } ], "description": "Добавляет новый комментарий к посту от имени текущего пользователя и отправляет событие в Kafka", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Comments" ], "summary": "Добавление комментария к посту", "parameters": [ { "type": "string", "description": "ID поста", "name": "id", "in": "path", "required": true }, { "description": "Данные комментария", "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.AddCommentRequest" } } ], "responses": { "201": { "description": "Created", "schema": { "$ref": "#/definitions/models.CommentResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/posts/{id}/like": { "post": { "security": [ { "sessionAuth": [] } ], "description": "Ставит или убирает лайк поста текущим пользователем и отправляет событие в Kafka", "produces": [ "application/json" ], "tags": [ "Posts" ], "summary": "Лайк поста", "parameters": [ { "type": "string", "description": "ID поста", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.LikePostResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/posts/{id}/view": { "post": { "security": [ { "sessionAuth": [] } ], "description": "Регистрирует просмотр поста текущим пользователем и отправляет событие в Kafka", "produces": [ "application/json" ], "tags": [ "Posts" ], "summary": "Просмотр поста", "parameters": [ { "type": "string", "description": "ID поста", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.SuccessResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/profile": { "get": { "security": [ { "sessionAuth": [] } ], "description": "Возвращает профиль текущего авторизованного пользователя", "produces": [ "application/json" ], "tags": [ "Profile" ], "summary": "Получение профиля пользователя", "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.ProfileResponse" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } }, "put": { "security": [ { "sessionAuth": [] } ], "description": "Обновляет данные профиля текущего пользователя", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Profile" ], "summary": "Обновление профиля пользователя", "parameters": [ { "description": "Новые данные для профиля", "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.ProfileUpdateRequest" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.ProfileUpdateResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/register": { "post": { "description": "Создает нового пользователя в системе", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Authentication" ], "summary": "Регистрация нового пользователя", "parameters": [ { "description": "Данные для регистрации", "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/models.RegisterRequest" } } ], "responses": { "201": { "description": "Created", "schema": { "$ref": "#/definitions/models.RegisterResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/stats/posts/top": { "get": { "description": "Возвращает топ-10 постов по количеству просмотров, лайков или комментариев", "produces": [ "application/json" ], "tags": [ "Statistics" ], "summary": "Получение топ-10 постов", "parameters": [ { "type": "string", "description": "Тип метрики (views, likes, comments)", "name": "metric_type", "in": "query", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.TopPostsResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/stats/posts/{id}": { "get": { "description": "Возвращает количество просмотров, лайков и комментариев по посту", "produces": [ "application/json" ], "tags": [ "Statistics" ], "summary": "Получение статистики по посту", "parameters": [ { "type": "string", "description": "ID поста", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.PostStatsResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/stats/posts/{id}/comments/timeline": { "get": { "description": "Возвращает массив с датой (день) и количеством комментариев за день", "produces": [ "application/json" ], "tags": [ "Statistics" ], "summary": "Получение динамики комментариев по посту", "parameters": [ { "type": "string", "description": "ID поста", "name": "id", "in": "path", "required": true }, { "type": "integer", "description": "Количество дней (по умолчанию 30)", "name": "days", "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.TimelineResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/stats/posts/{id}/likes/timeline": { "get": { "description": "Возвращает массив с датой (день) и количеством лайков за день", "produces": [ "application/json" ], "tags": [ "Statistics" ], "summary": "Получение динамики лайков по посту", "parameters": [ { "type": "string", "description": "ID поста", "name": "id", "in": "path", "required": true }, { "type": "integer", "description": "Количество дней (по умолчанию 30)", "name": "days", "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.TimelineResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/stats/posts/{id}/views/timeline": { "get": { "description": "Возвращает массив с датой (день) и количеством просмотров за день", "produces": [ "application/json" ], "tags": [ "Statistics" ], "summary": "Получение динамики просмотров по посту", "parameters": [ { "type": "string", "description": "ID поста", "name": "id", "in": "path", "required": true }, { "type": "integer", "description": "Количество дней (по умолчанию 30)", "name": "days", "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.TimelineResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } }, "/stats/users/top": { "get": { "description": "Возвращает топ-10 пользователей по количеству просмотров, лайков или комментариев", "produces": [ "application/json" ], "tags": [ "Statistics" ], "summary": "Получение топ-10 пользователей", "parameters": [ { "type": "string", "description": "Тип метрики (views, likes, comments)", "name": "metric_type", "in": "query", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.TopUsersResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/models.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/models.ErrorResponse" } } } } } }, "definitions": { "models.AddCommentRequest": { "type": "object", "required": [ "content" ], "properties": { "content": { "description": "Текст комментария\nrequired: true\nexample: Отличный пост, спасибо за информацию!", "type": "string" } } }, "models.Comment": { "type": "object", "properties": { "content": { "description": "Текст комментария\nexample: Это очень интересный пост!", "type": "string" }, "created_at": { "description": "Дата создания комментария\nexample: 2023-01-15T14:30:45Z", "type": "string" }, "id": { "description": "ID комментария\nexample: 456", "type": "integer" }, "post_id": { "description": "ID поста, к которому относится комментарий\nexample: 123", "type": "integer" }, "user_id": { "description": "ID пользователя, оставившего комментарий\nexample: 42", "type": "integer" } } }, "models.CommentListResponse": { "type": "object", "properties": { "comments": { "description": "Список комментариев", "type": "array", "items": { "$ref": "#/definitions/models.Comment" } }, "total_count": { "description": "Общее количество комментариев\nexample: 25", "type": "integer" } } }, "models.CommentResponse": { "type": "object", "properties": { "comment": { "description": "Данные комментария", "allOf": [ { "$ref": "#/definitions/models.Comment" } ] } } }, "models.CreatePostRequest": { "type": "object", "required": [ "title" ], "properties": { "description": { "description": "Описание поста\nexample: Это описание моего первого поста", "type": "string" }, "is_private": { "description": "Флаг приватности\nexample: false", "type": "boolean" }, "tags": { "description": "Список тегов\nexample: [\"тег1\", \"тег2\"]", "type": "array", "items": { "type": "string" } }, "title": { "description": "Название поста\nexample: Мой первый пост\nrequired: true", "type": "string" } } }, "models.DeletePostResponse": { "type": "object", "properties": { "success": { "description": "Результат удаления\nexample: true", "type": "boolean" } } }, "models.ErrorResponse": { "type": "object", "properties": { "error": { "description": "Сообщение об ошибке\nexample: Invalid credentials", "type": "string" } } }, "models.LikePostResponse": { "type": "object", "properties": { "success": { "description": "Успешность операции лайка\nexample: true", "type": "boolean" }, "total_likes": { "description": "Общее количество лайков у поста\nexample: 42", "type": "integer" } } }, "models.LoginRequest": { "type": "object", "required": [ "login", "password" ], "properties": { "login": { "description": "Логин пользователя\nrequired: true\nexample: johndoe", "type": "string" }, "password": { "description": "Пароль пользователя\nrequired: true\nexample: securePassword123", "type": "string" } } }, "models.LoginResponse": { "type": "object", "properties": { "message": { "description": "Сообщение о результате\nexample: Logged in successfully", "type": "string" } } }, "models.PostListResponse": { "type": "object", "properties": { "posts": { "description": "Список постов", "type": "array", "items": { "$ref": "#/definitions/models.PostResponse" } }, "total_count": { "description": "Общее количество постов\nexample: 42", "type": "integer" } } }, "models.PostResponse": { "type": "object", "properties": { "created_at": { "description": "Дата создания поста\nexample: 2023-01-01T12:00:00Z", "type": "string" }, "creator_id": { "description": "ID создателя поста\nexample: 42", "type": "integer" }, "description": { "description": "Описание поста\nexample: Это описание моего первого поста", "type": "string" }, "id": { "description": "ID поста\nexample: 123", "type": "integer" }, "is_private": { "description": "Флаг приватности\nexample: false", "type": "boolean" }, "tags": { "description": "Список тегов\nexample: [\"тег1\", \"тег2\"]", "type": "array", "items": { "type": "string" } }, "title": { "description": "Название поста\nexample: Мой первый пост", "type": "string" }, "updated_at": { "description": "Дата обновления поста\nexample: 2023-01-02T12:00:00Z", "type": "string" } } }, "models.PostStatsResponse": { "type": "object", "properties": { "comments_count": { "description": "Количество комментариев\nexample: 45", "type": "integer" }, "likes_count": { "description": "Количество лайков\nexample: 320", "type": "integer" }, "post_id": { "description": "ID поста\nexample: 123", "type": "integer" }, "views_count": { "description": "Количество просмотров\nexample: 1500", "type": "integer" } } }, "models.ProfileResponse": { "type": "object", "properties": { "user": { "description": "Данные пользователя", "allOf": [ { "$ref": "#/definitions/models.User" } ] } } }, "models.ProfileUpdateRequest": { "type": "object", "properties": { "birthDate": { "description": "Дата рождения пользователя\nexample: 1990-01-01T00:00:00Z", "type": "string" }, "email": { "description": "Email пользователя\nexample: john.doe@example.com", "type": "string" }, "name": { "description": "Имя пользователя\nexample: John", "type": "string", "maxLength": 50, "minLength": 2 }, "phoneNumber": { "description": "Номер телефона пользователя\nexample: +12345678901", "type": "string" }, "surname": { "description": "Фамилия пользователя\nexample: Doe", "type": "string", "maxLength": 50, "minLength": 2 } } }, "models.ProfileUpdateResponse": { "type": "object", "properties": { "status": { "description": "Статус операции\nexample: Profile updated successfully", "type": "string" }, "user": { "description": "Обновленные данные пользователя", "allOf": [ { "$ref": "#/definitions/models.User" } ] } } }, "models.RegisterRequest": { "type": "object", "required": [ "email", "login", "password" ], "properties": { "email": { "description": "Email пользователя\nrequired: true\nexample: john.doe@example.com", "type": "string" }, "login": { "description": "Логин пользователя (минимум 3 символа)\nrequired: true\nmin length: 3\nmax length: 50\nexample: johndoe", "type": "string", "maxLength": 50, "minLength": 3 }, "password": { "description": "Пароль пользователя (минимум 6 символов)\nrequired: true\nmin length: 6\nexample: securePassword123", "type": "string", "maxLength": 100, "minLength": 6 } } }, "models.RegisterResponse": { "type": "object", "properties": { "status": { "description": "Статус операции\nexample: user created", "type": "string" } } }, "models.SuccessResponse": { "type": "object", "properties": { "success": { "description": "Успешность выполнения операции\nexample: true", "type": "boolean" } } }, "models.TimelineItem": { "type": "object", "properties": { "count": { "description": "Количество событий\nexample: 42", "type": "integer" }, "date": { "description": "Дата (день)\nexample: 2023-09-01T00:00:00Z", "type": "string" } } }, "models.TimelineResponse": { "type": "object", "properties": { "items": { "description": "Временная динамика по дням", "type": "array", "items": { "$ref": "#/definitions/models.TimelineItem" } } } }, "models.TopPostItem": { "type": "object", "properties": { "count": { "description": "Количество (просмотров/лайков/комментариев)\nexample: 1500", "type": "integer" }, "post_id": { "description": "ID поста\nexample: 123", "type": "integer" } } }, "models.TopPostsResponse": { "type": "object", "properties": { "posts": { "description": "Список топ постов", "type": "array", "items": { "$ref": "#/definitions/models.TopPostItem" } } } }, "models.TopUserItem": { "type": "object", "properties": { "count": { "description": "Количество (просмотров/лайков/комментариев)\nexample: 1500", "type": "integer" }, "user_id": { "description": "ID пользователя\nexample: 42", "type": "integer" } } }, "models.TopUsersResponse": { "type": "object", "properties": { "users": { "description": "Список топ пользователей", "type": "array", "items": { "$ref": "#/definitions/models.TopUserItem" } } } }, "models.UpdatePostRequest": { "type": "object", "properties": { "description": { "description": "Описание поста\nexample: Обновленное описание поста", "type": "string" }, "is_private": { "description": "Флаг приватности\nexample: true", "type": "boolean" }, "tags": { "description": "Список тегов\nexample: [\"тег1\", \"тег2\", \"новыйТег\"]", "type": "array", "items": { "type": "string" } }, "title": { "description": "Название поста\nexample: Обновленное название поста", "type": "string" } } }, "models.User": { "type": "object", "properties": { "birthDate": { "description": "Дата рождения пользователя\nexample: 1990-01-01T00:00:00Z", "type": "string" }, "createdAt": { "description": "Дата создания пользователя\nexample: 2023-01-01T12:00:00Z", "type": "string" }, "email": { "description": "Email пользователя\nexample: john.doe@example.com", "type": "string" }, "id": { "description": "ID пользователя\nexample: 1", "type": "integer" }, "login": { "description": "Логин пользователя\nexample: johndoe", "type": "string" }, "name": { "description": "Имя пользователя\nexample: John", "type": "string" }, "phoneNumber": { "description": "Номер телефона пользователя\nexample: +12345678901", "type": "string" }, "surname": { "description": "Фамилия пользователя\nexample: Doe", "type": "string" }, "updatedAt": { "description": "Дата последнего обновления пользователя\nexample: 2023-01-02T12:00:00Z", "type": "string" } } } }, "securityDefinitions": { "sessionAuth": { "type": "apiKey", "name": "user-session", "in": "cookie" } } }