asg-server/api/swagger.json
Aleksandr Soloshenko 6cddeb33ab Added: errors logging
2023-11-29 11:58:49 +07:00

530 lines
20 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"schemes": [
"http"
],
"swagger": "2.0",
"info": {
"description": "Авторизацию пользователя по логин-паролю",
"title": "SMS-шлюз - API сервера",
"contact": {
"name": "Aleksandr Soloshenko",
"email": "capcom@soft-c.ru"
},
"version": "1.0.0"
},
"host": "localhost:3000",
"basePath": "/api",
"paths": {
"/3rdparty/v1/message": {
"get": {
"security": [
{
"ApiAuth": []
}
],
"description": "Возвращает состояние сообщения по его ID",
"produces": [
"application/json"
],
"tags": [
"Пользователь",
"Сообщения"
],
"summary": "Получить состояние сообщения",
"parameters": [
{
"type": "string",
"description": "ИД сообщения",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Состояние сообщения",
"schema": {
"$ref": "#/definitions/smsgateway.MessageState"
}
},
"400": {
"description": "Некорректный запрос",
"schema": {
"$ref": "#/definitions/smsgateway.ErrorResponse"
}
},
"401": {
"description": "Ошибка авторизации",
"schema": {
"$ref": "#/definitions/smsgateway.ErrorResponse"
}
},
"500": {
"description": "Внутренняя ошибка сервера",
"schema": {
"$ref": "#/definitions/smsgateway.ErrorResponse"
}
}
}
},
"post": {
"security": [
{
"ApiAuth": []
}
],
"description": "Ставит сообщение в очередь на отправку. Если идентификатор не указан, то он будет сгенерирован автоматически",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Пользователь",
"Сообщения"
],
"summary": "Поставить сообщение в очередь",
"parameters": [
{
"description": "Сообщение",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/smsgateway.Message"
}
}
],
"responses": {
"201": {
"description": "Сообщение поставлено в очередь",
"schema": {
"$ref": "#/definitions/smsgateway.MessageState"
}
},
"400": {
"description": "Некорректный запрос",
"schema": {
"$ref": "#/definitions/smsgateway.ErrorResponse"
}
},
"401": {
"description": "Ошибка авторизации",
"schema": {
"$ref": "#/definitions/smsgateway.ErrorResponse"
}
},
"500": {
"description": "Внутренняя ошибка сервера",
"schema": {
"$ref": "#/definitions/smsgateway.ErrorResponse"
}
}
}
}
},
"/mobile/v1/device": {
"post": {
"description": "Регистрирует устройство на сервере, генерируя авторизационные данные",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Устройство",
"Регистрация"
],
"summary": "Регистрация устройства",
"parameters": [
{
"description": "Запрос на регистрацию",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/smsgateway.MobileRegisterRequest"
}
}
],
"responses": {
"201": {
"description": "Успешная регистрация",
"schema": {
"$ref": "#/definitions/smsgateway.MobileRegisterResponse"
}
},
"400": {
"description": "Некорректный запрос",
"schema": {
"$ref": "#/definitions/smsgateway.ErrorResponse"
}
},
"500": {
"description": "Внутренняя ошибка сервера",
"schema": {
"$ref": "#/definitions/smsgateway.ErrorResponse"
}
}
}
},
"patch": {
"security": [
{
"MobileToken": []
}
],
"description": "Обновляет push-токен устройства",
"consumes": [
"application/json"
],
"tags": [
"Устройство"
],
"summary": "Обновление устройства",
"parameters": [
{
"description": "Запрос на обновление",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/smsgateway.MobileUpdateRequest"
}
}
],
"responses": {
"204": {
"description": "Успешное обновление"
},
"400": {
"description": "Некорректный запрос",
"schema": {
"$ref": "#/definitions/smsgateway.ErrorResponse"
}
},
"403": {
"description": "Операция запрещена",
"schema": {
"$ref": "#/definitions/smsgateway.ErrorResponse"
}
},
"500": {
"description": "Внутренняя ошибка сервера",
"schema": {
"$ref": "#/definitions/smsgateway.ErrorResponse"
}
}
}
}
},
"/mobile/v1/message": {
"get": {
"security": [
{
"MobileToken": []
}
],
"description": "Возвращает список сообщений, требующих отправки",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Устройство",
"Сообщения"
],
"summary": "Получить сообщения для отправки",
"responses": {
"200": {
"description": "Список сообщений",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/smsgateway.Message"
}
}
},
"500": {
"description": "Внутренняя ошибка сервера",
"schema": {
"$ref": "#/definitions/smsgateway.ErrorResponse"
}
}
}
},
"patch": {
"security": [
{
"MobileToken": []
}
],
"description": "Обновляет состояние сообщений. Состояние обновляется индивидуально для каждого сообщения, игнорируя ошибки",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Устройство",
"Сообщения"
],
"summary": "Обновить состояние сообщений",
"parameters": [
{
"description": "Состояние сообщений",
"name": "request",
"in": "body",
"required": true,
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/smsgateway.MessageState"
}
}
}
],
"responses": {
"204": {
"description": "Обновление выполнено"
},
"400": {
"description": "Некорректный запрос",
"schema": {
"$ref": "#/definitions/smsgateway.ErrorResponse"
}
},
"500": {
"description": "Внутренняя ошибка сервера",
"schema": {
"$ref": "#/definitions/smsgateway.ErrorResponse"
}
}
}
}
}
},
"definitions": {
"smsgateway.ErrorResponse": {
"type": "object",
"properties": {
"code": {
"description": "код ошибки",
"type": "integer"
},
"data": {
"description": "контекст"
},
"message": {
"description": "текст ошибки",
"type": "string",
"example": "Произошла ошибка"
}
}
},
"smsgateway.Message": {
"type": "object",
"required": [
"message",
"phoneNumbers"
],
"properties": {
"id": {
"description": "Идентификатор",
"type": "string",
"maxLength": 36,
"example": "PyDmBQZZXYmyxMwED8Fzy"
},
"message": {
"description": "Текст сообщения",
"type": "string",
"maxLength": 256,
"example": "Hello World!"
},
"phoneNumbers": {
"description": "Получатели",
"type": "array",
"maxItems": 100,
"minItems": 1,
"items": {
"type": "string"
},
"example": [
"79990001234"
]
},
"simNumber": {
"description": "Номер сим-карты",
"type": "integer",
"maximum": 3,
"example": 1
},
"ttl": {
"description": "Время жизни сообщения в секундах",
"type": "integer",
"minimum": 5,
"example": 86400
}
}
},
"smsgateway.MessageState": {
"type": "object",
"required": [
"recipients",
"state"
],
"properties": {
"id": {
"description": "Идентификатор",
"type": "string",
"maxLength": 36,
"example": "PyDmBQZZXYmyxMwED8Fzy"
},
"recipients": {
"description": "Детализация состояния по получателям",
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/definitions/smsgateway.RecipientState"
}
},
"state": {
"description": "Состояние",
"allOf": [
{
"$ref": "#/definitions/smsgateway.ProcessState"
}
],
"example": "Pending"
}
}
},
"smsgateway.MobileRegisterRequest": {
"type": "object",
"properties": {
"name": {
"description": "Имя устройства",
"type": "string",
"maxLength": 128,
"example": "Android Phone"
},
"pushToken": {
"description": "Токен для отправки PUSH-уведомлений",
"type": "string",
"maxLength": 256,
"example": "gHz-T6NezDlOfllr7F-Be"
}
}
},
"smsgateway.MobileRegisterResponse": {
"type": "object",
"properties": {
"id": {
"description": "Идентификатор",
"type": "string",
"example": "QslD_GefqiYV6RQXdkM6V"
},
"login": {
"description": "Логин пользователя",
"type": "string",
"example": "VQ4GII"
},
"password": {
"description": "Пароль пользователя",
"type": "string",
"example": "cp2pydvxd2zwpx"
},
"token": {
"description": "Ключ доступа",
"type": "string",
"example": "bP0ZdK6rC6hCYZSjzmqhQ"
}
}
},
"smsgateway.MobileUpdateRequest": {
"type": "object",
"properties": {
"id": {
"description": "Идентификатор, если есть",
"type": "string",
"example": "QslD_GefqiYV6RQXdkM6V"
},
"pushToken": {
"description": "Токен для отправки PUSH-уведомлений",
"type": "string",
"maxLength": 256,
"example": "gHz-T6NezDlOfllr7F-Be"
}
}
},
"smsgateway.ProcessState": {
"type": "string",
"enum": [
"Pending",
"Processed",
"Sent",
"Delivered",
"Failed"
],
"x-enum-comments": {
"MessageStateDelivered": "Доставлено",
"MessageStateFailed": "Ошибка",
"MessageStatePending": "В ожидании",
"MessageStateProcessed": "Обработано",
"MessageStateSent": "Отправлено"
},
"x-enum-varnames": [
"MessageStatePending",
"MessageStateProcessed",
"MessageStateSent",
"MessageStateDelivered",
"MessageStateFailed"
]
},
"smsgateway.RecipientState": {
"type": "object",
"required": [
"phoneNumber",
"state"
],
"properties": {
"error": {
"description": "Ошибка",
"type": "string",
"example": "timeout"
},
"phoneNumber": {
"description": "Номер телефона",
"type": "string",
"minLength": 10,
"example": "79990001234"
},
"state": {
"description": "Состояние",
"allOf": [
{
"$ref": "#/definitions/smsgateway.ProcessState"
}
],
"example": "Pending"
}
}
}
},
"securityDefinitions": {
"ApiAuth": {
"type": "basic"
},
"MobileToken": {
"description": "Авторизацию устройства по токену",
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
}
}