Skip to content

Update JSON schemas to use draft-07 #62462

Closed

Description

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.

  • There are some breaking changes from draft-04 to draft-06. You can migrate schemas from draft-04 to draft-07 using ajv-cli.
  • The pattern of *PropertiesComplete can be updated to use propertyNames instead of lists of empty objects.
  • The enum properties with single values can be updated to const where it would make sense to use const.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Good First IssueAn issue that's suitable for someone looking to contribute for the first time[Type] Code QualityIssues or PRs that relate to code quality[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions