Created
March 28, 2015 02:29
Example of using "allOf" to make JSON Schema mixins
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
{ | |
"definitions": { | |
"nameMixin": { | |
"type": "object", | |
"properties": { | |
"nameFirst": {"type": "string"}, | |
"nameLast": {"type": "string"} | |
}, | |
"required": ["nameFirst", "nameLast"] | |
}, | |
"person": { | |
"allOf": [ | |
{"$ref": "/definitions/nameMixin"}, | |
{ | |
"type": "object", | |
"properties": { | |
"age": {"type": "number"} | |
}, | |
"required": ["age"] | |
} | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice. I tried the same idea. The only thing to overcome is how to combine this successfully with
{ "additionalProperties": false }
.