Swagger PHP - how to define a nested property?
I'm using Swagger PHP and most of the definitions are easy to define, but I'm having an issue with a particular piece of data that is not part of a seperate class, but instead an associative array.
The json response I wish to show (simplified for this question):
{
"id": 1,
"status": "published",
"gps": {
"lat": "0.00000000",
"lng": "0.00000000"
}
Theid
andstatus
are easy enough to define, however thegps
is a problem as there is no seperate class to define it in, it is an array inside the model. Is it possible to define this array without having to create a dummy class?
The comments in the model file currently:
/**
* @SWG\Definition(@SWG\Xml(name="Event"))
*/
class Event extends BaseModel {
/**
* @SWG\Property(
* property="id",
* type="integer",
* example="103"
* )
* @SWG\Property(
* property="status",
* type="string",
* enum={"published", "draft", "suspended"}
* example="published"
* )
*/
}
Answer
Solution:
Faced the exact same issue, and resolved it today!
Following is the annotation nesting that I have used to achieve the nested parameters..
The output is as below
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")