Post json in swagger api

299 views
Skip to first unread message

Girish Patidar

unread,
Apr 28, 2017, 2:47:01 AM4/28/17
to Swagger

Hello All,

I have integrate swagger-php api with my rest-api in codeigniter,

Everything working fine but i got issue in post array in api from swagger-ui.

API Swagger 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 id 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")
     * )
     */


I want to post in below format
{"game_tournament":["18","8"]}

but swagger-ui tool post data in 
game_tournament:
8,18

Can you please let me know what wrong with my code.

Thanks in Advance



Ron Ratovsky

unread,
Apr 28, 2017, 2:16:11 PM4/28/17
to swagger-sw...@googlegroups.com

Hi Girish,

 

It looks like you’re looking to describe a body parameter and not a formData one, with an object as a payload.

You can take a look at the online petstore to see samples.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages