You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello!
I'm trying to use CSharpGenerator to generate C# code from JSON schema. The schema contains enums with camelStyle members. But when I serialize the generated classes with System.Text.Json, the resulting JSON contains PascalStyle enums, which violates the schema.
System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter)) attribute generated for StarType property overloads my JsonStringEnumConverter specified in JsonSerializerOptions.
I tried to find a workaround but failed.
Best regards,
Mikhail Virovets
The text was updated successfully, but these errors were encountered:
I'm having the exact issue where the EnumMemberAttribute value is not read. I also have a custom converter available, added to the JsonSerializerOptions of the generated client.
Currently I'm digging through the code of NJsonSchema. At this moment I think it should become optional to get the converter attribues generated in C#, regardless jsonLibrary setting - at this moment the option is not there.
I agree with @eholman, it should be optional to have the JsonConverter attribute added or not.
And if possible to use the JsonStringEnumMemberConvertor from the Macross.Json.Extensions or other custom one.
Hello!
I'm trying to use CSharpGenerator to generate C# code from JSON schema. The schema contains enums with camelStyle members. But when I serialize the generated classes with System.Text.Json, the resulting JSON contains PascalStyle enums, which violates the schema.
To reproduce
Schema example:
I run the generator in the following way:
Here is the code generated:
Then I serialize the generated class:
The resulting JSON is
Adding JsonStringEnumConverter has no effect:
Suggestions
System.Runtime.Serialization.EnumMember
attribute is ignored by System.Text.Json, see Support for EnumMemberAttribute in JsonConverterEnum dotnet/runtime#31081System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))
attribute generated forStarType
property overloads myJsonStringEnumConverter
specified inJsonSerializerOptions
.I tried to find a workaround but failed.
Best regards,
Mikhail Virovets
The text was updated successfully, but these errors were encountered: