Repository navigation
Document that System.Text.Json ignores [EnumMember] - #4127
Merged
martincostello merged 2 commits intoSep 29, 2026
Merged
martincostello merged 2 commits into
martincostello merged 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4127 +/- ##
=======================================
Coverage 95.24% 95.24%
=======================================
Files 111 111
Lines 4142 4142
Branches 848 848
=======================================
Hits 3945 3945
Misses 197 197
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The attribute is not implemented by System.Text.Json, so it renames nothing in the generated schema, while Newtonsoft.Json does honor it. Point at [JsonStringEnumMemberName], which System.Text.Json added in .NET 9 and which does reach the document.
Contributor
Author
|
Agreed. The section is now four lines: one sentence on why the serializer decides the names, and links to the upstream documentation for |
RaphaelFakhri
force-pushed
the
docs/3328-enum-member-naming
branch
from
September 29, 2026 10:06
3126a4b to
3812750
Compare
martincostello
approved these changes
Sep 29, 2026
This was referenced Oct 7, 2026
Open
Open
This was referenced Oct 11, 2026
Open
Bump Swashbuckle.AspNetCore from 5.6.3 to 10.3.0
Sebasxdd/skills-secure-repository-supply-chain-2#12
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3328.
Adds a
Rename Enum Values in Schemassection to the SwaggerGen docs, covering the difference you agreed was worth writing down:System.Text.Jsondoes not implement[EnumMember],Newtonsoft.Jsondoes, and[JsonStringEnumMemberName]is the native option.I verified all three claims against
masterrather than trusting the issue, by generating the schema for the same enum through each resolver:enumin the generated schemaSystem.Text.Json[EnumMember(Value = "X-foo")]Value1,XSystem.Text.Json[JsonStringEnumMemberName("X-foo")]Value1,X-fooNewtonsoft.Json[EnumMember(Value = "X-foo")]Value1,X-fooThe C# examples are plain fenced blocks rather than MarkdownSnippets snippets.
JsonStringEnumMemberNameAttributeis .NET 9 and later, andDocumentationSnippetsmulti-targets down to net8.0, so a compiled snippet would need an#if NET9_0_OR_GREATERaround it that would then show up in the rendered page. Happy to switch it to a snippet with the guard, or to a net9.0-and-later snippet project, if you would rather have it compiled.markdownlint-cli2with the repo's.markdownlint.jsonreports 0 issues, anddotnet mdsnippetsleaves the file unchanged.