Sco*_*ham 19 swagger swagger-ui swagger-2.0 swagger-editor
我在我的swagger REST API中有一个需要返回pdf文件的调用.没有明确的示例/文档说明如何在不导致语法错误的情况下执行此操作.
responses:
200:
description: Returns PDF
schema: [application/pdf]
Run Code Online (Sandbox Code Playgroud)
和
responses:
200:
description: Returns PDF
schema:
type: file
Run Code Online (Sandbox Code Playgroud)
和
responses:
200:
description: Returns PDF
schema:
type: [application/pdf]
Run Code Online (Sandbox Code Playgroud)
都失败了.这甚至可能吗?
dev*_*918 23
使用 Open API 3.0,尝试以下响应:
get:
summary: Returns the report in the PDF format
responses:
'200':
description: A PDF file
content:
application/pdf:
schema:
type: string
format: binary
Run Code Online (Sandbox Code Playgroud)
文档:swagger.io/docs/specification/describing-responses
部分:返回文件的响应
Ron*_*Ron 21
responses:
200:
description: Returns PDF
schema:
type: file
Run Code Online (Sandbox Code Playgroud)
在你给出的选项中,这是正确的选择.另外,请务必使用produces: [application/pdf]
如果它失败了,请确保使用最新版本的编辑器.有一个与file最近解决的类型相关的错误.
| 归档时间: |
|
| 查看次数: |
11728 次 |
| 最近记录: |