私はSwagger-phpを使用しています。クエリ文字列にあるパラメーターを定義すると、配列にすることができます。しかし、私が見る限り、この種のクエリ文字列はサポートされていません:
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"
}
}