fix(Annotations): model the JSON Schema keywords 3.1 added - #2195
Merged
DerManoMann merged 1 commit intoSep 13, 2026
Conversation
DerManoMann
added a commit
to DerManoMann/swagger-php
that referenced
this pull request
Sep 12, 2026
Classic adopted the 3.1 Schema keywords partway - contains without minContains, unevaluatedProperties without unevaluatedItems - and leaked contentMediaType/contentEncoding into 3.0 documents where they do not exist. The ten missing keywords land in JsonSchemaTrait, its constructor template and all six schema attribute constructors, with contentSchema added to the spec pipeline too. 3.0 handling mirrors the spec compilers: prefixItems, the unevaluated keywords and if/then/else warn, the rest drop silently. Three fixes forced along the way: the classic constructor now nests single annotation values, not just array elements, so an if: schema no longer collides with the class-named component; the bridge tolerates the array-form schema values classic carries; and the items-required warning exempts 3.1 schemas describing their items via prefixItems or contains.
DerManoMann
force-pushed
the
fix/classic-schema-keywords
branch
from
September 13, 2026 22:55
7769ee2 to
ecbe5af
Compare
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.
Overview
Classic adopted the 3.1 JSON Schema keywords partway —
containswithoutminContains/maxContains,unevaluatedPropertieswithoutunevaluatedItems, no conditionals, no tuples, no dependent keywords — and it leakscontentMediaType/contentEncodinginto 3.0 documents, where they don't exist. Fifth fix under the classic spec-compliance carve-out (#2190), and the largest.3.0 handling now mirrors the spec compilers exactly:
prefixItems, theunevaluated*keywords andif/then/elsewarn and drop; the rest drop silently — including the two previously-leaking content keywords.Changes
JsonSchemaTraitgainsif,then,else,prefixItems,unevaluatedItems,minContains,maxContains,dependentRequired,dependentSchemasandcontentSchema, mirrored in the constructor template and all six schema attribute constructorsSpec\SchemagainscontentSchema(the one keyword missing from both pipelines), emitted by the 3.1 compilerHybridBridge::convertSchema()maps the new keywords; aconvertSchemaValue()helper tolerates the array-form schema values classic carries (convertSchemaOrBool()raised aTypeErroron them before)AbstractAnnotation::__construct()nests single annotation values, not just array elements — anif:schema was collected as a root and collided with the class-named componentvalidate()and the 3.1 compiler) exempts schemas describing their items viaprefixItemsorcontains; 3.0 still warns, since those keywords drop thereScratch/SchemaKeywords{,-spec}pins one component schema per keyword family in all three modes, including a nestedSchema\Refresolving insidecontentSchema