【发布时间】:2015-05-30 18:10:37
【问题描述】:
使用json-editor 并查看answer,我正在尝试使用json-schema v4 执行以下操作:
使用根属性选择['clothing', 'accessory'] 的两个类别之一,这将确定material 属性的枚举值。
我试图解决的案例有多个枚举属性,具体取决于category-value。
伪代码示例:
{
"type": "object",
"Title": "Products",
"definitions": {
"clothing": {
"materials": ["yak", "merino"]
},
"accessories": {
"materials": ["brass", "silver"]
}
},
"properties": {
"productType": {
"type": "string",
"enum": [
"clothing",
"accessories"
]
},
"materials": {
"type": "array",
"title": "Materials",
"items": {
"type": "string",
"title": "Material",
"enum": [
{"$ref" : "#definitions/{{productType}}/materials"}
]
}
}
}
}
关于如何构建它有什么建议吗?
【问题讨论】:
标签: javascript json jsonschema