bw_*_*dev 8 swagger swagger-editor swagger-codegen
我将在线Swagger编辑器与OpenAPI 3.0结合使用,并且必须创建一个定义文件文件下载。我在服务器端进行开发,客户应该能够使用YAML描述来创建客户端,而无需我的“附加说明”。YAML的相关部分是:
/files/download/{fileName}:
get:
summary: download file
operationId: downloadFile
description: this API is for file download
parameters:
- in: path
name: fileName
schema:
type: string
required: true
description: The name of file to download
responses:
200:
description: Operation performed successfully.
content:
application/octet-stream:
schema:
type: string
format: binary
...
Run Code Online (Sandbox Code Playgroud)
问题是:
内容。当前,它被定义为八位字节流,这是最常见的类型,但是实际上,它取决于一些预定义的文件类型集中的文件类型。有什么方法可以定义这种映射(文件类型/内容类型)并将其与内容标签一起使用吗?
响应标头应包含键/值对附件或内联和文件名。文件名在路径-{fileName}中定义。有什么方法可以描述枚举{attachment,inline}和fileName值的串联吗?
小智 1
我相信content这就是您正在寻找的。您还可以用来contentReference引用 中的可重用对象components。例如:
paths:
/files/{fileName}:
get:
summary: download file
operationId: downloadFile
description: this API is for file download
parameters:
- in: path
name: fileName
schema:
type: string
required: true
description: The name of file to download
responses:
200:
description: Operation performed successfully.
content:
application/pdf:
schema:
type: string
format: binary
components:
contentTypes:
application/pdf:
schema:
type: string
format: binary
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1986 次 |
| 最近记录: |