Skip to content

feat(json-schema-document): render definitions like $defs - #11120

Draft
robert-hebel-sb wants to merge 1 commit into
feat/json-schema-2020-12-detectionfrom
feat/json-schema-2020-12-definitions
Draft

robert-hebel-sb wants to merge 1 commit into
feat/json-schema-2020-12-detectionfrom
feat/json-schema-2020-12-definitions

Conversation

@robert-hebel-sb

@robert-hebel-sb robert-hebel-sb commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

A standalone 2020-12 document now renders definitions like $defs, right after it, instead of hiding it as an extension keyword. The overrides live in the json-schema-document renderer instance only; the shared json-schema-2020-12 renderer and OpenAPI 3.1/3.2 rendering are unchanged.

Part 1 of 5 of a stack on top of #11117 (standalone JSON Schema 2020-12). The whole stack is blocked until the swagger-client release it needs is published.

Motivation and Context

The 2020-12 default meta-schema keeps definitions from earlier drafts, and implementations SHOULD assume it behaves like $defs (validation specification, Appendix A).

How Has This Been Tested?

  • Unit tests (npm run test:unit -- test/unit/core/plugins/json-schema-document) and ESLint on the plugin and its tests passed locally on this branch, while the local swagger-client tarballs were still in place.
  • A Playwright spec for the feature is included; it was not run.
  • Not re-run against the released swagger-client; CI is expected to fail until the release this stack depends on is published.

Screenshots (if appropriate):

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

The JSON Schema 2020-12 default meta-schema keeps "definitions" from
earlier drafts, and implementations SHOULD assume that it behaves like
"$defs" when that meta-schema is used (validation specification,
Appendix A). A standalone 2020-12 document now renders it like $defs,
right after it, instead of hiding it as an extension keyword.

JSONSchemaDocument's renderer instance takes the dialect's overrides
(overrides.ts): definitions in its keyword list, an isExpandable that
counts it (a copy of the json-schema-2020-12 one, kept in step by a unit
test), and Keyword$defs followed by a Definitions component (a copy of
$defs). The shared json-schema-2020-12 renderer is untouched, and
OpenAPI 3.1/3.2 rendering is unchanged: in an OpenAPI 3.1 Schema Object,
definitions stays an extension keyword.

A $ref into definitions is resolved; a $ref inside it stays as written,
because swagger-client's json-schema-2020-12-apidom strategy doesn't
dereference there (ApiDOM's 2020-12 namespace drops the keyword).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robert-hebel-sb
robert-hebel-sb force-pushed the feat/json-schema-2020-12-definitions branch from c7edc89 to 3ec9244 Compare October 28, 2026 12:38
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.

2 participants