I am using a Minimal API to recreate an old REST service and so I need to mimic the functionality of the previous service as close as possible. Information in the old service is returned Pascal case and I know that there are some old clients that are case-sensitive. Out of the box .NET 6 serializes to camel case on the web but that can be overridden with code such as:
builder.Services.Configure<JsonOptions>(options =>
{
options.JsonSerializerOptions.PropertyNamingPolicy = null;
});
If a breakpoint is set I can see that the policy is originally set to camel case and then reset to null. If I then use JsonSerializer.Serialize
it works as expected. The only issue is if I use Results.OK(colection)
it is back to camel case as if it is ignoring the options settings. I can set all the property names with declarative attributes on the model class and that works as expected so inline declarations work but setting on the service level does not. So, what options is the 'Results.OK' response pipeline looking at?
EDIT: Corrected method name