Closed deinok closed 1 hour ago
Where are you using the converter? Attributes in properties of types, or global configuration of MVC/HTTP options?
Some code that reproduces exactly what you're seeing would help.
@martincostello Globaly in the ConfigureServices
serviceCollection.AddControllers()
.AddJsonOptions(jsonOptions =>
{
jsonOptions.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
@deinok Thanks for filing this issue!
Unfortunately, you're running into a long-standing issue with the way configuring JsonOptions evolved in ASP.NET Core. The JSON options instance that you modify when calling .AddControllers().AddJsonOptions()
is local to MVC and doesn't get picked up by other components in ASP.NET Core. For that, you'll need to modify the lower-level HTTP-based JSON options via IServiceCollction.ConfigureJsonOptions
.
You can find more background on this problem in this earlier reported issue over at https://github.com/dotnet/aspnetcore/issues/57891.
Closing in favour of #57891
Is there an existing issue for this?
Describe the bug
As the title says, the new OpenApi package does not respect "JsonStringEnumConverter". It outputs enums as "integer".
Expected Behavior
The OpenApi takes into consideration the JsonStringEnumConverter and does not output the enums as its underlying primitive
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
9.0.0
Anything else?
No response