Add OpenAPI schema generation and validation for API routes

This commit is contained in:
Mike Cao committed 2026-08-31 19:37:37 -07:00
1 parent 5d822e6c7e
commit 5ce5664b29
25 files changed
+2019 -52

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
function sortJson(value: unknown): unknown {
if (Array.isArray(value)) {
return value.map(sortJson);
}
if (value && typeof value === 'object') {
return Object.fromEntries(
Object.entries(value)
.sort(([left], [right]) => left.localeCompare(right))
.map(([key, child]) => [key, sortJson(child)]),
);
}
return value;
}
export function serializeOpenApiDocument(document: unknown) {
return `${JSON.stringify(sortJson(document), null, 2)}\n`;
}