Skip to content

fix: deduplicate identical oneOf/anyOf groups before cartesian product#787

Merged
reuvenharrison merged 1 commit intomainfrom
fix-710-oneof-deduplication
Feb 3, 2026
Merged

fix: deduplicate identical oneOf/anyOf groups before cartesian product#787
reuvenharrison merged 1 commit intomainfrom
fix-710-oneof-deduplication

Conversation

@reuvenharrison
Copy link
Collaborator

Summary

  • Fixes issue Inconsistent flattening behavior for oneOf schemas in allOf structures #710 where identical oneOf/anyOf groups in allOf subschemas produce duplicate items after flattening
  • Adds deduplication logic to resolveCombinations() that removes equivalent groups before calculating the cartesian product
  • Two groups are considered equivalent if they contain the same set of schema references (matched by $ref path for referenced schemas, or content for inline schemas)

Problem

When multiple allOf subschemas reference the same oneOf definition, the flatten operation was creating a cartesian product of all groups, even when they were identical.

For example:

allOf:
  - oneOf: [A, B]
  - oneOf: [A, B]  # same definition

Without the fix: produces 4 items [A,A], [A,B], [B,A], [B,B]
With the fix: produces 2 items [A, B] (as expected)

Test plan

  • Added unit test TestMerge_IdenticalOneOfGroups to verify the fix
  • All existing flatten/allof tests pass
  • make test passes

Closes #710

🤖 Generated with Claude Code

@codecov-commenter
Copy link

codecov-commenter commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.47%. Comparing base (097780e) to head (880a450).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #787      +/-   ##
==========================================
+ Coverage   89.45%   89.47%   +0.02%     
==========================================
  Files         249      249              
  Lines       12409    12435      +26     
==========================================
+ Hits        11100    11126      +26     
  Misses        862      862              
  Partials      447      447              
Flag Coverage Δ
unittests 89.47% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@reuvenharrison reuvenharrison force-pushed the fix-710-oneof-deduplication branch 3 times, most recently from 766b680 to 447f0b9 Compare February 3, 2026 20:36
#710)

When multiple allOf subschemas reference the same oneOf/anyOf definition,
the flatten operation was creating a cartesian product of all groups,
even when they were identical. This resulted in duplicated oneOf items.

For example, two allOf subschemas both with oneOf: [A, B] would produce
4 items [A,A], [A,B], [B,A], [B,B] instead of the expected 2 items [A, B].

This fix deduplicates equivalent oneOf/anyOf groups before calculating
the cartesian product, ensuring identical groups are merged correctly.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@reuvenharrison reuvenharrison force-pushed the fix-710-oneof-deduplication branch from 447f0b9 to 880a450 Compare February 3, 2026 20:37
@reuvenharrison reuvenharrison merged commit c8cb0b1 into main Feb 3, 2026
14 checks passed
@reuvenharrison reuvenharrison deleted the fix-710-oneof-deduplication branch February 3, 2026 20:40
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

Successfully merging this pull request may close these issues.

Inconsistent flattening behavior for oneOf schemas in allOf structures

2 participants