You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Client-SDK] [Typescript] [Bug] Service class does not include the request "body" as 2nd parameter of "httpClient.post" and "httpClient.patch".
Description
The httpClient.post and httpClient.patch in typescript expects 3 parameters as follows respectively..
the api url
the request body
options
However in the client sdk the generated code submits only 1. api url and 2. options. As a result the options is submitted as body to the request.
Following is the code from typescript client sdk.
POST:
public ....Post(body?: model1, observe: any = 'body', reportProgress: boolean = false): Observable {
.......;
......;
return this.httpClient.post(${this.basePath}/api,
{
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}
PATCH:
public .....IdPatch(id: string, ifMatch: string, body?: model1, observe: any = 'body', reportProgress: boolean = false): Observable {
.......;
......;
return this.httpClient.patch(${this.basePath}/api/${encodeURIComponent(String(id))},
{
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}
paths:
/api:
post:
tags:
- tag1summary: Create a model1description: >- Create a model1requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/model1'responses:
'201':
description: Create model1content:
application/json:
schema:
type: objectproperties:
_id:
type: stringformat: stringcomponents:
model1:
type: objectproperties:
id:
type: stringformat: stringreadOnly: trueproperty1:
type: stringformat: stringproperty2:
type: integerformat: int32property3:
type: stringenum: [A, B, C, D]Command line used for generationweb interface of https://app.swaggerhub.comSteps to reproduce1. Login to https://app.swaggerhub.com2. Go to your My Hub and go to your project3. Click the "Export" > "Client SDK" > "typescript-angular" bropdown at the right top section.4. Check the Service class in the generated typescript code.Suggest a fix/enhancementEnter the "body" as the 2nd parameter to the "httpClient.post" and "httpClient.patch".POST:
public ....Post(body?: model1, observe: any = 'body', reportProgress: boolean = false): Observable<any> {.......;......;return this.httpClient.post(`api`, body, { options: .. });}PATCH:
public .....IdPatch(id: string, ifMatch: string, body?: model1, observe: any = 'body', reportProgress: boolean = false): Observable<any> {.......;......; return this.httpClient.patch(`api/${encodeURIComponent(String(id))}`, body, { options: .. });}
The text was updated successfully, but these errors were encountered:
cmalard
added a commit
to cmalard/swagger-codegen-generators
that referenced
this issue
Dec 23, 2019
[Client-SDK] [Typescript] [Bug] Service class does not include the request "body" as 2nd parameter of "httpClient.post" and "httpClient.patch".
Description
The httpClient.post and httpClient.patch in typescript expects 3 parameters as follows respectively..
However in the client sdk the generated code submits only 1. api url and 2. options. As a result the options is submitted as body to the request.
Following is the code from typescript client sdk.
POST:
public ....Post(body?: model1, observe: any = 'body', reportProgress: boolean = false): Observable {
.......;
......;
return this.httpClient.post(
${this.basePath}/api
,{
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}
PATCH:
public .....IdPatch(id: string, ifMatch: string, body?: model1, observe: any = 'body', reportProgress: boolean = false): Observable {
.......;
......;
return this.httpClient.patch(
${this.basePath}/api/${encodeURIComponent(String(id))}
,{
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}
Swagger-codegen version
as used in https://app.swaggerhub.com
Swagger declaration file content or url
The text was updated successfully, but these errors were encountered: