mirror of
https://github.com/immich-app/immich.git
synced 2025-12-19 17:23:21 +03:00
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:
@@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user