Swagger UI 未正确发送数组 [英] Swagger UI not sending array correctly

查看:20
本文介绍了Swagger UI 未正确发送数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试发送多个值(一个数组)(请参阅规范中的第 93 行 ->... 名称:收件人 [] ...)

I am trying to send multiple values (an array) (refer to on line 93 in spec ->... name: recipients[] ...)

我面临的问题是 Swagger-ui 调用端点如下:

The problem I am facing is the Swagger-ui call the endpoints as below:

实际

recipients[]=value1%2Cvalue2

预期

recipients[]=value1&recipients[]=value2

%2C 表示 ,(逗号).

The %2C means , (comma).

以下是所需的详细信息招摇-ui 版本 2.1.1以下是重现该问题的 swagger 规范文件内容的链接:http://pastebin.com/V3ZuCjVz

Below are the required details swagger-ui version 2.1.1 Below is the link for content of the swagger spec file reproducing the issue: http://pastebin.com/V3ZuCjVz

推荐答案

貌似指定的方式是添加collectionFormat: multi

- name: recipients[]
  in: formData
  description: Email addresses for recipients (multiple values allowed).
  required: true
  type: array
  collectionFormat: multi
  items:
      type: string

来自 http://swagger.io/specification/ 的可能值是:

  • csv - 逗号分隔值 foo,bar.
  • ssv - 空格分隔值 foo bar.
  • tsv - 制表符分隔值 foo\tbar.
  • pipes - 管道分隔值 foo|bar.
  • multi - 对应多个参数实例而不是单个实例的多个值 foo=bar&foo=baz.这是有效的仅适用于query"或formData"中的参数.

这篇关于Swagger UI 未正确发送数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆