swagger 上传文件 参数_Swagger发送正文和formData参数

I'm using Swagger 2.0 and I have a problem to send multiple post parameters. I have a swagger error Operation cannot have a body parameter and a formData parameter and I don't know how to fix it. In my definition I have a body parameter and this parameter need a JSON format but a side I have other parameter like files to upload and filename.

How can I do to send body and formData parameters both ?

Here is the web service definition :

/updateDatas:

post:

summary: Upadate datas

description: |

Update datas

consumes:

- multipart/form-data

produces:

- application/json

parameters:

- name: firstFileName

in: formData

description: First file name.

required: true

type: string

- name: secondFileName

in: formData

description: Second file name.

required: true

type: string

- name: datas

in: body

description: Json object informations.

required: true

schema:

$ref: '#/definitions/Datas'

- name: firstFile

in: formData

description: First file .jpg

required: true

type: file

- name: clientFile

in: formData

description: Second file .jpg

required: true

type: file

tags:

- Application

responses:

'200':

description: Uploaded

schema:

$ref: '#/definitions/Upload'

'401':

description: Unauthorized Bad Token

解决方案

According to the swagger specifications see, type:body and type:formData cannot exist together for the same operation.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值