chore: sort open api spec keys (#2710)

This commit is contained in:
Jason Rasmussen 2023-06-10 00:14:18 -04:00 committed by GitHub
parent 9a3a01ca78
commit e3694695ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3320 additions and 3302 deletions

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,25 @@ export const handleDownload = (download: DownloadArchive, res: Response) => {
return download.stream;
};
function sortKeys<T extends object>(obj: T): T {
if (!obj) {
return obj;
}
const result: Partial<T> = {};
const keys = Object.keys(obj).sort() as Array<keyof T>;
for (const key of keys) {
result[key] = obj[key];
}
return result as T;
}
const patchOpenAPI = (document: OpenAPIObject) => {
document.paths = sortKeys(document.paths);
if (document.components?.schemas) {
document.components.schemas = sortKeys(document.components.schemas);
}
for (const path of Object.values(document.paths)) {
const operations = {
get: path.get,