Repository navigation
feat(json-schema-document): render standalone JSON Schema 2020-12 - #11117
Draft
robert-hebel-sb wants to merge 5 commits into
Draft
robert-hebel-sb wants to merge 5 commits into
robert-hebel-sb wants to merge 5 commits into
Conversation
robert-hebel-sb
force-pushed
the
feat/json-schema-2020-12-detection
branch
from
October 27, 2026 17:28
32e966e to
9642c21
Compare
This was referenced Oct 28, 2026
requestResolvedSubtree([]) resolved the whole document and then dropped the result: lodash's set() and fp assocPath() ignore an empty path, so the batch wrote back only what earlier requests had stored. An empty path now replaces the batch's result with the resolved document (when it is an object), which is what a standalone JSON Schema document needs to be resolved at its root. Nothing requests an empty path today, so OpenAPI and Swagger documents resolve exactly as before; non-empty paths keep their behaviour, which the new unit test pins next to the empty-path cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SwaggerUI({ url }) now renders a standalone JSON Schema 2020-12 document
instead of "Unable to render this definition". A document is one when
its root $schema is https://json-schema.org/draft/2020-12/schema (an
empty fragment is normalised) and it has none of the fields openapi,
swagger, asyncapi and arazzo.
The new json-schema-document plugin, loaded after OpenAPI32Plugin in the
apis preset and exported as SwaggerUI.plugins.JSONSchemaDocument:
- spec selectors isJSONSchemaDocument() and jsonSchemaDialect();
- the JSONSchemaDocument component renders the root schema, resolved by
swagger-client, through a json-schema-2020-12 renderer instance
configured for the dialect (default$schema, defaultModelExpandDepth,
the 2020-12 keywords plus swagger-client's $$ref) and none of the
OpenAPI fn overrides, so OpenAPI keywords keep no meaning and
descriptions stay plain text;
- a VersionPragmaFilter wrapper renders it, refuses a root $schema
naming any other dialect with a message that names the value and the
supported identifiers, and renders the OpenAPI filter otherwise;
- a requestResolvedSubtree wrap-action resolves a JSON Schema document
at its root, whatever path is requested.
The swagger-client plugin lists the json-schema-2020-12-apidom strategy
in resolve and resolveSubtree, ahead of the generic strategy, so
internal, $anchor, $id-relative and external $refs are resolved and
every $dynamicRef stays as written.
OpenAPI 2.0, 3.0, 3.1 and 3.2 documents, including ones with $schema at
the root or in Schema Objects, render as before: ARIA snapshots recorded
on main pin them, together with AsyncAPI 3.0, Arazzo 1.0.1 and
nested-only $schema documents.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Core §8.1.1 allows $schema only in the root of an embedded schema resource, so the nested-only fixture and unit case now carry an $id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Embedded resources and external files declaring another dialect render with the 2020-12 meaning (PRD D3). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
robert-hebel-sb
force-pushed
the
feat/json-schema-2020-12-detection
branch
from
October 28, 2026 12:38
9642c21 to
dbf3063
Compare
robert-hebel-sb
marked this pull request as draft
October 28, 2026 12:40
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.
Description
Swagger UI renders standalone JSON Schema 2020-12 documents in
SwaggerUI({ url }). A document is one when its root$schemaishttps://json-schema.org/draft/2020-12/schema(an empty fragment#is normalised) and its root has none ofopenapi,swagger,asyncapi,arazzo. A root$schemanaming any other dialect (a custom meta-schema, an OpenAPI dialect,http://json-schema.org/draft/2020-12/schema, a draft not supported yet) is refused with "Unable to render this definition", naming the value and the supported identifiers.json-schema-documentplugin, afterOpenAPI32Pluginin theapispreset, exported asSwaggerUI.plugins.JSONSchemaDocument. It adds:isJSONSchemaDocument()andjsonSchemaDialect();JSONSchemaDocument, which renders the resolved root schema with the json-schema-2020-12 renderer configured for the dialect and without the OpenAPIfnoverrides, so OpenAPI keywords have no meaning and descriptions stay plain text;VersionPragmaFilterwrapper (document, refusal, or the OpenAPI filter unchanged);requestResolvedSubtreewrap-action that resolves a JSON Schema document at its root.swagger-client'sjson-schema-2020-12-apidomstrategy is in both strategy lists (resolve,resolveSubtree), ahead ofgeneric. Internal,$anchor,$id-relative and external$refs resolve, and every$dynamicRefstays as written.fix(spec):requestResolvedSubtree([])stored nothing, because lodashsetignores an empty path. Nothing requested[]before, so OpenAPI resolution is unchanged.Draft until the swagger-client release (swagger-api/swagger-client#4306). The branch no longer installs unreleased tarballs, so it needs a
swagger-clientrelease that includes thejson-schema-2020-12-apidomstrategy changes; until then CI is expected to fail. Before merging: bumpswagger-clientto the release and run every check again.Motivation and Context
Step U1 of "Standalone JSON Schema 2020-12". Today a JSON Schema document gets "Unable to render this definition". SwaggerEditor's preview needs swagger-ui-react to render it natively under the key
JSONSchemaDocument.How Has This Been Tested?
$schemain an embedded resource.$refresolution, refusal, and an OAS 2.0/3.0/3.1/3.2 regression against ARIA snapshots recorded on main. The same regression spec checks that nested-only$schemadocuments and AsyncAPI 3.0 / Arazzo 1.0.1 documents with a root$schemarender as before.lint-errors,type-check,test:unit, fulle2e,e2e:typecheck,build,test:artifact.Checklist
My PR contains...
requestResolvedSubtree([]))My changes...
Documentation
Automated tests
🤖 Generated with Claude Code