L10b Betrieb & Aufräumen: OpenAPI 3.1 unter /api/v1/openapi.json, API-Doku und API-Test
- src/lib/api/openapi.ts: statisch gepflegte Spezifikation aller v1-Routen inkl. Fehlerformat, Pagination, Idempotenz (clientOpId/clientId), Konflikte, Rate Limits, Rechte je Operation. - GET /api/v1/openapi.json liefert das Dokument (angemeldete Nutzer). - docs/craftvia/API.md: Kurzdoku mit Endpunkt-Tabelle. - scripts/test-betrieb-api.ts: jede Route nutzt requireApiContext/respond.ts, 401 ohne Sitzung im einheitlichen Format, 403 bei fremdem Origin/Sec-Fetch-Site, Fehler-Mapping, Rate Limit je Nutzer (Standard/Einsatz getrennt), OpenAPI deckt jede route.ts ab. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { openApiDocument } from "@/lib/api/openapi";
|
||||
|
||||
/**
|
||||
* GET /api/v1/openapi.json — the statically maintained OpenAPI 3.1 document (src/lib/api/openapi.ts).
|
||||
*
|
||||
* Auth: src/proxy.ts rejects every /api/v1 request without a session cookie with 401, so the
|
||||
* document is only reachable for signed-in users. It contains no tenant data, therefore no
|
||||
* further permission/module check is done here (deliberately — any API client may read it).
|
||||
*/
|
||||
export function GET() {
|
||||
return Response.json(openApiDocument, { headers: { "Cache-Control": "private, max-age=300" } });
|
||||
}
|
||||
Reference in New Issue
Block a user