Swagger OpenAPI3.0如何支持具有多个值的单个查询参数键?
对于此格式的api:Swagger OpenAPI3.0如何支持具有多个值的单个查询参数键?,swagger,openapi,Swagger,Openapi,对于此格式的api:GET/resource?param=value1¶m=value2¶m=value3 在OpenAPI 2.0中,我们可以这样指定: parameters: - in: query name: color type: array collectionFormat: multi items: type: string 但在v3.0中,属性collectionFormat不可用。因此,在
GET/resource?param=value1¶m=value2¶m=value3
在OpenAPI 2.0中,我们可以这样指定:
parameters:
- in: query
name: color
type: array
collectionFormat: multi
items:
type: string
但在v3.0中,属性collectionFormat不可用。因此,在尝试使用collectionFormat时,我收到一个错误消息,说不应该有额外的属性:collectionFormat
我已经搜索了文档,但找不到任何答案。有人知道要从2.0版迁移到3.0版,新的实现应该是什么吗?您可以使用这样的东西
- name: param
in: query
description: Id description
required: false
style: form
explode: true
schema:
type: array
items:
type: string
其中explode:true将形成param=abc¶m=xyz等
和分解:false将形成param=abc,xyzexplode(true/false)指定数组和对象是否应为每个数组项或对象属性生成单独的参数。您可以从本文的schema vs content部分检查这个概念。