From 0539011ca45415c881fcd0c706652da51068b38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Sat, 1 Aug 2026 19:31:06 +0400 Subject: [PATCH] =?UTF-8?q?v0.4.2:=20fix=205=20=D0=B1=D0=B0=D0=B3=D0=BE?= =?UTF-8?q?=D0=B2=20OpenAPI=20=E2=80=94=20security,=20nullable,=20RunRespo?= =?UTF-8?q?nse.error,=20pageSize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/config/loader.py | 2 +- site/routes/openapi.py | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/site/config/loader.py b/site/config/loader.py index 503743b..1c83e7d 100644 --- a/site/config/loader.py +++ b/site/config/loader.py @@ -71,4 +71,4 @@ DELAY = float(os.getenv("MOCK_OP_DELAY", "0.1")) # Версия полигона — единый источник правды для app.py и routes/root.py. # Меняется при КАЖДОМ изменении кода. -VERSION = "0.4.1" +VERSION = "0.4.2" diff --git a/site/routes/openapi.py b/site/routes/openapi.py index 4574395..e72c5ae 100644 --- a/site/routes/openapi.py +++ b/site/routes/openapi.py @@ -68,9 +68,7 @@ def _build_spec(): "description": "Polygon (mock)", }, ], - "security": [ - {"bearerAuth": []}, - ], + "security": [], "tags": [ {"name": "services", "description": "Сервисы (каталог)"}, {"name": "instances", "description": "Инстансы (CRUD)"}, @@ -81,11 +79,11 @@ def _build_spec(): "paths": _build_paths(), "components": { "securitySchemes": { - "bearerAuth": { - "type": "http", - "scheme": "bearer", - "bearerFormat": "token", - "description": "MOCK_AUTH_TOKEN (по умолчанию: test-token-123)", + "mockAuth": { + "type": "apiKey", + "in": "header", + "name": "X-Mock-Auth", + "description": "Токен для _mock/* эндпоинтов (по умолчанию: test-token-123)", }, }, "schemas": { @@ -235,9 +233,9 @@ def _build_spec(): "operation": {"type": "string"}, "kind": {"type": "string", "description": "instance | access"}, "action": {"type": "string", "description": "create | modify | delete | …"}, - "dtStart": {"type": "string", "format": "date-time"}, - "dtFinish": {"type": "string", "format": "date-time", "nullable": True}, - "isSuccessful": {"type": "boolean"}, + "dtStart": {"type": ["string", "null"], "format": "date-time"}, + "dtFinish": {"type": ["string", "null"], "format": "date-time"}, + "isSuccessful": {"type": ["boolean", "null"]}, "errorLog": {"type": "string"}, "svc": {"type": "string"}, "stages": {"type": "array", "items": {"$ref": "#/components/schemas/Stage"}}, @@ -288,6 +286,7 @@ def _build_spec(): "type": "object", "properties": { "ok": {"type": "boolean"}, + "error": {"type": "string", "description": "Сообщение об ошибке (только при ok=false)"}, }, }, "MockState": { @@ -389,8 +388,8 @@ def _build_paths(): { "name": "pageSize", "in": "query", - "schema": {"type": "integer", "default": 200, "maximum": 200}, - "description": "Размер страницы (макс. 200)", + "schema": {"type": "integer", "default": 200}, + "description": "Размер страницы (значения > 200 обрезаются до 200)", }, { "name": "page", @@ -703,6 +702,7 @@ def _build_paths(): "summary": "Сброс состояния", "description": "Удаляет **все** инстансы, операции и параметры. Используется в тестах для изоляции.", "operationId": "mockReset", + "security": [{"mockAuth": []}], "responses": { "200": { "description": "Состояние сброшено", @@ -717,6 +717,7 @@ def _build_paths(): "summary": "Дамп состояния", "description": "Возвращает все инстансы и операции для отладки.", "operationId": "mockState", + "security": [{"mockAuth": []}], "responses": { "200": { "description": "Текущее состояние", @@ -731,6 +732,7 @@ def _build_paths(): "summary": "Список загруженных сервисов", "description": "Возвращает все загруженные сервисы с количеством операций и параметров.", "operationId": "mockServices", + "security": [{"mockAuth": []}], "responses": { "200": { "description": "Список сервисов", @@ -748,6 +750,7 @@ def _build_paths(): "Минимум: 0, максимум: 5 (защита /health)." ), "operationId": "mockSetDelay", + "security": [{"mockAuth": []}], "parameters": [ { "name": "seconds", @@ -778,6 +781,7 @@ def _build_paths(): "Позволяет тестировать негативные сценарии." ), "operationId": "mockFailNext", + "security": [{"mockAuth": []}], "responses": { "200": { "description": "Флаг установлен",