查询中的索引数组

Indexed array in query

我正在努力为必须作为索引整数数组生成的字段编写参数注释:

voucher_products[0]: 23
voucher_products[1]: 102
voucher_products[2]: 233

我尝试了以下方法

 *     @OA\Parameter(
 *         name="voucher_products",
 *         in="query",
 *         description="",
 *         required=false,
 *         @OA\Schema(
 *             type="array",
 *               @OA\Items(
 *                 type="integer",
 *               )
 *         )
 *     ),
 

我是这样填表的: form

我在查询字符串参数中得到的结果是

voucher_products: 23
voucher_products: 102
voucher_products: 233

如果我检查 $_POST 中的这个字段,它的最终值为 voucher_products=233,因为这不会变成一个数组。

我做错了什么?

OpenAPI 规范目前没有办法表示包含索引数组的查询字符串,例如

?arr[0]=val1&arr[1]=val2&arr[2]=val3&...

以下是 OpenAPI 规范存储库中的相关问题:
Are indexes in the query parameter array representable?
Support deep objects for query parameters with deepObject style


但是,如果您的 API 可以接受只有方括号但没有索引的数组

?voucher_products[]=23&voucher_products[]=102&voucher_products[]=233

那么你可以将它定义为参数name="voucher_products[]"