/api/openapi.json is generated from a table of endpoints and the Go types the handlers bind and return, including the limits of their binding tags, so the document follows the code. A test fails for routes missing from the table or documented but not served. /api/docs shows it with Swagger UI from our own assets, usable without internet access; "Try it out" works with the browser session. Closes #84 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
18 lines
542 B
JavaScript
18 lines
542 B
JavaScript
// Swagger UI for /api/openapi.json. "Try it out" uses the browser session,
|
|
// which needs the CSRF token on changes.
|
|
(() => {
|
|
const csrf = document.querySelector('meta[name="csrf-token"]')?.content;
|
|
window.SwaggerUIBundle({
|
|
url: "/api/openapi.json",
|
|
dom_id: "#swagger",
|
|
deepLinking: true,
|
|
tryItOutEnabled: false,
|
|
withCredentials: true,
|
|
defaultModelsExpandDepth: 0,
|
|
requestInterceptor: (req) => {
|
|
if (csrf && req.method !== "GET") req.headers["X-CSRF-Token"] = csrf;
|
|
return req;
|
|
},
|
|
});
|
|
})();
|