Description
Hi,
Trying to use ajv-merge-patch in a scenario where my definitions are split up over multiple JSON files - lets say I have the following 4 files;
/system.json (all objects have these properties - however not always all of them required)
{
"id": "/system.json",
"type": "object",
"properties": {
"id": {
"type": "number"
}
}
}
/object/user.json (a specific object type - includes all from system.json)
{
"id": "/object/user.json",
"$merge": {
"source": {
"type": "object",
"properties": {
"firstname": {
"type": ["string", "null"]
}
}
},
"with": {
"$ref": "/system.json#"
}
}
}
/general/crud/create/request.json (template for incoming record create requests)
{
"id": "/general/crud/create/request.json",
"type": "object",
"properties": {
"userId": {
"type": "number"
},
"values": {
"type": "object"
}
},
"required": ["userId", "values"],
"additionalProperties": false
}
user/action/create/request.json (specific user create template - extends /general/crud/create/request.json above - making the values node specific with the user model above - adds one additional property)
{
"id": "/user/action/create/request.json",
"type": "object",
"$patch": {
"source": {
"$ref": "/general/crud/create/request.json#"
},
"with": [{
"op": "add",
"path": "/properties/values",
"value": {
"$merge": {
"source": {
"$ref": "/object/user.json#"
},
"with": {
"properties": {
"unencrypted_password": {
"type": "string"
}
},
"required": ["unencrypted_password"]
}
}
}
}]
}
}
Now what I would like to do is put an "additionalProperties: false" on the user model as other use cases besides create should not specify any additional properties - however if I do this currently my "unencrypted_password" will be rejected - injecting additionalProperties: true anywhere in the last schema does not seem to have any effect.
Am I just trying to do something stupid here, or is it just not possible to override additionalProperties when using patch/merge in its current state? Is this something on the roadmap to be done or something which would not even be considered if I wrote a PR for it?