Preserve all discriminator aliases when comparing oneOf schemas - #929
Open
MoChiUaena wants to merge 1 commit into
Open
MoChiUaena wants to merge 1 commit into
MoChiUaena wants to merge 1 commit into
Conversation
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.
When multiple discriminator values point to the same schema, reordering the mapping can incorrectly report a breaking change. The reverse mapping in
ComposedSchemaDiffResultkept only the last alias for each reference, which also hid additions, removals, and target changes involving a discarded alias.Keep the explicit alias-to-reference mapping intact and add implicit schema names for references without an explicit mapping. When scheduling aliases, check recursion against the references visited before entering this
oneOf, while retaining the shared visited set for deferred traversal. This lets aliases reuse cached comparisons and compare changed targets regardless of mapping order, without introducing circular dependencies between mutually recursive schemas. The existing request/response compatibility rules remain in place.Fixes #886.
Validation on Windows with the Maven wrapper (3.8.5):
OneOfDiffTestcases pass with the final fix../mvnw.cmd -B -ntp -pl core com.coveo:fmt-maven-plugin:format -Dtest=OneOfDiffTest test./mvnw.cmd -V -B -ntp -ff clean verify— all modules passed on JDK 8 (Corretto 8u504), 11 and 21; core: 288 tests, 2 existing disabled tests; Maven plugin: 13 tests; no failures or errors../mvnw.cmd -V -B -ntp -ff -Dmaven.compiler.release=8 clean verify— all modules passed on JDK 17, compiling against the Java 8 API../mvnw.cmd -B -ntp com.coveo:fmt-maven-plugin:check— all modules passed.The upstream Linux CI run is still pending.
Summary by cubic
Fixes false breaking changes when multiple discriminator aliases point to the same schema and their mapping order changes.
oneOfwhile keeping the shared visited set for deferred traversal.Written for commit 23699ce. Summary will update on new commits.