Swagger PHP - how to define a nested property? Swagger PHP - how to define a nested property? php php

Swagger PHP - how to define a nested property?


Faced the exact same issue, and resolved it today!

This is for Swagger 2.0

Following is the annotation nesting that I have used to achieve the nested parameters..

/** * @SWG\Post( *   path="/getCustomerByEmail.php", *   summary="List the details of customer by the email.", *   consumes={"string"}, *   produces={"application/json"}, *   @SWG\Parameter( *     name="email", *     in="body", *     description="Customer email to ge the data", *     required=true, *     @SWG\Schema( *       @SWG\Property( *         property="id", *         type="object", *         @SWG\Property( *           property="abc", *           type="object", *           @SWG\Property( *             property="inner abc", *             type="number", *             default=1, *             example=123 *           ) *         ), *         @SWG\Property( *           property="xyz", *           type="string", *           default="xyz default value", *           example="xyz example value", *         ) *       ) *     ) *   ), *   @SWG\Response( *     response=200, *     description="Details of the customer" *   ), *   @SWG\Response( *     response=400, *     description="Email required" *   ), *   @SWG\Response( *     response=404, *     description="Customer does not exist" *   ), *   @SWG\Response( *     response="default", *     description="an ""unexpected"" error" *   ) * ) *//**

The output is as below

Note: I was working on a project which required raw PHP but still wanted to use Swagger. So instead of creating the models, I used this technique to make the nested parameters.


Edit 1: I don't know what's the problem, UI is as expected but while making the request, there is no data in the post or the payload.

Edit 2: Converted Get to Post.Works fine with file_get_contents("php://input")