We are attempting to integrate System.Text.Json into our REST API and rest clients, previously using Newtonsoft.
We are using nswag CSharpClientGenerator.GenerateFile to generate our REST API clients via code (not nSwag Studio).
Because of the casing differences between the property names and the json name, items are not correctly deserializing. We have been able to over come this by setting PropertyNameCaseInsensitive = true.
We were able to do this via a partial class as below:
partial class MakeClient
{
partial void UpdateJsonSerializerSettings(JsonSerializerOptions settings)
{
settings.PropertyNameCaseInsensitive = true;
}
}
I really don't want to create these partial classes for every client.
Is there an easier way to do this, such as injecting JsonSerializerOptions into the client, or some type of global setting?