如何解决Swagger文档用于复杂的嵌套JSON
使用Swagger 2.0
。我的API响应如下,我必须为此做个草率的文档:
{
"id": "012","det": [
{
"rec1": {
"det1": "ok","det2": "notok"
},"rec2": {
"det3": "ok"
}
},{
"rec1": {
"det1": "bad","det2": "good"
},"rec2": {
"det3": "poor"
}
}
]
}
数组det
有两个对象。我能够创建一个描述此数组第一个对象的文档。但是在显示第二个错误时,它会给出各种错误,例如重复映射,对象映射问题等。
我没有使用example
方法。而是使用$ref
以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"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。