Php 如何在swagger api中发布数组

Php 如何在swagger api中发布数组,php,json,swagger,swagger-ui,swagger-2.0,Php,Json,Swagger,Swagger Ui,Swagger 2.0,我已经集成了swagger php api outr rest api所有服务,但我在api中的后json数组中面临问题。这不起作用,你能帮帮我吗 这里是我的招摇过市api代码 /** * @SWG\Post(path="/createbetsnap/get_all_game_data", * tags={"Create Betsnaps Section"}, * summary="This function used to get selected tournament sche

我已经集成了swagger php api outr rest api所有服务,但我在api中的后json数组中面临问题。这不起作用,你能帮帮我吗

这里是我的招摇过市api代码

/**
 * @SWG\Post(path="/createbetsnap/get_all_game_data",
 *   tags={"Create Betsnaps Section"},
 *   summary="This function used to get selected tournament schedule date and other master data like size, prize structure and entry fee",
 *   description="",
 *   operationId="get_all_game_data",
 *   produces={"application/json"},
 *   consumes={"application/json"},
 *   @SWG\Parameter(
 *     name="Login_Session_Key",
 *     in="header",
 *     description="The Login Session Key of logged in user.",
 *     required=true,
 *     type="string"
 *   ),
 *   @SWG\Parameter(
 *     name="game_tournament",
 *     in="formData",
 *     description="The game tournament ids array field.",
 *     required=true,
 *     type="array",
 *     @SWG\Items(type="string")
 *   ),
 *   @SWG\Response(response=200, description="success message with data array"),
 *   @SWG\Response(response=500, description="Invalid username/password supplied")
 * )
 */
上面是我在api之前添加的关于swagger的完整代码

我想在赛后的赛场上

{"game_tournament":["18","8"]}
但从以下格式的招摇过市用户界面面板帖子

game_tournament=8,18
你能帮助我我的代码有什么问题,我需要更改什么吗


提前感谢。

要发布JSON数据,您需要在:body参数中使用
,并使用
@SWG\Schema
指定数据类型:

 *   @SWG\Parameter(
 *     name="game_tournament",
 *     in="body",
 *     description="The game tournament ids array field.",
 *     required=true,
 *     @SWG\Schema(
 *       type="array",
 *       @SWG\Items(type="string")
 *     )
 *   ),
试试看:

  *   @SWG\Parameter(
  *       name="game_tournament[]",
  *       type="array",
  *       items="string",
  *       collectionFormat="multi",
  *       required=true,
  *       in="query",
  *   ),

例如,使用Laravel/Lumen的Swagger Lume软件包,您可以通过以下方式获得所需:

 *     @OA\Parameter(
 *         name="game_tournament[]",
 *         in="query",
 *         description="The game tournament ids array field",
 *         required=true,
 *         @OA\Schema(type="array", @OA\Items(type="string")),
 *     ),

但是如何发布带有body标记的数组,请提供一些示例代码。我添加了in=“body”,但它需要schema字段。@Helen在我的API中收到的“game\u Tornament”字段为空。Girish你能在API中收到发布的数组吗?我遇到了几乎相同的问题。我正在尝试在laravel的swagger 2.0中以多部分formData发送数组。但它不起作用。有什么建议吗?格式类似于设置[“网站名称”]、设置[“上传的文件名称”]。