If response is a blob (in schema defined with type string, format binary), the generated service fails to consume renspose (it tries to parse binary repsonse as blob):
typescript
return this.httpClient.get<Blob>(`${this.basePath}/api/Image/DesignPreview`,
{
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
We are transitioning to aspnetcore3, with that we need to transition to swagger-codegen-cli-3.0.13
This issue did not exist in cli-2.4.1-SNAPSHOT with schema v2
Relevant schema part:
json
"responses": {
"200": {
"description": "Success",
"content": {
"image/png": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
},
"401": {
"description": "Unauthorized"
},
"403": {
"description": "Forbidden"
}
},
java -jar swagger/swagger-codegen-cli-3.0.13.jar generate -i https://localhost:5001/swagger/0.1-Dev/swagger.json -l typescript-angular -c swagger/config.json -o src/app/api -D io.swagger.parser.util.RemoteUrl.trustAll=true -D io.swagger.v3.parser.util.RemoteUrl.trustAll=true
config.json:
json
{
"ngVersion":"8"
}
Very similar issue to #8399
responseType: 'blob' and non generic httpClient.get should be used
same for type=file,
this.httpClient.request<Blob> should be this.httpClient.request (remove the generic parameter)
and the options should add responseType: 'blob'
Also having this issue, it would be nice if it could be addressed soon
Most helpful comment
same for
type=file,this.httpClient.request<Blob>should bethis.httpClient.request(remove the generic parameter)and the options should add
responseType: 'blob'