我将在线Swagger编辑器与OpenAPI 3.0结合使用,我必须创建文件上传的定义。问题出在编辑器生成的CURL中。
如果文件扩展名是“未知”(例如.abc),则编辑器不会生成类型
curl -X POST "http://localhost:xxxx/files/upload" -H "accept: */*" -H
"Content-Type: multipart/form-data" -F "upload=@text.abc;type="
如果扩展名是“已知”,它将忽略YAML定义的contentType:
curl -X POST "http://localhost:xxxx/files/upload" -H "accept: */*" -H
"Content-Type: multipart/form-data" -F "upload=@text.txt;type=text/plain"
应该是(我需要):
curl -X POST "http://localhost:xxxx/files/upload" -H "accept: */*" -H
"Content-Type: multipart/form-data" -F "upload=@text.txt; type=application/octet-stream"
YAML是:
/files/upload:
post:
summary: upload file
operationId: uploadFile
description: this API is for file upload
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
upload:
type: string
format: binary
encoding:
upload:
contentType: application/octet-stream
responses:
200:
description: Operation performed succesfuly.
400:
description: Operation failed
我在这里想念什么?