在Swagger文档中的API响应示例中,作为对象数组的属性显示为空

时间:2018-10-23 06:29:19

标签: swagger

API响应格式是这样的(couponReportData下有更多属性,但此处未显示)-

{
    "status": "success",
    "success_id": "S-001",
    "message": "Request processed successfully",
    "couponReportData": [
        {
            "uuid": "8432732587408386841",

        },
        {
            "uuid": "7916954142184535581",

        }
    ]
}

我正在尝试通过编辑json文件(在swagger html文件的redoc spec-url属性中指定)来编写相同的swagger文档。

以下是我到目前为止在json的paths属性中写的内容-

"paths": {
        "/endPoint": {
            "get": {
                "tags": ["Fetch Data Apis"],
                "summary": "summary",
                "operationId": "fetchcouponGET",
                "consumes": ["application/json"],
                "produces": ["application/json"],
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/ResultDTO1_endpoint"
                        }
                    },
                    "400": {
                        "description": "Bad Request"
                    },
                    "500": {
                        "description": "Internal Server Error"
                    },
                    "404": {
                        "description": "Not Found"
                    }
                }
            }
        },
        "definitions": {
            "ResultDTO1_endpoint": {
                "type": "object",
                "properties": {
                    "status": {
                        "type": "string",
                        "description": "Api status success or error",
                        "example": "success"
                    },
                    "success_id": {
                        "type": "string",
                        "description": "When success Response",
                        "example": "S-001"
                    },
                    "message": {
                        "type": "string",
                        "description": "Api message response",
                        "example": "Request processed successfully"
                    },
                    "couponReportData": {
                        "type": "object",
                        "properties": {
                            "uuid": {
                                "type": "integer",
                                "description": "Some description",
                                "example": "2"
                            }
                        }
                    }
                }
            }
        }

以下是我在生成的Swagger文档的响应部分中得到的内容-

enter image description here

enter image description here

更新

在海伦(Helen)指导下的解决方案之后,正确生成了响应样本部分,但是响应模式仍然令人困惑-

enter image description here

0 个答案:

没有答案