Skip to content

JsonStringEnumMemberName not taken into account for url parameters #1866

@jochenjonc

Description

@jochenjonc

Hi,

After the update to NJsonSchema v11.5.1 the conversion of enum values to string is broken.

The reason is that in the Enum.liquid the [System.Runtime.Serialization.EnumMember(Value = @"somevalue")] has been replaced by [System.Text.Json.Serialization.JsonStringEnumMemberName(@"somevalue")], but the method ConvertToString that is used for URL parameters to convert a value to string only checks for the EnumMember attribute.

I see at least 2 possible solutions:

  • Keep the both [System.Runtime.Serialization.EnumMember(Value = @"somevalue")] and [System.Text.Json.Serialization.JsonStringEnumMemberName(@"somevalue")] on each enum value.
  • Adjust the ConvertToString method to read the JsonStringEnumMemberName attribute instead of the EnumMember attribute (or both)

Personally I would go for option 1 because it will have less backwards compatibility issues. Maybe there are other pieces of code that still use the EnumMember attribute.

Maybe the fix can be added to #1865.

Regards,

Jochen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions