Compare prefixItems by index - #1192
Open
reuvenharrison wants to merge 1 commit into
Open
Conversation
Fixes #1180. prefixItems is positional: the schema at index i validates the array element at index i. The diff compared it with getSubschemasDiff, which is built for allOf, anyOf and oneOf, where order carries no meaning, so it paired entries by $ref name, content and title. Under that matching, swapping two entries paired each with its identical twin on the other side and reported no change, when every position it touches now validates against a different schema. Inserting an entry at the front reported one addition while every later position changed type. getPrefixItemsDiff pairs entry i on each side and diffs the pair, so a type change at a position is reported as a type change at that position; an entry past the end of the shorter list is an addition or a deletion at its index. The output type is unchanged, so the diff JSON keeps its shape, and the subschema walker already descends into the modified entries, so the property-level checks inherit per-position reporting with no checker change: reorder [string, integer] -> [integer, string] error [request-property-type-changed] the `/prefixItems[subschema #1]/` request property `type` changed from `string` to `integer` error [request-property-type-changed] the `/prefixItems[subschema #2]/` request property `type` changed from `integer` to `string` getSubschemasDiff is untouched: it is correct for the unordered constructs it was built for. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QDvUFsg5nu1NBWQffErGDw
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1192 +/- ##
==========================================
- Coverage 88.60% 88.60% -0.01%
==========================================
Files 337 338 +1
Lines 15767 15781 +14
==========================================
+ Hits 13970 13982 +12
- Misses 1230 1231 +1
- Partials 567 568 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 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.
Fixes #1180.
prefixItemsis positional: the schema at index i validates the array element at index i. The diff compared it withgetSubschemasDiff, which is built forallOf,anyOfandoneOf, where order carries no meaning, so it paired entries by$refname, content and title. Under that matching, swapping two entries paired each with its identical twin on the other side and reported no change, when every position it touches now validates against a different schema. Inserting an entry at the front reported one addition while every later position changed type.getPrefixItemsDiffpairs entry i on each side and diffs the pair; an entry past the end of the shorter list is an addition or a deletion at its index. The output type is unchanged, so the diff JSON keeps its shape, and the subschema walker already descends into modifiedprefixItemsentries, so the property-level checks inherit per-position reporting with no checker change.The three cases from the issue, after:
getSubschemasDiffis untouched: it is correct for the unordered constructs it was built for.The full suite passes with no other change, which says nothing had pinned the unordered behaviour;
TestGetPrefixItemsDiff_PositionalandTestRequestBodyPrefixItemsReorderedpin the positional one.