Hi,
I have an issue with the library. When my model object has a property that is an instance of another object, the framework is not able to bind the controller argument from the request.
Here is a simplified example code to reproduce the issue.
Model classes
public record TestClass(
string? Name,
string? Description,
TestSubClass? Test);
public record TestSubClass(
string? Prop1,
string? Prop2);
Controller action
[HttpPatch]
[Consumes(JsonMergePatchDocument.ContentType)]
[Route("test")]
public Task<ActionResult> TestAction([FromBody] JsonMergePatchDocument<TestClass> patchDoc)
{
throw new NotImplementedException();
}
JsonMergePatch setup in application startup
var webApplicationOptions = new WebApplicationOptions
{
Args = Environment.GetCommandLineArgs(),
WebRootPath = frontendUiPath
};
var builder = WebApplication.CreateBuilder(webApplicationOptions);
builder.Services
.AddMvcCore()
.AddSystemTextJsonMergePatch();
When I call the endpoint with the following payload:
{
"name": "string",
"description": "string",
"test": {
"prop1": "string",
"prop2": "string"
}
}
the result is that the patchDoc argument of the controller action is null (not bound), and the ModelState is invalid, saying the patchDoc is required.

However if I leave out the the test property from the request, patchDoc is bound correctly:
{
"name": "string",
"description": "string"
}

Hi,
I have an issue with the library. When my model object has a property that is an instance of another object, the framework is not able to bind the controller argument from the request.
Here is a simplified example code to reproduce the issue.
Model classes
Controller action
JsonMergePatch setup in application startup
When I call the endpoint with the following payload:
{ "name": "string", "description": "string", "test": { "prop1": "string", "prop2": "string" } }the result is that the patchDoc argument of the controller action is null (not bound), and the ModelState is invalid, saying the patchDoc is required.

However if I leave out the the test property from the request, patchDoc is bound correctly:
{ "name": "string", "description": "string" }