[Typescript angular] responseType blob not set properly
luca-vercelli opened this issue · 0 comments
luca-vercelli commented
I have a GET endpoint that downloads a file:
responses:
'200':
description: OK
content:
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
schema:
type: string
format: binary
Generated typescript code is
(...)
return this.httpClient.request<any>('get',`${this.basePath}/mypath`,
{
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
while it should contain a responseType:
(...)
return this.httpClient.request('get',`${this.basePath}/mypath`,
{
params: queryParameters,
responseType: "blob",
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
Thanks to stackoverflow we can get the desired result setting a x-is-file
option:
responses:
'200':
description: OK
x-is-file: true
content:
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
schema:
type: string
format: binary
However of course this is a workaround, x-is-file
is an internal option, it is not part of OpenAPI standard.
I think there is a bug around this point of code:
This line is not executed.