Swagger Editor OpenAPI 3 上的文件上传在尝试时不显示文件浏览器

Abu*_*sae 5 swagger swagger-ui swagger-editor openapi

我在 OpenAPI 3.0 中使用 Swagger 编辑器。我需要记录一条包含上传图像的路线。尝试“试用”时,我没有让文件浏览器选择要在请求正文中上传的图像,我得到的只是一个带有参数名称和类型的 JSON 字符串。

文件上传“试用”屏幕截图

这是路由的 YAML 描述:

openapi: 3.0.0
...
paths:
  /media/upload/thumbnail:
    post:
      tags:
        - media
        - publications
      security:
        - bearerAuth: []
      summary: upload a kid's publication
      operationId: uploadPublication
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                upload:
                  type: string
                  format: binary
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: ObjectId of the uploaded file in db (original size)
                    example: 5a6048b3fad06019afe44f24
                  filename:
                    type: string
                    example: myPainting.png
                  thumbnail:
                    type: string
                    description: ObjectId of the uploaded file in db (thumbnai size)
                    example: 5a6048b3fad06019afe44f26
        '400':
          description: Authentication failed
Run Code Online (Sandbox Code Playgroud)

我在这里缺少什么?

Hel*_*len 4

你的定义是正确的。

multipart/form-dataSwagger Editor 3.5.7 和 Swagger UI 3.16.0 中添加了对 OpenAPI 3.0 定义中请求的文件上传的支持。确保您使用的版本支持文件上传。