Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

295
Views
How to post array in swagger api

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.

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

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")),
 *     ),
about 4 years ago · Santiago Trujillo Report

0

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")
 *     )
 *   ),
about 4 years ago · Santiago Trujillo Report

0

Just try it:

  *   @SWG\Parameter(
  *       name="game_tournament[]",
  *       type="array",
  *       items="string",
  *       collectionFormat="multi",
  *       required=true,
  *       in="query",
  *   ),
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!