File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed
libs/json-api-nestjs/src/lib Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,12 @@ export function setSwaggerDecorator(
2323 if ( ! apiTag ) {
2424 const entityName =
2525 entity instanceof Function ? entity . name : entity . options . name ;
26- ApiTags ( camelToKebab ( entityName ) ) ( controller ) ;
26+
27+ const resourceName = config . overrideName
28+ ? config . overrideName
29+ : `${ camelToKebab ( entityName ) } ` ;
30+
31+ ApiTags ( resourceName ) ( controller ) ;
2732 }
2833 ApiExtraModels ( FilterOperand ) ( controller ) ;
2934 ApiExtraModels ( createApiModels ( entity ) ) ( controller ) ;
Original file line number Diff line number Diff line change @@ -46,9 +46,19 @@ BaseModuleClass.forRoot = function (options): DynamicModule {
4646 const controllerClass =
4747 controller ||
4848 nameIt ( getProviderName ( entity , JSON_API_CONTROLLER_POSTFIX ) , class { } ) ;
49+
50+ const decoratorOptions : DecoratorOptions = Reflect . getMetadata (
51+ JSON_API_DECORATOR_OPTIONS ,
52+ controllerClass
53+ ) ;
54+
55+ const resourceName = decoratorOptions ?. overrideName
56+ ? decoratorOptions . overrideName
57+ : `${ camelToKebab ( entityName ) } ` ;
58+
4959 const transformService = transformMixin ( entity , connectionName ) ;
5060 const serviceClass = typeormMixin ( entity , connectionName , transformService ) ;
51- Controller ( ` ${ camelToKebab ( entityName ) } ` ) ( controllerClass ) ;
61+ Controller ( resourceName ) ( controllerClass ) ;
5262 UseInterceptors ( ErrorInterceptors ) ( controllerClass ) ;
5363 Inject ( serviceClass ) ( controllerClass . prototype , 'serviceMixin' ) ;
5464 const properties = Reflect . getMetadata (
@@ -73,10 +83,7 @@ BaseModuleClass.forRoot = function (options): DynamicModule {
7383 controllerClass
7484 ) ;
7585 }
76- const decoratorOptions : DecoratorOptions = Reflect . getMetadata (
77- JSON_API_DECORATOR_OPTIONS ,
78- controllerClass
79- ) ;
86+
8087 const moduleConfig : ConfigParam = {
8188 ...ConfigParamDefault ,
8289 ...options . config ,
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ export interface ConfigParam {
1818 debug : boolean ;
1919 maxExecutionTime : number ;
2020 pipeForId : PipeMixin ;
21+ overrideName ?: string ;
2122}
2223
2324export interface ModuleOptions {
You can’t perform that action at this time.
0 commit comments