【发布时间】:2020-08-05 13:10:26
【问题描述】:
我需要为对象的属性选择创建一个 Json 模式 第一个选项是:
"part_2_2_object_details_array": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"function": {
"type": "null"
},
"address": {
"type": "string"
},
"kosfn": {
"$ref": "#/definitions/kosfn"
}
}
}
第二个是:
"part_2_2_object_details_array": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"function": {
"type": "string"
},
"address": {
"type": "string"
},
"kosfn": {
"type": "null"
}
}
}
当函数为null - kosfn 属性为object,当函数为string - kosfn 为null。但是我不知道如何构建一个涵盖这两种情况的架构,因为 oneOf 不能应用于属性。
【问题讨论】:
-
“oneOf 不能应用于属性”是什么意思?
标签: jsonschema json-schema-validator