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:
2026-09-14 18:19:19 +02:00
co-authored by Claude Opus 5
parent fb993a7730
commit 49f05c8db3
4 changed files with 1419 additions and 0 deletions
+12
View File
@@ -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" } });
}