我的应用程序的响应如下:
{
"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"
}
如何定义数据属性以使用架构定义?或者可以用不同的方式来完成?
有趣的是,人们有时在发布问题后就找到了答案。
答案是:
* @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"
* ),
* )
* ),