|
| 1 | +/** |
| 2 | + * OpenAPI 3.1 spec for the Simulated-Self API gateway. |
| 3 | + * Served at /openapi.json; Swagger UI at /docs. |
| 4 | + */ |
| 5 | +export const openapiSpec = { |
| 6 | + openapi: '3.1.0', |
| 7 | + info: { |
| 8 | + title: 'Simulated-Self API', |
| 9 | + version: '0.1.0', |
| 10 | + description: |
| 11 | + 'Health, readiness, vision diagnostics, and Prometheus metrics for the Simulated-Self gateway.', |
| 12 | + }, |
| 13 | + servers: [{ url: '/', description: 'current host' }], |
| 14 | + paths: { |
| 15 | + '/healthz': { |
| 16 | + get: { |
| 17 | + summary: 'Liveness probe', |
| 18 | + responses: { |
| 19 | + 200: { |
| 20 | + description: 'Process alive', |
| 21 | + content: { |
| 22 | + 'application/json': { |
| 23 | + schema: { |
| 24 | + type: 'object', |
| 25 | + required: ['ok', 'ts'], |
| 26 | + properties: { ok: { const: true }, ts: { type: 'integer' } }, |
| 27 | + }, |
| 28 | + }, |
| 29 | + }, |
| 30 | + }, |
| 31 | + }, |
| 32 | + }, |
| 33 | + }, |
| 34 | + '/readyz': { |
| 35 | + get: { |
| 36 | + summary: 'Deep readiness probe', |
| 37 | + description: |
| 38 | + 'Aggregates Redis ping, WebSocket session pressure, and model manifest availability.', |
| 39 | + responses: { |
| 40 | + 200: { description: 'Ready', content: { 'application/json': { schema: { $ref: '#/components/schemas/Readiness' } } } }, |
| 41 | + 503: { description: 'Not ready', content: { 'application/json': { schema: { $ref: '#/components/schemas/Readiness' } } } }, |
| 42 | + }, |
| 43 | + }, |
| 44 | + }, |
| 45 | + '/diagnostics/vision': { |
| 46 | + get: { |
| 47 | + summary: 'Vision worker model preflight', |
| 48 | + parameters: [ |
| 49 | + { |
| 50 | + name: 'modelBaseUrl', |
| 51 | + in: 'query', |
| 52 | + required: false, |
| 53 | + schema: { type: 'string', format: 'uri' }, |
| 54 | + description: 'Override the model base URL (defaults to <origin>/models).', |
| 55 | + }, |
| 56 | + ], |
| 57 | + responses: { |
| 58 | + 200: { description: 'All model manifests reachable', content: { 'application/json': { schema: { $ref: '#/components/schemas/VisionPreflight' } } } }, |
| 59 | + 503: { description: 'One or more model manifests failed to resolve', content: { 'application/json': { schema: { $ref: '#/components/schemas/VisionPreflight' } } } }, |
| 60 | + }, |
| 61 | + }, |
| 62 | + }, |
| 63 | + '/metrics': { |
| 64 | + get: { |
| 65 | + summary: 'Prometheus metrics', |
| 66 | + responses: { |
| 67 | + 200: { |
| 68 | + description: 'text/plain; version=0.0.4', |
| 69 | + content: { 'text/plain': { schema: { type: 'string' } } }, |
| 70 | + }, |
| 71 | + }, |
| 72 | + }, |
| 73 | + }, |
| 74 | + }, |
| 75 | + components: { |
| 76 | + schemas: { |
| 77 | + Readiness: { |
| 78 | + type: 'object', |
| 79 | + required: ['ok', 'ts', 'checks'], |
| 80 | + properties: { |
| 81 | + ok: { type: 'boolean' }, |
| 82 | + ts: { type: 'integer' }, |
| 83 | + checks: { |
| 84 | + type: 'object', |
| 85 | + properties: { |
| 86 | + redis: { type: 'object', properties: { ok: { type: 'boolean' }, latencyMs: { type: 'integer' }, error: { type: 'string' } } }, |
| 87 | + ws: { type: 'object', properties: { ok: { type: 'boolean' }, active: { type: 'integer' }, softCap: { type: 'integer' } } }, |
| 88 | + models: { type: 'object', properties: { ok: { type: 'boolean' }, failed: { type: 'array', items: { type: 'string' } } } }, |
| 89 | + }, |
| 90 | + }, |
| 91 | + }, |
| 92 | + }, |
| 93 | + VisionPreflight: { |
| 94 | + type: 'object', |
| 95 | + required: ['ok', 'modelBaseUrl', 'models', 'message'], |
| 96 | + properties: { |
| 97 | + ok: { type: 'boolean' }, |
| 98 | + modelBaseUrl: { type: 'string' }, |
| 99 | + worker: { type: 'string' }, |
| 100 | + message: { type: 'string' }, |
| 101 | + models: { |
| 102 | + type: 'array', |
| 103 | + items: { |
| 104 | + type: 'object', |
| 105 | + required: ['file', 'url', 'ok'], |
| 106 | + properties: { |
| 107 | + file: { type: 'string' }, |
| 108 | + url: { type: 'string' }, |
| 109 | + ok: { type: 'boolean' }, |
| 110 | + status: { type: 'integer' }, |
| 111 | + error: { type: 'string' }, |
| 112 | + }, |
| 113 | + }, |
| 114 | + }, |
| 115 | + }, |
| 116 | + }, |
| 117 | + }, |
| 118 | + }, |
| 119 | +} as const; |
| 120 | + |
| 121 | +export const swaggerHtml = `<!doctype html> |
| 122 | +<html lang="en"> |
| 123 | + <head> |
| 124 | + <meta charset="utf-8" /> |
| 125 | + <title>Simulated-Self API · Swagger UI</title> |
| 126 | + <link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css" /> |
| 127 | + </head> |
| 128 | + <body> |
| 129 | + <div id="ui"></div> |
| 130 | + <script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js" crossorigin></script> |
| 131 | + <script> |
| 132 | + window.ui = SwaggerUIBundle({ url: '/openapi.json', dom_id: '#ui', deepLinking: true }); |
| 133 | + </script> |
| 134 | + </body> |
| 135 | +</html>`; |
0 commit comments