Add OpenAPI schema generation and validation for API routes
This commit is contained in:
1 parent
5d822e6c7e
commit
5ce5664b29
25 files changed
+2019
-52
No files matched your search
@@ -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`;
|
||||
}
|
||||
Reference in new issue
Block a user