/
dOJer113
/
Insect
Обзор
Документация
Войти
/
dOJer113
/
Insect
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
server
InsectOpenApi.json
448 строк
15 KB
aleks
испорченный в процессе файл
21 дек 2025, 16:42
21 дек 2025, 16:42
b801f0a
Код
Авторство
О чём код?
{ "openapi": "3.0.1", "info": { "title": "API для насекомых", "description": "REST API для управления насекомыми с дискриминатором typeName.", "version": "1.0.0" }, "servers": [ { "url": "https://127.0.0.1:5001/v1", "description": "Локальный сервер разработки" } ], "tags": [ { "name": "Insects", "description": "Операции с насекомыми" } ], "paths": { "/insects/list": { "get": { "tags": ["Insects"], "summary": "Получить список насекомых", "operationId": "GetInsectList", "responses": { "200": { "$ref": "#/components/responses/InsectListResponse" }, "500": { "$ref": "#/components/responses/InternalServerError" } } } }, "/insects/{id}": { "parameters": [ { "$ref": "#/components/parameters/InsectIdParam" } ], "get": { "tags": ["Insects"], "summary": "Получить насекомое по идентификатору", "operationId": "GetInsect", "responses": { "200": { "$ref": "#/components/responses/InsectResponse" }, "404": { "$ref": "#/components/responses/NotFound" }, "500": { "$ref": "#/components/responses/InternalServerError" } } }, "put": { "tags": ["Insects"], "summary": "Обновить насекомое", "operationId": "UpdateInsect", "requestBody": { "$ref": "#/components/requestBodies/InsectUpdateBody" }, "responses": { "200": { "$ref": "#/components/responses/SuccessResponse" }, "400": { "$ref": "#/components/responses/ValidationError" }, "404": { "$ref": "#/components/responses/NotFound" }, "500": { "$ref": "#/components/responses/InternalServerError" } } }, "delete": { "tags": ["Insects"], "summary": "Удалить насекомое", "operationId": "DeleteInsect", "responses": { "200": { "$ref": "#/components/responses/SuccessResponse" }, "404": { "$ref": "#/components/responses/NotFound" }, "500": { "$ref": "#/components/responses/InternalServerError" } } } }, "/insects": { "post": { "tags": ["Insects"], "summary": "Создать новое насекомое", "operationId": "CreateInsect", "requestBody": { "$ref": "#/components/requestBodies/InsectCreateBody" }, "responses": { "201": { "$ref": "#/components/responses/CreatedResponse" }, "400": { "$ref": "#/components/responses/ValidationError" }, "500": { "$ref": "#/components/responses/InternalServerError" } } } } }, "components": { "parameters": { "InsectIdParam": { "name": "id", "in": "path", "required": true, "schema": { "$ref": "#/components/schemas/InsectId" }, "description": "Идентификатор насекомого" } }, "schemas": { "Status": { "type": "object", "description": "Статус выполнения операции", "required": ["code", "description"], "properties": { "code": { "type": "integer", "format": "int32", "description": "HTTP код статуса ответа" }, "description": { "type": "string", "minLength": 1, "maxLength": 255, "description": "Текстовое описание статуса ответа" } } }, "InsectId": { "type": "integer", "format": "int32", "minimum": 1, "description": "Уникальный идентификатор насекомого" }, "InsectBase": { "type": "object", "description": "Базовые свойства насекомого", "required": ["typeName", "name", "hasWings", "mouthpieceType", "bodySize"], "properties": { "typeName": { "type": "string", "minLength": 1, "maxLength": 50, "enum": ["Ladybug", "Necrophages"], "description": "Тип насекомого, используется как дискриминатор для определения конкретного класса" }, "name": { "type": "string", "minLength": 2, "maxLength": 64, "description": "Название насекомого" }, "hasWings": { "type": "boolean", "description": "Наличие крыльев у насекомого" }, "mouthpieceType": { "type": "string", "minLength": 2, "maxLength": 32, "description": "Тип ротового аппарата насекомого" }, "bodySize": { "type": "number", "format": "double", "minimum": 0.01, "maximum": 100, "description": "Размер тела насекомого в сантиметрах" } }, "discriminator": { "propertyName": "typeName" } }, "InsectUpdateBase": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/InsectBase" }, { "type": "object", "required": ["id"], "properties": { "id": { "$ref": "#/components/schemas/InsectId" } }, "description": "Базовые поля для обновления насекомого, включая идентификатор" } ] }, "BeetleBase": { "type": "object", "description": "Базовые свойства жука с жвалами", "required": ["mandibleSize"], "properties": { "mandibleSize": { "type": "number", "format": "double", "minimum": 0.01, "maximum": 5, "description": "Размер жвал (мандибул) жука в сантиметрах" } } }, "Ladybug": { "title": "Ladybug", "type": "object", "description": "Божья коровка - тип насекомого с жвалами и пятнами на надкрыльях", "allOf": [ { "$ref": "#/components/schemas/InsectBase" }, { "$ref": "#/components/schemas/BeetleBase" }, { "type": "object", "required": ["numberOfSpots"], "properties": { "numberOfSpots": { "type": "integer", "format": "int32", "minimum": 2, "maximum": 10, "description": "Количество пятен на надкрыльях божьей коровки" } } } ] }, "Necrophages": { "title": "Necrophages", "type": "object", "description": "Жук-некрофаг - тип насекомого с жвалами, обитающий на определенной стадии сукцессии", "allOf": [ { "$ref": "#/components/schemas/InsectBase" }, { "$ref": "#/components/schemas/BeetleBase" }, { "type": "object", "required": ["stageOfSuccession"], "properties": { "stageOfSuccession": { "type": "integer", "format": "int32", "minimum": 1, "maximum": 5, "description": "Стадия сукцессии, на которой обитает жук-некрофаг (от 1 до 5)" } } } ] }, "LadybugUpdate": { "title": "LadybugUpdate", "type": "object", "description": "Данные для обновления божьей коровки", "allOf": [ { "$ref": "#/components/schemas/InsectUpdateBase" }, { "$ref": "#/components/schemas/BeetleBase" }, { "type": "object", "required": ["numberOfSpots"], "properties": { "numberOfSpots": { "type": "integer", "format": "int32", "minimum": 2, "maximum": 10, "description": "Количество пятен на надкрыльях божьей коровки" } } } ] }, "NecrophagesUpdate": { "title": "NecrophagesUpdate", "type": "object", "description": "Данные для обновления жука-некрофага", "allOf": [ { "$ref": "#/components/schemas/InsectUpdateBase" }, { "$ref": "#/components/schemas/BeetleBase" }, { "type": "object", "required": ["stageOfSuccession"], "properties": { "stageOfSuccession": { "type": "integer", "format": "int32", "minimum": 1, "maximum": 5, "description": "Стадия сукцессии, на которой обитает жук-некрофаг (от 1 до 5)" } } } ] }, "InsectCreate": { "description": "Данные для создания нового насекомого (божья коровка или жук-некрофаг)", "oneOf": [ { "$ref": "#/components/schemas/Ladybug" }, { "$ref": "#/components/schemas/Necrophages" } ], "discriminator": { "propertyName": "typeName", "mapping": { "Ladybug": "#/components/schemas/Ladybug", "Necrophages": "#/components/schemas/Necrophages" } } }, "InsectUpdate": { "description": "Данные для обновления существующего насекомого (божья коровка или жук-некрофаг)", "oneOf": [ { "$ref": "#/components/schemas/LadybugUpdate" }, { "$ref": "#/components/schemas/NecrophagesUpdate" } ], "discriminator": { "propertyName": "typeName", "mapping": { "Ladybug": "#/components/schemas/LadybugUpdate", "Necrophages": "#/components/schemas/NecrophagesUpdate" } } }, "Insect": { "description": "Полные данные насекомого с идентификатором", "$ref": "#/components/schemas/InsectUpdate" }, "StatusOnly": { "type": "object", "description": "Ответ, содержащий только статус операции", "required": ["status"], "properties": { "status": { "$ref": "#/components/schemas/Status", "description": "Статус выполнения операции" } } } }, "requestBodies": { "InsectCreateBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/InsectCreate" } } } }, "InsectUpdateBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/InsectUpdate" } } } } }, "responses": { "InsectListResponse": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "required": ["status", "insects"], "properties": { "status": { "$ref": "#/components/schemas/Status", "description": "Статус выполнения операции" }, "insects": { "type": "array", "items": { "$ref": "#/components/schemas/Insect" }, "description": "Список насекомых" } } } } } }, "InsectResponse": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "required": ["status", "insect"], "properties": { "status": { "$ref": "#/components/schemas/Status", "description": "Статус выполнения операции" }, "insect": { "$ref": "#/components/schemas/Insect", "description": "Данные насекомого" } } } } } }, "CreatedResponse": { "description": "Created", "content": { "application/json": { "schema": { "type": "object", "required": ["status", "id"], "properties": { "status": { "$ref": "#/components/schemas/Status", "description": "Статус выполнения операции" }, "id": { "$ref": "#/components/schemas/InsectId", "description": "Идентификатор созданного насекомого" } } } } } }, "SuccessResponse": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/StatusOnly" } } } }, "ValidationError": { "description": "Validation error", "content": { "application/json": { "schema": { "type": "object", "required": ["status", "errors"], "properties": { "status": { "$ref": "#/components/schemas/Status", "description": "Статус выполнения операции" }, "errors": { "type": "array", "items": { "type": "string", "minLength": 1, "maxLength": 255 }, "description": "Список ошибок валидации" } } } } } }, "NotFound": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/StatusOnly" } } } }, "InternalServerError": { "description": "Internal server error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/StatusOnly" } } } } } } }