Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some thoughts #6

Open
Sweetchuck opened this issue Jun 14, 2023 · 3 comments
Open

Some thoughts #6

Sweetchuck opened this issue Jun 14, 2023 · 3 comments

Comments

@Sweetchuck
Copy link

Sweetchuck commented Jun 14, 2023

Hello

Good to see that there is a central repository for this purpose 馃憤

I wrote some schema definition for myself, and I have been using it for quite a while, but I have never published them.

  • 8.extension.info.schema.yml
  • 9.extension.info.schema.yml
  • 9.extension.libraries.schema.yml
  • 9.extension.links.action.schema.yml
  • 9.extension.links.task.schema.yml

I had a plan to publish them on schemastore.org, but the workflow was difficult.

Version numbers

Time to time these schema definitions are changing, mostly with major, or minor releases.
In ideal world these kind of schema definition would be shipped by Drupal core and contrib modules. Maybe even dynamically generated.
For example the used/available keys in *.info.yml are depend on the actual codebase or enabled modules. When the locale module is enabled the interface translation project and interface translation server pattern are also a valid keys.
Not just those listed here

The point is that, a simple ./schema/drupal/info.yml.json is not enough, because the available or required keys in *.info.yml are different for Drupal 8, 9 and 10.
For example the core_version_requirement was not exists in Drupal 8, but it is required in Drupal 10.

Solution could be one of the following:

  1. add prefix to the file names ./schema/drupal/10-info.yml.json
  2. add suffix to the file names ./schema/drupal/info.yml-10.json
  3. add suffix to the directory name (assuming that it is the project name the schema belong s to) ./schema/drupal-10/info.yml.json
  4. add sub-directories ./schema/drupal/10/info.yml.json

required core_version_requirement

In my local schema definitions the core_version_requirement is also required like here

The problem is that when I configure my editor (PHPStorm) to use that schema for every *.info.yml in the project, then when I open an info.yml form the core (e.g.: node.info.yml) then I get this error message:

Schema validation: Missing required property 'core_version_requirement'

Not a big deal, at least it is not the fault of the schema definition. It is still useful everywhere else, except core.

File names end with .schema.json

When the file names are end with .schema.json then it is easier to attach the http://json-schema.org/draft-07/schema validation to the files and get more help from the IDE.

JSON vs YAML

I don't know too much about tooling ecosystem around the JSONSchema definitions, maybe some tooling does not support the YAML format, but I would prefer to maintain these definitions in YAML.

@Chi-teck
Copy link
Collaborator

The relevant core issue
https://www.drupal.org/project/drupal/issues/2998777

@Sweetchuck
Copy link
Author

I saw that core issue, but not too much progress there.

@Chi-teck
Copy link
Collaborator

The point is that any updates in this repository will not take affect anymore. We have to update schemas directly on schemastore.

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

No branches or pull requests

2 participants