docs: refresh API explorer for updated endpoints

This commit is contained in:
2026-06-27 21:47:45 +02:00
parent 23bb370836
commit c5d0a7c7e5
2 changed files with 16 additions and 16 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
+15 -15
View File
@@ -1,37 +1,37 @@
async function loadSpec() { async function loadSpec() {
const response = await fetch("/openapi.json"); const response = await fetch('/openapi.json');
const spec = await response.json(); const spec = await response.json();
if (!response.ok) { if (!response.ok) {
throw new Error(spec.error || "Failed to load OpenAPI spec"); throw new Error(spec.error || 'Failed to load OpenAPI spec');
} }
return spec; return spec;
} }
function methodPayload(operation) { function methodPayload(operation) {
const body = operation.requestBody?.content?.["application/json"]?.schema; const body = operation.requestBody?.content?.['application/json']?.schema;
if (!body) return ""; if (!body) return '';
return JSON.stringify(body.example || body.properties || body, null, 2); return JSON.stringify(body.example || body.properties || body, null, 2);
} }
function renderSpec(spec) { function renderSpec(spec) {
const root = document.getElementById("api-docs"); const root = document.getElementById('api-docs');
const sectionTemplate = document.getElementById("api-section-template"); const sectionTemplate = document.getElementById('api-section-template');
const methodTemplate = document.getElementById("api-method-template"); const methodTemplate = document.getElementById('api-method-template');
root.innerHTML = ""; root.innerHTML = '';
Object.entries(spec.paths || {}).forEach(([path, methods]) => { Object.entries(spec.paths || {}).forEach(([path, methods]) => {
const section = sectionTemplate.content.firstElementChild.cloneNode(true); const section = sectionTemplate.content.firstElementChild.cloneNode(true);
section.querySelector(".api-path").textContent = path; section.querySelector('.api-path').textContent = path;
const methodsRoot = section.querySelector(".api-methods"); const methodsRoot = section.querySelector('.api-methods');
Object.entries(methods).forEach(([method, operation]) => { Object.entries(methods).forEach(([method, operation]) => {
const node = methodTemplate.content.firstElementChild.cloneNode(true); const node = methodTemplate.content.firstElementChild.cloneNode(true);
node.querySelector(".api-verb").textContent = method.toUpperCase(); node.querySelector('.api-verb').textContent = method.toUpperCase();
node.querySelector(".api-summary").textContent = operation.summary || ""; node.querySelector('.api-summary').textContent = operation.summary || '';
node.querySelector(".api-description").textContent = operation.description || ""; node.querySelector('.api-description').textContent = operation.description || '';
const body = methodPayload(operation); const body = methodPayload(operation);
const bodyNode = node.querySelector(".api-body"); const bodyNode = node.querySelector('.api-body');
if (body) { if (body) {
bodyNode.textContent = body; bodyNode.textContent = body;
} else { } else {
@@ -49,5 +49,5 @@ loadSpec()
.then(renderSpec) .then(renderSpec)
.catch((error) => { .catch((error) => {
console.error(error); console.error(error);
document.getElementById("api-docs").innerHTML = `<section class="panel">${error.message}</section>`; document.getElementById('api-docs').innerHTML = `<section class="panel">${error.message}</section>`;
}); });