New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StringEnumConverter does not work in "5.0.0-rc5" #1459
Comments
As System.Text.Json is now the default serializer for ASP.NET Core, Swashbuckle honors it's options/attributes by default as well. To honor the Newtonsoft settings/attributes instead, you need to install a separate Swashbuckle package and opt-in. See https://github.com/domaindrivendev/Swashbuckle.AspNetCore#systemtextjson-stj-vs-newtonsoft |
I have the same problem. The difference is I have separate property attribute for viewmodel [JsonConverter(typeof(StringEnumConverter))] And 'services.AddSwaggerGenNewtonsoftSupport();' is used |
Did you call
|
Yes, the code:
and I don't use camelCase for enums, but general camel-case resolver
|
Hi @josalper , @Transmuter |
Thank you for fixes! Yes, it works for |
While global converters (i.e. via options) and type-level converters (i.e. via With that said, I can't think of too many use cases where you would want to serialize an enum one way for a certain property and a different way for another. Perhaps you could elaborate on your particular use case. If nothing else, it would help me understand your needs a little better and allow me to prioritize making the tricky enhancement accordingly. |
My case is a big project with much legacy code. So, the problem with attribute is not critical, but requires some refactoring. Anyway, I'm glad that there is a way to solve the original issue, thank you very much! |
@IlyaUhlianitsa it's helped for me but |
I have tested it in the final version and it works! Closing.... |
Hello, I've been testing the latest release candidate version "5.0.0-rc4" and "5.0.0-rc5", and I have detected a bug.
In "rc5" the string enum conversion to string does not work.
I have the same conversion configuration in ConfigureServices:
Result schema in rc4:
Result schema in rc5:
The text was updated successfully, but these errors were encountered: