chore(server): sort open api params (#6484)

* chore: sort spec

* chore: open api

* chore(mobile): sort auditDeletes params

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
Jason Rasmussen
2024-01-22 11:49:51 -05:00
committed by GitHub
parent bd2dbb4944
commit 7b314f9435
22 changed files with 1665 additions and 1646 deletions

View File

@@ -20,10 +20,12 @@ import {
import { NextFunction, Response } from 'express';
import { writeFileSync } from 'fs';
import { access, constants } from 'fs/promises';
import _ from 'lodash';
import path, { isAbsolute } from 'path';
import { promisify } from 'util';
import { applyDecorators, UsePipes, ValidationPipe } from '@nestjs/common';
import { SchemaObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
import { Metadata } from './app.guard';
export function UseValidation() {
@@ -110,8 +112,21 @@ export const routeToErrorMessage = (methodName: string) =>
const patchOpenAPI = (document: OpenAPIObject) => {
document.paths = sortKeys(document.paths);
if (document.components?.schemas) {
document.components.schemas = sortKeys(document.components.schemas);
const schemas = document.components.schemas as Record<string, SchemaObject>;
document.components.schemas = sortKeys(schemas);
for (const schema of Object.values(schemas)) {
if (schema.properties) {
schema.properties = sortKeys(schema.properties);
}
if (schema.required) {
schema.required = schema.required.sort();
}
}
}
for (const [key, value] of Object.entries(document.paths)) {
@@ -152,6 +167,10 @@ const patchOpenAPI = (document: OpenAPIObject) => {
if (operation.description === '') {
delete operation.description;
}
if (operation.parameters) {
operation.parameters = _.orderBy(operation.parameters, 'name');
}
}
}