Using the JSON Merge Patch specification, is there a way to identify members of a sub-collection in the target - for modification or deletion?
With the twist, that key
may be flagged as readOnly
!
For example, given the following original JSON document:
{
"a": "b",
"c": [
{
"key": "d",
"prop1": "e",
"prop2": "f"
},
{
"key": "g",
"prop": "h"
}
]
}
My gut (often wrong) tells me to send the following request:
PATCH /target HTTP/1.1
"c": [
{
"key": "d",
"prop1": "z"
},
]
To get the result:
{
"a": "b",
"c": [
{
"key": "d",
"prop1": "z",
"prop2": "f"
}
]
}
Does this, so far, make sense according to the spec?
But, what if key
is flagged as readOnly
in an OpenAPI schema? In that case we shouldn't technically be allowed to pass the key
(a UUID) on the wire.