From 700b1349764351fd1c47bd1aa6dd0025342fe868 Mon Sep 17 00:00:00 2001 From: Wahyu Budi Saputra Date: Wed, 1 Nov 2023 12:33:14 +0800 Subject: [PATCH] feat: change `sort` option --- src/patch-nest-swagger.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/patch-nest-swagger.ts b/src/patch-nest-swagger.ts index 74ddaed..c5cc022 100644 --- a/src/patch-nest-swagger.ts +++ b/src/patch-nest-swagger.ts @@ -19,7 +19,7 @@ interface Type extends Function { interface Options { /** @default default */ - sort?: 'default' | 'alpha' | 'localeCompare' + schemasSort?: 'default' | 'alpha' | 'localeCompare' } interface Modules { @@ -31,7 +31,7 @@ export function patchNestjsSwagger( options: Options = {}, modules: Modules = {}, ) { - const { sort = 'default' } = options + const { schemasSort = 'default' } = options const { schemaObjectFactoryModule = require('@nestjs/swagger/dist/services/schema-object-factory'), swaggerScannerModule = require('@nestjs/swagger/dist/swagger-scanner'), @@ -82,7 +82,7 @@ export function patchNestjsSwagger( ...doc.components?.schemas, } - if (sort === 'alpha') { + if (schemasSort === 'alpha') { const sortedSchemas = Object.entries(schemas).sort(([aKey], [bKey]) => { if (aKey < bKey) return -1 if (aKey > bKey) return 1 @@ -90,7 +90,7 @@ export function patchNestjsSwagger( }) openAPIObject.components.schemas = Object.fromEntries(sortedSchemas) - } else if (sort === 'localeCompare') { + } else if (schemasSort === 'localeCompare') { const sortedSchemas = Object.entries(schemas).sort(([aKey], [bKey]) => aKey.localeCompare(bKey), )