Skip to content

Commit fa06a62

Browse files
fixed parameter handling
1 parent b769376 commit fa06a62

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsServerCodegen.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,7 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap operations, L
299299
List<CodegenOperation> operationList = objectMap.getOperation();
300300

301301
for (CodegenOperation operation : operationList) {
302-
// operation.baseName = operation.baseName.toLowerCase(Locale.ROOT);
303-
// if(operation.path.startsWith("/" + operation.baseName)) {
304-
// operation.path = operation.path.substring(operation.baseName.length() + 1);
305-
// }
306-
302+
operation.path = operation.path.replaceAll("\\{([^}]+)}", ":$1");
307303
operation.httpMethod = camelize(operation.httpMethod.toLowerCase(Locale.ROOT));
308304

309305
List<CodegenParameter> params = operation.allParams;

modules/openapi-generator/src/main/resources/typescript-nestjs-server/controller.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Controller{{#httpMethods}}, {{.}}{{/httpMethods}}, Req } from '@nestjs/common';
1+
import { Body, Controller{{#httpMethods}}, {{.}}{{/httpMethods}}, Param, Query, Req } from '@nestjs/common';
22
import { Observable } from 'rxjs';
33
import { {{classname}} } from '../{{apiPackage}}';
44
import { {{#tsImports}}{{classname}}, {{/tsImports}} } from '../{{modelPackage}}';
@@ -10,7 +10,7 @@ export class {{classname}}Controller {
1010
{{#operations}}
1111
{{#operation}}
1212
@{{#vendorExtensions.x-http-method}}{{.}}{{/vendorExtensions.x-http-method}}{{^vendorExtensions.x-http-method}}{{httpMethod}}{{/vendorExtensions.x-http-method}}('{{path}}')
13-
{{operationId}}({{#allParams}}{{paramName}}: {{{dataType}}}, {{/allParams}}@Req() request: Request): {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} | Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> | Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
13+
{{operationId}}({{#allParams}}{{#isPathParam}}@Param('{{paramName}}') {{/isPathParam}}{{#isQueryParam}}@Query('{{paramName}}') {{/isQueryParam}}{{#isBodyParam}}@Body() {{/isBodyParam}}{{paramName}}: {{{dataType}}}, {{/allParams}}@Req() request: Request): {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} | Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> | Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
1414
return this.{{classVarName}}.{{operationId}}({{#useSingleRequestParameter}}{ {{/useSingleRequestParameter}}{{#allParams}}{{paramName}}, {{/allParams}}{{#useSingleRequestParameter}}}, {{/useSingleRequestParameter}}request);
1515
}
1616

0 commit comments

Comments
 (0)