Skip to content

Instantly share code, notes, and snippets.

@Fannon
Last active August 29, 2015 14:01
Show Gist options
  • Save Fannon/3307353eb2a00ccc01e2 to your computer and use it in GitHub Desktop.
Save Fannon/3307353eb2a00ccc01e2 to your computer and use it in GitHub Desktop.
JSON Schema $extends
// 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