json-editor
json-editor copied to clipboard
Use keyword "allof" to inherit a type
hello guys, I have a shcema like this:
BaseButton.json:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "BaseButton",
"type": "object",
"additionalProperties": false
}
SingleButton.json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "SingleButton",
"type": "object",
"additionalProperties": false,
"allOf": [
{
"$ref": "BaseButton.json"
}
]
}
SingleClickButton.json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "SingleClickButton",
"type": "object",
"additionalProperties": true,
"properties": {
"key": {
"type": [
"null",
"string"
]
}
},
"allOf": [
{
"$ref": "SingleButton.json"
}
]
}
MenuSettingSchema.json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"additionalProperties": false,
"type": "array",
"title": "ButtonGroup",
"format": "tabs",
"items": {
"title": "SubButton",
"oneOf": [
{
"$ref": "SingleClickButton.json",
"title": "SingleClickButton"
}
]
}
}
When I create a SingleClickButton, the validator always report an "invalid". I must add any anothor property to "SingleClickButton", then it can be passed. What's wrong with it? by the way, I can't understand the key word "allOf" clearly. THANKS A LOT!