复杂嵌套JSON的Swagger文档
使用复杂嵌套JSON的Swagger文档,swagger,microservices,swagger-2.0,restapi,Swagger,Microservices,Swagger 2.0,Restapi,使用Swagger 2.0。我的API响应如下,我必须为此制作一份招摇过市的文档: { "id": "012", "det": [ { "rec1": { "det1": "ok", "det2": "notok" }, "rec2":
Swagger 2.0
。我的API响应如下,我必须为此制作一份招摇过市的文档:
{
"id": "012",
"det": [
{
"rec1": {
"det1": "ok",
"det2": "notok"
},
"rec2": {
"det3": "ok"
}
},
{
"rec1": {
"det1": "bad",
"det2": "good"
},
"rec2": {
"det3": "poor"
}
}
]
}
数组det
有两个对象。我能够创建一个描述此数组的第一个对象的文档。但在显示第二个时,它会出现各种错误,如重复映射、对象映射问题等
我没有使用示例
的方法。相反,使用$ref
以YAML样式执行
任何指导都会有帮助
亚马尔:
你能发布你的YAML吗?用YAML更新了问题
TestModel:
type: object
properties:
id:
type: string
example: "012"
det:
type: array
items:
$ref: '#/definitions/Rec'
Rec:
type: object
properties:
rec1:
type: object
properties:
det1:
type: string
example: "ok"
det2:
type: string
example: "notok"
rec2:
type: object
properties:
det3:
type: string
example: "ok"