Skip to content

Jsonschemaupdate from draft-04 to draft-07#891

Open
weblorin wants to merge 3 commits intomasterfrom
jsonschemaupdate
Open

Jsonschemaupdate from draft-04 to draft-07#891
weblorin wants to merge 3 commits intomasterfrom
jsonschemaupdate

Conversation

@weblorin
Copy link
Copy Markdown
Contributor

I noticed that draft-04 of the json schema specification isn't even listed on https://json-schema.org/specification/release-notes. I tried upgrading to latest version but the built-in VSCode validator wasn't fully compatible (it works but throws a warning which is annoying) . So upgrading to draft-07 is compromise. The following notes written with help of chatgpt4.1. - LSG

Subject: Specific Analysis of Migrating vector.schema.json from draft-04 to draft-07

Current Schema Features:

  • The schema defines two main properties: legend (an array of string pairs) and layerStyles (an array of objects with required fields).
  • The only syntax adjustment required is in the legend property:
    • In draft-04, tuple validation used "items": [{...}, {...}].
    • In draft-07, this is replaced by "prefixItems": [{...}, {...}] with "minItems": 2, "maxItems": 2 for strict length enforcement.

Are We Using New Features?

  • No new draft-07 features (like if/then/else, const, or new formats) are used in this schema.
  • The schema remains simple and compatible with both drafts, except for the tuple validation syntax.

Benefits of Changing from items to prefixItems with minItems and maxItems:

  • Clarity: The intent is clearer—each array in legend must have exactly two strings.
  • Spec Compliance: prefixItems is the recommended way to specify tuple validation in draft-07 and later, making the schema future-proof.
  • Validation Strictness: Using minItems and maxItems ensures arrays are exactly the expected length, reducing the risk of malformed data.

Impact on Existing JSON Files:

  • No impact. Existing files that were valid under draft-04 remain valid under draft-07, as the structure and requirements are unchanged.

Summary of Syntax Adjustments:

  • Update $schema to draft-07.
  • Replace array form of items with prefixItems and add minItems/maxItems for tuple validation in legend.
  • No changes needed for layerStyles.

@weblorin weblorin requested a review from MattReimer August 20, 2025 16:28
@MattReimer MattReimer force-pushed the master branch 2 times, most recently from 930f69c to 7ba48e1 Compare October 28, 2025 22:08
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