我使用Swagger-php。当我定义一个在查询字符串中的参数时,它可以是一个数组。但据我所见,它不支持这种类型的查询字符串:
我相信如果可能的话,这应该会设置在
这导致以下JSON:
https://api.domain.tld/v1/objects?q[]=1&q[]=5&q[]=12
我相信如果可能的话,这应该会设置在
collectionFormat
字段中。目前我一直在使用pipes
,但我想使用上述格式,并让Swagger-UI也显示出来。然而,我读了这个github问题,这让我不禁想知道这到底是否可行,是不是我漏掉了什么?
以下是我的Swagger-PHP定义示例:
/**
* @SWG\Parameter(
* name="ids",
* in="query",
* description="A list of IDs (separated by pipes) to filter the Returns",
* required=false,
* type="array",
* @SWG\Items(
* type="integer",
* format="int32"
* ),
* collectionFormat="pipes"
* )
*/
这导致以下JSON:
"parameters": {
"ids": {
"name": "ids",
"in": "query",
"description": "A list of IDs (separated by pipes) to filter the Returns",
"required": false,
"type": "array",
"items": {
"type": "integer",
"format": "int32"
},
"collectionFormat": "pipes"
}
}