【发布时间】:2017-06-19 11:52:55
【问题描述】:
我正在创建一个 JsonSchema(v4)。 我正在尝试根据其父级的另一个属性的值来使一个属性成为必需。
父母
- 用户
- 亚型
- 地址
孩子
- 地址
- 第一行
- 第2行
- companyName(如果用户子类型是公司,则为必填)
如何做到这一点? 我现在有这样的东西......
{
"User": {
"title": "User",
"type": "object",
"id": "#User",
"properties": {
"subtype": {
"type": "string"
},
"address": {
"$ref": "Address"
}
}
}
"Address": {
"title": "Address",
"type": "object",
"id": "#Address",
"properties": {
"line1": {
"type": "string"
},
"line2": {
"type": "string"
},
"companyName": {
"type": "string"
}
},
"required": ["line1", "line2"]
}
}
子类型是任意字符串,因此不可能列出不同子类型的完整列表。
【问题讨论】:
标签: jsonschema