I can't seem to get this scenario to work:
Model {"a":"b"}
Patch {"x":{"y":"z"}}
Result {"a":"b", "x":{"y":"z"}}
To illustrate, in PatchTest.PatchObject() replace this line:
await server.PostAsync("api/data/0", GetTestModel());
with this line:
await server.PostAsync("api/data/0", new TestModel());
The error occurs when applying the underlying JsonPatch:
_jsonPatchDocument.ApplyTo(objectToApplyTo);
The issue seems to be that there are operations for the subModel properties, but not for the subModel itself.
To test, I changed JsonMergePatchInputFormatter.AddOperation() to instead add a replace operation for the object property instead of recursing and it worked for this case, however it breaks the ability to patch nested properties.
I can't seem to get this scenario to work: Model {"a":"b"} Patch {"x":{"y":"z"}} Result {"a":"b", "x":{"y":"z"}}
To illustrate, in PatchTest.PatchObject() replace this line:
await server.PostAsync("api/data/0", GetTestModel());
with this line:await server.PostAsync("api/data/0", new TestModel());
The error occurs when applying the underlying JsonPatch:
_jsonPatchDocument.ApplyTo(objectToApplyTo);
The issue seems to be that there are operations for the subModel properties, but not for the subModel itself.
To test, I changed
JsonMergePatchInputFormatter.AddOperation()
to instead add a replace operation for the object property instead of recursing and it worked for this case, however it breaks the ability to patch nested properties.-Ed