Object Swagger-1.2:如何在模型模式中显示n个嵌套的JSON对象

Object Swagger-1.2:如何在模型模式中显示n个嵌套的JSON对象,object,swagger,Object,Swagger,我使用的是Swagger 1.2,很难对JSON嵌套对象建模,我希望模型模式能够像Swagger在线演示宠物商店POST/Pet中那样显示(示例值)。例如,我的对象是: { "parent" : { "child_1" : { "child_2a" : "string", "child_2b" : { "child_3a" : "string", "child_3b" : ["str

我使用的是Swagger 1.2,很难对JSON嵌套对象建模,我希望模型模式能够像Swagger在线演示宠物商店POST/Pet中那样显示(示例值)。例如,我的对象是:

{
   "parent" : {
      "child_1" : {
          "child_2a" : "string",
          "child_2b" : {
              "child_3a" : "string",
              "child_3b" : ["string"]
          }
       }
    }
}
如您所见,我有一个超过1级的JSON。在我的
参数
数组中,我有如下内容:

....
stuff here
.....
api: [
{
            "path": "/api/foo/bar",
            "operations": [
                {
                    "method": "POST",
                    "summary": "a job",
                    "consumes": ["application/json"],
                    "authorizations": {},
                    "parameters": [
                        {
                            "name": "body",
                            "required": true,
                            "type" : "Parent",
                            "description": "some description",
                            "paramType": "body"
                        },
                        {
                            "name": "fooz",
                            "description": "some description",
                            "required": false,
                            "type": "string",
                            "paramType": "query"
                        }
                    ],
                    ...... 
                    ........
        }
],
"models" : {
    "Parent": {
            "id": "Parent",
            "required": ["parent"],
            "properties": {
              "parent": {
                "$ref": "Child1"
              }
            }
        },
        "Child1": {
            "id": "Child1",
            "required" : ["child_1"],
            "properties": {
              "child_1": {
                "$ref": "Child2"
              }
            }
        },

        "Child2" : {
            "id"  : "Child2",
            "required" : ["child_2a", "child_2b"],
            "properties" : {
                "child_2a" : {
                    "type" : "string"
                },
                "child_2b" : {
                    "$ref" : "Child3"
                }

            }
        },
        "Child3" : {
          "id"  : "Child2",
            "required" : ["child_3a", "child_3b"],
            "properties" : {
                "child_3a" : {
                    "type" : "string"
                },
                "child_3b" : {
                    "type" : "array",
                    "items": {
                       "type": "string"
                    }
                }
        }

}
但模型模式显示为:

{
   "parent" : "Child1"
}

我可能做错了什么?如何让它在模型模式中显示整个嵌套对象?正如Swagger演示宠物商店POST/pet示例值一样,Swagger 1.2要求整个模型定义为平面-这意味着,不能有嵌套的复杂对象,只能有基本体和对其他复杂对象的引用

从swagger 2.0开始,您现在可以拥有内嵌、嵌套或匿名对象


因此,简单的回答是,您无法对1.2中描述的内容进行建模。如果可以,请考虑更新您的图书馆使用SWAGER 2。

谢谢您的澄清。