-
-
Notifications
You must be signed in to change notification settings - Fork 282
Added migration page overview #1061
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
kwennB
wants to merge
76
commits into
json-schema-org:main
Choose a base branch
from
kwennB:migrationPage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
859a6f1
Added migration page overview
kwennB 93bcaba
Update pages/specification/migration/_index.md
kwennB d4c8b24
Update pages/specification/migration/_index.md
kwennB 8eb9721
Updated migration overview
kwennB 75ee2a1
Update pages/specification/migration/_index.md
kwennB a967f66
Update pages/specification/migration/_index.md
kwennB b22b2ff
Update pages/specification/migration/_index.md
kwennB c5d352e
Update pages/specification/migration/_index.md
kwennB 136ee2e
Update pages/specification/migration/_index.md
kwennB fa6391b
Update pages/specification/migration/_index.md
kwennB 83536f1
Update pages/specification/migration/_index.md
kwennB dd364ba
Update pages/specification/migration/_index.md
kwennB dd1d4e7
Update pages/specification/migration/_index.md
kwennB 33b69ab
Update pages/specification/migration/_index.md
kwennB 9c583ce
Update pages/specification/migration/_index.md
kwennB 5a4b8b3
Update pages/specification/migration/_index.md
kwennB 24488f9
Update pages/specification/migration/_index.md
kwennB 4e5a08d
Update pages/specification/migration/_index.md
kwennB d17e308
Update pages/specification/migration/_index.md
kwennB c5b1f87
Update pages/specification/migration/_index.md
kwennB 95276a0
Update pages/specification/migration/_index.md
kwennB 288e5d9
Update pages/specification/migration/_index.md
kwennB 7199292
Update pages/specification/migration/_index.md
kwennB 8cc36f0
Update pages/specification/migration/_index.md
kwennB 45aecbc
Update pages/specification/migration/_index.md
kwennB 65ba898
Update pages/specification/migration/_index.md
kwennB 9891c6e
Update pages/specification/migration/_index.md
kwennB 5bdfc65
added updates to migration overview
kwennB 3ef35de
Adding migration folders and cards
benjagm a68d4f3
updated overview
kwennB 65325b8
renamed page and added metadata
benjagm 419ea36
updated links to the rights migration docs
benjagm 43f9816
Added Alterschema details and individual draft pages
kwennB bb62eaa
Added migration data to single page-Draft 3-4.
kwennB 757f1f9
Updated the Draft 3-4
kwennB 5eae100
Updated Draft 3-4
kwennB 93da171
Update pages/specification/migration/_index.md
kwennB 994f731
Update pages/draft-04/migration-notes.md
kwennB ffcf639
Update pages/draft-04/migration-notes.md
kwennB b439468
Update pages/draft-04/migration-notes.md
kwennB 85b9ceb
Update pages/draft-04/migration-notes.md
kwennB 81ebeea
Updated Draft 3-4 & Overview
kwennB d718e51
added draft 2-3
kwennB 3a5a632
Update pages/draft-04/migration-notes.md
kwennB 33e536b
Update pages/specification/migration/_index.md
kwennB 266963b
Update pages/specification/migration/_index.md
kwennB e75e0da
Update pages/specification/migration/_index.md
kwennB 78d912a
Update pages/specification/migration/_index.md
kwennB 5a46c9d
Update pages/draft-03/migration-notes.md
kwennB 91c3b63
Update pages/draft-03/migration-notes.md
kwennB ddec102
Update pages/draft-03/migration-notes.md
kwennB f0fd4c2
Updated draft 2-3
kwennB f2aa409
Added Draft 6-7
kwennB 6e7aa3e
CI/CD fix
kwennB 7badaea
Added migration guide for draft 2019-09 to 2020-12
kwennB 625b9f8
Added migration notes page
benjagm 6649ac8
Update migration-notes.md
benjagm a215d13
Fix problem with slug
benjagm 2d34ff1
Update DocsHelp.tsx
benjagm 6009e19
Update pages/draft-03/migration-notes.md
kwennB 54a0e49
Update pages/draft-07/migration-notes.md
kwennB aa0ca88
Update pages/draft/2020-12/migration-notes.md
kwennB 586e3d0
Update pages/draft-07/migration-notes.md
kwennB f568aee
Update pages/draft/2020-12/migration-notes.md
kwennB 06de9fa
Update pages/draft/2020-12/migration-notes.md
kwennB bec87f1
Update pages/draft/2020-12/migration-notes.md
kwennB 8a56fdf
Update pages/draft/2020-12/migration-notes.md
kwennB f0d7f96
Update pages/draft/2020-12/migration-notes.md
kwennB e2e3fb7
Update pages/draft/2020-12/migration-notes.md
kwennB 8800dc0
Updated migration guides based on feedback
kwennB 9bbb1c2
Update index.page.tsx
benjagm 14b40d0
Added drafts
kwennB d2395dd
Merge branch 'main' into migrationPage
kwennB f4e333b
Update DocsHelp.tsx
kwennB f057db4
resolving build
kwennB 0fea2a3
modify draft 2019-09
kwennB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import Head from 'next/head'; | ||
import StyledMarkdown from '~/components/StyledMarkdown'; | ||
import { getLayout } from '~/components/Sidebar'; | ||
import getStaticMarkdownPaths from '~/lib/getStaticMarkdownPaths'; | ||
import getStaticMarkdownProps from '~/lib/getStaticMarkdownProps'; | ||
import { Headline1 } from '~/components/Headlines'; | ||
import { SectionContext } from '~/context'; | ||
import { DocsHelp } from '~/components/DocsHelp'; | ||
|
||
export async function getStaticPaths() { | ||
return getStaticMarkdownPaths('pages/draft-02'); | ||
} | ||
export async function getStaticProps(args: any) { | ||
return getStaticMarkdownProps(args, 'pages/draft-02'); | ||
} | ||
|
||
export default function StaticMarkdownPage({ | ||
frontmatter, | ||
content, | ||
}: { | ||
frontmatter: any; | ||
content: any; | ||
}) { | ||
const fileRenderType = '_md'; | ||
const newTitle = 'JSON Schema - ' + frontmatter.title; | ||
|
||
return ( | ||
<SectionContext.Provider value={frontmatter.section || null}> | ||
<Head> | ||
<title>{newTitle}</title> | ||
</Head> | ||
<Headline1>{frontmatter.title}</Headline1> | ||
<StyledMarkdown markdown={content} /> | ||
<DocsHelp fileRenderType={fileRenderType} /> | ||
</SectionContext.Provider> | ||
); | ||
} | ||
StaticMarkdownPage.getLayout = getLayout; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
title: Draft 01 to Draft 02 | ||
section: docs | ||
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import Head from 'next/head'; | ||
import StyledMarkdown from '~/components/StyledMarkdown'; | ||
import { getLayout } from '~/components/Sidebar'; | ||
import getStaticMarkdownPaths from '~/lib/getStaticMarkdownPaths'; | ||
import getStaticMarkdownProps from '~/lib/getStaticMarkdownProps'; | ||
import { Headline1 } from '~/components/Headlines'; | ||
import { SectionContext } from '~/context'; | ||
import { DocsHelp } from '~/components/DocsHelp'; | ||
|
||
export async function getStaticPaths() { | ||
return getStaticMarkdownPaths('pages/draft-03'); | ||
} | ||
export async function getStaticProps(args: any) { | ||
return getStaticMarkdownProps(args, 'pages/draft-03'); | ||
} | ||
|
||
export default function StaticMarkdownPage({ | ||
frontmatter, | ||
content, | ||
}: { | ||
frontmatter: any; | ||
content: any; | ||
}) { | ||
const fileRenderType = '_md'; | ||
const newTitle = 'JSON Schema - ' + frontmatter.title; | ||
|
||
return ( | ||
<SectionContext.Provider value={frontmatter.section || null}> | ||
<Head> | ||
<title>{newTitle}</title> | ||
</Head> | ||
<Headline1>{frontmatter.title}</Headline1> | ||
<StyledMarkdown markdown={content} /> | ||
<DocsHelp fileRenderType={fileRenderType} /> | ||
</SectionContext.Provider> | ||
); | ||
} | ||
StaticMarkdownPage.getLayout = getLayout; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
title: Draft 02 to Draft 03 | ||
section: docs | ||
--- | ||
|
||
### Introduction | ||
|
||
The migration from Draft 2 to Draft 3 of JSON Schema introduced significant updates in schema definition and validation behaviors. Draft 3 refined existing keywords, added new ones, and adjusted validation rules to improve schema precision and consistency. This guide will assist you in updating your JSON Schemas to meet Draft 3 requirements, detailing keyword replacements, vocabulary changes, and modifications in validation behaviors. | ||
|
||
### Keyword changelog | ||
|
||
| Keyword(Draft 2) | Keyword(Draft 3) | Specification | Keyword type | Behavior Details | | ||
| ----------------- | ------------------- | ------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| not present | `$schema` | `Core` | Identifier | The `$schema` keyword specifies the URI of the JSON Schema that defines the schema of the current document. Validators use this URI to resolve links and determine the JSON Schema version, enabling appropriate validation features. Including the `$schema` keyword is recommended to ensure compatibility with future JSON Schema changes. | | ||
| not present | `$ref` | `Core` | Applicator | `$ref` key references an external schema URI for validation. | | ||
| not present | `id` | `Core` | Identifier | This keyword defines the schema's current URI (a "self" link). The URI can be relative or absolute and is resolved against the parent schema's URI. If there is no parent schema, it is resolved against the URI used to retrieve the schema. | | ||
| `optional` | `required` | `Core` | Assertion | In **draft-02**, object properties defined within the `properties` keyword were required by default, and the `optional` keyword was used to explicitly make a property optional. In **draft-03**, this behavior changed: properties defined under `properties` are now optional by default. As a result, the `optional` keyword became redundant and was replaced by the `required` keyword to reflect the new default behavior, where properties are optional unless explicitly marked as required. | | ||
| `minimumCanEqual` | `exclusiveMinimum` | `Core` | Assertion | Specifies that instance values must be strictly greater than the minimum when `exclusiveMinimum` is `true`. | | ||
| `maximumCanEqual` | `exclusiveMaximum` | `Core` | Assertion | This ensures that instance values fall below the maximum when `exclusiveMaximum` is `true`. | | ||
| `format` | `format` | `Core` | Annotation | This update refined format handling by adding and removing specific types, offering clearer guidance for expected data formats. | | ||
| not present | `patternProperties` | `Core` | Applicator | Enforces schema validation on properties with names matching specified regex patterns. Each property matching a pattern must conform to the schema defined for that pattern in `patternProperties`. | | ||
| `requires` | `dependencies` | `Core` | Assertion | Defines property dependencies - if an instance includes a property named in this attribute, that property must meet additional validation requirements defined by its dependency value. | | ||
| not present | `additionalItems` | `Core` | Applicator | Defines rules for extra items in an array - can be set to false to disallow extra items beyond specified tuples, or to a schema that additional items must follow. | | ||
| `properties` | remained `properties` | `Core` | Applicator | The `properties` takes two values, either `optional` or `required`; where `optional `, is the default value. | | ||
| `alternate` | removed | `Core` | | - | | ||
|
||
### Tutorial | ||
|
||
#### Step 1: Review Core Changes | ||
|
||
Start by understanding the key differences between Draft 2 and Draft 3, especially regarding core changes in $schema, $ref, and validation keywords. | ||
|
||
- `$schema`: Draft 3 introduces the `$schema` keyword, it handles the schema dialect and the version of the specification being used. | ||
- `$ref`: Draft 3 introduces the `$ref` keyword, which allows referencing external schemas for validation and schemas within the same schema document. This will enable more modular and reusable schema definitions. | ||
|
||
#### Step 2: Update Validation Keywords | ||
|
||
Draft 3 introduces new validation keywords that improve flexibility in schema definitions. Notable changes include: | ||
|
||
- `optional` to `required`: Draft 3 removes the `optional` keyword and introduces `required`, which specifies the required properties for an object. | ||
- `minimumCanEqual` to `exclusiveMinimum`: For numerical validation, `exclusiveMinimum` enforces that the value must be strictly greater than the given minimum value. | ||
- `maximumCanEqual` to `exclusiveMaximum`: Similarly, `exclusiveMaximum` ensures the value is strictly less than the maximum allowed value. | ||
- `patternProperties`: Draft 3 introduces `patternProperties`, which allows you to define schema rules for properties whose names match a regular expression. | ||
|
||
#### Step 3: Refactor $ref Usage | ||
|
||
Draft 3 introduces `$ref`, which allows you to reference external schemas using **URIs**. This improves schema modularity and enables better reuse of schema definitions. | ||
|
||
Validate and test your updated schemas manually, or with your preferred [tool.](https://json-schema.org/tools) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import Head from 'next/head'; | ||
import StyledMarkdown from '~/components/StyledMarkdown'; | ||
import { getLayout } from '~/components/Sidebar'; | ||
import getStaticMarkdownPaths from '~/lib/getStaticMarkdownPaths'; | ||
import getStaticMarkdownProps from '~/lib/getStaticMarkdownProps'; | ||
import { Headline1 } from '~/components/Headlines'; | ||
import { SectionContext } from '~/context'; | ||
import { DocsHelp } from '~/components/DocsHelp'; | ||
|
||
export async function getStaticPaths() { | ||
return getStaticMarkdownPaths('pages/draft-04'); | ||
} | ||
export async function getStaticProps(args: any) { | ||
return getStaticMarkdownProps(args, 'pages/draft-04'); | ||
} | ||
|
||
export default function StaticMarkdownPage({ | ||
frontmatter, | ||
content, | ||
}: { | ||
frontmatter: any; | ||
content: any; | ||
}) { | ||
const fileRenderType = '_md'; | ||
const newTitle = 'JSON Schema - ' + frontmatter.title; | ||
|
||
return ( | ||
<SectionContext.Provider value={frontmatter.section || null}> | ||
<Head> | ||
<title>{newTitle}</title> | ||
</Head> | ||
<Headline1>{frontmatter.title}</Headline1> | ||
<StyledMarkdown markdown={content} /> | ||
<DocsHelp fileRenderType={fileRenderType} /> | ||
</SectionContext.Provider> | ||
); | ||
} | ||
StaticMarkdownPage.getLayout = getLayout; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
title: Migrating from Draft 03 to Draft 04 | ||
section: docs | ||
--- | ||
|
||
### Introduction | ||
|
||
The migration from Draft 3 to Draft 4 of JSON Schema introduces changes in how schemas are defined and validated. Draft 4, published on January 31, 2013, introduced new keywords and revised the behaviours of existing ones. | ||
|
||
This guide will help you adapt your JSON Schemas to align with Draft 4 requirements, covering keyword changes, updates, and behavioural modifications. | ||
|
||
### Keyword changelog | ||
|
||
Below is a summary table highlighting keyword changes between Draft 3 and Draft 4. | ||
|
||
| Keyword (Draft 3) | Keyword (Draft 4) | Specification | Keyword type | Behavior Details | | ||
| ----------------- | ----------------- | ------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `$schema` | `$schema` | Core | Identifier | Change in the dialect (Uses the latest Draft4 dialect) | | ||
| `type` | `type` | Validation | Assertion | This change no longer accepts the `any` type, restricting instances to the seven core primitive types only. | | ||
kwennB marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `disallow` | removed | Validation | Applicator | The `disallow` keyword specifies types or schemas that an instance must not match, although removed; this functionality has been replaced by the `not` keyword. | | ||
| `required` | `required` | Validation | Assertion | The `required` keyword shifted from being a boolean within each property to a standalone keyword that takes an array of required property names outside of properties. | | ||
| `divisibleBy` | `multipleOf` | Validation | Assertion | `divisibleBy` was renamed to `multipleOf` with a stricter requirement that its value must be greater than 0. | | ||
| `extends` | removed | Validation | Applicator | The `extends` keyword was removed; allOf was added as a new keyword to achieve similar functionality. | | ||
| `format` | `format` | Validation | Annotation | The attributes `phone`, `style`, and `color` have been removed and ip-address has been renamed to `ipv4`. | | ||
| `dependencies` | `dependencies` | Core | Assertion | The `dependencies` member values were changed to require an array of strings or a schema, eliminating the use of single strings. | | ||
| `id` | `id` | Core | Identifier | - | | ||
| Not present | `allOf` | Core | Applicator | - | | ||
| Not present | `anyOf` | Core | Applicator | - | | ||
| Not present | `definitions` | Validation | Reserved Location | - | | ||
| Not present | `maxProperties` | Validation | Assertion | - | | ||
| Not present | `minProperties` | Validation | Assertion | - | | ||
| Not present | `not` | Core | Applicator | - | | ||
| Not present | `oneOf` | Core | Applicator | - | | ||
|
||
#### Helpful notes for Keyword changelog | ||
|
||
1. `type` | ||
|
||
In Draft-03, the `type` keyword could hold a simple value like "string" or "number" and an entire schema as its value. | ||
|
||
For example: | ||
|
||
```json | ||
{ | ||
"type": { | ||
"type": "array", | ||
"items": { "type": "string" } | ||
} | ||
} | ||
``` | ||
|
||
This feature was in Draft-03 but changed in later versions of JSON Schema, where `type` is limited to simpler values like strings or arrays of strings. | ||
|
||
The `allOf` keyword has now replaced the previous type schema functionality. | ||
|
||
<Infobox label="Note"> Starting with Draft 4, schema identifiers that use an empty URI "" or a fragment-only URI "#" are no longer allowed. | ||
|
||
In Draft 3, these identifiers were considered valid: | ||
|
||
```json | ||
"id": "" | ||
"id": "#" | ||
``` | ||
|
||
However, this format is now prohibited from Draft 4 onwards. | ||
</Infobox> | ||
|
||
|
||
### Tutorial | ||
|
||
This tutorial walks you through key steps and considerations to help you successfully migrate your JSON schemas from Draft 3 to Draft 4. | ||
|
||
#### Step 1: Review Core Changes | ||
|
||
Start by familiarizing yourself with the updates in the [Draft 4 Core schema specification](https://json-schema.org/draft-04/draft-zyp-json-schema-04.html). Note the revised `type`, `required`, and `dependencies` keywords, which might affect your schemas if you rely on polymorphic types or cross-schema references. | ||
|
||
#### Step 2: Update Validation Keywords | ||
|
||
Draft 4 has introduced new keywords such as `oneOf`, `not`, `anyOf`, and `allOf`. Review each of these additions, and update your schemas to use these keywords if relevant. For instance: | ||
|
||
- If you have properties that must always be present, use `required` to define these properties explicitly. | ||
- For schemas that contain nested dependencies, consider restructuring them using `dependencies` to improve schema maintainability. | ||
|
||
Validate and test your updated schemas manually, or with your preferred [tool.](https://json-schema.org/tools) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.