import { readFileSync } from 'node:fs'; import { parse } from 'yaml'; interface Endpoint { method: string; path: string; summary: string; tag: string; } const specPath = new URL('../openapi.yaml', import.meta.url).pathname; const spec = parse(readFileSync(specPath, 'utf-8')); const endpoints: Endpoint[] = []; for (const [path, methods] of Object.entries(spec.paths as Record>)) { for (const [method, details] of Object.entries(methods)) { if (['get', 'post', 'put', 'delete', 'patch'].includes(method)) { const op = details as { summary?: string; tags?: string[] }; endpoints.push({ method: method.toUpperCase(), path, summary: op.summary ?? '', tag: op.tags?.[0] ?? 'Untagged', }); } } } endpoints.sort((a, b) => a.path.localeCompare(b.path) || a.method.localeCompare(b.method)); console.log(JSON.stringify(endpoints, null, 2));