Skip to content

Commit 8800dc0

Browse files
committed
Updated migration guides based on feedback
1 parent e2e3fb7 commit 8800dc0

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

pages/draft-03/migration-notes.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,27 @@ The migration from Draft 2 to Draft 3 of JSON Schema introduced significant upda
1111

1212
| Keyword(Draft 2) | Keyword(Draft 3) | Specification | Keyword type | Behavior Details |
1313
| ----------------- | ------------------- | ------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14-
| 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. |
15-
| not present | `$ref` | `core` | Applicator | `$ref` key references an external schema URI for validation. |
16-
| 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. |
17-
| `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. |
18-
| `minimumCanEqual` | `exclusiveMinimum` | `core` | Assertion | Specifies that instance values must be strictly greater than the minimum when `exclusiveMinimum` is `true`. |
19-
| `maximumCanEqual` | `exclusiveMaximum` | `core` | Assertion | This ensures that instance values fall below the maximum when `exclusiveMaximum` is `true`. |
20-
| `format` | `format` | `core` | Annotation | This update refined format handling by adding and removing specific types, offering clearer guidance for expected data formats. |
21-
| 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`. |
22-
| `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. |
23-
| 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. |
24-
| `alternate` | removed | `core` | | - |
14+
| 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. |
15+
| not present | `$ref` | `Core` | Applicator | `$ref` key references an external schema URI for validation. |
16+
| 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. |
17+
| `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. |
18+
| `minimumCanEqual` | `exclusiveMinimum` | `Core` | Assertion | Specifies that instance values must be strictly greater than the minimum when `exclusiveMinimum` is `true`. |
19+
| `maximumCanEqual` | `exclusiveMaximum` | `Core` | Assertion | This ensures that instance values fall below the maximum when `exclusiveMaximum` is `true`. |
20+
| `format` | `format` | `Core` | Annotation | This update refined format handling by adding and removing specific types, offering clearer guidance for expected data formats. |
21+
| 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`. |
22+
| `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. |
23+
| 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. |
24+
| `properties` | remained `properties` | `Core` | Applicator | The `properties` takes two values, either `optional` or `required`; where `optional `, is the default value. |
25+
| `alternate` | removed | `Core` | | - |
2526

2627
### Tutorial
2728

2829
#### Step 1: Review Core Changes
2930

3031
Start by understanding the key differences between Draft 2 and Draft 3, especially regarding core changes in $schema, $ref, and validation keywords.
3132

32-
- `$schema`: In Draft 3, this remains the same but is now more standardized to handle the schema dialect and the version of the specification being used.
33-
- `$ref`: Draft 3 introduces the `$ref` keyword, which allows referencing external schemas for validation. This will enable more modular and reusable schema definitions.
33+
- `$schema`: Draft 3 introduces the `$schema` keyword, it handles the schema dialect and the version of the specification being used.
34+
- `$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.
3435

3536
#### Step 2: Update Validation Keywords
3637

pages/draft-04/migration-notes.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Below is a summary table highlighting keyword changes between Draft 3 and Draft
2121
| `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. |
2222
| `divisibleBy` | `multipleOf` | Validation | Assertion | `divisibleBy` was renamed to `multipleOf` with a stricter requirement that its value must be greater than 0. |
2323
| `extends` | removed | Validation | Applicator | The `extends` keyword was removed; allOf was added as a new keyword to achieve similar functionality. |
24-
| `format` | `format` | Validation | Annotation | - |
24+
| `format` | `format` | Validation | Annotation | The attributes `phone`, `style`, and `color` have been removed and ip-address has been renamed to `ipv4`. |
2525
| `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. |
2626
| `id` | `id` | Core | Identifier | - |
2727
| Not present | `allOf` | Core | Applicator | - |
@@ -58,16 +58,13 @@ The `allOf` keyword has now replaced the previous type schema functionality.
5858
In Draft 3, these identifiers were considered valid:
5959

6060
```json
61-
id: ""
62-
id: "#"
61+
"id": ""
62+
"id": "#"
6363
```
6464

6565
However, this format is now prohibited from Draft 4 onwards.
6666
</Infobox>
6767

68-
<Infobox label="Note">
69-
Before Draft 3, the JSON Schema only included the Core specification, which outlined the foundational elements for schema structure. With Draft 4, the specification expanded to incorporate Validation, establishing rules for data format, structure, and type requirements. This addition enabled schema authors to define and enforce validation constraints directly within their schemas, making it easier for implementers to ensure data integrity and compatibility as schemas evolved.
70-
</Infobox>
7168

7269
### Tutorial
7370

pages/draft/2020-12/migration-notes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ JSON Schema Draft 2020-12 introduces key improvements over Draft 2019-09, focusi
1111

1212
| Keyword (Draft 2019-09) | Keyword (Draft 2020-12) | Specification | Keyword Type | Behavior Details |
1313
| --- | --- | --- | --- | --- |
14-
| $anchor | remained $anchor | Core | | In 2019-09, $anchor could use a colon and not start with an underscore, but in 2020-12, the upgrade in syntax rule can't use a colon. |
15-
| $schema | remained $schema | Core | | The behavior was updated to use dialect 2020-12 |
16-
| $recursiveAnchor | `$dynamicAnchor` | Core | Identifier | Similar to `$anchor`, but supports `$dynamicRef` for flexible schema resolution and $dynamicAnchor now has its own syntax. |
17-
| $recursiveRef | `$dynamicRef` | Core | Applicator | Works with `$dynamicAnchor` to allow referencing dynamically resolved schemas at runtime. |
18-
| $vocabulary | `$vocabulary` | Core | | Specifies which vocabularies a schema uses in 2019-09, but the update now uses format-annotation aiding compatibility and extensibility. |
14+
|` $anchor` | remained `$anchor` | Core | | In 2019-09, $anchor could use a colon and not start with an underscore, but in 2020-12, the upgrade in syntax rule can't use a colon. |
15+
| `$schema` | remained` $schema` | Core | | The behavior was updated to use dialect 2020-12 |
16+
| `$recursiveAnchor` | `$dynamicAnchor` | Core | Identifier | Similar to `$anchor`, but supports `$dynamicRef` for flexible schema resolution. |
17+
|` $recursiveRef` | `$dynamicRef` | Core | Applicator | Works with `$dynamicAnchor` to allow referencing dynamically resolved schemas at runtime. |
18+
| `$vocabulary` | `$vocabulary` | Core | | Specifies which vocabularies a schema uses in 2019-09, but the update now uses format-annotation aiding compatibility and extensibility. |
1919
| `items` (used for both lists and tuples) | `prefixItems` | Core | Applicator | Separates tuple validation (`prefixItems`) from list validation (`items`). Now, `items` applies only to additional elements beyond `prefixItems`. |
2020

2121
### Tutorial

0 commit comments

Comments
 (0)