我正在使用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"
* )
*/
}