352 lines
12 KiB
JSON
352 lines
12 KiB
JSON
{
|
||
"swagger": "2.0",
|
||
"info": {
|
||
"description": "API для агрегации онлайн-подписок пользователей.",
|
||
"title": "Subscription API",
|
||
"contact": {},
|
||
"version": "1.0"
|
||
},
|
||
"basePath": "/",
|
||
"paths": {
|
||
"/subscriptions": {
|
||
"get": {
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"subscriptions"
|
||
],
|
||
"summary": "Список подписок",
|
||
"responses": {
|
||
"200": {
|
||
"description": "OK",
|
||
"schema": {
|
||
"type": "array",
|
||
"items": {
|
||
"$ref": "#/definitions/model.Subscription"
|
||
}
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Internal Server Error",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"post": {
|
||
"consumes": [
|
||
"application/json"
|
||
],
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"subscriptions"
|
||
],
|
||
"summary": "Создать подписку",
|
||
"parameters": [
|
||
{
|
||
"description": "Создание подписки",
|
||
"name": "subscription",
|
||
"in": "body",
|
||
"required": true,
|
||
"schema": {
|
||
"$ref": "#/definitions/handler.CreateSubscriptionRequest"
|
||
}
|
||
}
|
||
],
|
||
"responses": {
|
||
"201": {
|
||
"description": "Created",
|
||
"schema": {
|
||
"$ref": "#/definitions/model.Subscription"
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "Bad Request",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Internal Server Error",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/subscriptions/sum": {
|
||
"get": {
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"subscriptions"
|
||
],
|
||
"summary": "Суммарная стоимость подписок за период с фильтрацией",
|
||
"parameters": [
|
||
{
|
||
"type": "string",
|
||
"description": "UUID пользователя",
|
||
"name": "user_id",
|
||
"in": "query"
|
||
},
|
||
{
|
||
"type": "string",
|
||
"description": "Название сервиса",
|
||
"name": "service_name",
|
||
"in": "query"
|
||
},
|
||
{
|
||
"type": "string",
|
||
"example": "\"07-2025\"",
|
||
"description": "Начало периода, формат MM-YYYY",
|
||
"name": "start",
|
||
"in": "query",
|
||
"required": true
|
||
},
|
||
{
|
||
"type": "string",
|
||
"example": "\"08-2025\"",
|
||
"description": "Конец периода, формат MM-YYYY",
|
||
"name": "end",
|
||
"in": "query",
|
||
"required": true
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "OK",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": {
|
||
"type": "integer"
|
||
}
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "Bad Request",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Internal Server Error",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/subscriptions/{id}": {
|
||
"get": {
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"subscriptions"
|
||
],
|
||
"summary": "Получить подписку по ID",
|
||
"parameters": [
|
||
{
|
||
"type": "integer",
|
||
"description": "ID подписки",
|
||
"name": "id",
|
||
"in": "path",
|
||
"required": true
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "OK",
|
||
"schema": {
|
||
"$ref": "#/definitions/model.Subscription"
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "Bad Request",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"404": {
|
||
"description": "Not Found",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"put": {
|
||
"consumes": [
|
||
"application/json"
|
||
],
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"subscriptions"
|
||
],
|
||
"summary": "Обновить подписку по ID",
|
||
"parameters": [
|
||
{
|
||
"type": "integer",
|
||
"description": "ID подписки",
|
||
"name": "id",
|
||
"in": "path",
|
||
"required": true
|
||
},
|
||
{
|
||
"description": "Обновление подписки",
|
||
"name": "subscription",
|
||
"in": "body",
|
||
"required": true,
|
||
"schema": {
|
||
"$ref": "#/definitions/handler.CreateSubscriptionRequest"
|
||
}
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "OK",
|
||
"schema": {
|
||
"$ref": "#/definitions/model.Subscription"
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "Bad Request",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Internal Server Error",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"delete": {
|
||
"tags": [
|
||
"subscriptions"
|
||
],
|
||
"summary": "Удалить подписку по ID",
|
||
"parameters": [
|
||
{
|
||
"type": "integer",
|
||
"description": "ID подписки",
|
||
"name": "id",
|
||
"in": "path",
|
||
"required": true
|
||
}
|
||
],
|
||
"responses": {
|
||
"204": {
|
||
"description": "No Content"
|
||
},
|
||
"400": {
|
||
"description": "Bad Request",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Internal Server Error",
|
||
"schema": {
|
||
"type": "object",
|
||
"additionalProperties": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"definitions": {
|
||
"handler.CreateSubscriptionRequest": {
|
||
"type": "object",
|
||
"properties": {
|
||
"end_date": {
|
||
"type": "string",
|
||
"example": "12-2025"
|
||
},
|
||
"price": {
|
||
"type": "integer",
|
||
"example": 400
|
||
},
|
||
"service_name": {
|
||
"type": "string",
|
||
"example": "Yandex Plus"
|
||
},
|
||
"start_date": {
|
||
"type": "string",
|
||
"example": "07-2025"
|
||
},
|
||
"user_id": {
|
||
"type": "string",
|
||
"example": "60601fee-2bf1-4721-ae6f-7636e79a0cba"
|
||
}
|
||
}
|
||
},
|
||
"model.Subscription": {
|
||
"type": "object",
|
||
"properties": {
|
||
"end_date": {
|
||
"type": "string"
|
||
},
|
||
"id": {
|
||
"type": "integer"
|
||
},
|
||
"price": {
|
||
"type": "integer"
|
||
},
|
||
"service_name": {
|
||
"type": "string"
|
||
},
|
||
"start_date": {
|
||
"type": "string"
|
||
},
|
||
"user_id": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} |