WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
9.99k stars 4.01k forks source link

Update JSON schemas to use draft-07 #62462

Open ajlende opened 3 weeks ago

ajlende commented 3 weeks ago

We've been following the SchemaStore best practices for the development of our JSON schemas. They recommend a schema version based on what is widely supported in editors and IDEs. Previously this was draft-04, so all of our schemas currently use that version. However the new recommendation is draft-07 which comes with some quality of life improvements that can improve the readability and maintainability of our JSON schemas. Namely:

  1. The $comment keyword to explain reasoning behind schema decisions inline.
  2. The propertyNames keyword to improve merging of two or more object subschemas while limiting additionalProperties.

Additionally, SchemaStore has an unofficial "strict mode" draft-07 meta schema https://json.schemastore.org/metaschema-draft-07-unofficial-strict.json that requires type, title, and description properties which we should be using and provides links to understanding-json-schema for each hint/check to help new JSON Schema contributors.

DivyanshVinayak23 commented 3 weeks ago

Hi, can I work on this?

ajlende commented 3 weeks ago

Hi, can I work on this?

@DivyanshVinayak23 Absolutely!

Check out the contributing guidelines, specifically the developer section, for general information on how to contribute code.

The #core-editor channel on Make WordPress Slack (registration required) is also a good place to ask questions if you have any.

scruffian commented 1 week ago

I noticed we use the ajv-draft-04 npm package, and I can't find an alternative for draft-07...

ajlende commented 1 week ago

I noticed we use the ajv-draft-04 npm package, and I can't find an alternative for draft-07...

The draft-07 validator is in the main ajv package. Because there were breaking changes, they made the draft-04 validator its own package.