Fix maxItems detection for array parameters (issue #760)#781
Merged
reuvenharrison merged 1 commit intomainfrom Jan 13, 2026
Merged
Fix maxItems detection for array parameters (issue #760)#781reuvenharrison merged 1 commit intomainfrom
reuvenharrison merged 1 commit intomainfrom
Conversation
Fixes #760 The checker was only looking for maxItems in the items schema (paramDiff.SchemaDiff.ItemsDiff.MaxItemsDiff) but not on the array parameter schema itself (paramDiff.SchemaDiff.MaxItemsDiff). This caused the tool to miss breaking changes when maxItems was set directly on an array parameter, which is the correct location according to the OpenAPI specification. The fix checks both locations: 1. First checks maxItems on the parameter schema itself (correct location) 2. Falls back to checking maxItems on items schema (legacy support) Changes: - Updated RequestParameterMaxItemsUpdatedCheck to check both locations - Added test case TestRequestParameterArrayMaxItemsDecreased - Added test fixtures for the new scenario 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #781 +/- ##
==========================================
+ Coverage 88.71% 88.73% +0.01%
==========================================
Files 246 246
Lines 12142 12144 +2
==========================================
+ Hits 10772 10776 +4
+ Misses 931 930 -1
+ Partials 439 438 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
Fixes #760 - The
oasdiff breakingcommand was not detecting whenmaxItemsis decreased on array query parameters because the checker was looking in the wrong location in the schema structure.Problem
When
maxItemsis set directly on an array parameter schema (the correct location per OpenAPI spec), the checker failed to detect changes. For example:When
maxItemschanged from 50 to 10,oasdiff diffwould report it, butoasdiff breakingwould not flag it as a breaking change.Root Cause
The checker was only looking for
maxItemsinparamDiff.SchemaDiff.ItemsDiff.MaxItemsDiff(on the items schema) but not inparamDiff.SchemaDiff.MaxItemsDiff(on the parameter schema itself).This worked for a legacy pattern where
maxItemswas incorrectly placed on the items schema, but failed for the correct OpenAPI specification pattern.Solution
Updated
RequestParameterMaxItemsUpdatedCheckto check both locations:maxItemson the parameter schema itself (correct per spec)maxItemson the items schema (for backward compatibility)Changes
TestRequestParameterArrayMaxItemsDecreasedTesting
TestRequestParameterArrayMaxItemsDecreasedpassesTest plan
go test github.com/oasdiff/oasdiff/checker -run ".*MaxItems" -vgo test github.com/oasdiff/oasdiff/checker🤖 Generated with Claude Code