我正在使用 Swagger PHP,并且大多数定义都很容易定义,但是我遇到了一个特定数据的问题,该数据不是单独类的一部分,而是关联数组的一部分。
我希望显示的 json 响应(针对这个问题进行了简化):
{
"id": 1,
"status": "published",
"gps": {
"lat": "0.00000000",
"lng": "0.00000000"
}
和很容易定义,但是id
是一个问题,因为没有单独的类来定义它,它是模型内部的一个数组。是否可以在不必创建虚拟类的情况下定义此数组?status
gps
目前模型文件中的注释:
/**
* @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"
* )
*/
}