Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

296
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda