Problem/Motivation

The SDC meta schema at https://git.drupalcode.org/project/drupal/-/blob/main/core/assets/schema... uses JSON schema draft-04. Draft-04 is extremely old so much so that on https://json-schema.org/specification, it's not even listed anymore. Draft-05 was published on October 13th, 2016 meaning draft-04 is possibly a decade old or older.

In order to build tooling around the frontend developer needs at my work, we would like to create component test data files and validate them against an SDC component schema. The de facto standard library for such validation tasks in JavaScript is ajv (https://ajv.js.org/) which supports JSON schema draft-04 up until its major version 6 whereas the current major version is 8.

Steps to reproduce

Look at $schema or $ref fields in https://git.drupalcode.org/project/drupal/-/blob/main/core/assets/schema.... They'll refer to http://json-schema.org/draft-04/schema#.

Proposed resolution

I'd like to request the SDC meta schema to be updated to use the most up-to-date JSON schema version that's feasible for the Drupal project, ideally version 2020-12 (the latest).

Remaining tasks

I don't know.

User interface changes

None.

Introduced terminology

None.

API changes

I don't know.

Data model changes

I don't know.

Release notes snippet

I don't know.

Notes

As an aside, some documentation like https://www.drupal.org/docs/develop/theming-drupal/using-single-director... refers to $schema https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/schemas... which I intermittently had trouble accessing: I was seeing a GitLab Terms of Service dialog that I had to (re-)confirm and was then redirected to an empty landing page of the hosted GitLab instance of Drupal. This is no longer happening as I finish typing it but I thought it's worth pointing out.

Comments

philipprudloff created an issue. See original summary.

philipprudloff’s picture

Issue summary: View changes
philipprudloff’s picture

On further inspection, it would seem that the SDC meta schema uses JSON schema features not available in draft-04:

I think this means the SDC meta schema isn't a valid draft-04 JSON schema.

Luckily, from what I can tell, the schema can reference JSON schema version 2020-12 in its JSON schema $refs without making any other changes and it should become valid.

d34dman’s picture

Looks like the reason why it was on draft-04 was lack of support for the same in justinrainbow/json-schema. I believe the discussion in #3352063: Allow schema references in Single Directory Component prop schemas is related but not duplicate. So linking that as well.

We also have https://git.drupalcode.org/project/canvas/-/work_items/3591028 which has landed in the "Canvas" project.