import wrappedOpenApi from "../../specs/openapi.json" with { type: "json" }; import rawOpenApi from "../../specs/openapi.raw.json" with { type: "json" }; export type OpenApiType = "wrapped" | "raw"; export function getOpenApiSchema(type: OpenApiType = "wrapped"): Record { if (type === "raw") { return rawOpenApi as Record; } return wrappedOpenApi as Record; } export function listOpenApiPaths(type: OpenApiType = "wrapped"): Array<{ path: string; method: string; summary: string; tags: string[]; }> { const schema = getOpenApiSchema(type); const paths = (schema.paths as Record>) || {}; const results: Array<{ path: string; method: string; summary: string; tags: string[] }> = []; for (const [pathKey, methods] of Object.entries(paths)) { if (typeof methods !== "object" || methods === null) continue; for (const [method, def] of Object.entries(methods)) { if (["get", "post", "put", "delete", "patch"].includes(method.toLowerCase()) && typeof def === "object") { results.push({ path: pathKey, method: method.toUpperCase(), summary: def.summary || def.description || "", tags: def.tags || [], }); } } } return results; }