- Move generated OpenAPI bundles out of dist/ into committed specs/ (specs/openapi.json, specs/openapi.raw.json); source YAML tree moves openapi/ -> specs/openapi/; schemas/workflow-schema.json joins as specs/workflow-schema.json - Update all generators/consumers: bundle-openapi, generate-raw-openapi, check-version-sync, bump-version, export-workflow-schema, packaging/embedded-openapi - Rewrite stale .env.example with current HOSE_* environment variables - Archive stale repo-local enterprise configs (superseded by ~/.config/hose-use/enterprises) out of the repo; root enterprises/ keeps only the tracked example.json plus an explanatory README - Add missing directory READMEs: approval/contact/message/task/events domains, cli/, http/, packaging/ - Fix stale domain doc links in README.domains.md and docs/modules/platform.md
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
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<string, unknown> {
|
|
if (type === "raw") {
|
|
return rawOpenApi as Record<string, unknown>;
|
|
}
|
|
return wrappedOpenApi as Record<string, unknown>;
|
|
}
|
|
|
|
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<string, Record<string, any>>) || {};
|
|
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;
|
|
}
|