Skip to content

Commit 4b74540

Browse files
authored
Merge pull request #568 from cmalard/master
fix(typescript-angular): correct httpClient call with URL query parameters & support body for all methods
2 parents d466104 + 7eb1e9c commit 4b74540

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/main/resources/handlebars/typescript-angular/api.service.mustache

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,14 @@ export class {{classname}} {
320320

321321
{{/hasFormParams}}
322322
{{#useHttpClient}}
323-
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.basePath}{{{path}}}`,{{#hasBodyParam}}
324-
{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}convertFormParamsToString ? formParams.toString() : formParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/hasBodyParam}}
323+
return this.httpClient.request{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}({{httpMethod}},`${this.basePath}{{{path}}}`,
325324
{
325+
{{#bodyParam}}
326+
body: {{paramName}}
327+
{{/bodyParam}}
328+
{{#hasFormParams}}
329+
body: convertFormParamsToString ? formParams.toString() : formParams
330+
{{/hasFormParams}}
326331
{{#hasQueryParams}}
327332
params: queryParameters,
328333
{{/hasQueryParams}}

src/main/resources/mustache/typescript-angular/api.service.mustache

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,14 @@ export class {{classname}} {
320320

321321
{{/hasFormParams}}
322322
{{#useHttpClient}}
323-
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.basePath}{{{path}}}`,{{#hasBodyParam}}
324-
{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}convertFormParamsToString ? formParams.toString() : formParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/hasBodyParam}}
323+
return this.httpClient.request{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}({{httpMethod}},`${this.basePath}{{{path}}}`,
325324
{
325+
{{#bodyParam}}
326+
body: {{paramName}}
327+
{{/bodyParam}}
328+
{{#hasFormParams}}
329+
body: convertFormParamsToString ? formParams.toString() : formParams
330+
{{/hasFormParams}}
326331
{{#hasQueryParams}}
327332
params: queryParameters,
328333
{{/hasQueryParams}}

0 commit comments

Comments
 (0)