I'm new to PHP Swagger and using the Laravel package L5-Swagger to create documentation for my API. Now I'm trying to let one model contain an array of the other model, an Order can have several OrderItems.
Unfortuantly I cannot get the linking to work. See attached screen shot.
What am I doing wrong?
This is my Order model:
/**
* @SWG\Definition(
* required={"order_id","order_items"},
* type="object",
* @SWG\Xml(name="Order")
* )
*/
class Order
{
/**
* @SWG\Property(example="O-789456123")
* @var string
*/
public $order_id;
/**
* @SWG\Property(type="array", items="$ref:OrderItem")
* @var array
*/
public $order_items = [];
}
This is my OrderItem model:
/**
* @SWG\Definition(
* required={"sku","quantity", "price_including_tax"},
* type="object",
* @SWG\Xml(name="OrderItem")
* )
*/
class OrderItem
{
/**
* @SWG\Property(example="SKU-123")
* @var string
*/
public $sku;
/**
* @SWG\Property(example=2)
* @var integer
*/
public $quantity;
/**
* @SWG\Property(example=199.75)
* @var float
*/
public $price_including_tax;
}
I think items="$ref:OrderItem"
should be @SWG\Items(ref="#/definitions/OrderItem")
Ps. Checking the intermediate format (the swagger.json) can provide insight into what going wrong.