【发布时间】:2015-12-02 08:40:07
【问题描述】:
看起来两者都适用于我的输入验证代码。那么具体有什么区别呢?
带有 oneof 的架构
[{
"id": "MyAction",
"oneOf": [{ "$ref": "A1" },
{ "$ref": "A2" }]
},
{
"id": "A1",
"properties": {
"class1": { "type": "string"},
"class2": { "type": "string"}
}
},
{
"id": "A2",
"properties": {
"class2": { "type": "string"},
"class3": { "type": "string"}
}
}
]
架构与任何一个
[{
"id": "MyAction",
"anyOf": [{ "$ref": "A1" },
{ "$ref": "A2" }]
},
{
"id": "A1",
"properties": {
"class1": { "type": "string"},
"class2": { "type": "string"}
}
},
{
"id": "A2",
"properties": {
"class2": { "type": "string"},
"class3": { "type": "string"}
}
}
]
【问题讨论】:
-
文档是怎么说的?您对文档的哪一部分有疑问?
标签: json validation jsonschema json-schema-validator