Open johannesmols opened 8 months ago
Yup, JsonStringEnumConverter
leaves much to be desired, you need 3rd party converter to support such scenarios. Most popular being JsonStringEnumMemberConverter. I'm just trying to figure out how to tell NSwag to not hardcode JsonStringEnumConverter.
Was looking for that as well. If I'm right the code is generated here: https://github.com/RicoSuter/NJsonSchema/blob/9bf8f695b373410e8b51e1363270c08dda7b8127/src/NJsonSchema.CodeGeneration.CSharp/Templates/Class.liquid#L82. Looks like there is no way for now to change it.
As stated in the System.Text.Json migration guide, the System.Runtime.Serialization attributes are not supported (see also https://github.com/dotnet/runtime/issues/31081).
I have noticed that it does work when my enum names do not contain spaces. Once they do, I get an exception:
This is the code generated:
When the names in the definition do not contain spaces, this works fine:
For completeness, this is how the enum is used in a class of the generated code:
And this is the specification defining the enum: