Swagger文档添加file上传参数写法


想在swagger ui的yaml文档里面写一个文件上传的接口,找了半天不知道怎么写,终于搜到了,如下:

/tools/upload:
    post:
      tags:
      - "tool"
      summary: "文件上传、图片上传"
      operationId: "upload"
      consumes:
        - multipart/form-data
      parameters:
      - name: file
        in: formData
        type: file
      responses:
        200:
          description: 文件上传成功
          schema:
            properties:
              url:
                type: string
                description: "文件上传后的地址"
        500:
          description: "服务器内部出错"
          schema:
            $ref: "#/definitions/ApiResponse"

效果如下:


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM