acacode / acacode/swagger-typescript-api

Not possible to set responseType to blob

未关闭
#767 3 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
TypeScript
星标
4.1k
派生
436
PR 合并指标
30 天内没有已合并 PR

描述

Hi, I am experiencing an issue when trying to generate client from drf's @extend_schema decorator. My endpoint returns a response which contains an xlsx file, I am only able to process that if I set the generated client's responseType manually to blob, but it is set incorrectly to json.
I've found many suggestions to set x-in-file in the decorator, I even tried to set it as header, but none of the suggestions works.
Here is how I currently specify the response in extend_schema decorator:
`
responses={

200: {
'x-is-file': 'true',
'content': {
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': {
'schema': {
'type': 'string',
'format': 'binary'
}
}
},
'headers': {
'x-is-file': {
'description': 'Indicates if the response is a file',
'type': 'string',
'example': 'true'
}
},
}
}`

and this is generated:

`
this.request({

path: '/api/v1/object/export/',
method: "GET",
query: query,
secure: true,
format: "json",
...params,
}),`
Rewriting this manually to:
`this.request({

path: '/api/v1/object/export/',
method: "GET",
query: query,
secure: true,
format: "blob",
...params,
}),`
works as intended.
Any ideas where the problem should be?
Many thanks in advance.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。