From 2d4fb30508bc994546f941db819d69f698e1435d Mon Sep 17 00:00:00 2001 From: Wahyu Budi Saputra Date: Tue, 31 Oct 2023 21:08:34 +0800 Subject: [PATCH] feat: make params on patch optional --- src/patch-nest-swagger.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/patch-nest-swagger.ts b/src/patch-nest-swagger.ts index 6d5de91..74ddaed 100644 --- a/src/patch-nest-swagger.ts +++ b/src/patch-nest-swagger.ts @@ -18,16 +18,25 @@ interface Type extends Function { } interface Options { - sort: 'default' | 'alpha' | 'localeCompare' + /** @default default */ + sort?: 'default' | 'alpha' | 'localeCompare' +} + +interface Modules { + schemaObjectFactoryModule?: typeof import('@nestjs/swagger/dist/services/schema-object-factory') + swaggerScannerModule?: typeof import('@nestjs/swagger/dist/swagger-scanner') } export function patchNestjsSwagger( - { sort = 'default' }: Options, - { + options: Options = {}, + modules: Modules = {}, +) { + const { sort = 'default' } = options + const { schemaObjectFactoryModule = require('@nestjs/swagger/dist/services/schema-object-factory'), swaggerScannerModule = require('@nestjs/swagger/dist/swagger-scanner'), - }, -) { + } = modules + const registry = new OpenAPIRegistry() /**