Need help on how to do this on swagger.
@SWG\Property(property="LineItems", type="array", @SWG\Items(ref="#/definitions/LineItem"))
@SWG\Definition(
definition="LineItem",
required={"Description","Quantity","UnitAmount"},
@SWG\Property(property="Description", type="string", example="Item 1"),
@SWG\Property(property="Quantity", type="integer", example=100),
@SWG\Property(property="UnitAmount", type="float", example=11)
)
@SWG\Definition(
definition="LineItem2",
required={"Description","Quantity","UnitAmount"},
@SWG\Property(property="Description", type="string", example="Item 2"),
@SWG\Property(property="Quantity", type="integer", example=10),
@SWG\Property(property="UnitAmount", type="float", example=21)
)
I want to add LineItem and LineItem2 on LineItems property, I want the output should be like this
"LineItems": [
{
"Description": "Item 1",
"Quantity": 100,
"UnitAmount": 11,
},
{
"Description": "Item 2",
"Quantity": 100,
"UnitAmount": 22,
}
]
To display array example with multiple items in Swagger UI, you need an array-level
example
, such as:That is, there is a single definition for array items (
LineItem
), and the multi-item example is defined using theexample
keyword on the array level.The Swagger-PHP version of this would be: