Schema merging - sgpinkus/json-schema GitHub Wiki
JSON-SCHEMA-ORG/JSON-SCHEMA-SPEC REPOSITORY.
THIS WIKI IS OBSOLETE. PLEASE SEE THE NEWThis page is entirely speculative. It does not represent behaviour in any existing specification.
The problem
A lot of questions are asked about how to "extend" a schema by refering to another. For instance, extending:
{
"type": "object",
"properties": {
"p1": {}
},
"additionalProperties": false
}
with:
{
"properties": {
"p2": {}
}
}
is expected to give:
{
"type": "object",
"properties": {
"p1": {}
},
"additionalProperties": false
}
Unfortunately, no keyword exists to do that, since both extends
(draft v3) or allOf
(draft v4) add constraints and do not merge them.
What is really needed is schema merging.
This page is an attempt at defining both a keyword and rules for merging.
The proposed keyword is $include
. Its valid value would be any JSON Schema.
Related pages
[Schema merging rules](Schema merging rules)
Open problems
$schema
and id
Merging of Currently, I see no solution for that...