Swagger - 对象不会嵌套

时间:2015-10-09 16:35:30

标签: json api swagger swagger-ui

我得到了这个结果,即使我想要一个完全嵌套的对象:

    {
        "content": {}
    }

这些是我使用的重要代码片段:

    "responses": {
            "200": {
                    "description": "An array of addresses",
                    "schema": {
                        "type": "object",
                        "$ref": "#/definitions/ContentWrapperAddress"
                    }
            }
    }

    "ContentWrapperAddress":{
        "properties": {
            "content": {
                "type": "object",
                "items": {
                    "$ref": "#/definitions/AddressList"
                }
            }
        }
    },
    "AddressList": {
        "properties": {
            "addresses": {
                "type": "array",
                "items": {
                    "$ref": "#/definitions/SplitAddress"
                },
                "description": "An array of split addresses. Will give back an empty array if nothing useful is returned."
            }
        }
    },
    "SplitAddress": {
        "properties": {
            "address1": {
                "type": "string"
            },
            "address2": {
                "type": "string"
            },
            "city": {
                "type": "string"
            },
            "state": {
                "type": "string"
            },
            "zip": {
                "type": "string"
            },
            "isMultiUnit":{
                "type": "boolean"
            }
        }

如果我只使用AddressList,那么它会完美显示。

0 个答案:

没有答案