Skip to content

Unify Handling of allOf/anyOf and oneOf in Diff logic #772

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

Open
DrSatyr opened this issue Apr 22, 2025 · 0 comments
Open

Unify Handling of allOf/anyOf and oneOf in Diff logic #772

DrSatyr opened this issue Apr 22, 2025 · 0 comments
Milestone

Comments

@DrSatyr
Copy link
Collaborator

DrSatyr commented Apr 22, 2025

Current Behavior:

The diffing mechanism currently handles allOf/anyOf and oneOf differently within composed schemas:

  1. allOf/anyOf: These schemas are recursively resolved and their properties are merged into the parent schema before the main diffing occurs. This happens in SchemaDiff#resolveComposedSchema, where properties from allOf/anyOf subschemas are added to the parent using SchemaDiff#addSchema. The original allOf/anyOf structure is effectively flattened.

  2. oneOf: These schemas are not merged beforehand. Instead, the ComposedSchemaDiffResult#diff method performs a structural comparison of the oneOf lists between the old and new schemas. It identifies added, removed, or changed oneOf options, storing the results in a ChangedOneOfSchema object which is then attached to the ChangedSchema.

Suggested Behavior:

This difference in processing leads to an inconsistency. While the merging for allOf/anyOf simplifies property comparison later, it loses the structural information about changes within the allOf/anyOf lists. Conversely, oneOf retains this structural information because it's crucial for understanding changes in available options.

Consider unifying the approach. Perhaps allOf/anyOf could also be compared structurally, similar to oneOf, to provide a more consistent and potentially more informative diff result regarding the composition itself, rather than just the flattened outcome. This would allow tracking additions, removals, or modifications within allOf/anyOf lists directly.

This was referenced Apr 22, 2025
@DrSatyr DrSatyr added this to the 2.2.0 milestone Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant