-
Couldn't load subscription status.
- Fork 396
v5: merge
This keyword is intended as a way to merge two schemas into one.
Implementing this keyword requires support for JSON merge-patch.
- the value of this keyword MUST be a JSON Object;
- it MUST have two members:
source,with; - the value of
sourceMUST be a valid JSON Schema; - the value of
withMUST be a JSON Object.
Example:
{
"merge": {
"source": {
"type": "object",
"properties": { "p": { "type": "string" } },
"additionalProperties": false
},
"with": {
"properties": { "q": { "enum": [ null ] } }
}
}
}- this keyword MUST NOT take precedence over a JSON Reference;
- when this keyword is encountered, other schema keywords SHALL be ignored;
- implementations MUST consider that the current schema is the result of the merge.
The schema above, when merged, becomes:
{
"type": "object",
"properties": {
"p": { "type": "string" },
"q": { "enum": [ null ] }
},
"additionalProperties": false
}This, and JSON Reference plus the $data proposal, would pretty much mandate that a new section in the core specification be dedicated to schema preprocessing; in order: $ref, merge, $data.
In addition, an optional keyword may be patch with the same syntax as merge, except that the value of with would be a JSON Patch. Supporting this keyword would mean setting a different, specified $schema, and moreover the presence of both keywords at once would be forbidden.