We are implementing a .NET Core 3.1 API and we are using Microsoft.AspNetCore.Mvc.NewtonsoftJson according to this doc. We are dealing with enums and we need the string representation instead of the integers. We are doing it using the JsonConverter attribute like this:
[JsonProperty("region")]
[JsonConverter(typeof(StringEnumConverter))]
public Region Region { get; set; }
We are trying to do it globally from the Startup.cs like below :
services.AddControllers().AddNewtonsoftJson(opts => opts.SerializerSettings.Converters.Add(new StringEnumConverter()));
If we do that, the Cosmos DB is complaining with
"PartitionKey extracted from document doesn't match the one specified in the header"
So we tried removing all the attributes except by the region one. All the other enums that don't have the attribute are stored as strings correctly, but the region still needs the attribute to work. Any clue why is this happening and how to solve it?