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"
效果如下:
作者:程序员小波与Bug
出处:https://codetrips.cn
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。如有问题,可以邮件:caiya928@aliyun.com
QQ:1419901425 联系我
如果喜欢我的文章,请关注我的公众号:程序员小波与Bug