【发布时间】:2020-03-27 15:41:04
【问题描述】:
我目前的 json 架构定义是这样的
{
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 1
},
"description": {
"type": "string",
"minLength": 1
},
"input": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"type": {
"type": "string"
}
},
"required": ["name", "description", "type"]
}
},
"output": {
"type": "array",
"maxItems": 1,
"items": {
"type": "object",
"properties": {
"description": {
"type": "string",
"minLength": 1
},
"type": {
"type": "string"
}
},
"required": ["description", "type"]
}
}
},
"required": ["name", "description"]
}
所以我需要验证以下条件的方案:
- 如果输入数组和输出数组都为空,则两者都必须;
- 如果输入数组不为空,那么输出数组应该不需要;
- 如果输出数组不为空,则输入数组不应该是必需的;
提前谢谢你。
【问题讨论】:
-
我可以为您提供解决方案,但目前还不行。我希望其他时区的人会打败我,但如果不是,我会回来的! =]
标签: json validation jsonschema