Fix JsonSchemaFlattenAttribute duplicate fields with multiple inheritance levels#1899
Open
lahma wants to merge 1 commit intoRicoSuter:masterfrom
Open
Fix JsonSchemaFlattenAttribute duplicate fields with multiple inheritance levels#1899lahma wants to merge 1 commit intoRicoSuter:masterfrom
lahma wants to merge 1 commit intoRicoSuter:masterfrom
Conversation
…ance When using [JsonSchemaFlatten] on a class with multiple levels of inheritance (e.g., A : B : C), properties from intermediate ancestors were duplicated - appearing both in the flattened schema's properties and in an allOf section. This happened because the recursive GenerateInheritance call used the ancestor's own flatten setting instead of continuing to flatten. Added FlattenAncestorProperties method that recursively flattens all ancestor properties without creating allOf entries. Fixes RicoSuter#1870 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
[JsonSchemaFlatten]on a class with multiple levels of inheritance (e.g.,Test : Test2 : Test1), properties from intermediate ancestors were duplicated — appearing both in the flattened schema'spropertiesand in anallOfsectionGenerateInheritancecall checked each ancestor type's own flatten setting, so unflatten ancestors createdallOfentries despite the top-level type being flattenedFlattenAncestorPropertiesmethod that recursively walks the entire inheritance chain and flattens all properties into the target schema without creatingallOfentriesTest plan
FlattenInheritanceHierarchyTests.cs:[JsonSchemaFlatten]attribute with 3-level inheritance → no duplicates, no allOf, all properties presentFlattenInheritanceHierarchysetting with 3-level inheritance → same behaviorFixes #1870
🤖 Generated with Claude Code