Created
February 26, 2013 11:19
-
-
Save fge/5037784 to your computer and use it in GitHub Desktop.
Animals with additionalProperties: false
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
{ | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"oneOf": [ | |
{ | |
"description": "a single animal", | |
"$ref": "#/definitions/animal" | |
}, | |
{ | |
"description": "a collection of animals", | |
"type": "array", | |
"minItems": 1, | |
"uniqueItems": true, | |
"items": { "$ref": "#/definitions/animal" } | |
} | |
], | |
"definitions": { | |
"common": { | |
"type": "object", | |
"required": [ "type", "name" ], | |
"properties": { | |
"name": { "type": "string" } | |
}, | |
"additionalProperties": false | |
}, | |
"cat": { | |
"patch": { "$ref": "#/definitions/common" }, | |
"with": [ | |
{ | |
"op": "add", | |
"path": "/properties/type", | |
"value": { "enum": [ "cat" ] } | |
}, | |
{ | |
"op": "replace", | |
"path": "/required", | |
"value": [ "type", "name", "favoriteToy" ] | |
}, | |
{ | |
"op": "add", | |
"path": "/properties/favoriteToy", | |
"value": { "type": "string" } | |
} | |
] | |
}, | |
"dog": { | |
"patch": { "$ref": "#/definitions/common" }, | |
"with": [ | |
{ | |
"op": "add", | |
"path": "/properties/type", | |
"value": { "enum": [ "dog" ] } | |
}, | |
{ | |
"op": "replace", | |
"path": "/required", | |
"value": [ "type", "name", "breed", "leashColor" ] | |
}, | |
{ | |
"op": "add", | |
"path": "/properties/breed", | |
"value": { "type": "string" } | |
}, | |
{ | |
"op": "add", | |
"path": "/properties/leashColot", | |
"value": { "type": "string" } | |
} | |
] | |
}, | |
"animal": { | |
"oneOf": [ | |
{ "$ref": "#/definitions/cat" }, | |
{ "$ref": "#/definitions/dog" } | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment