My App的回复如下:
{
"status": "success",
"data": {
"status": "ready"
},
"request_id": "string"
}
我尝试在Swagger中定义响应
* @SWG\Response (
* response=200,
* description="Success response",
* @SWG\Schema (
* @SWG\Property(
* property="status",
* type="string",
* default="success"
* ),
* @SWG\Property(
* property="data",
* @SWG\Schema(
* ref="#/definitions/Service/models/Status"
* )
* ),
* @SWG\Property(
* property="request_id",
* type="string"
* ),
* )
* ),
但是它没有使用状态的Schema定义,所以我的响应实际上是这样的:
{
"status": "success",
"data": {},
"request_id": "string"
}
如何定义数据属性以使用模式定义?或者它可以以不同的方式完成吗?
答案 0 :(得分:10)
有趣的是,人们有时会在发布问题后找到答案。
答案是:
* @SWG\Response (
* response=200,
* description="Success response",
* @SWG\Schema (
* @SWG\Property(
* property="status",
* type="string",
* default="success"
* ),
* @SWG\Property(
* property="data",
* ref="#/definitions/Service/models/Status"
* ),
* @SWG\Property(
* property="request_id",
* type="string"
* ),
* )
* ),