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