Swagger编辑器:无法在多部分请求中设置内容类型

时间:2018-07-26 17:27:45

标签: swagger swagger-editor

我将在线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 

我在这里想念什么?

0 个答案:

没有答案