v0.4.2: fix 5 багов OpenAPI — security, nullable, RunResponse.error, pageSize

This commit is contained in:
2026-08-01 19:31:06 +04:00
parent 352a33f588
commit 0539011ca4
2 changed files with 18 additions and 14 deletions
+1 -1
View File
@@ -71,4 +71,4 @@ DELAY = float(os.getenv("MOCK_OP_DELAY", "0.1"))
# Версия полигона — единый источник правды для app.py и routes/root.py. # Версия полигона — единый источник правды для app.py и routes/root.py.
# Меняется при КАЖДОМ изменении кода. # Меняется при КАЖДОМ изменении кода.
VERSION = "0.4.1" VERSION = "0.4.2"
+17 -13
View File
@@ -68,9 +68,7 @@ def _build_spec():
"description": "Polygon (mock)", "description": "Polygon (mock)",
}, },
], ],
"security": [ "security": [],
{"bearerAuth": []},
],
"tags": [ "tags": [
{"name": "services", "description": "Сервисы (каталог)"}, {"name": "services", "description": "Сервисы (каталог)"},
{"name": "instances", "description": "Инстансы (CRUD)"}, {"name": "instances", "description": "Инстансы (CRUD)"},
@@ -81,11 +79,11 @@ def _build_spec():
"paths": _build_paths(), "paths": _build_paths(),
"components": { "components": {
"securitySchemes": { "securitySchemes": {
"bearerAuth": { "mockAuth": {
"type": "http", "type": "apiKey",
"scheme": "bearer", "in": "header",
"bearerFormat": "token", "name": "X-Mock-Auth",
"description": "MOCK_AUTH_TOKEN (по умолчанию: test-token-123)", "description": "Токен для _mock/* эндпоинтов (по умолчанию: test-token-123)",
}, },
}, },
"schemas": { "schemas": {
@@ -235,9 +233,9 @@ def _build_spec():
"operation": {"type": "string"}, "operation": {"type": "string"},
"kind": {"type": "string", "description": "instance | access"}, "kind": {"type": "string", "description": "instance | access"},
"action": {"type": "string", "description": "create | modify | delete | …"}, "action": {"type": "string", "description": "create | modify | delete | …"},
"dtStart": {"type": "string", "format": "date-time"}, "dtStart": {"type": ["string", "null"], "format": "date-time"},
"dtFinish": {"type": "string", "format": "date-time", "nullable": True}, "dtFinish": {"type": ["string", "null"], "format": "date-time"},
"isSuccessful": {"type": "boolean"}, "isSuccessful": {"type": ["boolean", "null"]},
"errorLog": {"type": "string"}, "errorLog": {"type": "string"},
"svc": {"type": "string"}, "svc": {"type": "string"},
"stages": {"type": "array", "items": {"$ref": "#/components/schemas/Stage"}}, "stages": {"type": "array", "items": {"$ref": "#/components/schemas/Stage"}},
@@ -288,6 +286,7 @@ def _build_spec():
"type": "object", "type": "object",
"properties": { "properties": {
"ok": {"type": "boolean"}, "ok": {"type": "boolean"},
"error": {"type": "string", "description": "Сообщение об ошибке (только при ok=false)"},
}, },
}, },
"MockState": { "MockState": {
@@ -389,8 +388,8 @@ def _build_paths():
{ {
"name": "pageSize", "name": "pageSize",
"in": "query", "in": "query",
"schema": {"type": "integer", "default": 200, "maximum": 200}, "schema": {"type": "integer", "default": 200},
"description": "Размер страницы (макс. 200)", "description": "Размер страницы (значения > 200 обрезаются до 200)",
}, },
{ {
"name": "page", "name": "page",
@@ -703,6 +702,7 @@ def _build_paths():
"summary": "Сброс состояния", "summary": "Сброс состояния",
"description": "Удаляет **все** инстансы, операции и параметры. Используется в тестах для изоляции.", "description": "Удаляет **все** инстансы, операции и параметры. Используется в тестах для изоляции.",
"operationId": "mockReset", "operationId": "mockReset",
"security": [{"mockAuth": []}],
"responses": { "responses": {
"200": { "200": {
"description": "Состояние сброшено", "description": "Состояние сброшено",
@@ -717,6 +717,7 @@ def _build_paths():
"summary": "Дамп состояния", "summary": "Дамп состояния",
"description": "Возвращает все инстансы и операции для отладки.", "description": "Возвращает все инстансы и операции для отладки.",
"operationId": "mockState", "operationId": "mockState",
"security": [{"mockAuth": []}],
"responses": { "responses": {
"200": { "200": {
"description": "Текущее состояние", "description": "Текущее состояние",
@@ -731,6 +732,7 @@ def _build_paths():
"summary": "Список загруженных сервисов", "summary": "Список загруженных сервисов",
"description": "Возвращает все загруженные сервисы с количеством операций и параметров.", "description": "Возвращает все загруженные сервисы с количеством операций и параметров.",
"operationId": "mockServices", "operationId": "mockServices",
"security": [{"mockAuth": []}],
"responses": { "responses": {
"200": { "200": {
"description": "Список сервисов", "description": "Список сервисов",
@@ -748,6 +750,7 @@ def _build_paths():
"Минимум: 0, максимум: 5 (защита /health)." "Минимум: 0, максимум: 5 (защита /health)."
), ),
"operationId": "mockSetDelay", "operationId": "mockSetDelay",
"security": [{"mockAuth": []}],
"parameters": [ "parameters": [
{ {
"name": "seconds", "name": "seconds",
@@ -778,6 +781,7 @@ def _build_paths():
"Позволяет тестировать негативные сценарии." "Позволяет тестировать негативные сценарии."
), ),
"operationId": "mockFailNext", "operationId": "mockFailNext",
"security": [{"mockAuth": []}],
"responses": { "responses": {
"200": { "200": {
"description": "Флаг установлен", "description": "Флаг установлен",