Open API 3.0如何支持具有多个值的单个查询参数键? [英] How does open api 3.0 support a single query param key with multiple values?

查看:19
本文介绍了Open API 3.0如何支持具有多个值的单个查询参数键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

接口格式:GET /resource?param=value1&param=value2&param=value3 在Open Api 2.0中,我们可以这样指定:

parameters:
    - in: query
      name: color
      type: array
      collectionFormat: multi
      items:
        type: string 

但在v3.0中,属性收集Format不可用。因此,在尝试使用集合格式时,我收到错误:should not have additional property: collectionFormat

我搜索了文档,但找不到任何答案。有没有人知道从2.0版迁移到3.0版的新实现应该是什么?

推荐答案

您可以使用以下内容...

  - name: param
    in: query
    description: Id description
    required: false
    style: form
    explode: true
    schema:
      type: array
      items:
        type: string
其中EXPLADE:TRUE将形成param=abc&;param=xyz等 AND EXPLODE:FALSE将形成param=abc,xyz

这篇关于Open API 3.0如何支持具有多个值的单个查询参数键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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