Skip to content
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

Support System.Text.Json JsonStringEnumMemberNameAttribute #1738

Open
bdovaz opened this issue Oct 25, 2024 · 1 comment
Open

Support System.Text.Json JsonStringEnumMemberNameAttribute #1738

bdovaz opened this issue Oct 25, 2024 · 1 comment

Comments

@bdovaz
Copy link

bdovaz commented Oct 25, 2024

Added in 9.0.0: dotnet/runtime#74385

I think it should only affect:

[System.Runtime.Serialization.EnumMember(Value = @"{{ enum.Value | replace: '"', '""' }}")]

And maybe?

var enumMemberAttribute = contextualType.Type.GetRuntimeField(enumName)?.GetCustomAttribute<EnumMemberAttribute>();

@desjoerd
Copy link
Contributor

desjoerd commented Jan 13, 2025

Currently we do this in the file Enum.Member.Annotations.liquid. Maybe it's helpfull for someone :).

{%  if IsStringEnum %}
    [System.Text.Json.Serialization.JsonStringEnumMemberName(@"{{ enum.Value | replace: '"', '""' }}")]
{% endif %}

This is only usefull when generating the Client from openapi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants