Skip to content

fix(Annotations): model the JSON Schema keywords 3.1 added - #2195

Merged
DerManoMann merged 1 commit into
zircote:masterfrom
DerManoMann:fix/classic-schema-keywords
Sep 13, 2026
Merged

fix(Annotations): model the JSON Schema keywords 3.1 added#2195
DerManoMann merged 1 commit into
zircote:masterfrom
DerManoMann:fix/classic-schema-keywords

Conversation

@DerManoMann

Copy link
Copy Markdown
Collaborator

Overview

Classic adopted the 3.1 JSON Schema keywords partway — contains without minContains/maxContains, unevaluatedProperties without unevaluatedItems, no conditionals, no tuples, no dependent keywords — and it leaks contentMediaType/contentEncoding into 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, the unevaluated* keywords and if/then/else warn and drop; the rest drop silently — including the two previously-leaking content keywords.

Changes

  • JsonSchemaTrait gains if, then, else, prefixItems, unevaluatedItems, minContains, maxContains, dependentRequired, dependentSchemas and contentSchema, mirrored in the constructor template and all six schema attribute constructors
  • Spec\Schema gains contentSchema (the one keyword missing from both pipelines), emitted by the 3.1 compiler
  • HybridBridge::convertSchema() maps the new keywords; a convertSchemaValue() helper tolerates the array-form schema values classic carries (convertSchemaOrBool() raised a TypeError on them before)
  • AbstractAnnotation::__construct() nests single annotation values, not just array elements — an if: schema was collected as a root and collided with the class-named component
  • The items-required warning (classic validate() and the 3.1 compiler) exempts schemas describing their items via prefixItems or contains; 3.0 still warns, since those keywords drop there
  • Scratch/SchemaKeywords{,-spec} pins one component schema per keyword family in all three modes, including a nested Schema\Ref resolving inside contentSchema

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
DerManoMann force-pushed the fix/classic-schema-keywords branch from 7769ee2 to ecbe5af Compare September 13, 2026 22:55
@DerManoMann
DerManoMann merged commit 839d6b6 into zircote:master Sep 13, 2026
18 checks passed
@DerManoMann
DerManoMann deleted the fix/classic-schema-keywords branch September 13, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant