[BUG] fix(InlineModelResolver): do not merge distinct inline enums sharing the same values (#23978)
Fixes #23978
Problem
Since 7.23.0, inline enums that share the same values but are defined on different properties are no longer generated as separate types — only the first enum gets its own schema and the second property silently reuses it. This worked correctly in 7.22.0. The reporter bisected the change to #23856 (commit 170778a), and a second user confirmed the same behaviour on kotlin-spring.
Root cause
#23856 added a structural-signature fallback to matchGenerated(). To dedup the same multi-file $ref object schema across passes (where the Swagger Parser mutates shared Schema objects), the structural mapper strips description, type and example before comparing.
For object schemas that is fine, but for enum schemas it is too aggressive: two enums that list the same values but represent different things are distinguished only by their description. Stripping it makes their structural signatures identical, so the second enum matches the first and reuses its $ref.
Fix
Skip the structural-signature fallback for enum schemas in matchGenerated() — enums deduplicate on exact content only (the 7.22.0 behaviour). Object-schema multi-file deduplication is unchanged.
The diff is small and localized to matchGenerated() plus a new isEnumSchema() helper.
Test evidence
Added InlineModelResolverTest#doNotMergeDistinctInlineEnumsSharingTheSameValues, which builds an object with two inline enum properties that share the same values but carry different descriptions and asserts each is promoted to its own schema. The test fails on master (the two $refs are equal) and passes with this fix.
Full InlineModelResolverTest run: 56 tests, 0 failures — including the existing structural/multi-file dedup regression tests added by #23856 (resolveInlineModelDeduplicatesWhenParserMutatesPropertyTypes, the root.yaml dedup tests), confirming the multi-file object dedup behaviour is preserved.
mvn -pl modules/openapi-generator test -Dtest=InlineModelResolverTest
Tests run: 56, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS
Verification done: (1) no in-flight PR (searched open PRs for 23978 / InlineModelResolver enum); (2) issue unassigned, no claim comments; (3) code-focused (.java only); (4) reproduced on latest upstream/master with a failing unit test; (5) maintainer (@wing328) acknowledged the regression and cc'd the author of the change.
Summary by cubic
Fixes a regression that merged distinct inline enums with identical values; enum schemas now dedupe only on exact content so each inline enum generates its own schema. Also aligns the structural-signature fallback to run only for titled, non-enum schemas.
- Bug Fixes
- In
InlineModelResolver.matchGenerated()andaddGenerated(), exclude enums and require a title for the structural-signature fallback; object-schema multi-file dedup stays the same. - Add
isEnumSchema()and unit testdoNotMergeDistinctInlineEnumsSharingTheSameValues(InlineModelResolverTest: 57 tests, 0 failures). - Regenerate C# generichost FormModels samples: align header/query enum parameters to
EnumHeaderStringParameter; drop rust-server-deprecated output and adopt the newjaxrs-spec-enumsample from master.
- In