Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
swagger php如何通过formData在swagger中使用数组_Php_Arrays_Swagger_Swagger Php - Fatal编程技术网

swagger php如何通过formData在swagger中使用数组

swagger php如何通过formData在swagger中使用数组,php,arrays,swagger,swagger-php,Php,Arrays,Swagger,Swagger Php,我希望通过$u POST(formData)在我的api中接收如下数组: answers[458]=hi&answers[90]=hello 当我使用postman时,我可以这样做,因为我的代码没有问题,但现在我想使用swagger,这就是我无法让它工作的地方 我试过了 /** * @SWG\Post( * path="/sec/answer", * summary="location", * tags={"question"}, * @SWG\Parame

我希望通过$u POST(formData)在我的api中接收如下数组:

answers[458]=hi&answers[90]=hello

当我使用postman时,我可以这样做,因为我的代码没有问题,但现在我想使用swagger,这就是我无法让它工作的地方

我试过了

/**
 * @SWG\Post(
 *   path="/sec/answer",
 *   summary="location",
 *   tags={"question"},
 *   @SWG\Parameter(
 *         name="answer",
 *         in="formData",
 *         description="",
 *         type="array",
 *         @SWG\Items(
 *             type="string"
 *         )
 *   ),
 *   @SWG\Response(
 *     response=200,
 *     description="array"
 *   )
 * )
 */
但问题是,我得到了一个包含多行的字段,当我用以下内容填充该字段时: 你好 你好

这将导致以下请求:

'answer=hi&answer=hello'
因此:

array(1) {
  ["answer"]=>
  string(5) "hello"
}
我知道,使用此选项,我无法接收具有可变键的数组(因为我无法填充键),但就我所知,这甚至不是数组招摇过市者发送错误的请求和否决参数

怎么办?我希望有人能帮助我

附言。
我也尝试过数组中的数组,但结果相同

当你使用Postman时,请求主体是什么?“answers[458]=hi&answers[90]=hello”如果你将
name=“answer”
更改为
name=“answer[]”
,你会得到[]的url编码字符这里有一个类似的问题:,但似乎没有答案
array(1) {
  ["answer"]=>
  string(5) "hello"
}