Support prefixItems for OpenAPI 3.1 schemas (parse + positional tuple validation + PrefixItemsIn30 rule) - #202
Open
takayamaki wants to merge 4 commits into
Open
Support prefixItems for OpenAPI 3.1 schemas (parse + positional tuple validation + PrefixItemsIn30 rule)#202takayamaki wants to merge 4 commits into
takayamaki wants to merge 4 commits into
Conversation
…y PR13) - Schema gains a `prefixItems` list-of-Schema accessor - Rules::PrefixItemsIn30 flags the keyword on 3.0 documents - ArrayValidator now positional-dispatches: leading elements match the prefixItems schemas, the rest fall back to schema.items
`prefixItems` on a 3.0 document warns and raises (JSON Schema 2020-12 tuple keyword with no 3.0 equivalent); the same keyword on a 3.1 document stays clean.
takayamaki
marked this pull request as ready for review
August 19, 2026 17:52
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.
Continuing the OpenAPI 3.1 work from #152.
OpenAPI 3.1 adopts the JSON Schema 2020-12
prefixItemskeyword,which validates the leading elements of an array positionally (tuple typing).
3.0 has no equivalent — it only has
items, which applies uniformly to every element.This PR adds parse support, runtime validation, and version-mismatch detection.
Parse layer
prefixItemsis parsed as a list ofSchemaobjects and exposed as an accessor:The Ruby accessor is snake_case with
schema_key: :prefixItems,matching how
all_of/any_of/additional_propertiesare already declared.Following the permissive-parse strategy agreed in #152,
the parse layer accepts
prefixItemsregardless of the declared OpenAPI version.Runtime validation
ArrayValidatordispatches per position:element i is validated against
prefixItems[i]when one exists,and falls back to
itemsotherwise.This is how JSON Schema 2020-12 layers the two keywords.
A schema with
prefixItemsbut noitemsleaves the trailing elements unvalidated,which matches JSON Schema's default of an absent
itemsbeing unconstrained.SpecValidator rule
PrefixItemsIn30reports a violation for each schema in a 3.0 document that usesprefixItems: