I have integrate swagger php api outr rest-api all service working fine but i am facing issue in post json array in api. this is not working can you please help me.
Here my swagger api code
/**
* @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")
* )
*/
above complete code on swagger which i added before my api.
I want to post game_tournament field like
{"game_tournament":["18","8"]}
But from swagger-ui panel post in below format
game_tournament=8,18
can you please help me what wrong with my code, what i need to change.
Thanks in Advance.
using e.g. Swagger Lume package for Laravel / Lumen, you can obtain what you are asking by:
* @OA\Parameter(
* name="game_tournament[]",
* in="query",
* description="The game tournament ids array field",
* required=true,
* @OA\Schema(type="array", @OA\Items(type="string")),
* ),
To POST JSON data, you need to use an in: body parameter and specify the data type using @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")
* )
* ),
Just try it:
* @SWG\Parameter(
* name="game_tournament[]",
* type="array",
* items="string",
* collectionFormat="multi",
* required=true,
* in="query",
* ),