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(
23
23
if ( ! apiTag ) {
24
24
const entityName =
25
25
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 ) ;
27
32
}
28
33
ApiExtraModels ( FilterOperand ) ( controller ) ;
29
34
ApiExtraModels ( createApiModels ( entity ) ) ( controller ) ;
Original file line number Diff line number Diff line change @@ -46,9 +46,19 @@ BaseModuleClass.forRoot = function (options): DynamicModule {
46
46
const controllerClass =
47
47
controller ||
48
48
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
+
49
59
const transformService = transformMixin ( entity , connectionName ) ;
50
60
const serviceClass = typeormMixin ( entity , connectionName , transformService ) ;
51
- Controller ( ` ${ camelToKebab ( entityName ) } ` ) ( controllerClass ) ;
61
+ Controller ( resourceName ) ( controllerClass ) ;
52
62
UseInterceptors ( ErrorInterceptors ) ( controllerClass ) ;
53
63
Inject ( serviceClass ) ( controllerClass . prototype , 'serviceMixin' ) ;
54
64
const properties = Reflect . getMetadata (
@@ -73,10 +83,7 @@ BaseModuleClass.forRoot = function (options): DynamicModule {
73
83
controllerClass
74
84
) ;
75
85
}
76
- const decoratorOptions : DecoratorOptions = Reflect . getMetadata (
77
- JSON_API_DECORATOR_OPTIONS ,
78
- controllerClass
79
- ) ;
86
+
80
87
const moduleConfig : ConfigParam = {
81
88
...ConfigParamDefault ,
82
89
...options . config ,
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ export interface ConfigParam {
18
18
debug : boolean ;
19
19
maxExecutionTime : number ;
20
20
pipeForId : PipeMixin ;
21
+ overrideName ?: string ;
21
22
}
22
23
23
24
export interface ModuleOptions {
You can’t perform that action at this time.
0 commit comments