migrating-json-schemas

Solid

Migrates JSON Schemas between draft versions for use with z-schema. Use when the user wants to upgrade schemas from draft-04 to draft-2020-12, convert between draft formats, update deprecated keywords, replace id with $id, convert definitions to $defs, migrate items to prefixItems, replace dependencies with dependentRequired or dependentSchemas, adopt unevaluatedProperties or unevaluatedItems, or adapt schemas to newer JSON Schema features.

Data & Documents 345 stars 91 forks Updated 4 days ago NOASSERTION

Install

View on GitHub

Quality Score: 79/100

Stars 20%
85
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Migrating JSON Schemas Between Drafts z-schema supports draft-04, draft-06, draft-07, draft-2019-09, and draft-2020-12. This skill covers migrating schemas between drafts and verifying them with z-schema. ## Migration workflow 1. Identify the source draft (check `$schema` or `id`/`$id` usage). 2. Set the target version on the validator: ```typescript import ZSchema from 'z-schema'; const validator = ZSchema.create({ version: 'draft2020-12' }); ``` 3. Run `validator.validateSchema(schema)` to surface incompatibilities. 4. Fix each reported error using the keyword mapping below. 5. Re-validate until the schema passes. ## Quick reference: keyword changes | Old keyword (draft-04) | New keyword (draft-2020-12) | Introduced in | | ------------------------------------ | ------------------------------------ | ------------- | | `id` | `$id` | draft-06 | | `definitions` | `$defs` | draft-2019-09 | | Array-form `items` (tuple) | `prefixItems` | draft-2020-12 | | `additionalItems` | `items` (when `prefixItems` present) | draft-2020-12 | | `exclusiveMinimum: true` (boolean) | `exclusiveMinimum: <number>` | draft-06 | | `exclusiveMaximum: true` (boolean) | `exclusiveMaximum: <number>` | draft-06 | | `dependencies` (string arrays) | `dependentRe...

Details

Author
zaggino
Repository
zaggino/z-schema
Created
12 years ago
Last Updated
4 days ago
Language
TypeScript
License
NOASSERTION

Similar Skills

Semantically similar based on skill content — not just same category