【发布时间】:2020-05-01 22:01:22
【问题描述】:
当使用 json schema 7 时,是否可以设置对对象定义引用而不是单个字段的依赖关系?
例如,我有一个类型字符串和属性对象。根据类型,属性对象字段会有所不同,但我不想设置每个可能字段的依赖关系。这相当乏味,例如
{
"$id": "https://sibytes.datagovernor.com/dataset.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "dataset",
"type": "object",
"properties": {
"dataset_type": {
"type": "string",
"description": ""
},
"dataset_properties": {
<< BASICALLY HERE I WANT THE REFERENCE OBJECT DEFINITION TO BE DEPENDENT ON THE DATASET TYPE ABOVE>>
"$ref": "http://example.com/tableproperties.schema.json"
"$ref": "http://example.com/tableproperties.fileproperties.json"
...there will be others.
}
}
}
【问题讨论】:
-
这能回答你的问题吗? jsonSchema attribute conditionally required
-
No.. 我想根据 data_set 的值有条件地放入不同的整个对象定义。
标签: json jsonschema