我想在swagger-ui中显示示例请求正文。我试图在我的PHP Lumen API中使用SWG 2.x注释添加示例请求JSON对象。我需要在请求正文中添加以下提到的JSON对象。
{
"request-body": {
"date": "09 Feb 2019",
"country": "XX",
"type": "sample",
"info": {
"xyz": 1,
},
"test_internal": "abc"
},
"doc": {
"comments": "contains",
"name": "startup",
"test_list": [
{
"level": "NA",
"time_limit": "NA"
}
],
"test_list2": [
{
"level": "NA",
"type": "XYZ"
}
]
}
}
我尝试使用SWG注释添加上述对象。
/** @SWG\Post(
* path="/test",
* produces={"application/json"},
* tags={"Test"},
* @SWG\Parameter(
* name="body",
* in="body",
* required=true,
* @SWG\Schema(
* @SWG\Property(
* property="request-body", type="object", example={"date": "09 Feb 2019","country": "XX","type": "sample","info": {"xyz": 1,},"test_internal": "abc"} * ),
* @SWG\Property(
* property="doc", type="object", example={"comments": "contains","name": "startup"},
* @SWG\Property(
* property = "test_list",
* type = "array",
* @SWG\Items(
* @SWG\Property(property="test_list", type="object", example={"level": "NA","time_limit": "NA"}),
* ),
* ),
* ),
* ),
* )
* )
**/
但是我得到这样的输出,
{
"request-body": {
"date": "09 Feb 2019",
"country": "XX",
"type": "sample",
"info": {
"xyz": 1,
},
"test_internal": "abc"
},
"doc": {
"comments": "contains",
"name": "startup"
}
}
如何确定swg注释中的嵌套数组和对象?