(function () { "use strict"; const SPEC_URL = window.__DOXA_API_SPEC_URL__ || "doxaApi.json"; let apis = []; let activeApiIndex = 0; let spec = null; let activeEndpoint = null; let activeTryTab = "body"; let collapsedGroups = new Set(JSON.parse(localStorage.getItem("DoxaApi.collapsed") || "[]")); const el = { nav: document.getElementById("navContent"), detail: document.getElementById("detailContent"), try: document.getElementById("tryContent"), search: document.getElementById("searchInput"), themeToggle: document.getElementById("themeToggle"), brandTitle: document.getElementById("brandTitle"), brandVersion: document.getElementById("brandVersion"), apiSelector: document.getElementById("apiSelector"), }; function refreshApiSelector(){ if(!el.apiSelector) return; el.apiSelector.innerHTML = apis.map((a,i)=>``).join(''); el.apiSelector.value=String(activeApiIndex); } async function init() { renderSkeleton(); try { const res = await fetch(SPEC_URL); if (!res.ok) throw new Error("HTTP " + res.status); const importedSpec = await res.json(); const extend = apis.length > 0 && window.confirm("Extend the currently selected API?\n\nOK = Extend Current API\nCancel = Import As New API (default)"); if (extend) { spec.groups = [...(spec.groups||[]), ...(importedSpec.groups||[])]; spec.schemas = Object.assign(spec.schemas||{}, importedSpec.schemas||{}); } else { apis.push(importedSpec); activeApiIndex = apis.length - 1; spec = importedSpec; } refreshApiSelector(); if(spec.info && spec.info.title) el.brandTitle.textContent = spec.info.title; if(spec.info && spec.info.version) el.brandVersion.textContent = spec.info.version; } catch (err) { el.nav.innerHTML = `
`; return; } if (spec.info && spec.info.title) el.brandTitle.textContent = spec.info.title; if (spec.info && spec.info.version) el.brandVersion.textContent = spec.info.version; document.title = (spec.info && spec.info.title) || "API Documentation"; renderNav(""); renderOverview(); renderTryEmpty(); bindGlobalEvents(); } function renderSkeleton() { el.nav.innerHTML = Array.from({ length: 6 }) .map(() => ``) .join(""); } function totalEndpointCount() { return (spec.groups || []).reduce((n, g) => n + g.endpoints.length, 0); } function totalSchemaCount() { return Object.keys(spec.schemas || {}).length; } // Nav rendering function renderNav(filterText) { const term = filterText.trim().toLowerCase(); const groups = spec.groups || []; let html = ``; if (groups.length === 0) { html += ``; el.nav.innerHTML = html; return; } let totalMatches = 0; let groupHtml = ""; for (const group of groups) { const endpoints = group.endpoints.filter((e) => matchesFilter(e, term)); if (term && endpoints.length === 0) continue; totalMatches += endpoints.length; const isCollapsed = collapsedGroups.has(group.name) && !term; groupHtml += ` `; } if (term && totalMatches === 0) { html += ``; } else { html += groupHtml; } el.nav.innerHTML = html; } function navEndpointHtml(group, endpoint) { const isActive = activeEndpoint && activeEndpoint.endpoint.operationId === endpoint.operationId; return ` `; } function matchesFilter(endpoint, term) { if (!term) return true; return ( endpoint.path.toLowerCase().includes(term) || (endpoint.summary || "").toLowerCase().includes(term) || endpoint.method.toLowerCase().includes(term) ); } // Overview / welcome screen function renderOverview() { const info = spec.info || {}; const groups = spec.groups || []; let html = `${escapeHtml(info.description)}
`; } html += ``; html += `${escapeHtml(endpoint.description)}
`; } if (endpoint.deprecated) { html += ``; } html += `| Name | Located in | Type | Description |
|---|---|---|---|
| ${escapeHtml(p.name)}${p.required ? '*' : ""} | ${p.in} | ${schemaTypeLabel(p.schema)} | ${escapeHtml(p.description || "-")} |