Last active
August 29, 2015 14:01
-
-
Save Fannon/3307353eb2a00ccc01e2 to your computer and use it in GitHub Desktop.
JSON Schema $extends
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Abstract Shape Schema | |
{ | |
"id": "_Shape", | |
"type": "object", | |
"properties": { | |
"x": {"type": "number"}, | |
"y": {"type": "number"} | |
}, | |
"required": ["x", "y"] | |
} | |
// Circle Schema (extends Shape) | |
{ | |
"$extends": "/_Shape", | |
"id": "Circle", | |
"type": "object", | |
"properties": { | |
"radius": {"type": "number"} | |
}, | |
"required": ["x", "y", "radius"] | |
} | |
// There is one problem: How to remove an unwanted inherited attribute? | |
{ | |
"$extends": "/_Shape", | |
"id": "Circle", | |
"type": "object", | |
"properties": { | |
"x": {} | |
// This keeps the property, but since it has no informations | |
// a validator could threat it like it would be non existing | |
}, | |
"required": ["y", "radius"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment