Problem
When the diff layer detects higher-level patterns like ListOfTypesDiff (and the proposed OneOfWrappingDiff from #702), the raw lower-level diffs (TypeDiff, OneOfDiff, PropertiesDiff, etc.) are still populated even though they're misleading. Every checker must then call suppression functions like shouldSuppressTypeChangedForListOfTypes() to avoid double-reporting.
This is fragile — any new checker that forgets the suppression check will produce false positives.
Proposed solution
After detecting a higher-level pattern in getSchemaDiffInternal, null out the redundant lower-level diffs at the diff layer itself:
// After computing all diffs:
result.ListOfTypesDiff = getListOfTypesDiff(value1, value2)
if !result.ListOfTypesDiff.Empty() {
result.TypeDiff = nil
result.OneOfDiff = nil
result.AnyOfDiff = nil
}
result.OneOfWrappingDiff = getOneOfWrappingDiff(value1, value2)
if !result.OneOfWrappingDiff.Empty() {
result.TypeDiff = nil
result.PropertiesDiff = nil
result.RequiredDiff = nil
result.OneOfDiff = nil
}
Benefits
- The diff output accurately represents what changed (the pattern, not misleading raw deltas)
- Checkers don't need any suppression logic — the redundant diffs simply aren't there
- New checkers can't accidentally report suppressed changes
- The higher-level diff carries all the information needed
Tradeoff
Raw diffs are lost for consumers who want them, but arguably those raw diffs are wrong in these cases (e.g., TypeDiff: object → empty is misleading when it's really a oneOf wrapping).
Related: #702
Problem
When the diff layer detects higher-level patterns like
ListOfTypesDiff(and the proposedOneOfWrappingDifffrom #702), the raw lower-level diffs (TypeDiff,OneOfDiff,PropertiesDiff, etc.) are still populated even though they're misleading. Every checker must then call suppression functions likeshouldSuppressTypeChangedForListOfTypes()to avoid double-reporting.This is fragile — any new checker that forgets the suppression check will produce false positives.
Proposed solution
After detecting a higher-level pattern in
getSchemaDiffInternal, null out the redundant lower-level diffs at the diff layer itself:Benefits
Tradeoff
Raw diffs are lost for consumers who want them, but arguably those raw diffs are wrong in these cases (e.g.,
TypeDiff: object → emptyis misleading when it's really a oneOf wrapping).Related: #702