【发布时间】:2020-05-01 04:57:07
【问题描述】:
json-schema 是否允许基于另一个文件的属性值有条件子模式?
例子:
Jsons:
另一个.json
{
"honey": "honey"
}
main.json
{
"hello": "abc"
}
架构
{
"type": "object",
"properties": {
"hello": {
"type": "string"
}
},
"required": ["hello"],
"if": {
"properties": {
"another.json#/honey": { -->> is this possible
"const": "honey"
}
}
},
"then": {
"properties": {
"hi": {
"type": "string"
}
},
"required": ["hi"]
}
}
main.json 应该通过尖叫 “hi”是必需的验证失败,因为 another.json 具有“honey”作为值。
现在,将 another.json 更改为
{
"honey": "not_honey"
}
应该通过 main.json 的验证
问题是
【问题讨论】:
标签: json validation conditional-statements schema jsonschema