【发布时间】:2016-09-01 17:59:38
【问题描述】:
我有这个架构,我希望下面的 dataRecord 属性中只有 1 个“任意”架构。我还期望 dataRecord 属性应该只包含模式。目前我们只有 2 个子模式,我们在 dataRecord 属性中引用它们。在未来,我们预计会添加更多模式,例如 test2、test3 等。我想避免编辑以下架构以将更多 $ref 添加到 dataRecord 属性。有没有办法在不添加更多对 dataRecord 属性的引用的情况下实现这一点,同时确保始终提供 1 个模式。任何帮助将不胜感激。
{
"id": "http://anysiteaddress",
"type": "object",
"properties": {
"recordId": {
"type": "string"
},
"dbOperationType": {
"type": "string"
},
"schema": {
"type": "string"
},
"schemaVersion": {
"type": "string"
},
"utcTimeStamp": {
"type": "string"
},
"dataRecord": {
"oneOf" : [
{ "$ref": "test.json#/definitions/test"},
{ "$ref": "test1.json#/definitions/test1"}
]
}
},
"additionalProperties": false,
"required": [
"recordId",
"dbOperationType",
"schema",
"schemaVersion",
"utcTimeStamp",
"dataRecord"
]
}
【问题讨论】:
标签: json jsonschema