refactor(core,packaging): relocate embedded assets and binary runtime to src/packaging and enforce core whitelist
This commit is contained in:
1 parent
3864f0ffd0
commit
27c86e052a
10 files changed
+20
-5
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import wrappedOpenApi from "../../dist/openapi.json" with { type: "json" };
|
||||
import rawOpenApi from "../../dist/raw-hose-openapi.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;
|
||||
}
|
||||
Reference in new issue
Block a user