From d82ea38b85768de924f4106d7c447796fa5d05f9 Mon Sep 17 00:00:00 2001 From: Anthony Deschamps Date: Tue, 3 Sep 2019 15:38:39 -0400 Subject: [PATCH 001/311] Add link to Rust code generator. --- implementations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implementations.md b/implementations.md index 9e721bd4..7ee033e6 100644 --- a/implementations.md +++ b/implementations.md @@ -189,6 +189,8 @@ are the only keywords that changed. - [php-code-builder](https://github.com/swaggest/php-code-builder)(MIT) - generates PHP mapping structures defined by JSON schema using [swaggest/json-schema](https://github.com/swaggest/php-json-schema) *supports Draft 7* - Elm - [json-schema-to-elm](https://github.com/dragonwasrobot/json-schema-to-elm) - generates Elm types, JSON decoders+encoders, and fuzz tests from one or more JSON Schema files, using [dragonwasrobot/json_schema](https://github.com/dragonwasrobot/json_schema) *supports Draft 7* +- Rust + - [schemafy](https://github.com/Marwes/schemafy/) - generates Rust types and serialization code from a JSON schema. *supports Draft 4* #### Web UI generation From 06ed5c28578691b37a3e3333ed5f7830a9cf7b28 Mon Sep 17 00:00:00 2001 From: Todd O'Bryan Date: Sat, 14 Sep 2019 19:16:16 -0700 Subject: [PATCH 002/311] Notes change in integer behavior between 4 and 6 `1.0` was not a valid integer in draft-04 and earlier, but is in draft-06 and later. --- draft-06/json-schema-release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/draft-06/json-schema-release-notes.md b/draft-06/json-schema-release-notes.md index fa7ecdf6..68984b5c 100644 --- a/draft-06/json-schema-release-notes.md +++ b/draft-06/json-schema-release-notes.md @@ -25,6 +25,7 @@ keyword | change | consequence `"$id"` | replaces `"id"` | behavior is identical, `$` prefix matches the other two core keywords `"$ref"` | only allowed where a schema is expected | it is now possible to describe instance properties named `"$ref"` `"exclusiveMinimum"` and `"exclusiveMaximum"` | changed from a boolean to a number to be consistent with the principle of keyword independence | wherever one of these would be true before, change the value to the corresponding `"minimum"` or `"maximum"` value and remove the `"minimum"`/`"maximum"` keyword +`"type"` | definition of `"integer"` | in draft-04, `"integer"` is listed as a primitive type and defined as "a JSON number without a fraction or exponent part"; in draft-06, `"integer"` is not considered a primitive type and is only defined in the section for keyword `"type"` as "any number with a zero fractional part"; `1.0` is thus not a valid `"integer"` type in draft-04 and earlier, but is a valid `"integer"` type in draft-06 and later; note that both drafts say that integers SHOULD be encoded in JSON without fractional parts #### Additions and backwards-compatible changes From a51c9b2413d9504f26923fb4e2ee799828f54b9a Mon Sep 17 00:00:00 2001 From: Ondrej Kokes Date: Wed, 18 Sep 2019 09:04:58 +0200 Subject: [PATCH 003/311] add a python validator (fastjsonschema) --- _data/validator-libraries-modern.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 3cc7f269..68588384 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -57,7 +57,8 @@ url: https://github.com/santhosh-tekuri/jsonschema notes: draft: [7, 6, 4] - license: BSD-3-Clause + license: + -3-Clause - name: qri-io/jsonschema url: https://github.com/qri-io/jsonschema draft: [7] @@ -117,6 +118,11 @@ notes: draft: [7, 6, 4, 3] license: "MIT" + - name: fastjsonschema + url: https://github.com/horejsek/python-fastjsonschema + notes: Great performance thanks to code generation. + draft: [7, 6, 4] + license: BSD-3-Clause - name: Ruby implementations: - name: JSONSchemer From 7ca55090ca07540ffe20373a623bc38bb6a7122b Mon Sep 17 00:00:00 2001 From: Ondrej Kokes Date: Wed, 18 Sep 2019 09:07:19 +0200 Subject: [PATCH 004/311] typo --- _data/validator-libraries-modern.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 68588384..2cf9eae2 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -57,8 +57,7 @@ url: https://github.com/santhosh-tekuri/jsonschema notes: draft: [7, 6, 4] - license: - -3-Clause + license: BSD-3-Clause - name: qri-io/jsonschema url: https://github.com/qri-io/jsonschema draft: [7] From 87af65dfcee573da6075b66cc3b605be5152faf0 Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Wed, 18 Sep 2019 20:53:38 +1200 Subject: [PATCH 005/311] updated draft2019-09 submodule reference IAW json-schema-org/json-schema-spec/pull/804 --- _includes/draft-00 | 2 +- _includes/draft-01 | 2 +- _includes/draft-02 | 2 +- _includes/draft-03 | 2 +- _includes/draft-04 | 2 +- _includes/draft-05 | 2 +- _includes/draft-06 | 2 +- _includes/draft-07 | 2 +- _includes/draft/2019-09 | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/_includes/draft-00 b/_includes/draft-00 index 7ea575ae..b47f567e 160000 --- a/_includes/draft-00 +++ b/_includes/draft-00 @@ -1 +1 @@ -Subproject commit 7ea575aef8d5c0183acbe6ff65b4c98ee9c236ec +Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce diff --git a/_includes/draft-01 b/_includes/draft-01 index 2072feec..b47f567e 160000 --- a/_includes/draft-01 +++ b/_includes/draft-01 @@ -1 +1 @@ -Subproject commit 2072feec9fc7a7ff0b2bb5b02c2d6742c554cc4a +Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce diff --git a/_includes/draft-02 b/_includes/draft-02 index 707f6507..b47f567e 160000 --- a/_includes/draft-02 +++ b/_includes/draft-02 @@ -1 +1 @@ -Subproject commit 707f65070d09fe5baa1315bce4d31a66ff124171 +Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce diff --git a/_includes/draft-03 b/_includes/draft-03 index 89912ad6..b47f567e 160000 --- a/_includes/draft-03 +++ b/_includes/draft-03 @@ -1 +1 @@ -Subproject commit 89912ad69fe15e006e8336a59e93bf7a1e46fa54 +Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce diff --git a/_includes/draft-04 b/_includes/draft-04 index dba92b70..b47f567e 160000 --- a/_includes/draft-04 +++ b/_includes/draft-04 @@ -1 +1 @@ -Subproject commit dba92b702c94858162f653590230e7573c8b7dd0 +Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce diff --git a/_includes/draft-05 b/_includes/draft-05 index 88d3cff3..b47f567e 160000 --- a/_includes/draft-05 +++ b/_includes/draft-05 @@ -1 +1 @@ -Subproject commit 88d3cff344e32611e23cfdd44117b28723a8393d +Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce diff --git a/_includes/draft-06 b/_includes/draft-06 index 00e25c02..b47f567e 160000 --- a/_includes/draft-06 +++ b/_includes/draft-06 @@ -1 +1 @@ -Subproject commit 00e25c022514788dbb9161d52b70024f2646cfb5 +Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce diff --git a/_includes/draft-07 b/_includes/draft-07 index 4e016d92..6e2b4251 160000 --- a/_includes/draft-07 +++ b/_includes/draft-07 @@ -1 +1 @@ -Subproject commit 4e016d927839ed264f8d182abe9dc18a7e7a2c62 +Subproject commit 6e2b42516dc7e8845c980d284c61bd44c9f95cd2 diff --git a/_includes/draft/2019-09 b/_includes/draft/2019-09 index 38e1606d..b47f567e 160000 --- a/_includes/draft/2019-09 +++ b/_includes/draft/2019-09 @@ -1 +1 @@ -Subproject commit 38e1606d71ee848c6cf0490c3457681220c01663 +Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce From ee1ecd9b444dda0f04a10eaf11c0e2f9996836a1 Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Wed, 18 Sep 2019 21:15:15 +1200 Subject: [PATCH 006/311] updated draft2019-09 submodule reference IAW json-schema-org/json-schema-spec/pull/804 --- _includes/draft-00 | 2 +- _includes/draft-01 | 2 +- _includes/draft-02 | 2 +- _includes/draft-03 | 2 +- _includes/draft-04 | 2 +- _includes/draft-05 | 2 +- _includes/draft-06 | 2 +- _includes/draft-07 | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/_includes/draft-00 b/_includes/draft-00 index b47f567e..7ea575ae 160000 --- a/_includes/draft-00 +++ b/_includes/draft-00 @@ -1 +1 @@ -Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce +Subproject commit 7ea575aef8d5c0183acbe6ff65b4c98ee9c236ec diff --git a/_includes/draft-01 b/_includes/draft-01 index b47f567e..2072feec 160000 --- a/_includes/draft-01 +++ b/_includes/draft-01 @@ -1 +1 @@ -Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce +Subproject commit 2072feec9fc7a7ff0b2bb5b02c2d6742c554cc4a diff --git a/_includes/draft-02 b/_includes/draft-02 index b47f567e..707f6507 160000 --- a/_includes/draft-02 +++ b/_includes/draft-02 @@ -1 +1 @@ -Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce +Subproject commit 707f65070d09fe5baa1315bce4d31a66ff124171 diff --git a/_includes/draft-03 b/_includes/draft-03 index b47f567e..89912ad6 160000 --- a/_includes/draft-03 +++ b/_includes/draft-03 @@ -1 +1 @@ -Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce +Subproject commit 89912ad69fe15e006e8336a59e93bf7a1e46fa54 diff --git a/_includes/draft-04 b/_includes/draft-04 index b47f567e..dba92b70 160000 --- a/_includes/draft-04 +++ b/_includes/draft-04 @@ -1 +1 @@ -Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce +Subproject commit dba92b702c94858162f653590230e7573c8b7dd0 diff --git a/_includes/draft-05 b/_includes/draft-05 index b47f567e..88d3cff3 160000 --- a/_includes/draft-05 +++ b/_includes/draft-05 @@ -1 +1 @@ -Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce +Subproject commit 88d3cff344e32611e23cfdd44117b28723a8393d diff --git a/_includes/draft-06 b/_includes/draft-06 index b47f567e..00e25c02 160000 --- a/_includes/draft-06 +++ b/_includes/draft-06 @@ -1 +1 @@ -Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce +Subproject commit 00e25c022514788dbb9161d52b70024f2646cfb5 diff --git a/_includes/draft-07 b/_includes/draft-07 index 6e2b4251..4e016d92 160000 --- a/_includes/draft-07 +++ b/_includes/draft-07 @@ -1 +1 @@ -Subproject commit 6e2b42516dc7e8845c980d284c61bd44c9f95cd2 +Subproject commit 4e016d927839ed264f8d182abe9dc18a7e7a2c62 From b51783260d30379bbe58194e3a75e6d599d5d1ba Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Wed, 18 Sep 2019 10:19:01 -0700 Subject: [PATCH 007/311] Settle on "2019-09" rather than "draft/2019-09" --- draft/2019-09/release-notes.md | 2 +- index.md | 8 ++++++-- specification-links.md | 2 +- specification.md | 10 +++++----- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/draft/2019-09/release-notes.md b/draft/2019-09/release-notes.md index 45972a5b..dfedce1c 100644 --- a/draft/2019-09/release-notes.md +++ b/draft/2019-09/release-notes.md @@ -104,7 +104,7 @@ yes | off | not validated Obviously, each implementation will behave consistently from schema to schema, although some formats may be supported more thoroughly than others despite the wording in the specification. However, complex formats are, in practice, supported to different degrees in each implementation. If they are supported at all. -**Summary of draft/2019-09 behavior** +**Summary of 2019-09 behavior** The goal with this draft is to make the default behavior predictable, with the inconsistent behavior as an opt-in feature. This is not entirely satisfactory, but we feel that it is a good first step to reduce the number of complaints seen around surprising results. This way, there should at least be fewer surprises. diff --git a/index.md b/index.md index efe5fd9d..a67a09bb 100644 --- a/index.md +++ b/index.md @@ -7,7 +7,7 @@ permalink: / **NEW DRAFT PUBLISHED!** {: style="color:red; font-size: 200%; text-align: center;"} -The current version is [draft/2019-09](specification.html)! +The current version is [2019-09](specification.html)! {: style="color:gray; font-size: 150%; text-align: center;"} **JSON Schema** is a vocabulary that allows you to **annotate** and **validate** JSON documents. @@ -42,7 +42,11 @@ The current version is [draft/2019-09](specification.html)! 16 September 2019: Draft 2019-09 (formerly known as draft-08) has been published! -See the [Specification page](specification.html) for details. +The IETF document IDs are of the form `draft-handrews-*-02`. We are now using dates +for meta-schemas, which are what implementations should use to determine behavior, +so we will usually refer to `2019-09` (without the word "draft") on this web site. + +See the [Specification page](specification.html) for details about naming and numbering. ### The Path to Standardization diff --git a/specification-links.md b/specification-links.md index 6cc24ed7..b772dff2 100644 --- a/specification-links.md +++ b/specification-links.md @@ -208,7 +208,7 @@ For links to the somewhat more readably formatted versions on this web site, and
- draft/2019‑09 + 2019‑09 Draft 8 diff --git a/specification.md b/specification.md index a697b3b7..db0e3428 100644 --- a/specification.md +++ b/specification.md @@ -11,9 +11,9 @@ title: Specification Draft numbering --------------- -The latest Internet-Drafts at the IETF are the **draft-handrews-json-schema\*-02** documents, which correspond to the **draft/2019-09** meta-schemas. These were published on **2019-09-16**. +The latest Internet-Drafts at the IETF are the **draft-handrews-json-schema\*-02** documents, which correspond to the **2019-09** meta-schemas. These were published on **2019-09-16**. -For a full explanation of both the IETF and meta-schema numbering schemes, how they correspond, and why we are now using the date-based `draft/2019-09` rather than `draft-08`, see the [Specification Links](specification-links.html) page. +For a full explanation of both the IETF and meta-schema numbering schemes, how they correspond, and why we are now using the date-based `2019-09` rather than `draft-08`, see the [Specification Links](specification-links.html) page. Specification documents ----------------------- @@ -41,7 +41,7 @@ Meta-schemas The meta-schemas are schemas against which other schemas can be validated. They are self-descriptive: the JSON Schema meta-schema validates itself, while the JSON Hyper-Schema meta-schema both validates itself and defines its own "self" link. -The latest meta-schema is **draft/2019**. For an explanation of the change to date-based identifiers, see the [Specification Links](specification-links.html) page. +The latest meta-schema is **2019-09**. For an explanation of the change to date-based identifiers, see the [Specification Links](specification-links.html) page. _If you are accessing these JSON document links **from a web browser**, you will need to **save the file** then open it as a JSON document. This is due to limitations with GitHub Pages._ @@ -76,11 +76,11 @@ Migrating from older drafts The release notes discuss the changes impacting users and implementers: - JSON Schema Core and Validation - - [Draft-07 to Draft 2019-09](draft/2019-09/release-notes.html) + - [Draft-07 to 2019-09](draft/2019-09/release-notes.html) - [Draft-06 to Draft-07](draft-07/json-schema-release-notes.html) - [Draft-04 to Draft-06](draft-06/json-schema-release-notes.html) - JSON Hyper-Schema - - [Draft-07 to Draft 2019-09](draft/2019-09/release-notes.html#hyper-schema-vocabulary) + - [Draft-07 to 2019-09](draft/2019-09/release-notes.html#hyper-schema-vocabulary) - [Draft-04 to Draft-07](draft-07/json-hyper-schema-release-notes.html) - [Draft-04 to Draft-06](draft-06/json-hyper-schema-release-notes.html) From 69073fe069cf2d9603ac57a93d5efdbefe3ed15d Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Wed, 18 Sep 2019 11:40:38 -0700 Subject: [PATCH 008/311] Fix one last Draft-2019/09 error to 2019-09 --- draft/2019-09/release-notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/draft/2019-09/release-notes.md b/draft/2019-09/release-notes.md index dfedce1c..0f5c933d 100644 --- a/draft/2019-09/release-notes.md +++ b/draft/2019-09/release-notes.md @@ -1,5 +1,5 @@ --- -title: JSON Schema Draft-2019/09 Release Notes +title: JSON Schema 2019-09 Release Notes layout: page --- From 486884940ff8ea9ff1193dcdc7372c41139f23df Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Wed, 18 Sep 2019 13:14:31 -0700 Subject: [PATCH 009/311] Rel JSON Pointer-02 now approved... So remove the explanations for why it wasn't up yet. Also tweak/improve some details on the specification links page, and fix the change appendix links to be correct. --- specification-links.md | 51 ++++++++++++++++++++++++++++-------------- specification.md | 2 -- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/specification-links.md b/specification-links.md index b772dff2..4b04b567 100644 --- a/specification-links.md +++ b/specification-links.md @@ -213,23 +213,21 @@ For links to the somewhat more readably formatted versions on this web site, and Draft 8 - - Note that the Relative JSON Pointer draft is still pending approval due to how the IETF manages email addresses and authorship. - + ## Published Drafts -### Draft 2019-09 (formerly known as Draft 8) +### 2019-09 (formerly known as Draft 8) _**NOTE:** All meta-schema URIs now use `https://`. While currently also available over plain HTTP due to the limitations of GitHub pages and the need to keep prior drafts available over HTTP, only the HTTPS URIs should be used._ - Specifications - - Core: [draft-handrews-json-schema-02](https://tools.ietf.org/html/draft-handrews-json-schema-02) ([changes](https://tools.ietf.org/html/draft-handrews-json-schema-02#appendix-B)) - - Validation: [draft-handrews-json-schema-validation-02](https://tools.ietf.org/html/draft-handrews-json-schema-validation-02) ([changes](https://tools.ietf.org/html/draft-handrews-json-schema-validation-02#appendix-B)) + - Core: [draft-handrews-json-schema-02](https://tools.ietf.org/html/draft-handrews-json-schema-02) ([changes](https://tools.ietf.org/html/draft-handrews-json-schema-02#appendix-G)) + - Validation: [draft-handrews-json-schema-validation-02](https://tools.ietf.org/html/draft-handrews-json-schema-validation-02) ([changes](https://tools.ietf.org/html/draft-handrews-json-schema-validation-02#appendix-C)) - Hyper-Schema: [draft-handrews-json-schema-hyperschema-02](https://tools.ietf.org/html/draft-handrews-json-schema-hyperschema-02) ([changes](https://tools.ietf.org/html/draft-handrews-json-schema-hyperschema-02#appendix-B)) - - Relative JSON Pointers: [draft-handrews-relative-json-pointer-02](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-02) ([changes](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-02#appendix-B)) + - Relative JSON Pointer: [draft-handrews-relative-json-pointer-02](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-02) ([changes](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-02#appendix-A)) - General use meta-schemas - [JSON Schema meta-schema](https://json-schema.org/draft/2019-09/schema) - [JSON Hyper-Schema meta-schema](https://json-schema.org/draft/2019-09/hyper-schema) @@ -257,16 +255,16 @@ _**NOTE:** All meta-schema URIs now use `https://`. While currently also availa - [JSON Hyper-Schema meta-schema](http://json-schema.org/draft-07/hyper-schema) - [JSON Hyper-Schema Link Description Object meta-schema](http://json-schema.org/draft-07/links) - [JSON Hyper-Schema recommended output schema](http://json-schema.org/draft-07/hyper-schema-output) -- Relative JSON Pointers: [draft-handrews-relative-json-pointer-01](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01) ([changes](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01#appendix-B)) +- Relative JSON Pointer: [draft-handrews-relative-json-pointer-01](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01) ([changes](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01#appendix-B)) #### Obsolete Draft 7 Documents -Play "spot the bugs"! +_These were updated without changing functionality or meta-schemas due to a few errors and unclear sections._ - Core: [draft-handrews-json-schema-00](https://tools.ietf.org/html/draft-handrews-json-schema-00) ([changes](https://tools.ietf.org/html/draft-handrews-json-schema-00#appendix-B)) - Validation: [draft-handrews-json-schema-validation-00](https://tools.ietf.org/html/draft-handrews-json-schema-validation-00) ([changes](https://tools.ietf.org/html/draft-handrews-json-schema-validation-00#appendix-B)) - Hyper-Schema: [draft-handrews-json-schema-hyperschema-00](https://tools.ietf.org/html/draft-handrews-json-schema-hyperschema-00) ([changes](https://tools.ietf.org/html/draft-handrews-json-schema-hyperschema-00#appendix-B)) -- Relative JSON Pointers: [draft-handrews-relative-json-pointer-00](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-00) ([changes](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-00#appendix-B)) +- Relative JSON Pointer: [draft-handrews-relative-json-pointer-00](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-00) ([changes](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-00#appendix-B)) ### Draft 6 @@ -288,30 +286,49 @@ Play "spot the bugs"! - Core: [draft-zyp-json-schema-04](https://tools.ietf.org/html/draft-zyp-json-schema-04) ([changes](https://tools.ietf.org/html/draft-zyp-json-schema-04#appendix-A)) - Validation: [draft-fge-json-schema-validation-00](https://tools.ietf.org/html/draft-fge-json-schema-validation-00) ([changes](https://tools.ietf.org/html/draft-fge-json-schema-validation-00#appendix-A)) - Hyper-Schema: [draft-luff-json-hyper-schema-00](https://tools.ietf.org/html/draft-luff-json-hyper-schema-00) ([changes](https://tools.ietf.org/html/draft-luff-json-hyper-schema-00#appendix-A)) + - JSON Reference: [draft-pbryan-zyp-json-ref-03](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03) ([changes](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03#appendix-A)) * [JSON Schema meta-schema](http://json-schema.org/draft-04/schema) * [JSON Hyper-Schema meta-schema](http://json-schema.org/draft-04/hyper-schema) ### Draft 3 - - Core: [draft-zyp-json-schema-03](https://tools.ietf.org/html/draft-zyp-json-schema-03) ([changes](https://tools.ietf.org/html/draft-zyp-json-schema-03#appendix-A)) - - Validation: none (included in Core) - - Hyper-Schema: none (included in Core) + - Complete Specification: [draft-zyp-json-schema-03](https://tools.ietf.org/html/draft-zyp-json-schema-03) ([changes](https://tools.ietf.org/html/draft-zyp-json-schema-03#appendix-A)) * [JSON Schema meta-schema](http://json-schema.org/draft-03/schema) * [JSON Hyper-Schema meta-schema](http://json-schema.org/draft-03/hyper-schema) -### Drafts 0/1/2 -Meta-schemas for these older drafts can be found on GitHub: [Draft 0](https://github.com/json-schema-org/json-schema-org.github.io/tree/master/draft-00), [Draft 1](https://github.com/json-schema-org/json-schema-org.github.io/tree/master/draft-01), [Draft 2](https://github.com/json-schema-org/json-schema-org.github.io/tree/master/draft-02) +### Draft 2 + + - Complete Specification: [draft-zyp-json-schema-02](https://tools.ietf.org/html/draft-zyp-json-schema-02) ([changes](https://tools.ietf.org/html/draft-zyp-json-schema-02#appendix-A)) +* [JSON Schema meta-schema](http://json-schema.org/draft-02/schema) +* [JSON Hyper-Schema meta-schema](http://json-schema.org/draft-02/hyper-schema) + +### Draft 1 + + - Complete Specification: [draft-zyp-json-schema-01](https://tools.ietf.org/html/draft-zyp-json-schema-01) ([changes](https://tools.ietf.org/html/draft-zyp-json-schema-01#appendix-A)) +* [JSON Schema meta-schema](http://json-schema.org/draft-01/schema) +* [JSON Hyper-Schema meta-schema](http://json-schema.org/draft-01/hyper-schema) + +### Draft 0 + +_Note that Draft 0 erroneously claimed to update another RFC, and was replaced the same day by Draft 1. It is included here for completeness only._ + + - Specification: [draft-zyp-json-schema-00](https://tools.ietf.org/html/draft-zyp-json-schema-00) ([changes](https://tools.ietf.org/html/draft-zyp-json-schema-00#appendix-A)) +* [JSON Schema meta-schema](http://json-schema.org/draft-00/schema) +* [JSON Hyper-Schema meta-schema](http://json-schema.org/draft-00/hyper-schema) ## Latest Snapshot (work in progress) The next unreleased draft is a work in progress. You can [give feedback and get involved on GitHub](https://github.com/json-schema-org/json-schema-spec). +The specification links here link to the XML and JSON sources. We do not provide rendered [work-in-progress](work-in-progress) drafts except near the very end of a publication cycle, during the final review period. + - Core: [jsonschema-core.xml](https://github.com/json-schema-org/json-schema-spec/blob/master/jsonschema-core.xml) - Validation: [jsonschema-validation.xml](https://github.com/json-schema-org/json-schema-spec/blob/master/jsonschema-validation.xml) - Hyper-Schema: [jsonschema-hyperschema.xml](https://github.com/json-schema-org/json-schema-spec/blob/master/jsonschema-hyperschema.xml) +- Relative JSON Pointer: [relative-json-pointer.xml](https://github.com/json-schema-org/json-schema-spec/blob/master/relative-json-pointer.xml) - [JSON Schema meta-schema](https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json) - [JSON Hyper-Schema meta-schema](https://github.com/json-schema-org/json-schema-spec/blob/master/hyper-schema.json) - [JSON Hyper-Schema Link Description Object meta-schema](https://github.com/json-schema-org/json-schema-spec/blob/master/links.json) -- [JSON Hyper-Schema recommended output schema](https://github.com/json-schema-org/json-schema-spec/blob/master/hyper-schema-output.json) -- Relative JSON Pointers: [relative-json-pointer.xml](https://github.com/json-schema-org/json-schema-spec/blob/master/relative-json-pointer.xml) +- [JSON Schema Vocabulary meta-schemas](https://github.com/json-schema-org/json-schema-spec/blob/master/meta/) +- [JSON Schema Output schemas and examples](https://github.com/json-schema-org/json-schema-spec/blob/master/output/) diff --git a/specification.md b/specification.md index db0e3428..47b44b63 100644 --- a/specification.md +++ b/specification.md @@ -34,8 +34,6 @@ They are also available on the IETF main site: * [draft-handrews-json-schema-hyperschema-02](https://tools.ietf.org/html/draft-handrews-json-schema-hyperschema-02) * [draft-handrews-relative-json-pointer-02](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-02) -_Note that the Relative JSON Pointer draft is still pending approval due to how the IETF manages emails and author identification. It should be up within a few days._ - Meta-schemas ------------ From 04c590af4af7bfa6b0158ae7deed639175f55b09 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Thu, 19 Sep 2019 08:41:41 -0700 Subject: [PATCH 010/311] Add announcement to spec page as well. --- specification.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/specification.md b/specification.md index 47b44b63..469da8a0 100644 --- a/specification.md +++ b/specification.md @@ -5,6 +5,12 @@ permalink: /specification.html title: Specification --- +**NEW DRAFT PUBLISHED!** +{: style="color:red; font-size: 200%; text-align: center;"} + +The current version is 2019-09! +{: style="color:gray; font-size: 150%; text-align: center;"} + * TOC {:toc} From 60ac1213e18db10c9df63ff1f37e63d3734ba548 Mon Sep 17 00:00:00 2001 From: Zac-HD Date: Fri, 18 Oct 2019 22:45:21 +1100 Subject: [PATCH 011/311] Fix Hypothesis links & description --- implementations.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/implementations.md b/implementations.md index 5c403105..4181d18d 100644 --- a/implementations.md +++ b/implementations.md @@ -216,7 +216,8 @@ Various levels of support for UI generation primarily from the validation vocabu #### Data from schemas -_None currently support draft-06 or later._ +- Python + - [hypothesis-jsonschema](https://github.com/Zac-HD/hypothesis-jsonschema) (MPL) *draft-07, -06, -04*; takes any schema, even with complex and interacting constraints, and returns a [Hypothesis](https://hypothesis.works/) strategy which can generate valid documents for testing. Utilities --------- @@ -241,8 +242,7 @@ the utility, and decided on a case-by-case basis. #### Schema draft migration -- Python - - [hypothesis-jsonschema](https://github.com/Zac-HD/hypothesis-jsonschema) (MPL) *draft-07, -06, -04*; creates [Hypothesis](https://hypothesis.works/) strategies for documents which match any schema, even with complex and interacting constraints. +_None currently support draft-06 or later._ #### Format converters @@ -259,8 +259,7 @@ the utility, and decided on a case-by-case basis. #### Testing - Python - - [hypothesis-jsonschema](https://github.com/Zac-HD/hypothesis-jsonschema) (MPL) *draft-07, -06, -04*; creates [Hypothesis](https://hypothesis.works/) strategies for documents which match any schema, even with complex and interacting constraints. - - [hypo\_schema](https://github.com/mlakewood/hypo_schema) (BSD-2-Clause) Creates generators for Hypothesis from JSON Schema + - [hypothesis-jsonschema](https://github.com/Zac-HD/hypothesis-jsonschema) (MPL) *draft-07, -06, -04*; takes any schema, even with complex and interacting constraints, and returns a [Hypothesis](https://hypothesis.works/) strategy which can generate valid documents for testing. #### Editors From 30ea0f6dc258ac60dd3f1b372e97727d0190dc15 Mon Sep 17 00:00:00 2001 From: Yuansheng Date: Tue, 22 Oct 2019 22:38:56 -0400 Subject: [PATCH 012/311] change: added new validator lua-resty-jsonschema. --- _data/validator-libraries-modern.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 2cf9eae2..a8371b2d 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -136,6 +136,13 @@ notes: draft: [7, 6, 4] license: MIT +- name: Lua/LuaJIT + implementations: + - name: lua-resty-jsonschema + url: https://github.com/iresty/lua-resty-jsonschema + notes: + draft: [7, 6, 4] + license: MIT - name: Web (Online) implementations: - name: JSON Schema Validator From 51b25909f275792f7cbdadb53091ab7f8196cd24 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Thu, 24 Oct 2019 12:57:15 -0700 Subject: [PATCH 013/311] Support date-based drafts, update Manatee.JSON Jekyll/Liquid are limiting so this gets more complicated to display correctly. --- _data/validator-libraries-modern.yml | 30 ++++++++++++++++++++++++++++ implementations.md | 7 ++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index a8371b2d..7692ed83 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -3,16 +3,19 @@ implementations: - name: Json.NET Schema url: https://www.newtonsoft.com/jsonschema + date-draft: draft: [7, 6, 4, 3] license: "AGPL-3.0-only" - name: Manatee.Json url: https://github.com/gregsdennis/Manatee.Json + date-draft: [2019-09] draft: [7, 6, 4] license: MIT - name: C implementations: - name: WJElement url: https://github.com/netmail-open/wjelement + date-draft: draft: [4, 3] license: LGPL-3.0 notes: "Draft-06+ progress: issue [17](https://github.com/netmail-open/wjelement/issues/17#issuecomment-390899432)" @@ -20,46 +23,55 @@ implementations: - name: f5-json-schema url: https://github.com/KayEss/json-schema + date-draft: draft: [7] license: Boost Software License 1.0 - name: JSON schema validator for JSON for Modern C++ url: https://github.com/pboettch/json-schema-validator + date-draft: draft: [7] license: MIT - name: Clojure implementations: - name: jinx url: https://github.com/juxt/jinx + date-draft: draft: [7] license: MIT - name: json-schema url: https://github.com/luposlip/json-schema + date-draft: draft: [7] license: Apache License, Version 2.0 - name: Elixir implementations: - name: Elixir JSON Schema validator url: https://github.com/jonasschmidt/ex_json_schema + date-draft: draft: [4] notes: "Draft-06+ progress: issue [24](https://github.com/jonasschmidt/ex_json_schema/issues/24); branch [multi-draft-support](https://github.com/jonasschmidt/ex_json_schema/tree/multi-draft-support)" license: MIT - name: JsonXema url: https://github.com/hrzndhrn/json_xema + date-draft: draft: [7, 6, 4] license: MIT - name: Go implementations: - name: gojsonschema url: https://github.com/xeipuuv/gojsonschema + date-draft: draft: [7, 6, 4] license: "Apache 2.0" - name: santhosh-tekuri/jsonschema url: https://github.com/santhosh-tekuri/jsonschema notes: + date-draft: draft: [7, 6, 4] license: BSD-3-Clause - name: qri-io/jsonschema url: https://github.com/qri-io/jsonschema + date-draft: draft: [7] license: MIT notes: includes custom validator support, rich error returns @@ -68,11 +80,13 @@ - name: everit-org/json-schema url: https://github.com/everit-org/json-schema notes: + date-draft: draft: [7, 6, 4] license: Apache License 2.0 - name: Justify url: https://github.com/leadpony/justify notes: + date-draft: draft: [7, 6, 4] license: Apache License 2.0 - name: Kotlin @@ -80,6 +94,7 @@ - name: Medeia-validator url: https://github.com/worldturner/medeia-validator notes: streaming validator for Kotlin and Java clients; works with Jackson and Gson + date-draft: draft: [7, 6, 4] license: Apache License 2.0 - name: JavaScript @@ -87,15 +102,18 @@ - name: ajv url: https://github.com/epoberezkin/ajv notes: "for Node.js and browsers - supports [custom keywords](https://github.com/epoberezkin/ajv-keywords) and [$data reference](https://github.com/json-schema-org/json-schema-spec/issues/51)" + date-draft: draft: [7, 6, 4] license: MIT - name: djv url: https://github.com/korzio/djv notes: "for Node.js and browsers" + date-draft: draft: [6, 4] license: MIT - name: vue-vuelidate-jsonschema url: https://github.com/mokkabonna/vue-vuelidate-jsonschema + date-draft: draft: [6] license: MIT - name: PHP @@ -103,11 +121,13 @@ - name: Opis Json Schema url: https://github.com/opis/json-schema notes: + date-draft: draft: [7, 6] license: "Apache License 2.0" - name: Swaggest Json Schema url: https://github.com/swaggest/php-json-schema notes: + date-draft: draft: [7, 6, 4] license: "MIT" - name: Python @@ -115,11 +135,13 @@ - name: jsonschema url: https://github.com/Julian/jsonschema notes: + date-draft: draft: [7, 6, 4, 3] license: "MIT" - name: fastjsonschema url: https://github.com/horejsek/python-fastjsonschema notes: Great performance thanks to code generation. + date-draft: draft: [7, 6, 4] license: BSD-3-Clause - name: Ruby @@ -127,6 +149,7 @@ - name: JSONSchemer url: https://github.com/davishmcclurg/json_schemer notes: + date-draft: draft: [7, 6, 4] license: MIT - name: Objective-C @@ -134,6 +157,7 @@ - name: DSJSONSchemaValidation url: https://github.com/dashevo/JSONSchemaValidation notes: + date-draft: draft: [7, 6, 4] license: MIT - name: Lua/LuaJIT @@ -141,27 +165,33 @@ - name: lua-resty-jsonschema url: https://github.com/iresty/lua-resty-jsonschema notes: + date-draft: draft: [7, 6, 4] license: MIT - name: Web (Online) implementations: - name: JSON Schema Validator url: https://www.jsonschemavalidator.net/ + date-draft: draft: [7, 6, 4, 3] - name: JSON Schema Lint url: http://jsonschemalint.com/ + date-draft: draft: [7, 6, 4, 3, 2, 1] - name: ExtendsClass's JSON Schema Validator url: https://extendsclass.com/json-schema-validator.html + date-draft: draft: [7] - name: Command Line implementations: - name: ajv-cli license: MIT url: 'https://www.npmjs.com/package/ajv-cli' + date-draft: draft: [7, 6, 4] - name: Polyglottal JSON Schema Validator license: MIT url: 'https://www.npmjs.com/package/pajv' + date-draft: draft: [6, 4] notes: can be used with YAML and many other formats besides JSON diff --git a/implementations.md b/implementations.md index 4181d18d..1a308ae8 100644 --- a/implementations.md +++ b/implementations.md @@ -43,9 +43,14 @@ Validators
  • {{ implementation.name }} + + {% if implementation.date-draft %} + {{ implementation.date-draft | join: ", "}}{% if implementation.draft %}, {% endif %} + {% endif %} {% if implementation.draft %} - draft-0{{ implementation.draft | join: ", -0" }} + draft-0{{ implementation.draft | join: ", -0" }} {% endif %} + {{implementation.notes | markdownify | remove: '

    ' | remove: '

    '}} From 4b2bc46310565aa00d1e453f9839d28d43111a69 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 29 Oct 2019 12:15:22 -0700 Subject: [PATCH 014/311] Add milestone links, including future releases --- specification-links.md | 72 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/specification-links.md b/specification-links.md index 4b04b567..7f4253ed 100644 --- a/specification-links.md +++ b/specification-links.md @@ -40,8 +40,8 @@ For links to the somewhat more readably formatted versions on this web site, and Draft 0 - due to a markup error, this draft was replaced by - draft‑01 on the same day + due to a markup error, this draft was replaced by + draft‑01 on the same day @@ -74,7 +74,8 @@ For links to the somewhat more readably formatted versions on this web site, and draft‑zyp‑json‑schema‑03 - + + draft‑03 @@ -105,10 +106,12 @@ For links to the somewhat more readably formatted versions on this web site, and Draft 4 + json‑ref drafts 00‑02 were all published between json‑schema‑03 and json‑schema‑04 + @@ -127,8 +130,12 @@ For links to the somewhat more readably formatted versions on this web site, and Draft 5 - the meta‑schema was not changed, so - "draft‑05" has no formal meaning + meta‑schemas not changed, so + "draft‑05" is really + draft‑04 +
    + Milestone: draft-5 (2016-10-13)
    + @@ -148,7 +155,12 @@ For links to the somewhat more readably formatted versions on this web site, and Draft 6 - + + Milestones: + draft-6, + Meta-schema draft-06 + + @@ -166,13 +178,19 @@ For links to the somewhat more readably formatted versions on this web site, and
    - draft‑07 + draft‑07 + Draft 7 + the draft‑handrews‑*‑01 drafts were bugfixes and/or clarifications without meta‑schema or functional changes +
    + Milestone: + draft-07 +
    @@ -207,14 +225,48 @@ For links to the somewhat more readably formatted versions on this web site, and draft‑handrews‑relative‑json‑pointer‑02
    - + 2019‑09 - + Draft 8 - + + Milestone: + draft-08 + + + + + + (TBD, probably only a subset of the documents) + + + + bugfixes and/or clarifications, no functional changes +
    + Milestone: + draft-08-patch-1 +
    + + + + + (TBD) + + + (TBD) + + + Draft 9 + + + Milestone: + draft-09 + + + ## Published Drafts From a39bd176565a5d337ecea05dec9a2b6c7a6c3a95 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 29 Oct 2019 22:33:21 -0700 Subject: [PATCH 015/311] Replace "latest" specs with redirect stubs Jekyll can't do HTTP redirects, but this causes it to generate HTML files with a meta redirect tag, which is close enough as these are probably almost always accessed through browsers. --- latest/json-schema-core.html | 2423 ---------------------------- latest/json-schema-core.md | 5 + latest/json-schema-hypermedia.html | 2008 ----------------------- latest/json-schema-hypermedia.md | 4 + latest/json-schema-validation.html | 1397 ---------------- latest/json-schema-validation.md | 4 + latest/relative-json-pointer.html | 687 -------- latest/relative-json-pointer.md | 4 + 8 files changed, 17 insertions(+), 6515 deletions(-) delete mode 100644 latest/json-schema-core.html create mode 100644 latest/json-schema-core.md delete mode 100644 latest/json-schema-hypermedia.html create mode 100644 latest/json-schema-hypermedia.md delete mode 100644 latest/json-schema-validation.html create mode 100644 latest/json-schema-validation.md delete mode 100644 latest/relative-json-pointer.html create mode 100644 latest/relative-json-pointer.md diff --git a/latest/json-schema-core.html b/latest/json-schema-core.html deleted file mode 100644 index 80fb2685..00000000 --- a/latest/json-schema-core.html +++ /dev/null @@ -1,2423 +0,0 @@ - - - - - - - JSON Schema: A Media Type for Describing JSON Documents - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Internet Engineering Task ForceA. Wright, Ed.
    Internet-Draft
    Intended status: InformationalH. Andrews, Ed.
    Expires: March 20, 2020
    B. Hutton, Ed.
    Wellcome Sanger Institute
    G. Dennis
    September 17, 2019
    - -

    JSON Schema: A Media Type for Describing JSON Documents
    - draft-handrews-json-schema-02

    - -

    Abstract

    -

    JSON Schema defines the media type "application/schema+json", a JSON-based format for describing the structure of JSON data. JSON Schema asserts what a JSON document must look like, ways to extract information from it, and how to interact with it. The "application/schema-instance+json" media type provides additional feature-rich integration with "application/schema+json" beyond what can be offered for "application/json" documents.

    -

    Note to Readers

    -

    The issues list for this draft can be found at <https://github.com/json-schema-org/json-schema-spec/issues>.

    -

    For additional information, see <https://json-schema.org/>.

    -

    To provide feedback, use this issue tracker, the communication methods listed on the homepage, or email the document editors.

    -

    Status of This Memo

    -

    This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

    -

    Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

    -

    Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

    -

    This Internet-Draft will expire on March 20, 2020.

    -

    Copyright Notice

    -

    Copyright (c) 2019 IETF Trust and the persons identified as the document authors. All rights reserved.

    -

    This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

    - - -
    -

    Table of Contents

    - - -

    -1. Introduction

    -

    JSON Schema is a JSON media type for defining the structure of JSON data. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data.

    -

    This specification defines JSON Schema core terminology and mechanisms, including pointing to another JSON Schema by reference, dereferencing a JSON Schema reference, specifying the vocabulary being used, and defining the expected output.

    -

    Other specifications define the vocabularies that perform assertions about validation, linking, annotation, navigation, and interaction.

    -

    -2. Conventions and Terminology

    -

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

    -

    The terms "JSON", "JSON text", "JSON value", "member", "element", "object", "array", "number", "string", "boolean", "true", "false", and "null" in this document are to be interpreted as defined in RFC 8259.

    -

    -3. Overview

    -

    This document proposes a new media type "application/schema+json" to identify a JSON Schema for describing JSON data. It also proposes a further optional media type, "application/schema-instance+json", to provide additional integration features. JSON Schemas are themselves JSON documents. This, and related specifications, define keywords allowing authors to describe JSON data in several ways.

    -

    JSON Schema uses keywords to assert constraints on JSON instances or annotate those instances with additional information. Additional keywords are used to apply assertions and annotations to more complex JSON data structures, or based on some sort of condition.

    -

    To facilitate re-use, keywords can be organized into vocabularies. A vocabulary consists of a list of keywords, together with their syntax and semantics.

    -

    JSON Schema can be extended either by defining additional vocabularies, or less formally by defining additional keywords outside of any vocabulary. Unrecognized individual keywords are ignored, while the behavior with respect to an unrecognized vocabulary can be controlled when declaring which vocabularies are in use.

    -

    This document defines a core vocabulary that MUST be supported by any implementation, and cannot be disabled. Its keywords are each prefixed with a "$" character to emphasize their required nature. This vocabulary is essential to the functioning of the "application/schema+json" media type, and is used to bootstrap the loading of other vocabularies.

    -

    Additionally, this document defines a RECOMMENDED vocabulary of keywords for applying subschemas conditionally, and for applying subschemas to the contents of objects and arrays. Either this vocabulary or one very much like it is required to write schemas for non-trivial JSON instances, whether those schemas are intended for assertion validation, annotation, or both. While not part of the required core vocabulary, for maximum interoperability this additional vocabulary is included in this document and its use is strongly encouraged.

    -

    Further vocabularies for purposes such as structural validation or hypermedia annotation are defined in other documents.

    -

    -4. Definitions

    -

    -4.1. JSON Document

    -

    A JSON document is an information resource (series of octets) described by the application/json media type.

    -

    In JSON Schema, the terms "JSON document", "JSON text", and "JSON value" are interchangeable because of the data model it defines.

    -

    JSON Schema is only defined over JSON documents. However, any document or memory structure that can be parsed into or processed according to the JSON Schema data model can be interpreted against a JSON Schema, including media types like CBOR.

    -

    -4.2. Instance

    -

    A JSON document to which a schema is applied is known as an "instance".

    -

    -4.2.1. Instance Data Model

    -

    JSON Schema interprets documents according to a data model. A JSON value interpreted according to this data model is called an "instance".

    -

    An instance has one of six primitive types, and a range of possible values depending on the type:

    - -
    -
    null:
    -
    A JSON "null" production
    -
    boolean:
    -
    A "true" or "false" value, from the JSON "true" or "false" productions
    -
    object:
    -
    An unordered set of properties mapping a string to an instance, from the JSON "object" production
    -
    array:
    -
    An ordered list of instances, from the JSON "array" production
    -
    number:
    -
    An arbitrary-precision, base-10 decimal number value, from the JSON "number" production
    -
    string:
    -
    A string of Unicode code points, from the JSON "string" production
    -
    - -

    -

    Whitespace and formatting concerns, including different lexical representations of numbers that are equal within the data model, are thus outside the scope of JSON Schema. JSON Schema vocabularies that wish to work with such differences in lexical representations SHOULD define keywords to precisely interpret formatted strings within the data model rather than relying on having the original JSON representation Unicode characters available.

    -

    Since an object cannot have two properties with the same key, behavior for a JSON document that tries to define two properties (the "member" production) with the same key (the "string" production) in a single object is undefined.

    -

    Note that JSON Schema vocabularies are free to define their own extended type system. This should not be confused with the core data model types defined here. As an example, "integer" is a reasonable type for a vocabulary to define as a value for a keyword, but the data model makes no distinction between integers and other numbers.

    -

    -4.2.2. Instance Media Types

    -

    JSON Schema is designed to fully work with "application/json" documents, as well as media types using the "+json" structured syntax suffix.

    -

    Some functionality that is useful for working with schemas is defined by each media type, namely media type parameters and URI fragment identifier syntax and semantics. These features are useful in content negotiation and in calculating URIs for specific locations within an instance, respectively.

    -

    This specification defines the "application/schema-instance+json" media type in order to allow instance authors to take full advantage of parameters and fragment identifiers for these purposes.

    -

    -4.2.3. Instance Equality

    -

    Two JSON instances are said to be equal if and only if they are of the same type and have the same value according to the data model. Specifically, this means:

    - -
      -
    • both are null; or
    • -
    • both are true; or
    • -
    • both are false; or
    • -
    • both are strings, and are the same codepoint-for-codepoint; or
    • -
    • both are numbers, and have the same mathematical value; or
    • -
    • both are arrays, and have an equal value item-for-item; or
    • -
    • both are objects, and each property in one has exactly one property with a key equal to the other's, and that other property has an equal value.
    • -
    - -

    -

    Implied in this definition is that arrays must be the same length, objects must have the same number of members, properties in objects are unordered, there is no way to define multiple properties with the same key, and mere formatting differences (indentation, placement of commas, trailing zeros) are insignificant.

    -

    -4.3. JSON Schema Documents -

    -

    A JSON Schema document, or simply a schema, is a JSON document used to describe an instance. A schema can itself be interpreted as an instance, but SHOULD always be given the media type "application/schema+json" rather than "application/schema-instance+json". The "application/schema+json" media type is defined to offer a superset of the media type parameter and fragment identifier syntax and semantics provided by "application/schema-instance+json".

    -

    A JSON Schema MUST be an object or a boolean.

    -

    -4.3.1. JSON Schema Objects and Keywords

    -

    Object properties that are applied to the instance are called keywords, or schema keywords. Broadly speaking, keywords fall into one of four categories:

    - -
    -
    identifiers:
    -
    control schema identification through setting the schema's canonical URI and/or changing how the base URI is determined
    -
    assertions:
    -
    produce a boolean result when applied to an instance
    -
    annotations:
    -
    attach information to an instance for application use
    -
    applicators:
    -
    apply one or more subschemas to a particular location in the instance, and combine or modify their results
    -
    reserved locations:
    -
    do not directly affect results, but reserve a place for a specific purpose to ensure interoperability
    -
    - -

    -

    Keywords may fall into multiple categories, although applicators SHOULD only produce assertion results based on their subschemas' results. They should not define additional constraints independent of their subschemas.

    -

    Extension keywords, meaning those defined outside of this document and its companions, are free to define other behaviors as well.

    -

    A JSON Schema MAY contain properties which are not schema keywords. Unknown keywords SHOULD be ignored.

    -

    An empty schema is a JSON Schema with no properties, or only unknown properties.

    -

    -4.3.2. Boolean JSON Schemas

    -

    The boolean schema values "true" and "false" are trivial schemas that always produce themselves as assertions results, regardless of the instance value. They never produce annotation results.

    -

    These boolean schemas exist to clarify schema author intent and facilitate schema processing optimizations. They behave identically to the following schema objects (where "not" is part of the subschema application vocabulary defined in this document).

    - -
    -
    true:
    -
    Always passes validation, as if the empty schema {}
    -
    false:
    -
    Always fails validation, as if the schema { "not": {} }
    -
    - -

    While the empty schema object is unambiguous, there are many possible equivalents to the "false" schema. Using the boolean values ensures that the intent is clear to both human readers and implementations.

    -

    -4.3.3. Schema Vocabularies

    -

    A schema vocabulary, or simply a vocabulary, is a set of keywords, their syntax, and their semantics. A vocabulary is generally organized around a particular purpose. Different uses of JSON Schema, such as validation, hypermedia, or user interface generation, will involve different sets of vocabularies.

    -

    Vocabularies are the primary unit of re-use in JSON Schema, as schema authors can indicate what vocabularies are required or optional in order to process the schema. Since vocabularies are identified by URIs in the meta-schema, generic implementations can load extensions to support previously unknown vocabularies. While keywords can be supported outside of any vocabulary, there is no analogous mechanism to indicate individual keyword usage.

    -

    -4.3.4. Meta-Schemas

    -

    A schema that itself describes a schema is called a meta-schema. Meta-schemas are used to validate JSON Schemas and specify which vocabularies they are using.

    -

    Typically, a meta-schema will specify a set of vocabularies, and validate schemas that conform to the syntax of those vocabularies. However, meta-schemas and vocabularies are separate in order to allow meta-schemas to validate schema conformance more strictly or more loosely than the vocabularies' specifications call for. Meta-schemas may also describe and validate additional keywords that are not part of a formal vocabulary.

    -

    -4.3.5. Root Schema and Subschemas and Resources -

    -

    A JSON Schema resource is a schema which is canonically identified by an absolute URI.

    -

    The root schema is the schema that comprises the entire JSON document in question. The root schema is always a schema resource, where the URI is determined as described in section 8.2.1.

    -

    Some keywords take schemas themselves, allowing JSON Schemas to be nested:

    -
    -
    -{
    -    "title": "root",
    -    "items": {
    -        "title": "array item"
    -    }
    -}
    -
    -                        
    -

    In this example document, the schema titled "array item" is a subschema, and the schema titled "root" is the root schema.

    -

    As with the root schema, a subschema is either an object or a boolean.

    -

    As discussed in section 8.2.2, a JSON Schema document can contain multiple JSON Schema resources. When used without qualification, the term "root schema" refers to the document's root schema. In some cases, resource root schemas are discussed. A resource's root schema is its top-level schema object, which would also be a document root schema if the resource were to be extracted to a standalone JSON Schema document.

    -

    -5. Fragment Identifiers -

    -

    In accordance with section 3.1 of [RFC6839], the syntax and semantics of fragment identifiers specified for any +json media type SHOULD be as specified for "application/json". (At publication of this document, there is no fragment identification syntax defined for "application/json".)

    -

    Additionally, the "application/schema+json" media type supports two fragment identifier structures: plain names and JSON Pointers. The "application/schema-instance+json" media type supports one fragment identifier structure: JSON Pointers.

    -

    The use of JSON Pointers as URI fragment identifiers is described in RFC 6901. For "application/schema+json", which supports two fragment identifier syntaxes, fragment identifiers matching the JSON Pointer syntax, including the empty string, MUST be interpreted as JSON Pointer fragment identifiers.

    -

    Per the W3C's best practices for fragment identifiers, plain name fragment identifiers in "application/schema+json" are reserved for referencing locally named schemas. All fragment identifiers that do not match the JSON Pointer syntax MUST be interpreted as plain name fragment identifiers.

    -

    Defining and referencing a plain name fragment identifier within an "application/schema+json" document are specified in the "$anchor" keyword section.

    -

    -

    -6. General Considerations

    -

    -6.1. Range of JSON Values

    -

    An instance may be any valid JSON value as defined by JSON. JSON Schema imposes no restrictions on type: JSON Schema can describe any JSON value, including, for example, null.

    -

    -6.2. Programming Language Independence -

    -

    JSON Schema is programming language agnostic, and supports the full range of values described in the data model. Be aware, however, that some languages and JSON parsers may not be able to represent in memory the full range of values describable by JSON.

    -

    -6.3. Mathematical Integers -

    -

    Some programming languages and parsers use different internal representations for floating point numbers than they do for integers.

    -

    For consistency, integer JSON numbers SHOULD NOT be encoded with a fractional part.

    -

    -6.4. Regular Expressions -

    -

    Keywords MAY use regular expressions to express constraints, or constrain the instance value to be a regular expression. These regular expressions SHOULD be valid according to the regular expression dialect described in ECMA 262, section 15.10.1.

    -

    Furthermore, given the high disparity in regular expression constructs support, schema authors SHOULD limit themselves to the following regular expression tokens:

    - -
      -
    • individual Unicode characters, as defined by the JSON specification;
    • -
    • simple character classes ([abc]), range character classes ([a-z]);
    • -
    • complemented character classes ([^abc], [^a-z]);
    • -
    • simple quantifiers: "+" (one or more), "*" (zero or more), "?" (zero or one), and their lazy versions ("+?", "*?", "??");
    • -
    • range quantifiers: "{x}" (exactly x occurrences), "{x,y}" (at least x, at most y, occurrences), {x,} (x occurrences or more), and their lazy versions;
    • -
    • the beginning-of-input ("^") and end-of-input ("$") anchors;
    • -
    • simple grouping ("(...)") and alternation ("|").
    • -
    - -

    -

    Finally, implementations MUST NOT take regular expressions to be anchored, neither at the beginning nor at the end. This means, for instance, the pattern "es" matches "expression".

    -

    -6.5. Extending JSON Schema -

    -

    Additional schema keywords and schema vocabularies MAY be defined by any entity. Save for explicit agreement, schema authors SHALL NOT expect these additional keywords and vocabularies to be supported by implementations that do not explicitly document such support. Implementations SHOULD ignore keywords they do not support.

    -

    Implementations MAY provide the ability to register or load handlers for vocabularies that they do not support directly. The exact mechanism for registering and implementing such handlers is implementation-dependent.

    -

    -7. Keyword Behaviors

    -

    JSON Schema keywords fall into several general behavior categories. Assertions validate that an instance satisfies constraints, producing a boolean result. Annotations attach information that applications may use in any way they see fit. Applicators apply subschemas to parts of the instance and combine their results.

    -

    Extension keywords SHOULD stay within these categories, keeping in mind that annotations in particular are extremely flexible. Complex behavior is usually better delegated to applications on the basis of annotation data than implemented directly as schema keywords. However, extension keywords MAY define other behaviors for specialized purposes.

    -

    Evaluating an instance against a schema involves processing all of the keywords in the schema against the appropriate locations within the instance. Typically, applicator keywords are processed until a schema object with no applicators (and therefore no subschemas) is reached. The appropriate location in the instance is evaluated against the assertion and annotation keywords in the schema object, and their results are gathered into the parent schema according to the rules of the applicator.

    -

    Evaluation of a parent schema object can complete once all of its subschemas have been evaluated, although in some circumstances evaluation may be short-circuited due to assertion results. When annotations are being collected, some assertion result short-circuiting is not possible due to the need to examine all subschemas for annotation collection, including those that cannot further change the assertion result.

    -

    -7.1. Lexical Scope and Dynamic Scope -

    -

    While most JSON Schema keywords can be evaluated on their own, or at most need to take into account the values or results of adjacent keywords in the same schema object, a few have more complex behavior.

    -

    The lexical scope of a keyword is determined by the nested JSON data structure of objects and arrays. The largest such scope is an entire schema document. The smallest scope is a single schema object with no subschemas.

    -

    Keywords MAY be defined with a partial value, such as a URI-reference, which must be resolved against another value, such as another URI-reference or a full URI, which is found through the lexical structure of the JSON document. The "$id" core keyword and the "base" JSON Hyper-Schema keyword are examples of this sort of behavior. Additionally, "$ref" and "$recursiveRef" from this specification resolve their values in this way, although they do not change how further values are resolved.

    -

    Note that some keywords, such as "$schema", apply to the lexical scope of the entire schema document, and therefore MUST only appear in a schema resource's root schema.

    -

    Other keywords may take into account the dynamic scope that exists during the evaluation of a schema, typically together with an instance document. The outermost dynamic scope is the root schema of the schema document in which processing begins. The path from this root schema to any particular keyword (that includes any "$ref" and "$recursiveRef" keywords that may have been resolved) is considered the keyword's "validation path." [CREF1]Or should this be the schema object at which processing begins, even if it is not a root? This has some implications for the case where "$recursiveAnchor" is only allowed in the root schema but processing begins in a subschema.

    -

    Lexical and dynamic scopes align until a reference keyword is encountered. While following the reference keyword moves processing from one lexical scope into a different one, from the perspective of dynamic scope, following reference is no different from descending into a subschema present as a value. A keyword on the far side of that reference that resolves information through the dynamic scope will consider the originating side of the reference to be their dynamic parent, rather than examining the local lexically enclosing parent.

    -

    The concept of dynamic scope is primarily used with "$recursiveRef" and "$recursiveAnchor", and should be considered an advanced feature and used with caution when defining additional keywords. It also appears when reporting errors and collected annotations, as it may be possible to revisit the same lexical scope repeatedly with different dynamic scopes. In such cases, it is important to inform the user of the dynamic path that produced the error or annotation.

    -

    -7.2. Keyword Interactions

    -

    Keyword behavior MAY be defined in terms of the annotation results of subschemas and/or adjacent keywords. Such keywords MUST NOT result in a circular dependency. Keywords MAY modify their behavior based on the presence or absence of another keyword in the same schema object.

    -

    -7.3. Default Behaviors

    -

    A missing keyword MUST NOT produce a false assertion result, MUST NOT produce annotation results, and MUST NOT cause any other schema to be evaluated as part of its own behavioral definition. However, given that missing keywords do not contribute annotations, the lack of annotation results may indirectly change the behavior of other keywords.

    -

    In some cases, the missing keyword assertion behavior of a keyword is identical to that produced by a certain value, and keyword definitions SHOULD note such values where known. However, even if the value which produces the default behavior would produce annotation results if present, the default behavior still MUST NOT result in annotations.

    -

    Because annotation collection can add significant cost in terms of both computation and memory, implementations MAY opt out of this feature. Keywords known to an implementation to have assertion or applicator behavior that depend on annotation results MUST then be treated as errors, unless an alternate implementation producing the same behavior is available. Keywords of this sort SHOULD describe reasonable alternate approaches when appropriate. This approach is demonstrated by the "additionalItems" and "additionalProperties" keywords in this document.

    -

    -7.4. Identifiers -

    -

    Identifiers set the canonical URI of a schema, or affect how such URIs are resolved in references, or both. The Core vocabulary defined in this document defines several identifying keywords, most notably "$id".

    -

    Canonical schema URIs MUST NOT change while processing an instance, but keywords that affect URI-reference resolution MAY have behavior that is only fully determined at runtime.

    -

    While custom identifier keywords are possible, vocabulary designers should take care not to disrupt the functioning of core keywords. For example, the "$recursiveAnchor" keyword in this specification limits its URI resolution effects to the matching "$recursiveRef" keyword, leaving "$ref" undisturbed.

    -

    -7.5. Applicators -

    -

    Applicators allow for building more complex schemas than can be accomplished with a single schema object. Evaluation of an instance against a schema document begins by applying the root schema to the complete instance document. From there, keywords known as applicators are used to determine which additional schemas are applied. Such schemas may be applied in-place to the current location, or to a child location.

    -

    The schemas to be applied may be present as subschemas comprising all or part of the keyword's value. Alternatively, an applicator may refer to a schema elsewhere in the same schema document, or in a different one. The mechanism for identifying such referenced schemas is defined by the keyword.

    -

    Applicator keywords also define how subschema or referenced schema boolean assertion results are modified and/or combined to produce the boolean result of the applicator. Applicators may apply any boolean logic operation to the assertion results of subschemas, but MUST NOT introduce new assertion conditions of their own.

    -

    Annotation results are combined according to the rules specified by each annotation keyword.

    -

    -7.5.1. Referenced and Referencing Schemas -

    -

    As noted in Section 7.5, an applicator keyword may refer to a schema to be applied, rather than including it as a subschema in the applicator's value. In such situations, the schema being applied is known as the referenced schema, while the schema containing the applicator keyword is the referencing schema.

    -

    While root schemas and subschemas are static concepts based on a schema's position within a schema document, referenced and referencing schemas are dynamic. Different pairs of schemas may find themselves in various referenced and referencing arrangements during the evaluation of an instance against a schema.

    -

    For some by-reference applicators, such as "$ref", the referenced schema can be determined by static analysis of the schema document's lexical scope. Others, such as "$recursiveRef" and "$recursiveAnchor", may make use of dynamic scoping, and therefore only be resolvable in the process of evaluating the schema with an instance.

    -

    -7.6. Assertions -

    -

    JSON Schema can be used to assert constraints on a JSON document, which either passes or fails the assertions. This approach can be used to validate conformance with the constraints, or document what is needed to satisfy them.

    -

    JSON Schema implementations produce a single boolean result when evaluating an instance against schema assertions.

    -

    An instance can only fail an assertion that is present in the schema.

    -

    -7.6.1. Assertions and Instance Primitive Types

    -

    Most assertions only constrain values within a certain primitive type. When the type of the instance is not of the type targeted by the keyword, the instance is considered to conform to the assertion.

    -

    For example, the "maxLength" keyword from the companion validation vocabulary: will only restrict certain strings (that are too long) from being valid. If the instance is a number, boolean, null, array, or object, then it is valid against this assertion.

    -

    This behavior allows keywords to be used more easily with instances that can be of multiple primitive types. The companion validation vocabulary also includes a "type" keyword which can independently restrict the instance to one or more primitive types. This allows for a concise expression of use cases such as a function that might return either a string of a certain length or a null value:

    -
    -
    -{
    -    "type": ["string", "null"],
    -    "maxLength": 255
    -}
    -
    -                        
    -

    If "maxLength" also restricted the instance type to be a string, then this would be substantially more cumbersome to express because the example as written would not actually allow null values. Each keyword is evaluated separately unless explicitly specified otherwise, so if "maxLength" restricted the instance to strings, then including "null" in "type" would not have any useful effect.

    -

    -7.7. Annotations -

    -

    JSON Schema can annotate an instance with information, whenever the instance validates against the schema object containing the annotation, and all of its parent schema objects. The information can be a simple value, or can be calculated based on the instance contents.

    -

    Annotations are attached to specific locations in an instance. Since many subschemas can be applied to any single location, annotation keywords need to specify any unusual handling of multiple applicable occurrences of the keyword with different values.

    -

    Unlike assertion results, annotation data can take a wide variety of forms, which are provided to applications to use as they see fit. JSON Schema implementations are not expected to make use of the collected information on behalf of applications.

    -

    Unless otherwise specified, the value of an annotation keyword's annotation is the keyword's value. However, other behaviors are possible. For example, JSON Hyper-Schema's "links" keyword is a complex annotation that produces a value based in part on the instance data.

    -

    While "short-circuit" evaluation is possible for assertions, collecting annotations requires examining all schemas that apply to an instance location, even if they cannot change the overall assertion result. The only exception is that subschemas of a schema object that has failed validation MAY be skipped, as annotations are not retained for failing schemas.

    -

    -7.7.1. Collecting Annotations

    -

    Annotations are collected by keywords that explicitly define annotation-collecting behavior. Note that boolean schemas cannot produce annotations as they do not make use of keywords.

    -

    A collected annotation MUST include the following information:

    - -
      -
    • The name of the keyword that produces the annotation
    • -
    • The instance location to which it is attached, as a JSON Pointer
    • -
    • The schema location path, indicating how reference keywords such as "$ref" were followed to reach the absolute schema location.
    • -
    • The absolute schema location of the attaching keyword, as a URI. This MAY be omitted if it is the same as the schema location path from above.
    • -
    • The attached value(s)
    • -
    - -

    -

    If the same keyword attaches values from multiple schema locations to the same instance location, and the annotation defines a process for combining such values, then the combined value MUST also be associated with the instance location. The output formats described in this specification that include annotation information meet this requirement.

    -

    -7.7.1.1. Distinguishing Among Multiple Values

    -

    Applications MAY make decisions on which of multiple annotation values to use based on the schema location that contributed the value. This is intended to allow flexible usage. Collecting the schema location facilitates such usage.

    -

    For example, consider this schema, which uses annotations and assertions from the Validation specification:

    -

    Note that some lines are wrapped for clarity.

    -
    -
    -{
    -    "title": "Feature list",
    -    "type": "array",
    -    "items": [
    -        {
    -            "title": "Feature A",
    -            "properties": {
    -                "enabled": {
    -                    "$ref": "#/$defs/enabledToggle",
    -                    "default": true
    -                }
    -            }
    -        },
    -        {
    -            "title": "Feature B",
    -            "properties": {
    -                "enabled": {
    -                    "description": "If set to null, Feature B
    -                                    inherits the enabled
    -                                    value from Feature A",
    -                    "$ref": "#/$defs/enabledToggle"
    -                }
    -            }
    -        }
    -    ],
    -    "$defs": {
    -        "enabledToggle": {
    -            "title": "Enabled",
    -            "description": "Whether the feature is enabled (true),
    -                            disabled (false), or under
    -                            automatic control (null)",
    -            "type": ["boolean", "null"],
    -            "default": null
    -        }
    -    }
    -}
    -
    -                            
    -

    In this example, both Feature A and Feature B make use of the re-usable "enabledToggle" schema. That schema uses the "title", "description", and "default" annotations, none of which define special behavior for handling multiple values. Therefore the application has to decide how to handle the additional "default" value for Feature A, and the additional "description" value for Feature B.

    -

    The application programmer and the schema author need to agree on the usage. For this example, let's assume that they agree that the most specific "default" value will be used, and any additional, more generic "default" values will be silently ignored. Let's also assume that they agree that all "description" text is to be used, starting with the most generic, and ending with the most specific. This requires the schema author to write descriptions that work when combined in this way.

    -

    The application can use the schema location path to determine which values are which. The values in the feature's immediate "enabled" property schema are more specific, while the values under the re-usable schema that is referenced to with "$ref" are more generic. The schema location path will show whether each value was found by crossing a "$ref" or not.

    -

    Feature A will therefore use a default value of true, while Feature B will use the generic default value of null. Feature A will only have the generic description from the "enabledToggle" schema, while Feature B will use that description, and also append its locally defined description that explains how to interpret a null value.

    -

    Note that there are other reasonable approaches that a different application might take. For example, an application may consider the presence of two different values for "default" to be an error, regardless of their schema locations.

    -

    -7.7.1.2. Annotations and Assertions

    -

    Schema objects that produce a false assertion result MUST NOT produce any annotation results, whether from their own keywords or from keywords in subschemas.

    -

    Note that the overall schema results may still include annotations collected from other schema locations. Given this schema:

    -
    -
    -{
    -    "oneOf": [
    -        {
    -            "title": "Integer Value",
    -            "type": "integer"
    -        },
    -        {
    -            "title": "String Value",
    -            "type": "string"
    -        }
    -    ]
    -}
    -
    -                            
    -

    And the instance "This is a string", the title annotation "Integer Value" is discarded because the type assertion in that schema object fails. The title annotation "String Value" is kept, as the instance passes the string type assertions.

    -

    -7.7.1.3. Annotations and Applicators

    -

    In addition to possibly defining annotation results of their own, applicator keywords aggregate the annotations collected in their subschema(s) or referenced schema(s). The rules for aggregating annotation values are defined by each annotation keyword, and are not directly affected by the logic used for combining assertion results.

    -

    -7.8. Reserved Locations

    -

    A fourth category of keywords simply reserve a location to hold re-usable components or data of interest to schema authors that is not suitable for re-use. These keywords do not affect validation or annotation results. Their purpose in the core vocabulary is to ensure that locations are available for certain purposes and will not be redefined by extension keywords.

    -

    While these keywords do not directly affect results, as explained in section 8.2.4.4 unrecognized extension keywords that reserve locations for re-usable schemas may have undesirable interactions with references in certain circumstances.

    -

    -8. The JSON Schema Core Vocabulary

    -

    Keywords declared in this section, which all begin with "$", make up the JSON Schema Core vocabulary. These keywords are either required in order process any schema or meta-schema, including those split across multiple documents, or exist to reserve keywords for purposes that require guaranteed interoperability.

    -

    The Core vocabulary MUST be considered mandatory at all times, in order to bootstrap the processing of further vocabularies. Meta-schemas that use the "$vocabulary" keyword to declare the vocabularies in use MUST explicitly list the Core vocabulary, which MUST have a value of true indicating that it is required.

    -

    The behavior of a false value for this vocabulary (and only this vocabulary) is undefined, as is the behavior when "$vocabulary" is present but the Core vocabulary is not included. However, it is RECOMMENDED that implementations detect these cases and raise an error when they occur. It is not meaningful to declare that a meta-schema optionally uses Core.

    -

    Meta-schemas that do not use "$vocabulary" MUST be considered to require the Core vocabulary as if its URI were present with a value of true.

    -

    The current URI for the Core vocabulary is: <https://json-schema.org/draft/2019-09/vocab/core>.

    -

    The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-09/meta/core>.

    -

    While the "$" prefix is not formally reserved for the Core vocabulary, it is RECOMMENDED that extension keywords (in vocabularies or otherwise) begin with a character other than "$" to avoid possible future collisions.

    -

    -8.1. Meta-Schemas and Vocabularies -

    -

    Two concepts, meta-schemas and vocabularies, are used to inform an implementation how to interpret a schema. Every schema has a meta-schema, which can be declared using the "$schema" keyword.

    -

    The meta-schema serves two purposes:

    - -
    -
    Declaring the vocabularies in use
    -
    The "$vocabulary" keyword, when it appears in a meta-schema, declares which vocabularies are available to be used in schemas that refer to that meta-schema. Vocabularies define keyword semantics, as well as their general syntax.
    -
    Describing valid schema syntax
    -
    A schema MUST successfully validate against its meta-schema, which constrains the syntax of the available keywords. The syntax described is expected to be compatible with the vocabularies declared; while it is possible to describe an incompatible syntax, such a meta-schema would be unlikely to be useful.
    -
    - -

    -

    Meta-schemas are separate from vocabularies to allow for vocabularies to be combined in different ways, and for meta-schema authors to impose additional constraints such as forbidding certain keywords, or performing unusually strict syntactical validation, as might be done during a development and testing cycle. Each vocabulary typically identifies a meta-schema consisting only of the vocabulary's keywords.

    -

    Meta-schema authoring is an advanced usage of JSON Schema, so the design of meta-schema features emphasizes flexibility over simplicity.

    -

    -8.1.1. The "$schema" Keyword

    -

    The "$schema" keyword is both used as a JSON Schema feature set identifier and as the identifier of a resource which is itself a JSON Schema, which describes the set of valid schemas written for this particular feature set.

    -

    The value of this keyword MUST be a URI (containing a scheme) and this URI MUST be normalized. The current schema MUST be valid against the meta-schema identified by this URI.

    -

    If this URI identifies a retrievable resource, that resource SHOULD be of media type "application/schema+json".

    -

    The "$schema" keyword SHOULD be used in a resource root schema. It MUST NOT appear in resource subschemas. If absent from the root schema, the resulting behavior is implementation-defined.

    -

    If multiple schema resources are present in a single document, then all schema resources SHOULD Have the same value for "$schema". The result of differing values for "$schema" within the same schema document is implementation-defined. [CREF2]Using multiple "$schema" keywords in the same document would imply that the feature set and therefore behavior can change within a document. This would necessitate resolving a number of implementation concerns that have not yet been clearly defined. So, while the pattern of using "$schema" only in root schemas is likely to remain the best practice for schema authoring, implementation behavior is subject to be revised or liberalized in future drafts. [CREF3]The exception made for embedded schema resources is to allow bundling multiple schema resources into a single schema document without needing to change their contents, as described later in this specification.

    -

    Values for this property are defined elsewhere in this and other documents, and by other parties.

    -

    -8.1.2. The "$vocabulary" Keyword

    -

    The "$vocabulary" keyword is used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema. It is also used to indicate whether each vocabulary is required or optional, in the sense that an implementation MUST understand the required vocabularies in order to successfully process the schema.

    -

    The value of this keyword MUST be an object. The property names in the object MUST be URIs (containing a scheme) and this URI MUST be normalized. Each URI that appears as a property name identifies a specific set of keywords and their semantics.

    -

    The URI MAY be a URL, but the nature of the retrievable resource is currently undefined, and reserved for future use. Vocabulary authors MAY use the URL of the vocabulary specification, in a human-readable media type such as text/html or text/plain, as the vocabulary URI. [CREF4]Vocabulary documents may be added in forthcoming drafts. For now, identifying the keyword set is deemed sufficient as that, along with meta-schema validation, is how the current "vocabularies" work today. Any future vocabulary document format will be specified as a JSON document, so using text/html or other non-JSON formats in the meantime will not produce any future ambiguity.

    -

    The values of the object properties MUST be booleans. If the value is true, then implementations that do not recognize the vocabulary MUST refuse to process any schemas that declare this meta-schema with "$schema". If the value is false, implementations that do not recognize the vocabulary SHOULD proceed with processing such schemas.

    -

    Per 6.5, unrecognized keywords SHOULD be ignored. This remains the case for keywords defined by unrecognized vocabularies. It is not currently possible to distinguish between unrecognized keywords that are defined in vocabularies from those that are not part of any vocabulary.

    -

    The "$vocabulary" keyword SHOULD be used in the root schema of any schema document intended for use as a meta-schema. It MUST NOT appear in subschemas.

    -

    The "$vocabulary" keyword MUST be ignored in schema documents that are not being processed as a meta-schema. This allows validating a meta-schema M against its own meta-schema M' without requiring the validator to understand the vocabularies declared by M.

    -

    -8.1.2.1. Default vocabularies

    -

    If "$vocabulary" is absent, an implementation MAY determine behavior based on the meta-schema if it is recognized from the URI value of the referring schema's "$schema" keyword. This is how behavior (such as Hyper-Schema usage) has been recognized prior to the existence of vocabularies.

    -

    If the meta-schema, as referenced by the schema, is not recognized, or is missing, then the behavior is implementation-defined. If the implementation proceeds with processing the schema, it MUST assume the use of the core vocabulary. If the implementation is built for a specific purpose, then it SHOULD assume the use of all of the most relevant vocabularies for that purpose.

    -

    For example, an implementation that is a validator SHOULD assume the use of all vocabularies in this specification and the companion Validation specification.

    -

    -8.1.2.2. Non-inheritability of vocabularies

    -

    Note that the processing restrictions on "$vocabulary" mean that meta-schemas that reference other meta-schemas using "$ref" or similar keywords do not automatically inherit the vocabulary declarations of those other meta-schemas. All such declarations must be repeated in the root of each schema document intended for use as a meta-schema. This is demonstrated in the example meta-schema. [CREF5]This requirement allows implementations to find all vocabulary requirement information in a single place for each meta-schema. As schema extensibility means that there are endless potential ways to combine more fine-grained meta-schemas by reference, requiring implementations to anticipate all possibilities and search for vocabularies in referenced meta-schemas would be overly burdensome.

    -

    -8.1.3. Updates to Meta-Schema and Vocabulary URIs

    -

    Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations SHOULD consider URIs dated after this specification draft and before the next to indicate the same syntax and semantics as those listed here.

    -

    -8.1.4. Detecting a Meta-Schema

    -

    Implementations MUST recognize a schema as a meta-schema if it is being examined because it was identified as such by another schema's "$schema" keyword. This means that a single schema document might sometimes be considered a regular schema, and other times be considered a meta-schema.

    -

    In the case of examining a schema which is its own meta-schema, when an implementation begins processing it as a regular schema, it is processed under those rules. However, when loaded a second time as a result of checking its own "$schema" value, it is treated as a meta-schema. So the same document is processed both ways in the course of one session.

    -

    Implementations MAY allow a schema to be explicitly passed as a meta-schema, for implementation-specific purposes, such as pre-loading a commonly used meta-schema and checking its vocabulary support requirements up front. Meta-schema authors MUST NOT expect such features to be interoperable across implementations.

    -

    -8.2. Base URI, Anchors, and Dereferencing

    -

    To differentiate between schemas in a vast ecosystem, schemas are identified by URI, and can embed references to other schemas by specifying their URI.

    -

    Several keywords can accept a relative URI-reference, or a value used to construct a relative URI-reference. For these keywords, it is necessary to establish a base URI in order to resolve the reference.

    -

    -8.2.1. Initial Base URI -

    -

    RFC3986 Section 5.1 defines how to determine the default base URI of a document.

    -

    Informatively, the initial base URI of a schema is the URI at which it was found, whether that was a network location, a local filesystem, or any other situation identifiable by a URI of any known scheme.

    -

    If a schema document defines no explicit base URI with "$id" (embedded in content), the base URI is that determined per RFC 3986 section 5.

    -

    If no source is known, or no URI scheme is known for the source, a suitable implementation-specific default URI MAY be used as described in RFC 3986 Section 5.1.4. It is RECOMMENDED that implementations document any default base URI that they assume.

    -

    Unless the "$id" keyword described in the next section is present in the root schema, this base URI SHOULD be considered the canonical URI of the schema document's root schema resource.

    -

    -8.2.2. The "$id" Keyword -

    -

    The "$id" keyword identifies a schema resource with its canonical URI.

    -

    Note that this URI is an identifier and not necessarily a network locator. In the case of a network-addressable URL, a schema need not be downloadable from its canonical URI.

    -

    If present, the value for this keyword MUST be a string, and MUST represent a valid URI-reference. This URI-reference SHOULD be normalized, and MUST resolve to an absolute-URI (without a fragment). Therefore, "$id" MUST NOT contain a non-empty fragment, and SHOULD NOT contain an empty fragment.

    -

    Since an empty fragment in the context of the application/schema+json media type refers to the same resource as the base URI without a fragment, an implementation MAY normalize a URI ending with an empty fragment by removing the fragment. However, schema authors SHOULD NOT rely on this behavior across implementations. [CREF6]This is primarily allowed because older meta-schemas have an empty fragment in their $id (or previously, id). A future draft may outright forbid even empty fragments in "$id".

    -

    This URI also serves as the base URI for relative URI-references in keywords within the schema resource, in accordance with RFC 3986 section 5.1.1 regarding base URIs embedded in content.

    -

    The presence of "$id" in a subschema indicates that the subschema constitutes a distinct schema resource within a single schema document. Furthermore, in accordance with RFC 3986 section 5.1.2 regarding encapsulating entities, if an "$id" in a subschema is a relative URI-reference, the base URI for resolving that reference is the URI of the parent schema resource.

    -

    If no parent schema object explicitly identifies itself as a resource with "$id", the base URI is that of the entire document, as established by the steps given in the previous section.

    -

    -8.2.2.1. Identifying the root schema

    -

    The root schema of a JSON Schema document SHOULD contain an "$id" keyword with an absolute-URI (containing a scheme, but no fragment).

    -

    -8.2.2.2. JSON Pointer fragments and embedded schema resources -

    -

    Since JSON Pointer URI fragments are constructed based on the structure of the schema document, an embedded schema resource and its subschemas can be identified by JSON Pointer fragments relative to either its own canonical URI, or relative to the containing resource's URI.

    -

    Conceptually, a set of linked schema resources should behave identically whether each resource is a separate document connected with schema references, or is structured as a single document with one or more schema resources embedded as subschemas.

    -

    Since URIs involving JSON Pointer fragments relative to the parent schema resource's URI cease to be valid when the embedded schema is moved to a separate document and referenced, applications and schemas SHOULD NOT use such URIs to identify embedded schema resources or locations within them.

    -

    Consider the following schema document that contains another schema resource embedded within it:

    -
    -
    -{
    -  "$id": "https://example.com/foo",
    -  "items": {
    -    "$id": "https://example.com/bar",
    -    "additionalProperties": { }
    -  }
    -}
    -
    -                            
    -

    The URI "https://example.com/foo#/items/additionalProperties" points to the schema of the "additionalProperties" keyword in the embedded resource. The canonical URI of that schema, however, is "https://example.com/bar#/additionalProperties".

    -

    Now consider the following two schema resources linked by reference using a URI value for "$ref":

    -
    -
    -{
    -  "$id": "https://example.com/foo",
    -  "items": {
    -    "$ref": "bar"
    -  }
    -}
    -
    -{
    -  "$id": "https://example.com/bar",
    -  "additionalProperties": { }
    -}
    -
    -                            
    -

    Here we see that the canonical URI for that "additionalProperties" subschema is still valid, while the non-canonical URI with the fragment beginning with "#/items/$ref" now resolves to nothing.

    -

    Note also that "https://example.com/foo#/items" is valid in both arrangments, but resolves to a different value. This URI ends up functioning similarly to a retrieval URI for a resource. While valid, examining the resolved value and either using the "$id" (if the value is a subschema), or resolving the reference and using the "$id" of the reference target, is preferable.

    -

    An implementation MAY choose not to support addressing schemas by non-canonical URIs. As such, it is RECOMENDED that schema authors only use canonical URIs, as using non-canonical URIs may reduce schema interoperability. [CREF7]This is to avoid requiring implementations to keep track of a whole stack of possible base URIs and JSON Pointer fragments for each, given that all but one will be fragile if the schema resources are reorganized. Some have argued that this is easy so there is no point in forbidding it, while others have argued that it complicates schema identification and should be forbidden. Feedback on this topic is encouraged.

    -

    Further examples of such non-canonical URIs, as well as the appropriate canonical URIs to use instead, are provided in appendix A.

    -

    -8.2.3. Defining location-independent identifiers with "$anchor" -

    -

    Using JSON Pointer fragments requires knowledge of the structure of the schema. When writing schema documents with the intention to provide re-usable schemas, it may be preferable to use a plain name fragment that is not tied to any particular structural location. This allows a subschema to be relocated without requiring JSON Pointer references to be updated.

    -

    The "$anchor" keyword is used to specify such a fragment. It is an identifier keyword that can only be used to create plain name fragments.

    -

    If present, the value of this keyword MUST be a string, which MUST start with a letter ([A-Za-z]), followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), or periods ("."). [CREF8]Note that the anchor string does not include the "#" character, as it is not a URI-reference. An "$anchor": "foo" becomes the fragment "#foo" when used in a URI. See below for full examples.

    -

    The base URI to which the resulting fragment is appended is determined by the "$id" keyword as explained in the previous section. Two "$anchor" keywords in the same schema document MAY have the same value if they apply to different base URIs, as the resulting full URIs will be distinct. However, the effect of two "$anchor" keywords with the same value and the same base URI is undefined. Implementations MAY raise an error if such usage is detected.

    -

    -8.2.4. Schema References -

    -

    Several keywords can be used to reference a schema which is to be applied to the current instance location. "$ref" and "$recursiveRef" are applicator keywords, applying the referenced schema to the instance. "$recursiveAnchor" is an identifier keyword that controls how the base URI for resolving the URI-reference value of "$recursiveRef is determined.

    -

    As the values of "$ref" and "$recursiveRef" are URI References, this allows the possibility to externalise or divide a schema across multiple files, and provides the ability to validate recursive structures through self-reference.

    -

    The resolved URI produced by these keywords is not necessarily a network locator, only an identifier. A schema need not be downloadable from the address if it is a network-addressable URL, and implementations SHOULD NOT assume they should perform a network operation when they encounter a network-addressable URI.

    -

    -8.2.4.1. Direct References with "$ref" -

    -

    The "$ref" keyword is an applicator that is used to reference a statically identified schema. Its results are the results of the referenced schema. [CREF9]Note that this definition of how the results are determined means that other keywords can appear alongside of "$ref" in the same schema object.

    -

    The value of the "$ref" property MUST be a string which is a URI-Reference. Resolved against the current URI base, it produces the URI of the schema to apply.

    -

    -8.2.4.2. Recursive References with "$recursiveRef" and "$recursiveAnchor" -

    -

    The "$recursiveRef" and "$recursiveAnchor" keywords are used to construct extensible recursive schemas. A recursive schema is one that has a reference to its own root, identified by the empty fragment URI reference ("#").

    -

    Simply stated, a "$recursiveRef" behaves identically to "$ref", except when its target schema contains "$recursiveAnchor" with a value of true. In that case, the dynamic scope is examined to determine a new base URI, and the URI-reference in "$recursiveRef" is re-evaluated against that base URI. Unlike base URI changes with "$id", changes with "$recursiveAnchor" are calculated each time a "$recursiveRef" is resolved, and do not impact any other keywords.

    -

    For an example using these keyword, see appendix C. [CREF10]The difference between the hyper-schema meta-schema in previous drafts and an this draft dramatically demonstrates the utility of these keywords.

    -

    -8.2.4.2.1. Dynamically recursive references with "$recursiveRef"

    -

    The value of the "$recursiveRef" property MUST be a string which is a URI-reference. It is a by-reference applicator that uses a dynamically calculated base URI to resolve its value.

    -

    The behavior of this keyword is defined only for the value "#". Implementations MAY choose to consider other values to be errors. [CREF11]This restriction may be relaxed in the future, but to date only the value "#" has a clear use case.

    -

    The value of "$recursiveRef" is initially resolved against the current base URI, in the same manner as for "$ref".

    -

    The schema identified by the resulting URI is examined for the presence of "$recursiveAnchor", and a new base URI is calculated as described for that keyword in the following section.

    -

    Finally, the value of "$recursiveRef" is resolved against the new base URI determined according to "$recursiveAnchor" producing the final resolved reference URI.

    -

    Note that in the absence of "$recursiveAnchor" (and in some cases when it is present), "$recursiveRef"'s behavior is identical to that of "$ref".

    -

    As with "$ref", the results of this keyword are the results of the referenced schema.

    -

    -8.2.4.2.2. Enabling Recursion with "$recursiveAnchor"

    -

    The value of the "$recursiveAnchor" property MUST be a boolean.

    -

    "$recursiveAnchor" is used to dynamically identify a base URI at runtime for "$recursiveRef" by marking where such a calculation can start, and where it stops. This keyword MUST NOT affect the base URI of other keywords, unless they are explicitly defined to rely on it.

    -

    If set to true, then when the containing schema object is used as a target of "$recursiveRef", a new base URI is determined by examining the dynamic scope for the outermost schema that also contains "$recursiveAnchor" with a value of true. The base URI of that schema is then used as the dynamic base URI.

    -

    If no such schema exists, then the base URI is unchanged.

    -

    If this keyword is set to false, the base URI is unchanged.

    -

    Omitting this keyword has the same behavior as a value of false.

    -

    -8.2.4.3. Guarding Against Infinite Recursion

    -

    A schema MUST NOT be run into an infinite loop against an instance. For example, if two schemas "#alice" and "#bob" both have an "allOf" property that refers to the other, a naive validator might get stuck in an infinite recursive loop trying to validate the instance. Schemas SHOULD NOT make use of infinite recursive nesting like this; the behavior is undefined.

    -

    -8.2.4.4. References to Possible Non-Schemas -

    -

    Subschema objects (or booleans) are recognized by their use with known applicator keywords or with location-reserving keywords such as "$defs" that take one or more subschemas as a value. These keywords may be "$defs" and the standard applicators from this document, or extension keywords from a known vocabulary, or implementation-specific custom keywords.

    -

    Multi-level structures of unknown keywords are capable of introducing nested subschemas, which would be subject to the processing rules for "$id". Therefore, having a reference target in such an unrecognized structure cannot be reliably implemented, and the resulting behavior is undefined. Similarly, a reference target under a known keyword, for which the value is known not to be a schema, results in undefined behavior in order to avoid burdening implementations with the need to detect such targets. [CREF12]These scenarios are analogous to fetching a schema over HTTP but receiving a response with a Content-Type other than application/schema+json. An implementation can certainly try to interpret it as a schema, but the origin server offered no guarantee that it actually is any such thing. Therefore, interpreting it as such has security implications and may produce unpredictable results.

    -

    Note that single-level custom keywords with identical syntax and semantics to "$defs" do not allow for any intervening "$id" keywords, and therefore will behave correctly under implementations that attempt to use any reference target as a schema. However, this behavior is implementation-specific and MUST NOT be relied upon for interoperability.

    -

    -8.2.4.5. Loading a referenced schema

    -

    The use of URIs to identify remote schemas does not necessarily mean anything is downloaded, but instead JSON Schema implementations SHOULD understand ahead of time which schemas they will be using, and the URIs that identify them.

    -

    When schemas are downloaded, for example by a generic user-agent that doesn't know until runtime which schemas to download, see Usage for Hypermedia.

    -

    Implementations SHOULD be able to associate arbitrary URIs with an arbitrary schema and/or automatically associate a schema's "$id"-given URI, depending on the trust that the validator has in the schema. Such URIs and schemas can be supplied to an implementation prior to processing instances, or may be noted within a schema document as it is processed, producing associations as shown in appendix A.

    -

    A schema MAY (and likely will) have multiple URIs, but there is no way for a URI to identify more than one schema. When multiple schemas try to identify as the same URI, validators SHOULD raise an error condition.

    -

    -8.2.4.6. Dereferencing

    -

    Schemas can be identified by any URI that has been given to them, including a JSON Pointer or their URI given directly by "$id". In all cases, dereferencing a "$ref" reference involves first resolving its value as a URI reference against the current base URI per RFC 3986.

    -

    If the resulting URI identifies a schema within the current document, or within another schema document that has been made available to the implementation, then that schema SHOULD be used automatically.

    -

    For example, consider this schema:

    -
    -
    -{
    -    "$id": "https://example.net/root.json",
    -    "items": {
    -        "type": "array",
    -        "items": { "$ref": "#item" }
    -    },
    -    "$defs": {
    -        "single": {
    -            "$anchor": "item",
    -            "type": "object",
    -            "additionalProperties": { "$ref": "other.json" }
    -        }
    -    }
    -}
    -
    -                            
    -

    When an implementation encounters the <#/$defs/single> schema, it resolves the "$id" URI reference against the current base URI to form <https://example.net/root.json#item>.

    -

    When an implementation then looks inside the <#/items> schema, it encounters the <#item> reference, and resolves this to <https://example.net/root.json#item>, which it has seen defined in this same document and can therefore use automatically.

    -

    When an implementation encounters the reference to "other.json", it resolves this to <https://example.net/other.json>, which is not defined in this document. If a schema with that identifier has otherwise been supplied to the implementation, it can also be used automatically. [CREF13]What should implementations do when the referenced schema is not known? Are there circumstances in which automatic network dereferencing is allowed? A same origin policy? A user-configurable option? In the case of an evolving API described by Hyper-Schema, it is expected that new schemas will be added to the system dynamically, so placing an absolute requirement of pre-loading schema documents is not feasible.

    -

    -8.2.5. Schema Re-Use With "$defs" -

    -

    The "$defs" keyword reserves a location for schema authors to inline re-usable JSON Schemas into a more general schema. The keyword does not directly affect the validation result.

    -

    This keyword's value MUST be an object. Each member value of this object MUST be a valid JSON Schema.

    -
    -
    -{
    -    "type": "array",
    -    "items": { "$ref": "#/$defs/positiveInteger" },
    -    "$defs": {
    -        "positiveInteger": {
    -            "type": "integer",
    -            "exclusiveMinimum": 0
    -        }
    -    }
    -}
    -
    -                            
    -

    As an example, here is a schema describing an array of positive integers, where the positive integer constraint is a subschema in "$defs":

    -

    -8.3. Comments With "$comment"

    -

    This keyword reserves a location for comments from schema authors to readers or maintainers of the schema.

    -

    The value of this keyword MUST be a string. Implementations MUST NOT present this string to end users. Tools for editing schemas SHOULD support displaying and editing this keyword. The value of this keyword MAY be used in debug or error output which is intended for developers making use of schemas.

    -

    Schema vocabularies SHOULD allow "$comment" within any object containing vocabulary keywords. Implementations MAY assume "$comment" is allowed unless the vocabulary specifically forbids it. Vocabularies MUST NOT specify any effect of "$comment" beyond what is described in this specification.

    -

    Tools that translate other media types or programming languages to and from application/schema+json MAY choose to convert that media type or programming language's native comments to or from "$comment" values. The behavior of such translation when both native comments and "$comment" properties are present is implementation-dependent.

    -

    Implementations SHOULD treat "$comment" identically to an unknown extension keyword. They MAY strip "$comment" values at any point during processing. In particular, this allows for shortening schemas when the size of deployed schemas is a concern.

    -

    Implementations MUST NOT take any other action based on the presence, absence, or contents of "$comment" properties. In particular, the value of "$comment" MUST NOT be collected as an annotation result.

    -

    -9. A Vocabulary for Applying Subschemas

    -

    This section defines a vocabulary of applicator keywords that are RECOMMENDED for use as the basis of other vocabularies.

    -

    Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

    -

    The current URI for this vocabulary, known as the Applicator vocabulary, is: <https://json-schema.org/draft/2019-09/vocab/applicator>.

    -

    The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-09/meta/applicator>.

    -

    Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations SHOULD consider URIs dated after this specification draft and before the next to indicate the same syntax and semantics as those listed here.

    -

    -9.1. Keyword Independence

    -

    Schema keywords typically operate independently, without affecting each other's outcomes.

    -

    For schema author convenience, there are some exceptions among the keywords in this vocabulary:

    - -
      -
    • "additionalProperties", whose behavior is defined in terms of "properties" and "patternProperties"
    • -
    • "unevaluatedProperties", whose behavior is defined in terms of annotations from "properties", "patternProperties", "additionalProperties" and itself
    • -
    • "additionalItems", whose behavior is defined in terms of "items"
    • -
    • "unevaluatedItems", whose behavior is defined in terms of annotations from "items", "additionalItems" and itself
    • -
    - -

    -

    -9.2. Keywords for Applying Subschemas in Place -

    -

    These keywords apply subschemas to the same location in the instance as the parent schema is being applied. They allow combining or modifying the subschema results in various ways.

    -

    -9.2.1. Keywords for Applying Subschemas With Boolean Logic -

    -

    These keywords correspond to logical operators for combining or modifying the boolean assertion results of the subschemas. They have no direct impact on annotation collection, although they enable the same annotation keyword to be applied to an instance location with different values. Annotation keywords define their own rules for combining such values.

    -

    -9.2.1.1. allOf -

    -

    This keyword's value MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.

    -

    An instance validates successfully against this keyword if it validates successfully against all schemas defined by this keyword's value.

    -

    -9.2.1.2. anyOf

    -

    This keyword's value MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.

    -

    An instance validates successfully against this keyword if it validates successfully against at least one schema defined by this keyword's value. Note that when annotations are being collected, all subschemas MUST be examined so that annotations are collected from each subschema that validates successfully.

    -

    -9.2.1.3. oneOf

    -

    This keyword's value MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.

    -

    An instance validates successfully against this keyword if it validates successfully against exactly one schema defined by this keyword's value.

    -

    -9.2.1.4. not -

    -

    This keyword's value MUST be a valid JSON Schema.

    -

    An instance is valid against this keyword if it fails to validate successfully against the schema defined by this keyword.

    -

    -9.2.2. Keywords for Applying Subschemas Conditionally -

    -

    Three of these keywords work together to implement conditional application of a subschema based on the outcome of another subschema. The fourth is a shortcut for a specific conditional case.

    -

    "if", "then", and "else" MUST NOT interact with each other across subschema boundaries. In other words, an "if" in one branch of an "allOf" MUST NOT have an impact on a "then" or "else" in another branch.

    -

    There is no default behavior for "if", "then", or "else" when they are not present. In particular, they MUST NOT be treated as if present with an empty schema, and when "if" is not present, both "then" and "else" MUST be entirely ignored.

    -

    -9.2.2.1. if

    -

    This keyword's value MUST be a valid JSON Schema.

    -

    This validation outcome of this keyword's subschema has no direct effect on the overall validation result. Rather, it controls which of the "then" or "else" keywords are evaluated.

    -

    Instances that successfully validate against this keyword's subschema MUST also be valid against the subschema value of the "then" keyword, if present.

    -

    Instances that fail to validate against this keyword's subschema MUST also be valid against the subschema value of the "else" keyword, if present.

    -

    If annotations are being collected, they are collected from this keyword's subschema in the usual way, including when the keyword is present without either "then" or "else".

    -

    -9.2.2.2. then

    -

    This keyword's value MUST be a valid JSON Schema.

    -

    When "if" is present, and the instance successfully validates against its subschema, then validation succeeds against this keyword if the instance also successfully validates against this keyword's subschema.

    -

    This keyword has no effect when "if" is absent, or when the instance fails to validate against its subschema. Implementations MUST NOT evaluate the instance against this keyword, for either validation or annotation collection purposes, in such cases.

    -

    -9.2.2.3. else

    -

    This keyword's value MUST be a valid JSON Schema.

    -

    When "if" is present, and the instance fails to validate against its subschema, then validation succeeds against this keyword if the instance successfully validates against this keyword's subschema.

    -

    This keyword has no effect when "if" is absent, or when the instance successfully validates against its subschema. Implementations MUST NOT evaluate the instance against this keyword, for either validation or annotation collection purposes, in such cases.

    -

    -9.2.2.4. dependentSchemas

    -

    This keyword specifies subschemas that are evaluated if the instance is an object and contains a certain property.

    -

    This keyword's value MUST be an object. Each value in the object MUST be a valid JSON Schema.

    -

    If the object key is a property in the instance, the entire instance must validate against the subschema. Its use is dependent on the presence of the property.

    -

    Omitting this keyword has the same behavior as an empty object.

    -

    -9.3. Keywords for Applying Subschemas to Child Instances

    -

    Each of these keywords defines a rule for applying its subschema(s) to child instances, specifically object properties and array items, and combining their results.

    -

    -9.3.1. Keywords for Applying Subschemas to Arrays

    -

    -9.3.1.1. items

    -

    The value of "items" MUST be either a valid JSON Schema or an array of valid JSON Schemas.

    -

    If "items" is a schema, validation succeeds if all elements in the array successfully validate against that schema.

    -

    If "items" is an array of schemas, validation succeeds if each element of the instance validates against the schema at the same position, if any.

    -

    This keyword produces an annotation value which is the largest index to which this keyword applied a subschema. The value MAY be a boolean true if a subschema was applied to every index of the instance, such as when "items" is a schema.

    -

    Annotation results for "items" keywords from multiple schemas applied to the same instance location are combined by setting the combined result to true if any of the values are true, and otherwise retaining the largest numerical value.

    -

    Omitting this keyword has the same assertion behavior as an empty schema.

    -

    -9.3.1.2. additionalItems -

    -

    The value of "additionalItems" MUST be a valid JSON Schema.

    -

    The behavior of this keyword depends on the presence and annotation result of "items" within the same schema object. If "items" is present, and its annotation result is a number, validation succeeds if every instance element at an index greater than that number validates against "additionalItems".

    -

    Otherwise, if "items" is absent or its annotation result is the boolean true, "additionalItems" MUST be ignored.

    -

    If the "additionalItems" subschema is applied to any positions within the instance array, it produces an annotation result of boolean true, analogous to the single schema behavior of "items". If any "additionalItems" keyword from any subschema applied to the same instance location produces an annotation value of true, then the combined result from these keywords is also true.

    -

    Omitting this keyword has the same assertion behavior as an empty schema.

    -

    Implementations MAY choose to implement or optimize this keyword in another way that produces the same effect, such as by directly checking for the presence and size of an "items" array. Implementations that do not support annotation collection MUST do so.

    -

    -9.3.1.3. unevaluatedItems -

    -

    The value of "unevaluatedItems" MUST be a valid JSON Schema.

    -

    The behavior of this keyword depends on the annotation results of adjacent keywords that apply to the instance location being validated. Specifically, the annotations from "items" and "additionalItems", which can come from those keywords when they are adjacent to the "unevaluatedItems" keyword. Those two annotations, as well as "unevaluatedItems", can also result from any and all adjacent in-place applicator keywords. This includes but is not limited to the in-place applicators defined in this document.

    -

    If an "items" annotation is present, and its annotation result is a number, and no "additionalItems" or "unevaluatedItems" annotation is present, then validation succeeds if every instance element at an index greater than the "items" annotation validates against "unevaluatedItems".

    -

    Otherwise, if any "items", "additionalItems", or "unevaluatedItems" annotations are present with a value of boolean true, then "unevaluatedItems" MUST be ignored. However, if none of these annotations are present, "unevaluatedItems" MUST be applied to all locations in the array.

    -

    This means that "items", "additionalItems", and all in-place applicators MUST be evaluated before this keyword can be evaluated. Authors of extension keywords MUST NOT define an in-place applicator that would need to be evaluated before this keyword.

    -

    If the "unevaluatedItems" subschema is applied to any positions within the instance array, it produces an annotation result of boolean true, analogous to the single schema behavior of "items". If any "unevaluatedItems" keyword from any subschema applied to the same instance location produces an annotation value of true, then the combined result from these keywords is also true.

    -

    Omitting this keyword has the same assertion behavior as an empty schema.

    -

    Implementations that do not collect annotations MUST raise an error upon encountering this keyword.

    -

    -9.3.1.4. contains

    -

    The value of this keyword MUST be a valid JSON Schema.

    -

    An array instance is valid against "contains" if at least one of its elements is valid against the given schema. Note that when collecting annotations, the subschema MUST be applied to every array element even after the first match has been found. This is to ensure that all possible annotations are collected.

    -

    -9.3.2. Keywords for Applying Subschemas to Objects

    -

    -9.3.2.1. properties

    -

    The value of "properties" MUST be an object. Each value of this object MUST be a valid JSON Schema.

    -

    Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value, the child instance for that name successfully validates against the corresponding schema.

    -

    The annotation result of this keyword is the set of instance property names matched by this keyword. Annotation results for "properties" keywords from multiple schemas applied to the same instance location are combined by taking the union of the sets.

    -

    Omitting this keyword has the same assertion behavior as an empty object.

    -

    -9.3.2.2. patternProperties

    -

    The value of "patternProperties" MUST be an object. Each property name of this object SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect. Each property value of this object MUST be a valid JSON Schema.

    -

    Validation succeeds if, for each instance name that matches any regular expressions that appear as a property name in this keyword's value, the child instance for that name successfully validates against each schema that corresponds to a matching regular expression.

    -

    The annotation result of this keyword is the set of instance property names matched by this keyword. Annotation results for "patternProperties" keywords from multiple schemas applied to the same instance location are combined by taking the union of the sets.

    -

    Omitting this keyword has the same assertion behavior as an empty object.

    -

    -9.3.2.3. additionalProperties -

    -

    The value of "additionalProperties" MUST be a valid JSON Schema.

    -

    The behavior of this keyword depends on the presence and annotation results of "properties" and "patternProperties" within the same schema object. Validation with "additionalProperties" applies only to the child values of instance names that do not appear in the annotation results of either "properties" or "patternProperties".

    -

    For all such properties, validation succeeds if the child instance validates against the "additionalProperties" schema.

    -

    The annotation result of this keyword is the set of instance property names validated by this keyword's subschema. Annotation results for "additionalProperties" keywords from multiple schemas applied to the same instance location are combined by taking the union of the sets.

    -

    Omitting this keyword has the same assertion behavior as an empty schema.

    -

    Implementations MAY choose to implement or optimize this keyword in another way that produces the same effect, such as by directly checking the names in "properties" and the patterns in "patternProperties" against the instance property set. Implementations that do not support annotation collection MUST do so.

    -

    -9.3.2.4. unevaluatedProperties -

    -

    The value of "unevaluatedProperties" MUST be a valid JSON Schema.

    -

    The behavior of this keyword depends on the annotation results of adjacent keywords that apply to the instance location being validated. Specifically, the annotations from "properties", "patternProperties", and "additionalProperties", which can come from those keywords when they are adjacent to the "unevaluatedProperties" keyword. Those three annotations, as well as "unevaluatedProperties", can also result from any and all adjacent in-place applicator keywords. This includes but is not limited to the in-place applicators defined in this document.

    -

    Validation with "unevaluatedProperties" applies only to the child values of instance names that do not appear in the "properties", "patternProperties", "additionalProperties", or "unevaluatedProperties" annotation results that apply to the instance location being validated.

    -

    For all such properties, validation succeeds if the child instance validates against the "unevaluatedProperties" schema.

    -

    This means that "properties", "patternProperties", "additionalProperties", and all in-place applicators MUST be evaluated before this keyword can be evaluated. Authors of extension keywords MUST NOT define an in-place applicator that would need to be evaluated before this keyword.

    -

    The annotation result of this keyword is the set of instance property names validated by this keyword's subschema. Annotation results for "unevaluatedProperties" keywords from multiple schemas applied to the same instance location are combined by taking the union of the sets.

    -

    Omitting this keyword has the same assertion behavior as an empty schema.

    -

    Implementations that do not collect annotations MUST raise an error upon encountering this keyword.

    -

    -9.3.2.5. propertyNames

    -

    The value of "propertyNames" MUST be a valid JSON Schema.

    -

    If the instance is an object, this keyword validates if every property name in the instance validates against the provided schema. Note the property name that the schema is testing will always be a string.

    -

    Omitting this keyword has the same behavior as an empty schema.

    -

    -10. Output Formatting -

    -

    JSON Schema is defined to be platform-independent. As such, to increase compatibility across platforms, implementations SHOULD conform to a standard validation output format. This section describes the minimum requirements that consumers will need to properly interpret validation results.

    -

    -10.1. Format

    -

    JSON Schema output is defined using the JSON Schema data instance model as described in section 4.2.1. Implementations MAY deviate from this as supported by their specific languages and platforms, however it is RECOMMENDED that the output be convertible to the JSON format defined herein via serialization or other means.

    -

    -10.2. Output Formats

    -

    This specification defines four output formats. See the "Output Structure" section for the requirements of each format.

    - -
      -
    • Flag - A boolean which simply indicates the overall validation result with no further details.
    • -
    • Basic - Provides validation information in a flat list structure.
    • -
    • Detailed - Provides validation information in a condensed hierarchical structure based on the structure of the schema.
    • -
    • Verbose - Provides validation information in an uncondensed hierarchical structure that matches the exact structure of the schema.
    • -
    - -

    An implementation SHOULD provide at least the "flag", "basic", or "detailed" format and MAY provide the "verbose" format. If it provides one or more of the complex formats, it MUST also provide the "flag" format. Implementations SHOULD specify in their documentation which formats they support.

    -

    -10.3. Minimum Information

    -

    Beyond the simplistic "flag" output, additional information is useful to aid in debugging a schema or instance. Each sub-result SHOULD contain the information contained within this section at a minimum.

    -

    A single object that contains all of these components is considered an output unit.

    -

    Implementations MAY elect to provide additional information.

    -

    -10.3.1. Keyword Relative Location

    -

    The relative location of the validating keyword that follows the validation path. The value MUST be expressed as a JSON Pointer, and it MUST include any by-reference applicators such as "$ref" or "$recursiveRef".

    -
    -
    -#/properties/width/$ref/minimum
    -
    -                        
    -

    Note that this pointer may not be resolvable by the normal JSON Pointer process due to the inclusion of these by-reference applicator keywords.

    -

    The JSON key for this information is "keywordLocation".

    -

    -10.3.2. Keyword Absolute Location

    -

    The absolute, dereferenced location of the validating keyword. The value MUST be expressed as an absolute URI using the canonical URI of the relevant schema object, and it MUST NOT include by-reference applicators such as "$ref" or "$recursiveRef" as non-terminal path components. It MAY end in such keywords if the error or annotation is for that keyword, such as an unresolvable reference.

    -
    -
    -https://example.com/schemas/common#/$defs/count/minimum
    -
    -                        
    -

    This information MAY be omitted only if either the relative location contains no references or if the schema does not declare an absolute URI as its "$id".

    -

    The JSON key for this information is "absoluteKeywordLocation".

    -

    -10.3.3. Instance Location

    -

    The location of the JSON value within the instance being validated. The value MUST be expressed as a URI fragment-encoded JSON Pointer.

    -

    The JSON key for this information is "instanceLocation".

    -

    -10.3.4. Error or Annotation

    -

    The error or annotation that is produced by the validation.

    -

    For errors, the specific wording for the message is not defined by this specification. Implementations will need to provide this.

    -

    For annotations, each keyword that produces an annotation specifies its format. By default, it is the keyword's value.

    -

    The JSON key for failed validations is "error"; for successful validations it is "annotation".

    -

    -10.3.5. Nested Results

    -

    For the two hierarchical structures, this property will hold nested errors and annotations.

    -

    The JSON key for nested results in failed validations is "errors"; for successful validations it is "annotations". Note the plural forms, as a keyword with nested results can also have a local error or annotation.

    -

    -10.4. Output Structure

    -

    The output MUST be an object containing a boolean property named "valid". When additional information about the result is required, the output MUST also contain "errors" or "annotations" as described below.

    - -
      -
    • "valid" - a boolean value indicating the overall validation success or failure
    • -
    • "errors" - the collection of errors or annotations produced by a failed validation
    • -
    • "annotations" - the collection of errors or annotations produced by a successful validation
    • -
    - -

    For these examples, the following schema and instance will be used.

    -
    -
    -{
    -  "$id": "https://example.com/polygon",
    -  "$schema": "https://json-schema.org/draft/2019-09/schema",
    -  "$defs": {
    -    "point": {
    -      "type": "object",
    -      "properties": {
    -        "x": { "type": "number" },
    -        "y": { "type": "number" }
    -      },
    -      "additionalProperties": false,
    -      "required": [ "x", "y" ]
    -    }
    -  },
    -  "type": "array",
    -  "items": { "$ref": "#/$defs/point" },
    -  "minItems": 3
    -}
    -
    -[
    -  {
    -    "x": 2.5,
    -    "y": 1.3,
    -  },
    -  {
    -    "x": 1,
    -    "z": 6.7
    -  }
    -]
    -
    -                    
    -

    This instance will fail validation and produce errors, but it's trivial to deduce examples for passing schemas that produce annotations.

    -

    Specifically, the errors it will produce are:

    - -
      -
    • The second element in the "vertices" property is missing a "y" property.
    • -
    • The second element in the "vertices" property has a disallowed "z" property.
    • -
    • There are only two vertices, but three are required.
    • -
    - -

    Note that the error message wording as depicted in these examples is not a requirement of this specification. Implementations SHOULD craft error messages tailored for their audience or provide a templating mechanism that allows their users to craft their own messages.

    -

    -10.4.1. Flag

    -

    In the simplest case, merely the boolean result for the "valid" valid property needs to be fulfilled.

    -
    -
    -{
    -  "valid": false
    -}
    -
    -                        
    -

    Because no errors or annotations are returned with this format, it is RECOMMENDED that implementations use short-circuiting logic to return failure or success as soon as the outcome can be determined. For example, if an "anyOf" keyword contains five sub-schemas, and the second one passes, there is no need to check the other three. The logic can simply return with success.

    -

    -10.4.2. Basic

    -

    The "Basic" structure is a flat list of output units.

    -
    -
    -{
    -  "valid": false,
    -  "errors": [
    -    {
    -      "keywordLocation": "#",
    -      "instanceLocation": "#",
    -      "error": "A subschema had errors."
    -    },
    -    {
    -      "keywordLocation": "#/items/$ref",
    -      "absoluteKeywordLocation":
    -        "https://example.com/polygon#/$defs/point",
    -      "instanceLocation": "#/1",
    -      "error": "A subschema had errors."
    -    },
    -    {
    -      "keywordLocation": "#/items/$ref/required",
    -      "absoluteKeywordLocation":
    -        "https://example.com/polygon#/$defs/point/required",
    -      "instanceLocation": "#/1",
    -      "error": "Required property 'y' not found."
    -    },
    -    {
    -      "keywordLocation": "#/items/$ref/additionalProperties",
    -      "absoluteKeywordLocation":
    -        "https://example.com/polygon#/$defs/point/additionalProperties",
    -      "instanceLocation": "#/1/z",
    -      "error": "Additional property 'z' found but was invalid."
    -    },
    -    {
    -      "keywordLocation": "#/minItems",
    -      "instanceLocation": "#",
    -      "error": "Expected at least 3 items but found 2"
    -    }
    -  ]
    -}
    -
    -                        
    -

    -10.4.3. Detailed

    -

    The "Detailed" structure is based on the schema and can be more readable for both humans and machines. Having the structure organized this way makes associations between the errors more apparent. For example, the fact that the missing "y" property and the extra "z" property both stem from the same location in the instance is not immediately obvious in the "Basic" structure. In a hierarchy, the correlation is more easily identified.

    -

    The following rules govern the construction of the results object:

    - -
      -
    • All applicator keywords ("*Of", "$ref", "if"/"then"/"else", etc.) require a node.
    • -
    • Nodes that have no children are removed.
    • -
    • Nodes that have a single child are replaced by the child.
    • -
    - -

    Branch nodes do not require an error message or an annotation.

    -
    -
    -{
    -  "valid": false,
    -  "keywordLocation": "#",
    -  "instanceLocation": "#",
    -  "errors": [
    -    {
    -      "valid": false,
    -      "keywordLocation": "#/items/$ref",
    -      "absoluteKeywordLocation":
    -        "https://example.com/polygon#/$defs/point",
    -      "instanceLocation": "#/1",
    -      "errors": [
    -        {
    -          "valid": false,
    -          "keywordLocation": "#/items/$ref/required",
    -          "absoluteKeywordLocation":
    -            "https://example.com/polygon#/$defs/point/required",
    -          "instanceLocation": "#/1",
    -          "error": "Required property 'y' not found."
    -        },
    -        {
    -          "valid": false,
    -          "keywordLocation": "#/items/$ref/additionalProperties",
    -          "absoluteKeywordLocation":
    -            "https://example.com/polygon#/$defs/point/additionalProperties",
    -          "instanceLocation": "#/1/z",
    -          "error": "Additional property 'z' found but was invalid."
    -        }
    -      ]
    -    },
    -    {
    -      "valid": false,
    -      "keywordLocation": "#/minItems",
    -      "instanceLocation": "#",
    -      "error": "Expected at least 3 items but found 2"
    -    }
    -  ]
    -}
    -
    -                        
    -

    -10.4.4. Verbose

    -

    The "Verbose" structure is a fully realized hierarchy that exactly matches that of the schema. This structure has applications in form generation and validation where the error's location is important.

    -

    The primary difference between this and the "Detailed" structure is that all results are returned. This includes sub-schema validation results that would otherwise be removed (e.g. annotations for failed validations, successful validations inside a `not` keyword, etc.). Because of this, it is RECOMMENDED that each node also carry a `valid` property to indicate the validation result for that node.

    -

    Because this output structure can be quite large, a smaller example is given here for brevity. The URI of the full output structure of the example above is: <https://json-schema.org/draft/2019-09/output/verbose-example>.

    -
    -
    -// schema
    -{
    -  "$id": "https://example.com/polygon",
    -  "$schema": "https://json-schema.org/draft/2019-09/schema",
    -  "type": "object",
    -  "properties": {
    -    "validProp": true,
    -  },
    -  "additionalProperties": false
    -}
    -
    -// instance
    -{
    -  "validProp": 5,
    -  "disallowedProp": "value"
    -}
    -
    -// result
    -{
    -  "valid": false,
    -  "keywordLocation": "#",
    -  "instanceLocation": "#",
    -  "errors": [
    -    {
    -      "valid": true,
    -      "keywordLocation": "#/type",
    -      "instanceLocation": "#"
    -    },
    -    {
    -      "valid": true,
    -      "keywordLocation": "#/properties",
    -      "instanceLocation": "#"
    -    },
    -    {
    -      "valid": false,
    -      "keywordLocation": "#/additionalProperties",
    -      "instanceLocation": "#",
    -      "errors": [
    -        {
    -          "valid": false,
    -          "keywordLocation": "#/additionalProperties",
    -          "instanceLocation": "#/disallowedProp",
    -          "error": "Additional property 'disallowedProp' found but was invalid."
    -        }
    -      ]
    -    }
    -  ]
    -}
    -
    -                        
    -

    -10.4.5. Output validation schemas

    -

    For convenience, JSON Schema has been provided to validate output generated by implementations. Its URI is: <https://json-schema.org/draft/2019-09/output/schema>.

    -

    -11. Usage for Hypermedia -

    -

    JSON has been adopted widely by HTTP servers for automated APIs and robots. This section describes how to enhance processing of JSON documents in a more RESTful manner when used with protocols that support media types and Web linking.

    -

    -11.1. Linking to a Schema

    -

    It is RECOMMENDED that instances described by a schema provide a link to a downloadable JSON Schema using the link relation "describedby", as defined by Linked Data Protocol 1.0, section 8.1.

    -

    In HTTP, such links can be attached to any response using the Link header. An example of such a header would be:

    -
    -
    -Link: <https://example.com/my-hyper-schema#>; rel="describedby"
    -
    -                    
    -

    -11.2. Identifying a Schema via a Media Type Parameter -

    -

    Media types MAY allow for a "schema" media type parameter, which gives HTTP servers the ability to perform Content-Type Negotiation based on schema. The media-type parameter MUST be a whitespace-separated list of URIs (i.e. relative references are invalid).

    -

    When using the media type application/schema-instance+json, the "schema" parameter MUST be supplied.

    -

    When using the media type application/schema+json, the "schema" parameter MAY be supplied. If supplied, it SHOULD contain the same URI as identified by the "$schema" keyword, and MAY contain additional URIs. The "$schema" URI MUST be considered the schema's canonical meta-schema, regardless of the presence of alternative or additional meta-schemas as a media type parameter.

    -

    The schema URI is opaque and SHOULD NOT automatically be dereferenced. If the implementation does not understand the semantics of the provided schema, the implementation can instead follow the "describedby" links, if any, which may provide information on how to handle the schema. Since "schema" doesn't necessarily point to a network location, the "describedby" relation is used for linking to a downloadable schema. However, for simplicity, schema authors should make these URIs point to the same resource when possible.

    -

    In HTTP, the media-type parameter would be sent inside the Content-Type header:

    -
    -
    -Content-Type: application/json;
    -          schema="https://example.com/my-hyper-schema#"
    -
    -                    
    -

    Multiple schemas are whitespace separated, and indicate that the instance conforms to all of the listed schemas:

    -
    -
    -Content-Type: application/json;
    -          schema="https://example.com/alice https://example.com/bob"
    -
    -                    
    -

    Media type parameters are also used in HTTP's Accept request header:

    -
    -
    -Accept: application/json;
    -          schema="https://example.com/qiang https://example.com/li",
    -        application/json;
    -          schema="https://example.com/kumar"
    -
    -                    
    -

    As with Content-Type, multiple schema parameters in the same string requests an instance that conforms to all of the listed schemas.

    -

    Unlike Content-Type, Accept can contain multiple values to indicate that the client can accept several media types. In the above example, note that the two media types differ only by their schema parameter values. This requests an application/json representation that conforms to at least one of the identified schemas.

    -

    [CREF14]This paragraph assumes that we can register a "schema" link relation. Should we instead specify something like "tag:json-schema.org,2017:schema" for now? HTTP can also send the "schema" in a Link, though this may impact media-type semantics and Content-Type negotiation if this replaces the media-type parameter entirely:

    -
    -
    -Link: </alice>;rel="schema", </bob>;rel="schema"
    -
    -                    
    -

    -11.3. Usage Over HTTP

    -

    When used for hypermedia systems over a network, HTTP is frequently the protocol of choice for distributing schemas. Misbehaving clients can pose problems for server maintainers if they pull a schema over the network more frequently than necessary, when it's instead possible to cache a schema for a long period of time.

    -

    HTTP servers SHOULD set long-lived caching headers on JSON Schemas. HTTP clients SHOULD observe caching headers and not re-request documents within their freshness period. Distributed systems SHOULD make use of a shared cache and/or caching proxy.

    -
    -
    -User-Agent: product-name/5.4.1 so-cool-json-schema/1.0.2 curl/7.43.0
    -
    -                        
    -

    Clients SHOULD set or prepend a User-Agent header specific to the JSON Schema implementation or software product. Since symbols are listed in decreasing order of significance, the JSON Schema library name/version should precede the more generic HTTP library name (if any). For example:

    -

    Clients SHOULD be able to make requests with a "From" header so that server operators can contact the owner of a potentially misbehaving script.

    -

    -12. Security Considerations -

    -

    Both schemas and instances are JSON values. As such, all security considerations defined in RFC 8259 apply.

    -

    Instances and schemas are both frequently written by untrusted third parties, to be deployed on public Internet servers. Validators should take care that the parsing and validating against schemas doesn't consume excessive system resources. Validators MUST NOT fall into an infinite loop.

    -

    Servers MUST ensure that malicious parties can't change the functionality of existing schemas by uploading a schema with a pre-existing or very similar "$id".

    -

    Individual JSON Schema vocabularies are liable to also have their own security considerations. Consult the respective specifications for more information.

    -

    Schema authors should take care with "$comment" contents, as a malicious implementation can display them to end-users in violation of a spec, or fail to strip them if such behavior is expected.

    -

    A malicious schema author could place executable code or other dangerous material within a "$comment". Implementations MUST NOT parse or otherwise take action based on "$comment" contents.

    -

    -13. IANA Considerations

    -

    -13.1. application/schema+json

    -

    The proposed MIME media type for JSON Schema is defined as follows:

    - -
      -
    • Type name: application
    • -
    • Subtype name: schema+json
    • -
    • Required parameters: N/A
    • -
    • Optional parameters:
      -
      schema:
      -
      A non-empty list of space-separated URIs, each identifying a JSON Schema resource. The instance SHOULD successfully validate against at least one of these meta-schemas. Non-validating meta-schemas MAY be included for purposes such as allowing clients to make use of older versions of a meta-schema as long as the runtime instance validates against that older version.
      -
      -

      -
    • -
    • Encoding considerations: Encoding considerations are identical to those specified for the "application/json" media type. See JSON.
    • -
    • Security considerations: See Section 12 above.
    • -
    • Interoperability considerations: See Sections 6.2, 6.3, and 6.4 above.
    • -
    • Fragment identifier considerations: See Section 5
    • -
    - -

    -

    -13.2. application/schema-instance+json

    -

    The proposed MIME media type for JSON Schema Instances that require a JSON Schema-specific media type is defined as follows:

    - -
      -
    • Type name: application
    • -
    • Subtype name: schema-instance+json
    • -
    • Required parameters:
      -
      schema:
      -
      A non-empty list of space-separated URIs, each identifying a JSON Schema resource. The instance SHOULD successfully validate against at least one of these schemas. Non-validating schemas MAY be included for purposes such as allowing clients to make use of older versions of a schema as long as the runtime instance validates against that older version.
      -
      -

      -
    • -
    • Encoding considerations: Encoding considerations are identical to those specified for the "application/json" media type. See JSON.
    • -
    • Security considerations: See Section 12 above.
    • -
    • Interoperability considerations: See Sections 6.2, 6.3, and 6.4 above.
    • -
    • Fragment identifier considerations: See Section 5
    • -
    - -

    -

    -14. References

    -

    -14.1. Normative References

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    [ecma262]"ECMA 262 specification"
    [RFC2119] -Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.
    [RFC3986] -Berners-Lee, T., Fielding, R. and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, January 2005.
    [RFC6839] -Hansen, T. and A. Melnikov, "Additional Media Type Structured Syntax Suffixes", RFC 6839, DOI 10.17487/RFC6839, January 2013.
    [RFC6901] -Bryan, P., Zyp, K. and M. Nottingham, "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, April 2013.
    [RFC8259] -Bray, T., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, December 2017.
    [W3C.REC-ldp-20150226] -Speicher, S., Arwe, J. and A. Malhotra, "Linked Data Platform 1.0", World Wide Web Consortium Recommendation REC-ldp-20150226, February 2015.
    -

    -14.2. Informative References

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    [json-hyper-schema] -Andrews, H. and A. Wright, "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON", Internet-Draft draft-handrews-json-schema-hyperschema-02, November 2017.
    [json-schema-validation] -Wright, A., Andrews, H. and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of JSON", Internet-Draft draft-handrews-json-schema-validation-02, November 2017.
    [RFC6596] -Ohye, M. and J. Kupke, "The Canonical Link Relation", RFC 6596, DOI 10.17487/RFC6596, April 2012.
    [RFC7049] -Bormann, C. and P. Hoffman, "Concise Binary Object Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, October 2013.
    [RFC7231] -Fielding, R. and J. Reschke, "Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content", RFC 7231, DOI 10.17487/RFC7231, June 2014.
    [RFC8288] -Nottingham, M., "Web Linking", RFC 8288, DOI 10.17487/RFC8288, October 2017.
    [W3C.WD-fragid-best-practices-20121025] -Tennison, J., "Best Practices for Fragment Identifiers and Media Type Definitions", World Wide Web Consortium WD WD-fragid-best-practices-20121025, October 2012.
    -

    -Appendix A. Schema identification examples -

    -

    Consider the following schema, which shows "$id" being used to identify both the root schema and various subschemas, and "$anchor" being used to define plain name fragment identifiers.

    -
    -
    -{
    -    "$id": "https://example.com/root.json",
    -    "$defs": {
    -        "A": { "$anchor": "foo" },
    -        "B": {
    -            "$id": "other.json",
    -            "$defs": {
    -                "X": { "$anchor": "bar" },
    -                "Y": {
    -                    "$id": "t/inner.json",
    -                    "$anchor": "bar"
    -                }
    -            }
    -        },
    -        "C": {
    -            "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f"
    -        }
    -    }
    -}
    -
    -                
    -

    The schemas at the following URI-encoded JSON Pointers (relative to the root schema) have the following base URIs, and are identifiable by any listed URI in accordance with sections 5 and 8.2.2.2 above.

    -

    - -
    -
    # (document root)
    -
    -
    -
    canonical absolute-URI (and also base URI)
    -
    https://example.com/root.json
    -
    canonical URI with pointer fragment
    -
    https://example.com/root.json#
    -
    -

    -
    -
    #/$defs/A
    -
    -
    -
    base URI
    -
    https://example.com/root.json
    -
    canonical URI with plain fragment
    -
    https://example.com/root.json#foo
    -
    canonical URI with pointer fragment
    -
    https://example.com/root.json#/$defs/A
    -
    -

    -
    -
    #/$defs/B
    -
    -
    -
    base URI
    -
    https://example.com/other.json
    -
    canonical URI with pointer fragment
    -
    https://example.com/other.json#
    -
    non-canonical URI with fragment relative to root.json
    -
    https://example.com/root.json#/$defs/B
    -
    -

    -
    -
    #/$defs/B/$defs/X
    -
    -
    -
    base URI
    -
    https://example.com/other.json
    -
    canonical URI with plain fragment
    -
    https://example.com/other.json#bar
    -
    canonical URI with pointer fragment
    -
    https://example.com/other.json#/$defs/X
    -
    non-canonical URI with fragment relative to root.json
    -
    https://example.com/root.json#/$defs/B/$defs/X
    -
    -

    -
    -
    #/$defs/B/$defs/Y
    -
    -
    -
    base URI
    -
    https://example.com/t/inner.json
    -
    canonical URI with plain fragment
    -
    https://example.com/t/inner.json#bar
    -
    canonical URI with pointer fragment
    -
    https://example.com/t/inner.json#
    -
    non-canonical URI with fragment relative to other.json
    -
    https://example.com/other.json#/$defs/Y
    -
    non-canonical URI with fragment relative to root.json
    -
    https://example.com/root.json#/$defs/B/$defs/Y
    -
    -

    -
    -
    #/$defs/C
    -
    -
    -
    base URI
    -
    urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f
    -
    canonical URI with pointer fragment
    -
    urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f#
    -
    non-canonical URI with fragment relative to root.json
    -
    https://example.com/root.json#/$defs/C
    -
    -

    -
    -
    - -

    -

    -Appendix B. Manipulating schema documents and references

    -

    Various tools have been created to rearrange schema documents based on how and where references ("$ref") appear. This appendix discusses which use cases and actions are compliant with this specification.

    -

    -B.1. Bundling schema resources into a single document

    -

    A set of schema resources intended for use together can be organized with each in its own schema document, all in the same schema document, or any granularity of document grouping in between.

    -

    Numerous tools exist to perform various sorts of reference removal. A common case of this is producing a single file where all references can be resolved within that file. This is typically done to simplify distribution, or to simplify coding so that various invocations of JSON Schema libraries do not have to keep track of and load a large number of resources.

    -

    This transformation can be safely and reversibly done as long as all static references (e.g. "$ref") use URI-references that resolve to canonical URIs, and all schema resources have an absolute-URI as the "$id" in their root schema.

    -

    With these conditions met, each external resource can be copied under "$defs", without breaking any references among the resources' schema objects, and without changing any aspect of validation or annotation results. The names of the schemas under "$defs" do not affect behavior, assuming they are each unique, as they do not appear in canonical URIs for the embedded resources.

    -

    -B.2. Reference removal is not always safe

    -

    Attempting to remove all references and produce a single schema document does not, in all cases, produce a schema with identical behavior to the original form.

    -

    Since "$ref" is now treated like any other keyword, with other keywords allowed in the same schema objects, fully supporting non-recursive "$ref" removal in all cases can require relatively complex schema manipulations. It is beyond the scope of this specification to determine or provide a set of safe "$ref" removal transformations, as they depend not only on the schema structure but also on the intended usage.

    -

    -Appendix C. Example of recursive schema extension -

    -

    Consider the following two schemas describing a simple recursive tree structure, where each node in the tree can have a "data" field of any type. The first schema allows and ignores other instance properties. The second is more strict and only allows the "data" and "children" properties. An example instance with "data" misspelled as "daat" is also shown.

    -
    -
    -// tree schema, extensible
    -{
    -    "$schema": "https://json-schema.org/draft/2019-09/schema",
    -    "$id": "https://example.com/tree",
    -    "$recursiveAnchor": true,
    -
    -    "type": "object",
    -    "properties": {
    -        "data": true,
    -        "children": {
    -            "type": "array",
    -            "items": {
    -                "$recursiveRef": "#"
    -            }
    -        }
    -    }
    -}
    -
    -// strict-tree schema, guards against misspelled properties
    -{
    -    "$schema": "https://json-schema.org/draft/2019-09/schema",
    -    "$id": "https://example.com/strict-tree",
    -    "$recursiveAnchor": true,
    -
    -    "$ref": "tree",
    -    "unevaluatedProperties": false
    -}
    -
    -// instance with misspelled field
    -{
    -    "children": [ { "daat": 1 } ]
    -}
    -
    -                
    -

    If we apply the "strict-tree" schema to the instance, we will follow the "$ref" to the "tree" schema, examine its "children" subschema, and find the "$recursiveAnchor" in its "items" subschema. At this point, the dynamic path is "#/$ref/properties/children/items/$recursiveRef".

    -

    The base URI at this point is "https://example.com/tree", so the "$recursiveRef" initially resolves to "https://example.com/tree#". Since "$recursiveAnchor" is true, we examine the dynamic path to see if there is a different base URI to use. We find "$recursiveAnchor" with a true value at the dynamic paths of "#" and "#/$ref".

    -

    The outermost is "#", which is the root schema of the "strict-tree" schema, so we use its base URI of "https://example.com/strict-tree", which produces a final resolved URI of "https://example.com/strict-tree#" for the "$recursiveRef".

    -

    This way, the recursion in the "tree" schema recurses to the root of "strict-tree", instead of only applying "strict-tree" to the instance root, but applying "tree" to instance children.

    -

    -Appendix D. Working with vocabularies

    -

    -D.1. Best practices for vocabulary and meta-schema authors

    -

    Vocabulary authors should take care to avoid keyword name collisions if the vocabulary is intended for broad use, and potentially combined with other vocabularies. JSON Schema does not provide any formal namespacing system, but also does not constrain keyword names, allowing for any number of namespacing approaches.

    -

    Vocabularies may build on each other, such as by defining the behavior of their keywords with respect to the behavior of keywords from another vocabulary, or by using a keyword from another vocabulary with a restricted or expanded set of acceptable values. Not all such vocabulary re-use will result in a new vocabulary that is compatible with the vocabulary on which it is built. Vocabulary authors should clearly document what level of compatibility, if any, is expected.

    -

    Meta-schema authors should not use "$vocabulary" to combine multiple vocabularies that define conflicting syntax or semantics for the same keyword. As semantic conflicts are not generally detectable through schema validation, implementations are not expected to detect such conflicts. If conflicting vocabularies are declared, the resulting behavior is undefined.

    -

    Vocabulary authors should provide a meta-schema that validates the expected usage of the vocabulary's keywords on their own. Such meta-schemas should not forbid additional keywords, and must not forbid any keywords from the Core vocabulary.

    -

    It is recommended that meta-schema authors reference each vocabulary's meta-schema using the "allOf" keyword, although other mechanisms for constructing the meta-schema may be appropriate for certain use cases.

    -

    The recursive nature of meta-schemas makes the "$recursiveAnchor" and "$recursiveRef" keywords particularly useful for extending existing meta-schemas, as can be seen in the JSON Hyper-Schema meta-schema which extends the Validation meta-schema.

    -

    Meta-schemas may impose additional constraints, including describing keywords not present in any vocabulary, beyond what the meta-schemas associated with the declared vocabularies describe. This allows for restricting usage to a subset of a vocabulary, and for validating locally defined keywords not intended for re-use.

    -

    However, meta-schemas should not contradict any vocabularies that they declare, such as by requiring a different JSON type than the vocabulary expects. The resulting behavior is undefined.

    -

    Meta-schemas intended for local use, with no need to test for vocabulary support in arbitrary implementations, can safely omit "$vocabulary" entirely.

    -

    -D.2. Example meta-schema with vocabulary declarations -

    -

    This meta-schema explicitly declares both the Core and Applicator vocabularies, together with an extension vocabulary, and combines their meta-schemas with an "allOf". The extension vocabulary's meta-schema, which describes only the keywords in that vocabulary, is shown after the main example meta-schema.

    -

    The main example meta-schema also restricts the usage of the Applicator vocabulary by forbidding the keywords prefixed with "unevaluated", which are particularly complex to implement. This does not change the semantics or set of keywords defined by the Applicator vocabulary. It just ensures that schemas using this meta-schema that attempt to use the keywords prefixed with "unevaluted" will fail validation against this meta-schema.

    -

    Finally, this meta-schema describes the syntax of a keyword, "localKeyword", that is not part of any vocabulary. Presumably, the implementors and users of this meta-schema will understand the semantics of "localKeyword". JSON Schema does not define any mechanism for expressing keyword semantics outside of vocabularies, making them unsuitable for use except in a specific environment in which they are understood.

    -

    This meta-schema combines several vocabularies for general use.

    -
    -
    -{
    -  "$schema": "https://json-schema.org/draft/2019-09/schema",
    -  "$id": "https://example.com/meta/general-use-example",
    -  "$recursiveAnchor": true,
    -  "$vocabulary": {
    -    "https://json-schema.org/draft/2019-09/vocab/core": true,
    -    "https://json-schema.org/draft/2019-09/vocab/applicator": true,
    -    "https://json-schema.org/draft/2019-09/vocab/validation": true,
    -    "https://example.com/vocab/example-vocab": true
    -  },
    -  "allOf": [
    -    {"$ref": "https://json-schema.org/draft/2019-09/meta/core"},
    -    {"$ref": "https://json-schema.org/draft/2019-09/meta/applicator"},
    -    {"$ref": "https://json-schema.org/draft/2019-09/meta/validation"},
    -    {"$ref": "https://example.com/meta/example-vocab",
    -  ],
    -  "patternProperties": {
    -    "^unevaluated.*$": false
    -  },
    -  "properties": {
    -    "localKeyword": {
    -      "$comment": "Not in vocabulary, but validated if used",
    -      "type": "string"
    -    }
    -  }
    -}
    -
    -                    
    -

    This meta-schema describes only a single extension vocabulary.

    -
    -
    -{
    -  "$schema": "https://json-schema.org/draft/2019-09/schema",
    -  "$id": "https://example.com/meta/example-vocab",
    -  "$recursiveAnchor": true,
    -  "$vocabulary": {
    -    "https://example.com/vocab/example-vocab": true,
    -  },
    -  "type": ["object", "boolean"],
    -  "properties": {
    -    "minDate": {
    -      "type": "string",
    -      "pattern": "\d\d\d\d-\d\d-\d\d",
    -      "format": "date",
    -    }
    -  }
    -}
    -
    -                    
    -

    As shown above, even though each of the single-vocabulary meta-schemas referenced in the general-use meta-schema's "allOf" declares its corresponding vocabulary, this new meta-schema must re-declare them.

    -

    The standard meta-schemas that combine all vocabularies defined by the Core and Validation specification, and that combine all vocabularies defined by those specifications as well as the Hyper-Schema specification, demonstrate additional complex combinations. These URIs for these meta-schemas may be found in the Validation and Hyper-Schema specifications, respectively.

    -

    While the general-use meta-schema can validate the syntax of "minDate", it is the vocabulary that defines the logic behind the semantic meaning of "minDate". Without an understanding of the semantics (in this example, that the instance value must be a date equal to or after the date provided as the keyword's value in the schema), an implementation can only validate the syntactic usage. In this case, that means validating that it is a date-formatted string (using "pattern" to ensure that it is validated even when "format" functions purely as an annotation, as explained in the Validation specification.

    -

    -Appendix E. References and generative use cases

    -

    While the presence of references is expected to be transparent to validation results, generative use cases such as code generators and UI renderers often consider references to be semantically significant.

    -

    To make such use case-specific semantics explicit, the best practice is to create an annotation keyword for use in the same schema object alongside of a reference keyword such as "$ref".

    -

    For example, here is a hypothetical keyword for determining whether a code generator should consider the reference target to be a distinct class, and how those classes are related. Note that this example is solely for illustrative purposes, and is not intended to propose a functional code generation keyword.

    -
    -
    -{
    -    "allOf": [
    -        {
    -            "classRelation": "is-a",
    -            "$ref": "classes/base.json"
    -        },
    -        {
    -            "$ref": "fields/common.json"
    -        }
    -    ],
    -    "properties": {
    -        "foo": {
    -            "classRelation": "has-a",
    -            "$ref": "classes/foo.json"
    -        },
    -        "date": {
    -            "$ref": "types/dateStruct.json",
    -        }
    -    }
    -}
    -
    -                
    -

    Here, this schema represents some sort of object-oriented class. The first reference in the "allOf" is noted as the base class. The second is not assigned a class relationship, meaning that the code generator should combine the target's definition with this one as if no reference were involved.

    -

    Looking at the properties, "foo" is flagged as object composition, while the "date" property is not. It is simply a field with sub-fields, rather than an instance of a distinct class.

    -

    This style of usage requires the annotation to be in the same object as the reference, which must be recognizable as a reference.

    -

    -Appendix F. Acknowledgments

    -

    Thanks to Gary Court, Francis Galiegue, Kris Zyp, and Geraint Luff for their work on the initial drafts of JSON Schema.

    -

    Thanks to Jason Desrosiers, Daniel Perrett, Erik Wilde, Ben Hutton, Evgeny Poberezkin, Brad Bowman, Gowry Sankar, Donald Pipowitch, and Dave Finlay for their submissions and patches to the document.

    -

    -Appendix G. ChangeLog

    -

    [CREF15]This section to be removed before leaving Internet-Draft status.

    -

    - -
    -
    draft-handrews-json-schema-02
    -
    -
      -
    • Update to RFC 8259 for JSON specification
    • -
    • Moved "definitions" from the Validation specification here as "$defs"
    • -
    • Moved applicator keywords from the Validation specification as their own vocabulary
    • -
    • Moved the schema form of "dependencies" from the Validation specification as "dependentSchemas"
    • -
    • Formalized annotation collection
    • -
    • Specified recommended output formats
    • -
    • Defined keyword interactions in terms of annotation and assertion results
    • -
    • Added "unevaluatedProperties" and "unevaluatedItems"
    • -
    • Define "$ref" behavior in terms of the assertion, applicator, and annotation model
    • -
    • Allow keywords adjacent to "$ref"
    • -
    • Note undefined behavior for "$ref" targets involving unknown keywords
    • -
    • Add recursive referencing, primarily for meta-schema extension
    • -
    • Add the concept of formal vocabularies, and how they can be recognized through meta-schemas
    • -
    • Additional guidance on initial base URIs beyond network retrieval
    • -
    • Allow "schema" media type parameter for "application/schema+json"
    • -
    • Better explanation of media type parameters and the HTTP Accept header
    • -
    • Use "$id" to establish canonical and base absolute-URIs only, no fragments
    • -
    • Replace plain-name-fragment-only form of "$id" with "$anchor"
    • -
    • Clarified that the behavior of JSON Pointers across "$id" boundary is unreliable
    • -
    -

    -
    -
    draft-handrews-json-schema-01
    -
    -
      -
    • This draft is purely a clarification with no functional changes
    • -
    • Emphasized annotations as a primary usage of JSON Schema
    • -
    • Clarified $id by use cases
    • -
    • Exhaustive schema identification examples
    • -
    • Replaced "external referencing" with how and when an implementation might know of a schema from another document
    • -
    • Replaced "internal referencing" with how an implementation should recognized schema identifiers during parsing
    • -
    • Dereferencing the former "internal" or "external" references is always the same process
    • -
    • Minor formatting improvements
    • -
    -

    -
    -
    draft-handrews-json-schema-00
    -
    -
      -
    • Make the concept of a schema keyword vocabulary more clear
    • -
    • Note that the concept of "integer" is from a vocabulary, not the data model
    • -
    • Classify keywords as assertions or annotations and describe their general behavior
    • -
    • Explain the boolean schemas in terms of generalized assertions
    • -
    • Reserve "$comment" for non-user-visible notes about the schema
    • -
    • Wording improvements around "$id" and fragments
    • -
    • Note the challenges of extending meta-schemas with recursive references
    • -
    • Add "application/schema-instance+json" media type
    • -
    • Recommend a "schema" link relation / parameter instead of "profile"
    • -
    -

    -
    -
    draft-wright-json-schema-01
    -
    -
      -
    • Updated intro
    • -
    • Allowed for any schema to be a boolean
    • -
    • "$schema" SHOULD NOT appear in subschemas, although that may change
    • -
    • Changed "id" to "$id"; all core keywords prefixed with "$"
    • -
    • Clarify and formalize fragments for application/schema+json
    • -
    • Note applicability to formats such as CBOR that can be represented in the JSON data model
    • -
    -

    -
    -
    draft-wright-json-schema-00
    -
    -
      -
    • Updated references to JSON
    • -
    • Updated references to HTTP
    • -
    • Updated references to JSON Pointer
    • -
    • Behavior for "id" is now specified in terms of RFC3986
    • -
    • Aligned vocabulary usage for URIs with RFC3986
    • -
    • Removed reference to draft-pbryan-zyp-json-ref-03
    • -
    • Limited use of "$ref" to wherever a schema is expected
    • -
    • Added definition of the "JSON Schema data model"
    • -
    • Added additional security considerations
    • -
    • Defined use of subschema identifiers for "id"
    • -
    • Rewrote section on usage with HTTP
    • -
    • Rewrote section on usage with rel="describedBy" and rel="profile"
    • -
    • Fixed numerous invalid examples
    • -
    -

    -
    -
    draft-zyp-json-schema-04
    -
    -
      -
    • Salvaged from draft v3.
    • -
    • Split validation keywords into separate document.
    • -
    • Split hypermedia keywords into separate document.
    • -
    • Initial post-split draft.
    • -
    • Mandate the use of JSON Reference, JSON Pointer.
    • -
    • Define the role of "id". Define URI resolution scope.
    • -
    • Add interoperability considerations.
    • -
    -

    -
    -
    draft-zyp-json-schema-00
    -
    -
    • Initial draft.
    -

    -
    -
    - -

    -

    Authors' Addresses

    -
    -
    - - Austin Wright (editor) - - - - - - - - - - - - - EMail: aaa@bzfx.net - -
    -
    -
    - - Henry Andrews (editor) - - - - - - - - - - - - - EMail: andrews_henry@yahoo.com - -
    -
    -
    - - Ben Hutton (editor) - - - Wellcome Sanger Institute - - - - - - - - - - EMail: bh7@sanger.ac.uk - -URI: https://jsonschema.dev - -
    -
    -
    - - Greg Dennis - - - - - - - Auckland, - - - - NZ - - EMail: gregsdennis@yahoo.com - -
    -
    - - - diff --git a/latest/json-schema-core.md b/latest/json-schema-core.md new file mode 100644 index 00000000..600039c6 --- /dev/null +++ b/latest/json-schema-core.md @@ -0,0 +1,5 @@ +--- +redirect_to: "/draft/2019-09/json-schema-core.html" +title: "JSON Schema: A Media Type for Describing JSON Documents" +--- + diff --git a/latest/json-schema-hypermedia.html b/latest/json-schema-hypermedia.html deleted file mode 100644 index 2c919aae..00000000 --- a/latest/json-schema-hypermedia.html +++ /dev/null @@ -1,2008 +0,0 @@ - - - - - - - JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Internet Engineering Task ForceH. Andrews, Ed.
    Internet-Draft
    Intended status: InformationalA. Wright, Ed.
    Expires: March 20, 2020September 17, 2019
    - -

    JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON
    - draft-handrews-json-schema-hyperschema-02

    - -

    Abstract

    -

    JSON Schema is a JSON-based format for describing JSON data using various vocabularies. This document specifies a vocabulary for annotating JSON documents with hyperlinks. These hyperlinks include attributes describing how to manipulate and interact with remote resources through hypermedia environments such as HTTP, as well as determining whether the link is usable based on the instance value. The hyperlink serialization format described in this document is also usable independent of JSON Schema.

    -

    Note to Readers

    -

    The issues list for this draft can be found at <https://github.com/json-schema-org/json-schema-spec/issues>.

    -

    For additional information, see <https://json-schema.org/>.

    -

    To provide feedback, use this issue tracker, the communication methods listed on the homepage, or email the document editors.

    -

    Status of This Memo

    -

    This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

    -

    Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

    -

    Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

    -

    This Internet-Draft will expire on March 20, 2020.

    -

    Copyright Notice

    -

    Copyright (c) 2019 IETF Trust and the persons identified as the document authors. All rights reserved.

    -

    This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

    - - -
    -

    Table of Contents

    - - -

    -1. Introduction

    -

    JSON Hyper-Schema is a JSON Schema vocabulary for annotating JSON documents with hyperlinks and instructions for processing and manipulating remote JSON resources through hypermedia environments such as HTTP.

    -

    The term JSON Hyper-Schema is used to refer to a JSON Schema that uses these keywords. The term "hyper-schema" on its own refers to a JSON Hyper-Schema within the scope of this specification.

    -

    The primary mechanism introduced for specifying links is the Link Description Object (LDO), which is a serialization of the abstract link model defined in RFC 8288, section 2.

    -

    This specification will use the concepts, syntax, and terminology defined by the JSON Schema core and JSON Schema validation specifications. It is advised that readers have a copy of these specifications.

    -

    -2. Notational Conventions

    -

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

    -

    -3. Overview

    -

    JSON Hyper-Schema makes it possible to build hypermedia systems from JSON documents by describing how to construct hyperlinks from instance data.

    -

    The combination of a JSON instance document and a valid application/schema+json hyper-schema for that instance behaves as a single hypermedia representation. By allowing this separation, hyper-schema-based systems can gracefully support applications that expect plain JSON, while providing full hypermedia capabilities for hyper-schema-aware applications and user agents.

    -

    User agents can detect the presence of hyper-schema by looking for the application/schema+json media type and a "$schema" value that indicates the presence of the hyper-schema vocabulary. A user agent can then use an implementation of JSON Hyper-Schema to provide an interface to the combination of the schema and instance documents as a single logical representation of a resource, just as with any single-document hypermedia representation format.

    -

    Hyper-schemas allow representations to take up fewer bytes on the wire, and distribute the burden of link construction from the server to each client. A user agent need not construct a link unless a client application requests that link. JSON Hyper-Schema can also be used on the server side to generate other link serializations or representation formats at runtime, or pre-emptively follow links to facilitate server push usage.

    -

    Here is an example hyper-schema that adds a single link, with the IANA-registered link relation type "self", that is built from an instance with one known object field named "id":

    -
    -{
    -    "type": "object",
    -    "properties": {
    -        "id": {
    -            "type": "number",
    -            "readOnly": true
    -        }
    -    },
    -    "links": [
    -        {
    -            "rel": "self",
    -            "href": "thing/{id}"
    -        }
    -    ]
    -}
    -                
    -

    If the instance is {"id": 1234}, and its base URI according to RFC 3986 section 5.1, is "https://example.com/api/", then "https://example.com/api/thing/1234" is the resulting link's target URI.

    -

    -3.1. Terminology

    -

    The terms "schema", "instance", and "meta-schema" are to be interpreted as defined in the JSON Schema core specification.

    -

    The terms "applicable" and "attached" are to be interpreted as defined in Section 3.1 of the JSON Schema core specification.

    -

    The terms "link", "link context" (or "context"), "link target" (or "target"), and "target attributes" are to be interpreted as defined in Section 2 of RFC 8288.

    -

    The term "user agent" is to be interpreted as defined in Section 2.1 of RFC 7230, generalized to apply to any protocol that may be used in a hypermedia system rather than specifically being an HTTP client.

    -

    This specification defines the following terms:

    - -
    -
    JSON Hyper-Schema
    -
    A JSON Schema using the keywords defined by this specification.
    -
    hyper-schema
    -
    Within this document, the term "hyper-schema" always refers to a JSON Hyper-Schema
    -
    link validity
    -
    A valid link for an instance is one that is applicable to that instance and does not fail any requirement imposed by the keywords in the Link Description Object. Note that invalid links can occur when using keywords such as "if" or "oneOf" (from the Core specification) to describe links that are conditional on the representation's structure or value.
    -
    generic user agent
    -
    A user agent which can be used to interact with any resource, from any server, from among the standardized link relations, media types, URI schemes, and protocols that it supports; though it may be extendible to specially handle particular profiles of media types.
    -
    client application
    -
    An application which uses a hypermedia system for a specific purpose. Such an application may also be its own user agent, or it may be built on top of a generic user agent. A client application is programmed with knowledge of link relations, media types, URI schemes, protocols, and data structures that are specific to the application's domain.
    -
    client input
    -
    Data provided through a user agent, and most often also through a client application. Such data may be requested from a user interactively, or provided before interaction in forms such as command-line arguments, configuration files, or hardcoded values in source code.
    -
    operation
    -
    A specific use of a hyperlink, such as making a network request (for a URI with a scheme such as "http://" that indicates a protocol) or otherwise taking action based on a link (reading data from a "data:" URI, or constructing an email message based on a "mailto:" link). For protocols such as HTTP that support multiple methods, each method is considered to be a separate operation on the same link.
    -
    - -

    -

    -3.2. Functionality

    -

    A JSON Hyper-Schema implementation is able to take a hyper-schema, an instance, and in some cases client input, and produce a set of fully resolved valid links. As defined by RFC 8288, section 2, a link consists of a context, a typed relation, a target, and optionally additional target attributes.

    -

    The relation type and target attributes are taken directly from each link's Link Description Object. The context and target identifiers are constructed from some combination of URI Templates, instance data, and (in the case of the target identifier) client input.

    -

    The target is always fully identified by a URI. Due to the lack of a URI fragment identifier syntax for application/json and many other media types that can be used with JSON Hyper-Schema, the context may be only partially identified by a URI. In such cases, the remaining identification will be provided as a JSON Pointer.

    -

    A few IANA-registered link relation types are given specific semantics in a JSON Hyper-Schema document. A "self" link is used to interact with the resource that the instance document represents, while "collection" and "item" links identify resources for which collection-specific semantics can be assumed.

    -

    -4. Meta-Schemas and Output Schema

    -

    The current URI for the JSON Hyper-Schema meta-schema is <https://json-schema.org/draft/2019-09/hyper-schema#>.

    -

    The current URI for this vocabulary, known as the Hyper-Schema vocabulary, is: <https://json-schema.org/draft/2019-09/vocab/hyper-schema>.

    -

    The current URI for the corresponding meta-schema, which differs from the convenience meta-schema above in that it describes only the hyper-schema keywords ("base" and "link") is: <https://json-schema.org/draft/2019-09/meta/hyper-schema>.

    -

    The link description format can be used without JSON Schema, and use of this format can be declared by referencing the normative link description schema as the schema for the data structure that uses the links. The URI of the normative link description schema is: <https://json-schema.org/draft/2019-09/links#>.

    -

    JSON Hyper-Schema implementations are free to provide output in any format. However, a specific format is defined for use in the conformance test suite, which is also used to illustrate points in the "Implementation Requirements", and to show the output generated by examples. It is RECOMMENDED that implementations be capable of producing output in this format to facilitated testing. The URI of the JSON Schema describing the recommended output format is <https://json-schema.org/draft/2019-09/output/hyper-schema#>.

    -

    Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations SHOULD consider URIs dated after this specification draft and before the next to indicate the same syntax and semantics as those listed here.

    -

    -5. Schema Keywords

    -

    Hyper-schema keywords from all schemas that are applicable to a position in an instance, as defined by Section 3.1 of JSON Schema core, can be used with that instance.

    -

    When multiple subschemas are applicable to a given sub-instance, all "link" arrays MUST be combined, in any order, into a single set. Each object in the resulting set MUST retain its own list of applicable "base" values, in resolution order, from the same schema and any parent schemas.

    -

    As with all JSON Schema keywords, all keywords described in this section are optional. The minimal valid JSON Hyper-schema is the blank object.

    -

    -5.1. base -

    -

    If present, this keyword MUST be first resolved as a URI Template, and then MUST be resolved as a URI Reference against the current URI base of the instance. The result MUST be set as the new URI base for the instance while processing the sub-schema containing "base" and all sub-schemas within it.

    -

    The process for resolving the "base" template can be different when being resolved for use with "anchor" than when being resolved for use with "href", which is explained in detail in the URI Templating section.

    -

    -5.2. links

    -

    The "links" property of schemas is used to associate Link Description Objects with instances. The value of this property MUST be an array, and the items in the array must be Link Description Objects, as defined below.

    -

    -6. Link Description Object -

    -

    A Link Description Object (LDO) is a serialization of the abstract link model defined in RFC 8288, section 2. As described in that document, a link consists of a context, a relation type, a target, and optionally target attributes. JSON Hyper-Schema's LDO provides all of these, along with additional features using JSON Schema to describe input for use with the links in various ways.

    -

    Due to the use of URI Templates to identify link contexts and targets, as well as optional further use of client input when identifying targets, an LDO is a link template that may resolve to multiple links when used with a JSON instance document.

    -

    A specific use of an LDO, typically involving a request and response across a protocol, is referred to as an operation. For many protocols, multiple operations are possible on any given link. The protocol is indicated by the target's URI scheme. Note that not all URI schemes indicate a protocol that can be used for communications, and even resources with URI schemes that do indicate such protocols need not be available over that protocol.

    -

    A Link Description Object MUST be an object, and the "href" and "rel" properties MUST be present. Each keyword is covered briefly in this section, with additional usage explanation and comprehensive examples given later in the document.

    -

    -6.1. Link Context -

    -

    In JSON Hyper-Schema, the link's context resource is, by default, the sub-instance to which it is attached (as defined by Section 3.1 of the JSON Schema core specification). This is often not the entire instance document. This default context can be changed using the keywords in this section.

    -

    Depending on the media type of the instance, it may or may not be possible to assign a URI to the exact default context resource. In particular, application/json does not define a URI fragment resolution syntax, so properties or array elements within a plain JSON document cannot be fully identified by a URI. When it is not possible to produce a complete URI, the position of the context SHOULD be conveyed by the URI of the instance document, together with a separate plain-string JSON Pointer.

    -

    Implementations MUST be able to construct the link context's URI, and (if necessary for full identification), a JSON Pointer in string representation form as per RFC 6901, section 5 in place of a URI fragment. The process for constructing a URI based on a URI template is given in the URI Templating section.

    -

    -6.1.1. anchor -

    -

    This property sets the context URI of the link. The value of the property is a URI Template, and the resulting URI-reference MUST be resolved against the base URI of the instance.

    -

    The URI is computed from the provided URI template using the same process described for the "href" property, with the exception that "hrefSchema" MUST NOT be applied. Unlike target URIs, context URIs do not accept user input.

    -

    -6.1.2. anchorPointer -

    -

    This property changes the point within the instance that is considered to be the context resource of the link. The value of the property MUST be a valid JSON Pointer in JSON String representation form, or a valid Relative JSON Pointer which is evaluated relative to the default context.

    -

    While an alternate context with a known URI is best set with the "anchor" keyword, the lack of a fragment identifier syntax for application/json means that it is usually not possible to change the context within a JSON instance using a URI.

    -

    Even in "+json" media types that define JSON Pointer as a fragment identifier syntax, if the default context is nested within an array, it is not possible to obtain the index of the default context's position in that array in order to construct a pointer to another property in that same nested JSON object. This will be demonstrated in the examples.

    -

    The result of processing this keyword SHOULD be a URI fragment if the media type of the instance allows for such a fragment. Otherwise it MUST be a string-encoded JSON Pointer.

    -

    -6.2. Link Relation Type -

    -

    The link's relation type identifies its semantics. It is the primary means of conveying how an application can interact with a resource.

    -

    Relationship definitions are not normally media type dependent, and users are encouraged to utilize the most suitable existing accepted relation definitions.

    -

    -6.2.1. rel -

    -

    The value of this property MUST be either a string or an array of strings. If the value is an array, it MUST contain at least one string.

    -

    Each string MUST be a single Link Relation Type as defined in RFC 8288, Section 2.1, including the restriction that additional semantics SHOULD NOT be inferred based upon the presence or absence of another link relation type.

    -

    This property is required.

    -

    -6.2.2. "self" Links -

    -

    A "self" link, as originally defined by Section 4.2.7.2 of RFC 4287, indicates that the target URI identifies a resource equivalent to the link context. In JSON Hyper-Schema, a "self" link MUST be resolvable from the instance, and therefore "hrefSchema" MUST NOT be present.

    -

    Hyper-schema authors SHOULD use "templateRequired" to ensure that the "self" link has all instance data that is needed for use.

    -

    A hyper-schema implementation MUST recognize that a link with relation type "self" that has the entire current instance document as its context describes how a user agent can interact with the resource represented by that instance document.

    -

    -6.2.3. "collection" and "item" Links -

    -

    RFC 6573 defines and registers the "item" and "collection" link relation types. JSON Hyper-Schema imposes additional semantics on collection resources indicated by these types.

    -

    Implementations MUST recognize the target of a "collection" link and the context of an "item" link as collections.

    -

    A well-known design pattern in hypermedia is to use a collection resource to create a member of the collection and give it a server-assigned URI. If the protocol indicated by the URI scheme defines a specific method that is suited to creating a resource with a server-assigned URI, then a collection resource, as identified by these link relation types, MUST NOT define semantics for that method that conflict with the semantics of creating a collection member. Collection resources MAY implement item creation via such a protocol method, and user agents MAY assume that any such operation, if it exists, has item creation semantics.

    -

    As such a method would correspond to JSON Hyper-Schema's data submission concept, the "submissionSchema" field for the link SHOULD be compatible with the schema of the representation of the collection's items, as indicated by the "item" link's target resource or the "self" link of the "collection" link's context resource.

    -

    -6.2.4. Using Extension Relation Types -

    -

    When no registered relation (aside from "related") applies, users are encouraged to mint their own extension relation types, as described in section 2.1.2 of RFC 8288. The simplest approaches for choosing link relation type URIs are to either use a URI scheme that is already in use to identify the system's primary resources, or to use a human-readable, non-dereferenceable URI scheme such as "tag", defined by RFC 4151.

    -

    Extension relation type URIs need not be dereferenceable, even when using a scheme that allows it.

    -

    -6.3. Link Target -

    -

    The target URI template is used to identify the link's target, potentially making use of instance data. Additionally, with "hrefSchema", this template can identify a set of possible target resources to use based on client input. The full process of resolving the URI template, with or without client input, is covered in the URI Templating section.

    -

    -6.3.1. href -

    -

    The value of the "href" link description property is a template used to determine the target URI of the related resource. The value of the instance property MUST be resolved as a URI-reference against the base URI of the instance.

    -

    This property is REQUIRED.

    -

    -6.4. Adjusting URI Template Resolution

    -

    The keywords in this section are used when resolving all URI Templates involved in hyper-schema: "base", "anchor", and "href". See the URI Templating section for the complete template resolution algorithm.

    -

    Note that when resolving a "base" template, the attachment point from which resolution begins is the attachment point of the "href" or "anchor" keyword being resolved which requires "base" templates to be resolved, not the attachment point of the "base" keyword itself.

    -

    -6.4.1. templatePointers -

    -

    The value of the "templatePointers" link description property MUST be an object. Each property value in the object MUST be a valid JSON Pointer, or a valid Relative JSON Pointer which is evaluated relative to the attachment point of the link for which the template is being resolved.

    -

    For each property name in the object that matches a variable name in the template being resolved, the value of that property adjusts the starting position of variable resolution for that variable. Properties which do not match template variable names in the template being resolved MUST be ignored.

    -

    -6.4.2. templateRequired -

    -

    The value of this keyword MUST be an array, and the elements MUST be unique. Each element SHOULD match a variable in the link's URI Template, without percent-encoding. After completing the entire URI Template resolution process, if any variable that is present in this array does not have a value, the link MUST NOT be used.

    -

    -6.5. Link Target Attributes -

    -

    All properties in this section are advisory only. While keywords such as "title" and "description" are used primarily to present the link to users, those keywords that predict the nature of a link interaction or response MUST NOT be considered authoritative. The runtime behavior of the target resource MUST be respected whenever it conflicts with the target attributes in the LDO.

    -

    -6.5.1. title

    -

    This property defines a title for the link. The value MUST be a string.

    -

    User agents MAY use this title when presenting the link to the user.

    -

    -6.5.2. description

    -

    This property provides additional information beyond what is present in the title. The value MUST be a string. While a title is preferably short, a description can be used to go into more detail about the purpose and usage of the link.

    -

    User agents MAY use this description when presenting the link to the user.

    -

    -6.5.3. targetMediaType

    -

    The value of this property represents the media type RFC 2046, that is expected to be returned when fetching this resource. This property value MAY be a media range instead, using the same pattern defined in RFC 7231, section 5.3.2 - HTTP "Accept" header.

    -

    This property is analogous to the "type" property of other link serialization formats. User agents MAY use this information to inform the interface they present to the user before the link is followed, but MUST NOT use this information in the interpretation of the resulting data. Instead, a user agent MUST use the media type given by the response for run-time interpretation. See the section on "Security Concerns" for a detailed examination of mis-use of "targetMediaType".

    -

    For protocols supporting content-negotiation, implementations MAY choose to describe possible target media types using protocol-specific information in "headerSchema". If both protocol-specific information and "targetMediaType" are present, then the value of "targetMediaType" MUST be compatible with the protocol-specific information, and SHOULD indicate the media type that will be returned in the absence of content negotiation.

    -

    When no such protocol-specific information is available, or when the implementation does not recognize the protocol involved, then the value SHOULD be taken to be "application/json".

    -

    -6.5.4. targetSchema -

    -

    This property provides a schema that is expected to describe the link target's representation. Depending on the protocol, the schema may or may not describe the request or response to any particular operation performed with the link. See the JSON Hyper-Schema and HTTP section for an in-depth discussion of how this keyword is used with HTTP.

    -

    -6.5.5. targetHints -

    -

    [CREF1]This section attempts to strike a balance between comprehensiveness and flexibility by deferring most of its structure to the protocol indicated by the URI scheme. Note that a resource can be identified by a URI with a dereferenceable scheme, yet not be accessible over that protocol. While currently very loose, this section is expected to become more well-defined based on draft feedback, and may change significantly in future drafts.

    -

    The value of this property is advisory only. It represents information that is expected to be discoverable through interacting with the target resource, typically in the form of protocol-specific control information or meta-data such as headers returned in response to an HTTP HEAD or OPTIONS request. The protocol is determined by the "href" URI scheme, although note that resources are not guaranteed to be accessible over such a protocol.

    -

    The value of this property SHOULD be an object. The keys to this object SHOULD be lower-cased forms of the control data field names. Each value SHOULD be an array, in order to uniformly handle multi-valued fields. Multiple values MUST be presented as an array, and not as a single string.

    -

    Protocols with control information not suitable for representation as a JSON object MAY be represented by another data type, such as an array.

    -

    Values that cannot be understood as part of the indicated protocol MUST be ignored by a JSON Hyper-Schema implementation. Applications MAY make use of such values, but MUST NOT assume interoperability with other implementations.

    -

    Implementations MUST NOT assume that all discoverable information is accounted for in this object. Client applications MUST properly handle run-time responses that contradict this property's values.

    -

    Client applications MUST NOT assume that an implementation will automatically take any action based on the value of this property.

    -

    See "JSON Hyper-Schema and HTTP" for guidance on using this keyword with HTTP and analogous protocols.

    -

    -6.6. Link Input -

    -

    There are four ways to use client input with a link, and each is addressed by a separate link description object keyword. When performing operations, user agents SHOULD ignore schemas that are not relevant to their semantics.

    -

    -6.6.1. hrefSchema -

    -

    The value of the "hrefSchema" link description property MUST be a valid JSON Schema. This schema is used to validate user input or other user agent data for filling out the URI Template in "href".

    -

    Omitting "hrefSchema" or setting the entire schema to "false" prevents any user agent data from being accepted.

    -

    Setting any subschema that applies to a particular variable to the JSON literal value "false" prevents any user agent data from being accepted for that single variable.

    -

    For template variables that can be resolved from the instance data, if the instance data is valid against all applicable subschemas in "hrefSchema", then it MUST be used to pre-populate the input data set for that variable.

    -

    Note that even when data is pre-populated from the instance, the validation schema for that variable in "hrefSchema" need not be identical to the validation schema(s) that apply to the instance data's location. This allows for different validation rules for user agent data, such as supporting spelled-out months for date-time input, but using the standard date-time format for storage.

    -

    After input is accepted, potentially overriding the pre-populated instance data, the resulting data set MUST successfully validate against the value of "hrefSchema". If it does not then the link MUST NOT be used. If it is valid, then the process given in the "URI Templating" section continues with this updated data set.

    -

    -6.6.2. headerSchema -

    -

    [CREF2]As with "targetHints", this keyword is somewhat under-specified to encourage experimentation and feedback as we try to balance flexibility and clarity.

    -

    If present, this property is a schema for protocol-specific request headers or analogous control and meta-data. The value of this object MUST be a valid JSON Schema. The protocol is determined by the "href" URI scheme, although note that resources are not guaranteed to be accessible over such a protocol. The schema is advisory only; the target resource's behavior is not constrained by its presence.

    -

    The purpose of this keyword is to advertise target resource interaction features, and indicate to user agents and client applications what headers and header values are likely to be useful. User agents and client applications MAY use the schema to validate relevant headers, but MUST NOT assume that missing headers or values are forbidden from use. While schema authors MAY set "additionalProperties" to false, this is NOT RECOMMENDED and MUST NOT prevent client applications or user agents from supplying additional headers when requests are made.

    -

    The exact mapping of the JSON data model into the headers is protocol-dependent. However, in most cases this schema SHOULD specify a type of "object", and the property names SHOULD be lower-cased forms of the control data field names. As with "targetHints", the values SHOULD be described as arrays to allow for multiple values, even if only one value is expected.

    -

    See the "JSON Hyper-Schema and HTTP" section for detailed guidance on using this keyword with HTTP and analogous protocols.

    -

    "headerSchema" is applicable to any request method or command that the protocol supports. When generating a request, user agents and client applications SHOULD ignore schemas for headers that are not relevant to that request.

    -

    -6.6.3. Manipulating the Target Resource Representation

    -

    In JSON Hyper-Schema, "targetSchema" supplies a non-authoritative description of the target resource's representation. A client application can use "targetSchema" to structure input for replacing or modifying the representation, or as the base representation for building a patch document based on a patch media type.

    -

    Alternatively, if "targetSchema" is absent or if the client application prefers to only use authoritative information, it can interact with the target resource to confirm or discover its representation structure.

    -

    "targetSchema" is not intended to describe link operation responses, except when the response semantics indicate that it is a representation of the target resource. In all cases, the schema indicated by the response itself is authoritative. See "JSON Hyper-Schema and HTTP" for detailed examples.

    -

    -6.6.4. Submitting Data for Processing

    -

    The "submissionSchema" and "submissionMediaType" keywords describe the domain of the processing function implemented by the target resource. Otherwise, as noted above, the submission schema and media type are ignored for operations to which they are not relevant.

    -

    -6.6.4.1. submissionMediaType -

    -

    If present, this property indicates the media type format the client application and user agent should use for the request payload described by "submissionSchema".

    -

    Omitting this keyword has the same behavior as a value of application/json.

    -

    Note that "submissionMediaType" and "submissionSchema" are not restricted to HTTP URIs. [CREF3]This statement might move to wherever the example ends up.

    -

    -6.6.4.2. submissionSchema -

    -

    This property contains a schema which defines the acceptable structure of the document to be encoded according to the "submissionMediaType" property and sent to the target resource for processing. This can be viewed as describing the domain of the processing function implemented by the target resource.

    -

    This is a separate concept from the "targetSchema" property, which describes the target information resource (including for replacing the contents of the resource in a PUT request), unlike "submissionSchema" which describes the user-submitted request data to be evaluated by the resource. "submissionSchema" is intended for use with requests that have payloads that are not necessarily defined in terms of the target representation.

    -

    Omitting "submissionSchema" has the same behavior as a value of "true".

    -

    -7. Implementation Requirements -

    -

    At a high level, a conforming implementation will meet the following requirements. Each of these requirements is covered in more detail in the individual keyword sections and keyword group overviews.

    -

    Note that the requirements around how an implementation MUST recognize "self", "collection", and "item" links are thoroughly covered in the link relation type section and are not repeated here.

    -

    While it is not a mandatory format for implementations, the output format used in the test suite summarizes what needs to be computed for each link before it can be used:

    - -
    -
    contextUri
    -
    The fully resolved URI (with scheme) of the context resource. If the context is not the entire resource and there is a usable fragment identifier syntax, then the URI includes a fragment. Note that there is no such syntax for application/json.
    -
    contextPointer
    -
    The JSON Pointer for the location within the instance of the context resource. If the instance media type supports JSON Pointers as fragment identifiers, this pointer will be the same as the one encoded in the fragment of the "contextUri" field.
    -
    rel
    -
    The link relation type. When multiple link relation types appear in the LDO, for the purpose of producing output, they are to be treated as multiple LDOs, each with a single link relation type but otherwise identical.
    -
    targetUri
    -
    The fully resolved URI (with a scheme) of the target resource. If the link accepts input, this can only be produced once the input has been supplied.
    -
    hrefInputTemplates
    -
    The list of partially resolved URI references for a link that accepts input. The first entry in the list is the partially resolved "href". The additional entries, if any, are the partially resolved "base" values ordered from the most immediate out to the root of the schema. Template variables that are pre-populated in the input are not resolved at this stage, as the pre-populated value can be overridden.
    -
    hrefPrepopulatedInput
    -
    The data set that the user agent should use to prepopulate any input mechanism before accepting client input. If input is to be accepted but no fields are to be pre-populated, then this will be an empty object.
    -
    attachmentPointer
    -
    The JSON Pointer for the location within the instance to which the link is attached. By default, "contextUri" and "attachmentPointer" are the same, but "contextUri" can be changed by LDO keywords, while "attachmentPointer" cannot.
    -
    - -

    Other LDO keywords that are not involved in producing the above information are included exactly as they appear when producing output for the test suite. Those fields will not be further discussed here unless specifically relevant.

    -

    -7.1. Link Discovery and Look-Up

    -

    Before links can be used, they must be discovered by applying the hyper-schema to the instance and finding all applicable and valid links. Note that in addition to collecting valid links, any "base" values necessary to resolve each LDO's URI Templates must also be located and associated with the LDO through whatever mechanism is most useful for the implementation's URI Template resolution process.

    -

    And implementation MUST support looking up links by either their attachment pointer or context pointer, either by performing the look-up or by providing the set of all links with both pointers determined so that user agents can implement the look-up themselves.

    -

    When performing look-ups by context pointer, links that are attached to elements of the same array MUST be returned in the same order as the array elements to which they are attached.

    -

    -7.2. URI Templating -

    -

    Three hyper-schema keywords are URI Templates: "base", "anchor", and "href". Each are resolved separately to URI-references, and then the anchor or href URI-reference is resolved against the base (which is itself resolved against earlier bases as needed, each of which was first resolved from a URI Template to a URI-reference).

    -

    All three keywords share the same algorithm for resolving variables from instance data, which makes use of the "templatePointers" and "templateRequired" keywords. When resolving "href", both it and any "base" templates needed for resolution to an absolute URI, the algorithm is modified to optionally accept user input based on the "hrefSchema" keyword.

    -

    For each URI Template (T), the following pseudocode describes an algorithm for resolving T into a URI-reference (R). For the purpose of this algorithm:

    - -
      -
    • "ldo.templatePointers" is an empty object if the keyword was not present and "ldo.templateRequired" is likewise an empty array.
    • -
    • "attachmentPointer" is the absolute JSON Pointer for the attachment location of the LDO.
    • -
    • "getApplicableSchemas()" returns an iterable set of all (sub)schemas that apply to the attachment point in the instance.
    • -
    - -

    -

    This algorithm should be applied first to either "href" or "anchor", and then as needed to each successive "base". The order is important, as it is not always possible to tell whether a template will resolve to a full URI or a URI-reference.

    -

    In English, the high-level algorithm is:

    - -
      -
    1. Populate template variable data from the instance
    2. -
    3. If input is desired, accept input
    4. -
    5. Check that all required variables have a value
    6. -
    7. Encode values into strings and fill out the template
    8. -
    - -

    -

    This is the high-level algorithm as pseudocode. "T" comes from either "href" or "anchor" within the LDO, or from "base" in a containing schema. Pseudocode for each step follows. "initialTemplateKeyword" indicates which of the two started the process (since "base" is always resolved in order to finish resolving one or the other of those keywords).

    -
    -
    -templateData = populateDataFromInstance(T, ldo, instance)
    -
    -if initialTemplateKeyword == "href" and ldo.hrefSchema exists:
    -    inputData = acceptInput(ldo, instance, templateData)
    -    for varname in inputData:
    -        templateData[varname] = inputData[varname]
    -
    -for varname in ldo.templateRequired:
    -    if not exists templateData[varname]
    -        fatal("Missing required variable(s)")
    -
    -templateData = stringEncode(templateData)
    -R = rfc6570ResolutionAlgorithm(T, templateData)
    -
    -                    
    -

    -7.2.1. Populating Template Data From the Instance

    -

    This step looks at various locations in the instance for variable values. For each variable:

    - -
      -
    1. Use "templatePointers" to find a value if the variable appears in that keyword's value
    2. -
    3. Otherwise, look for a property name matching the variable in the instance location to which the link is attached
    4. -
    5. In either case, if there is a value at the location, put it in the template resolution data set
    6. -
    - -

    -
    -
    -for varname in T:
    -    varname = rfc3986PercentDecode(varname)
    -    if varname in ldo.templatePointers:
    -        valuePointer = templatePointers[varname]
    -        if valuePointer is relative:
    -            valuePointer = resolveRelative(attachmentPointer,
    -                                           valuePointer)
    -    else
    -        valuePointer = attachmentPointer + "/" + varname
    -
    -    value = instance.valueAt(valuePointer)
    -    if value is defined:
    -        templateData[varname] = value
    -
    -                        
    -

    -7.2.2. Accepting Input for Template Data

    -

    This step is relatively complex, as there are several cases to support. Some variables will forbid input and some will allow it. Some will have initial values that need to be presented in the input interface, and some will not.

    -

    - -
      -
    1. Determine which variables can accept input
    2. -
    3. Pre-populate the input data set if the template resolution data set has a value
    4. -
    5. Accept input (present a web form, make a callback, etc.)
    6. -
    7. Validate the input data set, (not the template resolution data set)
    8. -
    9. Put the input in the template resolution data set, overriding any existing values
    10. -
    - -

    -

    "InputForm" represents whatever sort of input mechanism is appropriate. This may be a literal web form, or may be a more programmatic construct such as a callback function accepting specific fields and data types, with the given initial values, if any.

    -
    -
    -form = new InputForm()
    -for varname in T:
    -    useField = true
    -    useInitialData = true
    -    for schema in getApplicableSchemas(ldo.hrefSchema,
    -                                       "/" + varname):
    -        if schema is false:
    -            useField = false
    -            break
    -
    -        if varname in templateData and
    -           not isValid(templateData[varname], schema)):
    -            useInitialData = false
    -            break
    -
    -    if useField:
    -        if useInitialData:
    -            form.addInputFieldFor(varname, ldo.hrefSchema,
    -                                  templateData[varname])
    -        else:
    -            form.addInputFieldFor(varname, ldo.hrefSchema)
    -
    -inputData = form.acceptInput()
    -
    -if not isValid(inputData, hrefSchema):
    -    fatal("Input invalid, link is not usable")
    -
    -return inputData:
    -
    -                        
    -

    -7.2.3. Encoding Data as Strings

    -

    This section is straightforward, converting literals to their names as strings, and converting numbers to strings in the most obvious manner, and percent-encoding as needed for use in the URI.

    -
    -
    -for varname in templateData:
    -    value = templateData[varname]
    -    if value is true:
    -        templateData[varname] = "true"
    -    else if value is false:
    -        templateData[varname] = "false"
    -    else if value is null:
    -        templateData[varname] = "null"
    -    else if value is a number:
    -        templateData[varname] =
    -            bestEffortOriginalJsonString(value)
    -    else:
    -        templateData[varname] = rfc3986PercentEncode(value)
    -
    -                        
    -

    In some software environments the original JSON representation of a number will not be available (there is no way to tell the difference between 1.0 and 1), so any reasonable representation should be used. Schema and API authors should bear this in mind, and use other types (such as string or boolean) if the exact representation is important. If the number was provide as input in the form of a string, the string used as input SHOULD be used.

    -

    -7.3. Providing Access to LDO Keywords

    -

    For a given link, an implementation MUST make the values of all target attribute keywords directly available to the user agent. Implementations MAY provide additional interfaces for using this information, as discussed in each keyword's section.

    -

    For a given link, an implementation MUST make the value of each input schema keyword directly available to the user agent.

    -

    To encourage encapsulation of the URI Template resolution process, implementations MAY omit the LDO keywords that are used only to construct URIs. However, implementations MUST provide access to the link relation type.

    -

    Unrecognized keywords SHOULD be made available to the user agent, and MUST otherwise be ignored.

    -

    -7.4. Requests

    -

    A hyper-schema implementation SHOULD provide access to all information needed to construct any valid request to the target resource.

    -

    The LDO can express all information needed to perform any operation on a link. This section explains what hyper-schema fields a user agent should examine to build requests from any combination of instance data and client input. A hyper-schema implementation is not itself expected to construct and send requests.

    -

    Target URI construction rules, including "hrefSchema" for accepting input, are identical for all possible requests.

    -

    Requests that do not carry a body payload do not require additional keyword support.

    -

    Requests that take a target representation as a payload SHOULD use the "targetSchema" and "targetMediaType" keywords for input description and payload validation. If a protocol allows an operation taking a payload that is based on the representation as modified by a media type (such as a patch media type), then such a media type SHOULD be indicated through "targetHints" in a protocol-specific manner.

    -

    Requests that take a payload that is not derived from the target resource's representation SHOULD use the "submissionSchema" and "submissionMediaType" keywords for input description and payload validation. Protocols used in hypermedia generally only support one such non-representation operation per link.

    -

    RPC systems that pipe many application operations with arbitrarily different request structures through a single hypermedia protocol operation are outside of the scope of a hypermedia format such as JSON Hyper-Schema.

    -

    -7.5. Responses

    -

    As a hypermedia format, JSON Hyper-Schema is concerned with describing a resource, including describing its links in sufficient detail to make all valid requests. It is not concerned with directly describing all possible responses for those requests.

    -

    As in any hypermedia system, responses are expected to be self-describing. In the context of hyper-schema, this means that each response MUST link its own hyper-schema(s). While responses that consist of a representation of the target resource are expected to be valid against "targetSchema" and "targetMediaType", those keywords are advisory only and MUST be ignored if contradicted by the response itself.

    -

    Other responses, including error responses, complex redirections, and processing status representations SHOULD also link to their own schemas and use appropriate media types (e.g. "application/problem+json" for errors). Certain errors might not link a schema due to being generated by an intermediary that is not aware of hyper-schema, rather than by the origin.

    -

    User agents are expected to understand protocol status codes and response media types well enough to handle common situations, and provide enough information to client applications to handle domain-specific responses.

    -

    Statically mapping all possible responses and their schemas at design time is outside of the scope of JSON Hyper-Schema, but may be within the scope of other JSON Schema vocabularies which build on hyper-schema (see Appendix A.3).

    -

    -7.6. Streaming Parsers -

    -

    The requirements around discovering links based on their context, or using the context of links to identify collections, present unique challenges when used with streaming parsers. It is not possible to authoritatively fulfill these requirements without processing the entire schema and instance documents.

    -

    Such implementations MAY choose to return non-authoritative answers based on data processed to date. When offering this approach, implementations MUST be clear on the nature of the response, and MUST offer an option to block and wait until all data is processed and an authoritative answer can be returned.

    -

    -8. JSON Hyper-Schema and HTTP -

    -

    While JSON Hyper-Schema is a hypermedia format and therefore protocol-independent, it is expected that its most common use will be in HTTP systems, or systems using protocols such as CoAP that are explicitly analogous to HTTP.

    -

    This section provides guidance on how to use each common HTTP method with a link, and how collection resources impose additional constraints on HTTP POST. Additionally, guidance is provided on hinting at HTTP response header values and describing possible HTTP request headers that are relevant to the given resource.

    -

    Section 13 of the JSON Schema core specification provides guidance on linking instances in a hypermedia system to their schemas. This may be done with network-accessible schemas, or may simply identify schemas which were pre-packaged within the client application. JSON Hyper-Schema intentionally does not constrain this mechanism, although it is RECOMMENDED that the techniques outlined in the core specification be used to whatever extent is possible.

    -

    -8.1. One Link Per Target and Relation Type

    -

    Link Description Objects do not directly indicate what operations, such as HTTP methods, are supported by the target resource. Instead, operations should be inferred primarily from link relation types and URI schemes.

    -

    This means that for each target resource and link relation type pair, schema authors SHOULD only define a single LDO. While it is possible to use "allow" with "targetHints" to repeat a relation type and target pair with different HTTP methods marked as allowed, this is NOT RECOMMENDED and may not be well-supported by conforming implementations.

    -

    All information necessary to use each HTTP method can be conveyed in a single LDO as explained in this section. The "allow" field in "targetHints" is intended simply to hint at which operations are supported, not to separately define each operation.

    -

    Note, however, that a resource may always decline an operation at runtime, for instance due to authorization failure, or due to other application state that controls the operation's availability.

    -

    -8.2. "targetSchema" and HTTP -

    -

    "targetSchema" describes the resource on the target end of the link, while "targetMediaType" defines that resource's media type. With HTTP links, "headerSchema" can also be used to describe valid values for use in an "Accept" request header, which can support multiple media types or media ranges. When both ways of indicating the target media type are present, "targetMediaType" SHOULD indicate the default representation media type, while the schema for "accept" in "headerSchema" SHOULD include the default as well as any alternate media types or media ranges that can be requested.

    -

    Since the semantics of many HTTP methods are defined in terms of the target resource, "targetSchema" is used for requests and/or responses for several HTTP methods. In particular, "targetSchema" suggests what a client application can expect for the response to an HTTP GET or any response for which the "Content-Location" header is equal to the request URI, and what a client application should send if it creates or replaces the resource with an HTTP PUT request. These correlations are defined by RFC 7231, section 4.3.1 - "GET", section 4.3.4 "PUT", and section 3.1.4.2, "Content-Location".

    -

    Per RFC 5789, the request structure for an HTTP PATCH is determined by the combination of "targetSchema" and the request media type, which is conveyed by the "Accept-Patch" header, which may be included in "targetHints". Media types that are suitable for PATCH-ing define a syntax for expressing changes to a document, which can be applied to the representation described by "targetSchema" to determine the set of syntactically valid request payloads. Often, the simplest way to validate a PATCH request is to apply it and validate the result as a normal representation.

    -

    -8.3. HTTP POST and the "submission*" keywords -

    -

    JSON Hyper-Schema allows for resources that process arbitrary data in addition to or instead of working with the target's representation. This arbitrary data is described by the "submissionSchema" and "submissionMediaType" keywords. In the case of HTTP, the POST method is the only one that handles such data. While there are certain conventions around using POST with collections, the semantics of a POST request are defined by the target resource, not HTTP.

    -

    In addition to the protocol-neutral "submission*" keywords (see Section 9.3 for a non-HTTP example), the "Accept-Post" header can be used to specify the necessary media type, and MAY be advertised via the "targetHints" field. [CREF4]What happens if both are used? Also, "submissionSchema" is a MUST to support, while "targetHints" are at most a SHOULD. But forbidding the use of "Accept-Post" in "targetHints" seems incorrect.

    -

    Successful responses to POST other than a 201 or a 200 with "Content-Location" set likewise have no HTTP-defined semantics. As with all HTTP responses, any representation in the response should link to its own hyper-schema to indicate how it may be processed. As noted in Appendix A.2, connecting hyperlinks with all possible operation responses is not within the scope of JSON Hyper-Schema.

    -

    -8.4. Optimizing HTTP Discoverability With "targetHints"

    -

    [CREF5]It would be good to also include a section with CoAP examples.

    -

    JSON serializations of HTTP response header information SHOULD follow the guidelines established by the work in progress "A JSON Encoding for HTTP Header Field Values". Approaches shown in that document's examples SHOULD be applied to other similarly structured headers wherever possible.

    -

    Headers for all possible HTTP method responses all share "headerSchema". In particular, both headers that appear in a HEAD response and those that appear in an OPTIONS response can appear. No distinction is made within "headerSchema" as to which method response contains which header.

    -

    It is RECOMMENDED that schema authors provide hints for the values of the following types of HTTP headers whenever applicable:

    - -
      -
    • Method allowance
    • -
    • Method-specific request media types
    • -
    • Authentication challenges
    • -
    - -

    -

    In general, headers that are likely to have different values at different times SHOULD NOT be included in "targetHints".

    -

    As an example, an Allow header allowing HEAD, GET, and POST would be shown as follows:

    -
    -
    -{
    -    "targetHints": {
    -        "allow": ["HEAD", "GET", "POST"]
    -    }
    -}
    -
    -                    
    -

    Note that this is represented identically whether there is a single-line Allow header with comma-separated values, multiple Allow headers on separate lines, each with one value, or any combination of such arrangements. As is generally true with HTTP headers, comma-separated values and multiple occurrences of the header are treated the same way.

    -

    -8.5. Advertising HTTP Features With "headerSchema"

    -

    Schemas SHOULD be written to describe JSON serializations that follow guidelines established by the work in progress "A JSON Encoding for HTTP Header Field Values" Approaches shown in that document's examples SHOULD be applied to other similarly structured headers wherever possible.

    -

    It is RECOMMENDED that schema authors describe the available usage of the following types of HTTP headers whenever applicable:

    - -
      -
    • Content negotiation
    • -
    • Authentication and authorization
    • -
    • Range requests
    • -
    • The "Prefer" header
    • -
    - -

    -

    Headers such as cache control and conditional request headers are generally implemented by intermediaries rather than the resource, and are therefore not generally useful to describe. While the resource must supply the information needed to use conditional requests, the runtime handling of such headers and related responses is not resource-specific.

    -

    -8.6. Creating Resources Through Collections

    -

    When using HTTP, or a protocol such as CoAP that is explicitly analogous to HTTP, this is done by POST-ing a representation of the individual resource to be created to the collection resource. The process for recognizing collection and item resources is described in Section 6.2.3.

    -

    -8.7. Content Negotiation and Schema Evolution

    -

    JSON Hyper-Schema facilitates HTTP content negotiation, and allows for a hybrid of the proactive and reactive strategies. As mentioned above, a hyper-schema can include a schema for HTTP headers such as "Accept", "Accept-Charset", "Accept-Language", etc with the "headerSchema" keyword. A user agent or client application can use information in this schema, such as an enumerated list of supported languages, in lieu of making an initial request to start the reactive negotiation process.

    -

    In this way, the proactive content negotiation technique of setting these headers can be informed by server information about what values are possible, similar to examining a list of alternatives in reactive negotiation.

    -

    For media types that allow specifying a schema as a media type parameter, the "Accept" values sent in a request or advertised in "headerSchema" can include the URI(s) of the schema(s) to which the negotiated representation is expected to conform. One possible use for schema parameters in content negotiation is if the resource has conformed to several different schema versions over time. The client application can indicate what version(s) it understands in the "Accept" header in this way.

    -

    -9. Examples -

    -

    This section shows how the keywords that construct URIs and JSON Pointers are used. The results are shown in the format used by the test suite. [CREF6]Need to post that and link it, but it should be pretty self-explanatory to those of you reviewing things at this stage.

    -

    Most other keywords are either straightforward ("title" and "description"), apply validation to specific sorts of input, requests, or responses, or have protocol-specific behavior. Examples demonstrating HTTP usage are available in an Appendix.

    -

    -9.1. Entry Point Links, No Templates -

    -

    For this example, we will assume an example API with a documented entry point URI of https://example.com/api, which is an empty JSON object with a link to a schema. Here, the entry point has no data of its own and exists only to provide an initial set of links:

    -
    -
    -GET https://example.com/api HTTP/1.1
    -
    -200 OK
    -Content-Type: application/json
    -Link: <https://schema.example.com/entry>; rel="describedBy"
    -{}
    -
    -                    
    -

    The linked hyper-schema defines the API's base URI and provides two links: an "about" link to API documentation, and a "self" link indicating that this is a schema for the base URI.

    -
    -
    -{
    -    "$id": "https://schema.example.com/entry",
    -    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
    -    "base": "https://example.com/api/",
    -    "links": [
    -        {
    -            "rel": "self",
    -            "href": "../api",
    -        }, {
    -            "rel": "about",
    -            "href": "docs"
    -        }
    -    ]
    -}
    -                    
    -

    These are the simplest possible links, with only a relation type and an "href" with no template variables. They resolve as follows:

    -

    The duplication of "api" in both the base and the "../api" href in the "self" link is due to quirks of the RFC 3986 URI-reference resolution algorithm. In order for relative URI-references to work well in general, the base URI needs to include a trailing slash. The "about" link with its "docs" href shows the common case of relative references, which is used in the other examples in this document.

    -

    However, if an API uses URIs without trailing slashes for its resources, there is no way to provide a relative reference that just removes a trailing slash without duplicating the path component above it. Which makes the case of the entry point resource, which differs from the base URI only in terms of the trailing slash, somewhat awkward.

    -

    Resource URIs, of course, may have trailing slashes, but this example is intended to highlight this frequently confusing special case.

    -
    -[
    -    {
    -        "contextUri": "https://example.com/api",
    -        "contextPointer": "",
    -        "rel": "self",
    -        "targetUri": "https://example.com/api",
    -        "attachmentPointer": ""
    -    },
    -    {
    -        "contextUri": "https://example.com/api",
    -        "contextPointer": "",
    -        "rel": "about",
    -        "targetUri": "https://example.com/api/docs",
    -        "attachmentPointer": ""
    -    }
    -]
    -                    
    -

    The attachment pointer is the root pointer (the only possibility with an empty object for the instance). The context URI is the default, which is the requested document. Since application/json does not allow for fragments, the context pointer is necessary to fully describe the context. Its default behavior is to be the same as the attachment pointer.

    -

    -9.2. Individually Identified Resources

    -

    Let's add "things" to our system, starting with an individual thing:

    -
    -{
    -    "$id": "https://schema.example.com/thing",
    -    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
    -    "base": "https://example.com/api/",
    -    "type": "object",
    -    "required": ["data"],
    -    "properties": {
    -        "id": {"$ref": "#/$defs/id"},
    -        "data": true
    -    },
    -    "links": [
    -        {
    -            "rel": "self",
    -            "href": "things/{id}",
    -            "templateRequired": ["id"],
    -            "targetSchema": {"$ref": "#"}
    -        }
    -    ],
    -    "$defs": {
    -        "id": {
    -            "type": "integer",
    -            "minimum": 1,
    -            "readOnly": true
    -        }
    -    }
    -}
    -                    
    -

    Our "thing" has a server-assigned id, which is required in order to construct the "self" link. It also has a "data" field which can be of any type. The reason for the "$defs" section will be clear in the next example.

    -

    Note that "id" is not required by the validation schema, but is required by the self link. This makes sense: a "thing" only has a URI if it has been created, and the server has assigned an id. However, you can use this schema with an instance containing only the data field, which allows you to validate "thing" instances that you are about to create.

    -

    Let's add a link to our entry point schema that lets you jump directly to a particular thing if you can supply it's id as input. To save space, only the new LDO is shown. Unlike "self" and "about", there is no IANA-registered relationship about hypothetical things, so an extension relationship is defined using the "tag:" URI scheme:

    -
    -{
    -    "rel": "tag:rel.example.com,2017:thing",
    -    "href": "things/{id}",
    -    "hrefSchema": {
    -        "required": ["id"],
    -        "properties": {
    -            "id": {"$ref": "thing#/$defs/id"}
    -        }
    -    },
    -    "targetSchema": {"$ref": "thing#"}
    -}
    -                    
    -

    The "href" value here is the same, but everything else is different. Recall that the instance is an empty object, so "id" cannot be resolved from instance data. Instead it is required as client input. This LDO could also have used "templateRequired" but with "required" in "hrefSchema" it is not strictly necessary. Providing "templateRequired" without marking "id" as required in "hrefSchema" would lead to errors, as client input is the only possible source for resolving this link.

    -

    -9.3. Submitting a Payload and Accepting URI Input -

    -

    This example covers using the "submission" fields for non-representation input, as well as using them alongside of resolving the URI Template with input. Unlike HTML forms, which require either constructing a URI or sending a payload, but do not allow not both at once, JSON Hyper-Schema can describe both sorts of input for the same operation on the same link.

    -

    The "submissionSchema" and "submissionMediaType" fields are for describing payloads that are not representations of the target resource. When used with "http(s)://" URIs, they generally refer to a POST request payload, as seen in the appendix on HTTP usage.

    -

    In this case, we use a "mailto:" URI, which, per RFC 6068, Section 3", does not provide any operation for retrieving a resource. It can only be used to construct a message for sending. Since there is no concept of a retrievable, replaceable, or deletable target resource, "targetSchema" and "targetMediaType" are not used. Non-representation payloads are described by "submissionSchema" and "submissionMediaType".

    -

    We use "submissionMediaType" to indicate a multipart/alternative payload format, providing two representations of the same data (HTML and plain text). Since a multipart/alternative message is an ordered sequence (the last part is the most preferred alternative), we model the sequence as an array in "submissionSchema". Since each part is itself a document with a media type, we model each item in the array as a string, using "contentMediaType" to indicate the format within the string.

    -

    Note that media types such as multipart/form-data, which associate a name with each part and are not ordered, should be modeled as JSON objects rather than arrays.

    -

    Note that some lines are wrapped to fit this document's width restrictions.

    -
    -{
    -    "$id": "https://schema.example.com/interesting-stuff",
    -    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
    -    "required": ["stuffWorthEmailingAbout", "email", "title"],
    -    "properties": {
    -        "title": {
    -            "type": "string"
    -        },
    -        "stuffWorthEmailingAbout": {
    -            "type": "string"
    -        },
    -        "email": {
    -            "type": "string",
    -            "format": "email"
    -        },
    -        "cc": false
    -    },
    -    "links": [
    -        {
    -            "rel": "author",
    -            "href": "mailto:{email}?subject={title}{&cc}",
    -            "templateRequired": ["email"],
    -            "hrefSchema": {
    -                "required": ["title"],
    -                "properties": {
    -                    "title": {
    -                        "type": "string"
    -                    },
    -                    "cc": {
    -                        "type": "string",
    -                        "format": "email"
    -                    },
    -                    "email": false
    -                }
    -            },
    -            "submissionMediaType":
    -                    "multipart/alternative; boundary=ab2",
    -            "submissionSchema": {
    -                "type": "array",
    -                "items": [
    -                    {
    -                        "type": "string",
    -                        "contentMediaType":
    -                                "text/plain; charset=utf8"
    -                    },
    -                    {
    -                        "type": "string",
    -                        "contentMediaType": "text/html"
    -                    }
    -                ],
    -                "minItems": 2
    -            }
    -        }
    -    ]
    -}
    -                    
    -

    For the URI parameters, each of the three demonstrates a different way of resolving the input:

    - -
    -
    email:
    -
    This variable's presence in "templateRequired" means that it must be resolved for the template to be used. Since the "false" schema assigned to it in "hrefSchema" excludes it from the input data set, it must be resolved from the instance.
    -
    title:
    -
    The instance field matching this variable is required, and it is also allowed in the input data. So its instance value is used to pre-populate the input data set before accepting client input. The client application can opt to leave the instance value in place. Since this field is required in "hrefSchema", the client application cannot delete it (although it could set it to an empty string).
    -
    cc:
    -
    The "false" schema set for this in the main schema prevents this field from having an instance value. If it is present at all, it must come from client input. As it is not required in "hrefSchema", it may not be used at all.
    -
    - -

    -

    So, given the following instance retrieved from "https://example.com/api/stuff":

    -
    -{
    -    "title": "The Awesome Thing",
    -    "stuffWorthEmailingAbout": "Lots of text here...",
    -    "email": "someone@example.com"
    -}
    -                    
    -

    We can partially resolve the link as follows, before asking the client application for input.

    -
    -{
    -    "contextUri": "https://example.com/api/stuff",
    -    "contextPointer": "",
    -    "rel": "author",
    -    "hrefInputTemplates": [
    -      "mailto:someone@example.com?subject={title}{&cc}"
    -    ],
    -    "hrefPrepopulatedInput": {
    -        "title": "The Awesome Thing"
    -    },
    -    "attachmentPointer": ""
    -}
    -                    
    -

    Notice the "href*" keywords in place of "targetUri". These are three possible kinds of "targetUri" values covering different sorts of input. Here are examples of each:

    - -
    -
    No additional or changed input:
    -
    "mailto:someone@example.com?subject=The%20Awesome%20Thing"
    -
    Change "title" to "your work":
    -
    "mailto:someone@example.com?subject=your%20work"
    -
    Change title and add a "cc" of "other@elsewhere.org":
    -
    "mailto:someone@example.com?subject=your%20work&cc=other@elsewhere.org"
    -
    - -

    -

    -9.4. "anchor", "base" and URI Template Resolution

    -

    A link is a typed connection from a context resource to a target resource. Older link serializations support a "rev" keyword that takes a link relation type as "rel" does, but reverses the semantics. This has long been deprecated, so JSON Hyper-Schema does not support it. Instead, "anchor"'s ability to change the context URI can be used to reverse the direction of a link. It can also be used to describe a link between two resources, neither of which is the current resource.

    -

    As an example, there is an IANA-registered "up" relation, but there is no "down". In an HTTP Link header, you could implement "down" as "rev": "up".

    -

    First let's look at how this could be done in HTTP, showing a "self" link and two semantically identical links, one with "rev": "up" and the other using "anchor" with "rel": "up" (line wrapped due to formatting limitations).

    -
    -
    -GET https://example.com/api/trees/1/nodes/123 HTTP/1.1
    -
    -200 OK
    -Content-Type: application/json
    -Link: <https://example.com/api/trees/1/nodes/123>; rel="self"
    -Link: <https://example.com/api/trees/1/nodes/123>; rel="up";
    -        anchor="https://example.com/api/trees/1/nodes/456"
    -Link: <https://example.com/api/trees/1/nodes/456>; rev="up"
    -{
    -    "id": 123,
    -    "treeId": 1,
    -    "childIds": [456]
    -}
    -
    -                    
    -

    Note that the "rel=up" link has a target URI identical to the "rel=self" link, and sets "anchor" (which identifies the link's context) to the child's URI. This sort of reversed link is easily detectable by tools when a "self" link is also present.

    -

    The following hyper-schema, applied to the instance in the response above, would produce the same "self" link and "up" link with "anchor". It also shows the use of a templated "base" URI, plus both absolute and relative JSON Pointers in "templatePointers".

    -
    -{
    -    "$id": "https://schema.example.com/tree-node",
    -    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
    -    "base": "trees/{treeId}/",
    -    "properties": {
    -        "id": {"type": "integer"},
    -        "treeId": {"type": "integer"},
    -        "childIds": {
    -            "type": "array",
    -            "items": {
    -                "type": "integer",
    -                "links": [
    -                    {
    -                        "anchor": "nodes/{thisNodeId}",
    -                        "rel": "up",
    -                        "href": "nodes/{childId}",
    -                        "templatePointers": {
    -                            "thisNodeId": "/id",
    -                            "childId": "0"
    -                        }
    -                    }
    -                ]
    -            }
    -        }
    -    },
    -    "links": [
    -        {
    -            "rel": "self",
    -            "href": "nodes/{id}"
    -        }
    -    ]
    -}
    -                    
    -

    The "base" template is evaluated identically for both the target ("href") and context ("anchor") URIs.

    -

    Note the two different sorts of templatePointers used. "thisNodeId" is mapped to an absolute JSON Pointer, "/id", while "childId" is mapped to a relative pointer, "0", which indicates the value of the current item. Absolute JSON Pointers do not support any kind of wildcarding, so there is no way to specify a concept like "current item" without a relative JSON Pointer.

    -

    -9.5. Collections

    -

    In many systems, individual resources are grouped into collections. Those collections also often provide a way to create individual item resources with server-assigned identifiers.

    -

    For this example, we will re-use the individual thing schema as shown in an earlier section. It is repeated here for convenience, with an added "collection" link with a "targetSchema" reference pointing to the collection schema we will introduce next.

    -
    -{
    -    "$id": "https://schema.example.com/thing",
    -    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
    -    "base": "https://example.com/api/",
    -    "type": "object",
    -    "required": ["data"],
    -    "properties": {
    -        "id": {"$ref": "#/$defs/id"},
    -        "data": true
    -    },
    -    "links": [
    -        {
    -            "rel": "self",
    -            "href": "things/{id}",
    -            "templateRequired": ["id"],
    -            "targetSchema": {"$ref": "#"}
    -        }, {
    -            "rel": "collection",
    -            "href": "/things",
    -            "targetSchema": {"$ref": "thing-collection#"},
    -            "submissionSchema": {"$ref": "#"}
    -        }
    -    ],
    -    "$defs": {
    -        "id": {
    -            "type": "integer",
    -            "minimum": 1,
    -            "readOnly": true
    -        }
    -    }
    -}
    -                    
    -

    The "collection" link is the same for all items, so there are no URI Template variables. The "submissionSchema" is that of the item itself. As described in Section 6.2.3, if a "collection" link supports a submission mechanism (POST in HTTP) then it MUST implement item creation semantics. Therefore "submissionSchema" is the schema for creating a "thing" via this link.

    -

    Now we want to describe collections of "thing"s. This schema describes a collection where each item representation is identical to the individual "thing" representation. While many collection representations only include subset of the item representations, this example uses the entirety to minimize the number of schemas involved. The actual collection items appear as an array within an object, as we will add more fields to the object in the next example.

    -
    -{
    -    "$id": "https://schema.example.com/thing-collection",
    -    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
    -    "base": "https://example.com/api/",
    -    "type": "object",
    -    "required": ["elements"],
    -    "properties": {
    -        "elements": {
    -            "type": "array",
    -            "items": {
    -                "allOf": [{"$ref": "thing#"}],
    -                "links": [
    -                    {
    -                        "anchorPointer": "",
    -                        "rel": "item",
    -                        "href": "things/{id}",
    -                        "templateRequired": ["id"],
    -                        "targetSchema": {"$ref": "thing#"}
    -                    }
    -                ]
    -            }
    -        }
    -    },
    -    "links": [
    -        {
    -            "rel": "self",
    -            "href": "things",
    -            "targetSchema": {"$ref": "#"},
    -            "submissionSchema": {"$ref": "thing"}
    -        }
    -    ]
    -}
    -                    
    -

    Here is a simple two-element collection instance:

    -
    -{
    -    "elements": [
    -        {"id": 12345, "data": {}},
    -        {"id": 67890, "data": {}}
    -    ]
    -}
    -                    
    -

    Here are all of the links that apply to this instance, including those that are defined in the referenced individual "thing" schema:

    -
    -[
    -    {
    -        "contextUri": "https://example.com/api/things",
    -        "contextPointer": "",
    -        "rel": "self",
    -        "targetUri": "https://example.com/api/things",
    -        "attachmentPointer": ""
    -    },
    -    {
    -        "contextUri": "https://example.com/api/things",
    -        "contextPointer": "/elements/0",
    -        "rel": "self",
    -        "targetUri": "https://example.com/api/things/12345",
    -        "attachmentPointer": "/elements/0"
    -    },
    -    {
    -        "contextUri": "https://example.com/api/things",
    -        "contextPointer": "/elements/1",
    -        "rel": "self",
    -        "targetUri": "https://example.com/api/things/67890",
    -        "attachmentPointer": "/elements/1"
    -    },
    -    {
    -        "contextUri": "https://example.com/api/things",
    -        "contextPointer": "",
    -        "rel": "item",
    -        "targetUri": "https://example.com/api/things/12345",
    -        "attachmentPointer": "/elements/0"
    -    },
    -    {
    -        "contextUri": "https://example.com/api/things",
    -        "contextPointer": "",
    -        "rel": "item",
    -        "targetUri": "https://example.com/api/things/67890",
    -        "attachmentPointer": "/elements/1"
    -    },
    -    {
    -        "contextUri": "https://example.com/api/things",
    -        "contextPointer": "/elements/0",
    -        "rel": "collection",
    -        "targetUri": "https://example.com/api/things",
    -        "attachmentPointer": "/elements/0"
    -    },
    -    {
    -        "contextUri": "https://example.com/api/things",
    -        "contextPointer": "/elements/1",
    -        "rel": "collection",
    -        "targetUri": "https://example.com/api/things",
    -        "attachmentPointer": "/elements/1"
    -    }
    -]
    -
    -                    
    -

    In all cases, the context URI is shown for an instance of media type application/json, which does not support fragments. If the instance media type was application/instance+json, which supports JSON Pointer fragments, then the context URIs would contain fragments identical to the context pointer field. For application/json and other media types without fragments, it is critically important to consider the context pointer as well as the context URI.

    -

    There are three "self" links, one for the collection, and one for each item in the "elements" array. The item "self" links are defined in the individual "thing" schema which is referenced with "$ref". The three links can be distinguished by their context or attachment pointers. We will revisit the "submissionSchema" of the collection's "self" link in Section 9.5.2.

    -

    There are two "item" links, one for each item in the "elements" array. Unlike the "self" links, these are defined only in the collection schema. Each of them have the same target URI as the corresponding "self" link that shares the same attachment pointer. However, each has a different context pointer. The context of the "self" link is the entry in "elements", while the context of the "item" link is always the entire collection regardless of the specific item.

    -

    Finally, there are two "collection" links, one for each item in "elements". In the individual item schema, these produce links with the item resource as the context. When referenced from the collection schema, the context is the location in the "elements" array of the relevant "thing", rather than that "thing"'s own separate resource URI.

    -

    The collection links have identical target URIs as there is only one relevant collection URI. While calculating both links as part of a full set of constructed links may not seem useful, when constructing links on an as-needed basis, this arrangement means that there is a "collection" link definition close at hand no matter which "elements" entry you are processing.

    -

    -9.5.1. Pagination

    -

    Here we add pagination to our collection. There is a "meta" section to hold the information about current, next, and previous pages. Most of the schema is the same as in the previous section and has been omitted. Only new fields and new or (in the case of the main "self" link) changed links are shown in full.

    -
    -{
    -    "properties": {
    -        "elements": {
    -            ...
    -        },
    -        "meta": {
    -            "type": "object",
    -            "properties": {
    -                "prev": {"$ref": "#/$defs/pagination"},
    -                "current": {"$ref": "#/$defs/pagination"},
    -                "next": {"$ref": "#/$defs/pagination"}
    -            }
    -        }
    -    },
    -    "links": [
    -        {
    -            "rel": "self",
    -            "href": "things{?offset,limit}",
    -            "templateRequired": ["offset", "limit"],
    -            "templatePointers": {
    -                "offset": "/meta/current/offset",
    -                "limit": "/meta/current/limit"
    -            },
    -            "targetSchema": {"$ref": "#"}
    -        }, {
    -            "rel": "prev",
    -            "href": "things{?offset,limit}",
    -            "templateRequired": ["offset", "limit"],
    -            "templatePointers": {
    -                "offset": "/meta/prev/offset",
    -                "limit": "/meta/prev/limit"
    -            },
    -            "targetSchema": {"$ref": "#"}
    -        }, {
    -            "rel": "next",
    -            "href": "things{?offset,limit}",
    -            "templateRequired": ["offset", "limit"],
    -            "templatePointers": {
    -                "offset": "/meta/next/offset",
    -                "limit": "/meta/next/limit"
    -            },
    -            "targetSchema": {"$ref": "#"}
    -        }
    -    ],
    -    "$defs": {
    -        "pagination": {
    -            "type": "object",
    -            "properties": {
    -                "offset": {
    -                    "type": "integer",
    -                    "minimum": 0,
    -                    "default": 0
    -                },
    -                "limit": {
    -                    "type": "integer",
    -                    "minimum": 1,
    -                    "maximum": 100,
    -                    "default": 10
    -                }
    -            }
    -        }
    -    }
    -}
    -                        
    -

    Notice that the "self" link includes the pagination query that produced the exact representation, rather than being a generic link to the collection allowing selecting the page via input.

    -

    Given this instance:

    -
    -{
    -    "elements": [
    -        {"id": 12345, "data": {}},
    -        {"id": 67890, "data": {}}
    -    ],
    -    "meta": {
    -        "current": {
    -            "offset": 0,
    -            "limit": 2
    -        },
    -        "next": {
    -            "offset": 3,
    -            "limit": 2
    -        }
    -    }
    -}
    -                        
    -

    Here are all of the links that apply to this instance that either did not appear in the previous example or have been changed with pagination added.

    -
    -[
    -    {
    -        "contextUri": "https://example.com/api/things",
    -        "contextPointer": "",
    -        "rel": "self",
    -        "targetUri":
    -            "https://example.com/api/things?offset=0&limit=2",
    -        "attachmentPointer": ""
    -    },
    -    {
    -        "contextUri": "https://example.com/api/things",
    -        "contextPointer": "",
    -        "rel": "next",
    -        "targetUri":
    -            "https://example.com/api/things?offset=3&limit=2",
    -        "attachmentPointer": ""
    -    }
    -]
    -                        
    -

    Note that there is no "prev" link in the output, as we are looking at the first page. The lack of a "prev" field under "meta", together with the "prev" link's "templateRequired" values, means that the link is not usable with this particular instance.

    -

    [CREF7]It's not clear how pagination should work with the link from the "collection" links in the individual "thing" schema. Technically, a link from an item to a paginated or filtered collection should go to a page/filter that contains the item (in this case the "thing") that is the link context. See GitHub issue #421 for more discussion.

    -

    Let's add a link for this collection to the entry point schema (Section 9.1), including pagination input in order to allow client applications to jump directly to a specific page. Recall that the entry point schema consists only of links, therefore we only show the newly added link:

    -
    -{
    -    "rel": "tag:rel.example.com,2017:thing-collection",
    -    "href": "/things{?offset,limit}",
    -    "hrefSchema": {
    -        "$ref": "thing-collection#/$defs/pagination"
    -    },
    -    "submissionSchema": {
    -        "$ref": "thing#"
    -    },
    -    "targetSchema": {
    -        "$ref": "thing-collection#"
    -    }
    -}
    -                        
    -

    Now we see the pagination parameters being accepted as input, so we can jump to any page within the collection. The link relation type is a custom one as the generic "collection" link can only be used with an item as its context, not an entry point or other resource.

    -

    -9.5.2. Creating the First Item -

    -

    When we do not have any "thing"s, we do not have any resources with a relevant "collection" link. Therefore we cannot use a "collection" link's submission keywords to create the first "thing"; hyper-schemas must be evaluated with respect to an instance. Since the "elements" array in the collection instance would be empty, it cannot provide us with a collection link either.

    -

    However, our entry point link can take us to the empty collection, and we can use the presence of "item" links in the hyper-schema to recognize that it is a collection. Since the context of the "item" link is the collection, we simply look for a "self" link with the same context, which we can then treat as collection for the purposes of a creation operation.

    -

    Presumably, our custom link relation type in the entry point schema was sufficient to ensure that we have found the right collection. A client application that recognizes that custom link relation type may know that it can immediately assume that the target is a collection, but a generic user agent cannot do so. Despite the presence of a "-collection" suffix in our example, a generic user agent would have no way of knowing whether that substring indicates a hypermedia resource collection, or some other sort of collection.

    -

    Once we have recognized the "self" link as being for the correct collection, we can use its "submissionSchema" and/or "submissionMediaType" keywords to perform an item creation operation. [CREF8]This works perfectly if the collection is unfiltered and unpaginated. However, one should generally POST to a collection that will contain the created resource, and a "self" link MUST include any filters, pagination, or other query parameters. Is it still valid to POST to such a "self" link even if the resulting item would not match the filter or appear within that page? See GitHub issue #421 for further discussion. [CREF9]Draft-04 of Hyper-Schema defined a "create" link relation that had the schema, rather than the instance, as its context. This did not fit into the instance-based link model, and incorrectly used an operation name for a link relation type. However, defining a more correctly designed link from the schema to the collection instance may be one possible approach to solving this. Again, see GitHub issue #421 for more details.

    -

    -10. Security Considerations -

    -

    JSON Hyper-Schema defines a vocabulary for JSON Schema core and concerns all the security considerations listed there. As a link serialization format, the security considerations of RFC 8288 Web Linking also apply, with appropriate adjustments (e.g. "anchor" as an LDO keyword rather than an HTTP Link header attribute).

    -

    -10.1. Target Attributes

    -

    As stated in Section 6.5, all LDO keywords describing the target resource are advisory and MUST NOT be used in place of the authoritative information supplied by the target resource in response to an operation. Target resource responses SHOULD indicate their own hyper-schema, which is authoritative.

    -

    If the hyper-schema in the target response matches (by "$id") the hyper-schema in which the current LDO was found, then the target attributes MAY be considered authoritative. [CREF10]Need to add something about the risks of spoofing by "$id", but given that other parts of the specification discourage always re-downloading the linked schema, the risk mitigation options are unclear.

    -

    User agents or client applications MUST NOT use the value of "targetSchema" to aid in the interpretation of the data received in response to following the link, as this leaves "safe" data open to re-interpretation.

    -

    When choosing how to interpret data, the type information provided by the server (or inferred from the filename, or any other usual method) MUST be the only consideration, and the "targetMediaType" property of the link MUST NOT be used. User agents MAY use this information to determine how they represent the link or where to display it (for example hover-text, opening in a new tab). If user agents decide to pass the link to an external program, they SHOULD first verify that the data is of a type that would normally be passed to that external program.

    -

    This is to guard against re-interpretation of "safe" data, similar to the precautions for "targetSchema".

    -

    Protocol meta-data values conveyed in "targetHints" MUST NOT be considered authoritative. Any security considerations defined by the protocol that may apply based on incorrect assumptions about meta-data values apply.

    -

    Even when no protocol security considerations are directly applicable, implementations MUST be prepared to handle responses that do not match the link's "targetHints" values.

    -

    -10.2. "self" Links

    -

    When link relation of "self" is used to denote a full representation of an object, the user agent SHOULD NOT consider the representation to be the authoritative representation of the resource denoted by the target URI if the target URI is not equivalent to or a sub-path of the URI used to request the resource representation which contains the target URI with the "self" link. [CREF11]It is no longer entirely clear what was intended by the "sub-path" option in this paragraph. It may have been intended to allow "self" links for embedded item representations in a collection, which usually have target URIs that are sub-paths of that collection's URI, to be considered authoritative. However, this is simply a common design convention and does not appear to be based in RFC 3986 or any other guidance on URI usage. See GitHub issue #485 for further discussion.

    -

    -11. Acknowledgments

    -

    Thanks to Gary Court, Francis Galiegue, Kris Zyp, and Geraint Luff for their work on the initial drafts of JSON Schema.

    -

    Thanks to Jason Desrosiers, Daniel Perrett, Erik Wilde, Ben Hutton, Evgeny Poberezkin, Brad Bowman, Gowry Sankar, Donald Pipowitch, Dave Finlay, and Denis Laxalde for their submissions and patches to the document.

    -

    -12. References

    -

    -12.1. Normative References

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    [json-schema] -Wright, A. and H. Andrews, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-handrews-json-schema-02, November 2017.
    [json-schema-validation] -Wright, A., Andrews, H. and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of JSON", Internet-Draft draft-handrews-json-schema-validation-02, November 2017.
    [relative-json-pointer] -Luff, G. and H. Andrews, "Relative JSON Pointers", Internet-Draft draft-handrews-relative-json-pointer-02, January 2018.
    [RFC2119] -Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.
    [RFC3986] -Berners-Lee, T., Fielding, R. and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, January 2005.
    [RFC4287] -Nottingham, M. and R. Sayre, "The Atom Syndication Format", RFC 4287, DOI 10.17487/RFC4287, December 2005.
    [RFC6570] -Gregorio, J., Fielding, R., Hadley, M., Nottingham, M. and D. Orchard, "URI Template", RFC 6570, DOI 10.17487/RFC6570, March 2012.
    [RFC6573] -Amundsen, M., "The Item and Collection Link Relations", RFC 6573, DOI 10.17487/RFC6573, April 2012.
    [RFC6901] -Bryan, P., Zyp, K. and M. Nottingham, "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, April 2013.
    [RFC8288] -Nottingham, M., "Web Linking", RFC 8288, DOI 10.17487/RFC8288, October 2017.
    -

    -12.2. Informative References

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    [I-D.reschke-http-jfv] -Reschke, J., "A JSON Encoding for HTTP Header Field Values", Internet-Draft draft-reschke-http-jfv-06, June 2017.
    [RFC2046] -Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types", RFC 2046, DOI 10.17487/RFC2046, November 1996.
    [RFC4151] -Kindberg, T. and S. Hawke, "The 'tag' URI Scheme", RFC 4151, DOI 10.17487/RFC4151, October 2005.
    [RFC5789] -Dusseault, L. and J. Snell, "PATCH Method for HTTP", RFC 5789, DOI 10.17487/RFC5789, March 2010.
    [RFC6068] -Duerst, M., Masinter, L. and J. Zawinski, "The 'mailto' URI Scheme", RFC 6068, DOI 10.17487/RFC6068, October 2010.
    [RFC7230] -Fielding, R. and J. Reschke, "Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing", RFC 7230, DOI 10.17487/RFC7230, June 2014.
    [RFC7231] -Fielding, R. and J. Reschke, "Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content", RFC 7231, DOI 10.17487/RFC7231, June 2014.
    [RFC7807] -Nottingham, M. and E. Wilde, "Problem Details for HTTP APIs", RFC 7807, DOI 10.17487/RFC7807, March 2016.
    -

    -Appendix A. Using JSON Hyper-Schema in APIs -

    -

    Hypermedia APIs, which follow the constraints of the REST architectural style, enable the creation of generic user agents. Such a user agent has no application-specific knowledge. Rather, it understands pre-defined media types, URI schemes, protocols, and link relations, often by recognizing these and coordinating the use of existing software that implements support for them. Client applications can then be built on top of such a user agent, focusing on their own semantics and logic rather than the mechanics of the interactions.

    -

    Hyper-schema is only concerned with one resource and set of associated links at a time. Just as a web browser works with only one HTML page at a time, with no concept of whether or how that page functions as part of a "site", a hyper-schema-aware user agent works with one resource at a time, without any concept of whether or how that resource fits into an API.

    -

    Therefore, hyper-schema is suitable for use within an API, but is not suitable for the description of APIs as complete entities in their own right. There is no way to describe concepts at the API scope, rather than the resource and link scope, and such descriptions are outside of the boundaries of JSON Hyper-Schema.

    -

    -A.1. Resource Evolution With Hyper-Schema

    -

    Since a given JSON Hyper-Schema is used with a single resource at a single point in time, it has no inherent notion of versioning. However, a given resource can change which schema or schemas it uses over time, and the URIs of these schemas can be used to indicate versioning information. When used with a media type that supports indicating a schema with a media type parameter, these versioned schema URIs can be used in content negotiation.

    -

    A resource can indicate that it is an instance of multiple schemas, which allows supporting multiple compatible versions simultaneously. A client application can then make use of the hyper-schema that it recognizes, and ignore newer or older versions.

    -

    -A.2. Responses and Errors -

    -

    Because a hyper-schema represents a single resource at a time, it does not provide for an enumeration of all possible responses to protocol operations performed with links. Each response, including errors, is considered its own (possibly anonymous) resource, and should identify its own hyper-schema, and optionally use an appropriate media type such as RFC 7807's "application/problem+json", to allow the user agent or client application to interpret any information that is provided beyond the protocol's own status reporting.

    -

    -A.3. Static Analysis of an API's Hyper-Schemas -

    -

    It is possible to statically analyze a set of hyper-schemas without instance data in order to generate output such as documentation or code. However, the full feature set of both validation and hyper-schema cannot be accessed without runtime instance data.

    -

    This is an intentional design choice to provide the maximum runtime flexibility for hypermedia systems. JSON Schema as a media type allows for establishing additional vocabularies for static analysis and content generation, which are not addressed in this specification. Additionally, individual systems may restrict their usage to subsets that can be analyzed statically if full design-time description is a goal. [CREF12]Vocabularies for API documentation and other purposes have been proposed, and contributions are welcome at https://github.com/json-schema-org/json-schema-vocabularies

    -

    -Appendix B. ChangeLog

    -

    [CREF13]This section to be removed before leaving Internet-Draft status.

    -

    - -
    -
    draft-handrews-json-schema-hyperschema-02
    -
    -
      -
    • Allow multiple values for "rel"
    • -
    • Clarify that "headerSchema", like "targetHints", should use array values
    • -
    • Clarified link behavior with conditional applicator keywords such as "if"
    • -
    • Added and clarified various examples
    • -
    • Avoid accidentally implying that only POST can be used to create in HTTP
    • -
    -

    -
    -
    draft-handrews-json-schema-hyperschema-01
    -
    -
      -
    • This draft is purely a bug fix with no functional changes
    • -
    • Fixed erroneous meta-schema URI (draft-07, not draft-07-wip)
    • -
    • Removed stray "work in progress" language left over from review period
    • -
    • Fixed missing trailing "/" in various "base" examples
    • -
    • Fixed incorrect draft name in changelog (luff-*-00, not -01)
    • -
    • Update relative pointer ref to handrews-*-01, also purely a bug fix
    • -
    -

    -
    -
    draft-handrews-json-schema-hyperschema-00
    -
    -
      -
    • Top to bottom reorganization and rewrite
    • -
    • Group keywords per RFC 8288 context/relation/target/target attributes
    • -
    • Additional keyword groups for template resolution and describing input
    • -
    • Clarify implementation requirements with a suggested output format
    • -
    • Expanded overview to provide context
    • -
    • Consolidated examples into their own section, illustrate real-world patterns
    • -
    • Consolidated HTTP guidance in its own section
    • -
    • Added a subsection on static analysis of hyper-schemas
    • -
    • Consolidated security concerns in their own section
    • -
    • Added an appendix on usage in APIs
    • -
    • Moved "readOnly" to the validation specification
    • -
    • Moved "media" to validation as "contentMediaType"/"contentEncoding"
    • -
    • Renamed "submissionEncType" to "submissionMediaType"
    • -
    • Renamed "mediaType" to "targetMediaType"
    • -
    • Added "anchor" and "anchorPointer"
    • -
    • Added "templatePointers" and "templateRequired"
    • -
    • Clarified how "hrefSchema" is used
    • -
    • Added "targetHints" and "headerSchema"
    • -
    • Added guidance on "self", "collection" and "item" link usage
    • -
    • Added "description" as an LDO keyword
    • -
    • Added "$comment" in LDOs to match the schema keyword
    • -
    -

    -
    -
    draft-wright-json-schema-hyperschema-01
    -
    -
      -
    • Fixed examples
    • -
    • Added "hrefSchema" for user input to "href" URI Templates
    • -
    • Removed URI Template pre-processing
    • -
    • Clarified how links and data submission work
    • -
    • Clarified how validation keywords apply hyper-schema keywords and links
    • -
    • Clarified HTTP use with "targetSchema"
    • -
    • Renamed "schema" to "submissionSchema"
    • -
    • Renamed "encType" to "submissionEncType"
    • -
    • Removed "method"
    • -
    -

    -
    -
    draft-wright-json-schema-hyperschema-00
    -
    -
      -
    • "rel" is now optional
    • -
    • rel="self" no longer changes URI base
    • -
    • Added "base" keyword to change instance URI base
    • -
    • Removed "root" link relation
    • -
    • Removed "create" link relation
    • -
    • Removed "full" link relation
    • -
    • Removed "instances" link relation
    • -
    • Removed special behavior for "describedBy" link relation
    • -
    • Removed "pathStart" keyword
    • -
    • Removed "fragmentResolution" keyword
    • -
    • Updated references to JSON Pointer, HTML
    • -
    • Changed behavior of "method" property to align with hypermedia best current practices
    • -
    -

    -
    -
    draft-luff-json-hyper-schema-00
    -
    -
    • Split from main specification.
    -

    -
    -
    - -

    -

    Authors' Addresses

    -
    -
    - - Henry Andrews (editor) - - - - - - - - - - - - - EMail: andrews_henry@yahoo.com - -
    -
    -
    - - Austin Wright (editor) - - - - - - - - - - - - - EMail: aaa@bzfx.net - -
    -
    - - - diff --git a/latest/json-schema-hypermedia.md b/latest/json-schema-hypermedia.md new file mode 100644 index 00000000..7935b0df --- /dev/null +++ b/latest/json-schema-hypermedia.md @@ -0,0 +1,4 @@ +--- +redirect_to: "/draft/2019-09/json-schema-hypermedia.html" +title: "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON" +--- diff --git a/latest/json-schema-validation.html b/latest/json-schema-validation.html deleted file mode 100644 index 4635b1f6..00000000 --- a/latest/json-schema-validation.html +++ /dev/null @@ -1,1397 +0,0 @@ - - - - - - - JSON Schema Validation: A Vocabulary for Structural Validation of JSON - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Internet Engineering Task ForceA. Wright, Ed.
    Internet-Draft
    Intended status: InformationalH. Andrews, Ed.
    Expires: March 20, 2020
    B. Hutton, Ed.
    Wellcome Sanger Institute
    September 17, 2019
    - -

    JSON Schema Validation: A Vocabulary for Structural Validation of JSON
    - draft-handrews-json-schema-validation-02

    - -

    Abstract

    -

    JSON Schema (application/schema+json) has several purposes, one of which is JSON instance validation. This document specifies a vocabulary for JSON Schema to describe the meaning of JSON documents, provide hints for user interfaces working with JSON data, and to make assertions about what a valid document must look like.

    -

    Note to Readers

    -

    The issues list for this draft can be found at <https://github.com/json-schema-org/json-schema-spec/issues>.

    -

    For additional information, see <https://json-schema.org/>.

    -

    To provide feedback, use this issue tracker, the communication methods listed on the homepage, or email the document editors.

    -

    Status of This Memo

    -

    This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

    -

    Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

    -

    Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

    -

    This Internet-Draft will expire on March 20, 2020.

    -

    Copyright Notice

    -

    Copyright (c) 2019 IETF Trust and the persons identified as the document authors. All rights reserved.

    -

    This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

    - - -
    -

    Table of Contents

    - - -

    -1. Introduction

    -

    JSON Schema can be used to require that a given JSON document (an instance) satisfies a certain number of criteria. These criteria are asserted by using keywords described in this specification. In addition, a set of keywords is also defined to assist in interactive user interface instance generation.

    -

    This specification will use the concepts, syntax, and terminology defined by the JSON Schema core specification.

    -

    -2. Conventions and Terminology

    -

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

    -

    This specification uses the term "container instance" to refer to both array and object instances. It uses the term "children instances" to refer to array elements or object member values.

    -

    Elements in an array value are said to be unique if no two elements of this array are equal.

    -

    -3. Overview

    -

    JSON Schema validation asserts constraints on the structure of instance data. An instance location that satisfies all asserted constraints is then annotated with any keywords that contain non-assertion information, such as descriptive metadata and usage hints. If all locations within the instance satisfy all asserted constraints, then the instance is said to be valid against the schema.

    -

    Each schema object is independently evaluated against each instance location to which it applies. This greatly simplifies the implementation requirements for validators by ensuring that they do not need to maintain state across the document-wide validation process.

    -

    This specification defines a set of assertion keywords, as well as a small vocabulary of metadata keywords that can be used to annotate the JSON instance with useful information. The Section 7 keyword is intended primarily as an annotation, but can optionally be used as an assertion. The Section 8 keywords are annotations for working with documents embedded as JSON strings.

    -

    -4. Interoperability Considerations

    -

    -4.1. Validation of String Instances

    -

    It should be noted that the nul character (\u0000) is valid in a JSON string. An instance to validate may contain a string value with this character, regardless of the ability of the underlying programming language to deal with such data.

    -

    -4.2. Validation of Numeric Instances

    -

    The JSON specification allows numbers with arbitrary precision, and JSON Schema does not add any such bounds. This means that numeric instances processed by JSON Schema can be arbitrarily large and/or have an arbitrarily long decimal part, regardless of the ability of the underlying programming language to deal with such data.

    -

    -4.3. Regular Expressions -

    -

    Keywords that use regular expressions, or constrain the instance value to be a regular expression, are subject to the interoperability considerations for regular expressions in the JSON Schema Core specification.

    -

    -5. Meta-Schema -

    -

    The current URI for the default JSON Schema meta-schema is <http://json-schema.org/draft/2019-09/schema>. For schema author convenience, this meta-schema describes all vocabularies defined in this specification and the JSON Schema Core specification, as well as two former keywords which are reserved for a transitional period. Individual vocabulary and vocabulary meta-schema URIs are given for each section below. Certain vocabularies are optional to support, which is explained in detail in the relevant sections.

    -

    Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations SHOULD consider URIs dated after this specification draft and before the next to indicate the same syntax and semantics as those listed here.

    -

    -6. A Vocabulary for Structural Validation

    -

    Validation keywords in a schema impose requirements for successful validation of an instance. These keywords are all assertions without any annotation behavior.

    -

    Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

    -

    The current URI for this vocabulary, known as the Validation vocabulary, is: <https://json-schema.org/draft/2019-09/vocab/validation>.

    -

    The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-09/meta/validation>.

    -

    -6.1. Validation Keywords for Any Instance Type -

    -

    -6.1.1. type

    -

    The value of this keyword MUST be either a string or an array. If it is an array, elements of the array MUST be strings and MUST be unique.

    -

    String values MUST be one of the six primitive types ("null", "boolean", "object", "array", "number", or "string"), or "integer" which matches any number with a zero fractional part.

    -

    An instance validates if and only if the instance is in any of the sets listed for this keyword.

    -

    -6.1.2. enum -

    -

    The value of this keyword MUST be an array. This array SHOULD have at least one element. Elements in the array SHOULD be unique.

    -

    An instance validates successfully against this keyword if its value is equal to one of the elements in this keyword's array value.

    -

    Elements in the array might be of any type, including null.

    -

    -6.1.3. const

    -

    The value of this keyword MAY be of any type, including null.

    -

    Use of this keyword is functionally equivalent to an "enum" with a single value.

    -

    An instance validates successfully against this keyword if its value is equal to the value of the keyword.

    -

    -6.2. Validation Keywords for Numeric Instances (number and integer) -

    -

    -6.2.1. multipleOf

    -

    The value of "multipleOf" MUST be a number, strictly greater than 0.

    -

    A numeric instance is valid only if division by this keyword's value results in an integer.

    -

    -6.2.2. maximum

    -

    The value of "maximum" MUST be a number, representing an inclusive upper limit for a numeric instance.

    -

    If the instance is a number, then this keyword validates only if the instance is less than or exactly equal to "maximum".

    -

    -6.2.3. exclusiveMaximum

    -

    The value of "exclusiveMaximum" MUST be number, representing an exclusive upper limit for a numeric instance.

    -

    If the instance is a number, then the instance is valid only if it has a value strictly less than (not equal to) "exclusiveMaximum".

    -

    -6.2.4. minimum

    -

    The value of "minimum" MUST be a number, representing an inclusive lower limit for a numeric instance.

    -

    If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to "minimum".

    -

    -6.2.5. exclusiveMinimum

    -

    The value of "exclusiveMinimum" MUST be number, representing an exclusive lower limit for a numeric instance.

    -

    If the instance is a number, then the instance is valid only if it has a value strictly greater than (not equal to) "exclusiveMinimum".

    -

    -6.3. Validation Keywords for Strings -

    -

    -6.3.1. maxLength

    -

    The value of this keyword MUST be a non-negative integer.

    -

    A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.

    -

    The length of a string instance is defined as the number of its characters as defined by RFC 8259.

    -

    -6.3.2. minLength

    -

    The value of this keyword MUST be a non-negative integer.

    -

    A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.

    -

    The length of a string instance is defined as the number of its characters as defined by RFC 8259.

    -

    Omitting this keyword has the same behavior as a value of 0.

    -

    -6.3.3. pattern -

    -

    The value of this keyword MUST be a string. This string SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect.

    -

    A string instance is considered valid if the regular expression matches the instance successfully. Recall: regular expressions are not implicitly anchored.

    -

    -6.4. Validation Keywords for Arrays

    -

    -6.4.1. maxItems

    -

    The value of this keyword MUST be a non-negative integer.

    -

    An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword.

    -

    -6.4.2. minItems

    -

    The value of this keyword MUST be a non-negative integer.

    -

    An array instance is valid against "minItems" if its size is greater than, or equal to, the value of this keyword.

    -

    Omitting this keyword has the same behavior as a value of 0.

    -

    -6.4.3. uniqueItems

    -

    The value of this keyword MUST be a boolean.

    -

    If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.

    -

    Omitting this keyword has the same behavior as a value of false.

    -

    -6.4.4. maxContains

    -

    The value of this keyword MUST be a non-negative integer.

    -

    An array instance is valid against "maxContains" if the number of elements that are valid against the schema for "contains" is less than, or equal to, the value of this keyword.

    -

    If "contains" is not present within the same schema object, then this keyword has no effect.

    -

    -6.4.5. minContains

    -

    The value of this keyword MUST be a non-negative integer.

    -

    An array instance is valid against "minContains" if the number of elements that are valid against the schema for "contains" is greater than, or equal to, the value of this keyword.

    -

    A value of 0 is allowed, but is only useful for setting a range of occurrences from 0 to the value of "maxContains". A value of 0 with no "maxContains" causes "contains" to always pass validation.

    -

    If "contains" is not present within the same schema object, then this keyword has no effect.

    -

    Omitting this keyword has the same behavior as a value of 1.

    -

    -6.5. Validation Keywords for Objects

    -

    -6.5.1. maxProperties

    -

    The value of this keyword MUST be a non-negative integer.

    -

    An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword.

    -

    -6.5.2. minProperties

    -

    The value of this keyword MUST be a non-negative integer.

    -

    An object instance is valid against "minProperties" if its number of properties is greater than, or equal to, the value of this keyword.

    -

    Omitting this keyword has the same behavior as a value of 0.

    -

    -6.5.3. required

    -

    The value of this keyword MUST be an array. Elements of this array, if any, MUST be strings, and MUST be unique.

    -

    An object instance is valid against this keyword if every item in the array is the name of a property in the instance.

    -

    Omitting this keyword has the same behavior as an empty array.

    -

    -6.5.4. dependentRequired

    -

    The value of this keyword MUST be an object. Properties in this object, if any, MUST be arrays. Elements in each array, if any, MUST be strings, and MUST be unique.

    -

    This keyword specifies properties that are required if a specific other property is present. Their requirement is dependent on the presence of the other property.

    -

    Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value, every item in the corresponding array is also the name of a property in the instance.

    -

    Omitting this keyword has the same behavior as an empty object.

    -

    -7. A Vocabulary for Semantic Content With "format" -

    -

    -7.1. Foreword

    -

    Structural validation alone may be insufficient to allow an application to correctly utilize certain values. The "format" annotation keyword is defined to allow schema authors to convey semantic information for a fixed subset of values which are accurately described by authoritative resources, be they RFCs or other external specifications.

    -

    Implementations MAY treat "format" as an assertion in addition to an annotation, and attempt to validate the value's conformance to the specified semantics. See the Implementation Requirements below for details.

    -

    The value of this keyword is called a format attribute. It MUST be a string. A format attribute can generally only validate a given set of instance types. If the type of the instance to validate is not in this set, validation for this format attribute and instance SHOULD succeed. All format attributes defined in this section apply to strings, but a format attribute can be specified to apply to any instance types defined in the data model defined in the core JSON Schema. [CREF1]Note that the "type" keyword in this specification defines an "integer" type which is not part of the data model. Therefore a format attribute can be limited to numbers, but not specifically to integers. However, a numeric format can be used alongside the "type" keyword with a value of "integer", or could be explicitly defined to always pass if the number is not an integer, which produces essentially the same behavior as only applying to integers.

    -

    Meta-schemas that do not use "$vocabulary" SHOULD be considered to utilize this vocabulary as if its URI were present with a value of false. See the Implementation Requirements below for details.

    -

    The current URI for this vocabulary, known as the Format vocabulary, is: <https://json-schema.org/draft/2019-09/vocab/format>.

    -

    The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-09/meta/format>.

    -

    -7.2. Implementation Requirements

    -

    The "format" keyword functions as an annotation, and optionally as an assertion. [CREF2]This is due to the keyword's history, and is not in line with current keyword design principles. In order to manage this ambiguity, the "format" keyword is defined in its own separate vocabulary, as noted above. The true or false value of the vocabulary declaration governs the implementation requirements necessary to process a schema that uses "format", and the behaviors on which schema authors can rely.

    -

    -7.2.1. As an annotation

    -

    The value of format MUST be collected as an annotation, if the implementation supports annotation collection. This enables application-level validation when schema validation is unavailable or inadequate.

    -

    This requirement is not affected by the boolean value of the vocabulary declaration, nor by the configuration of "format"'s assertion behavior described in the next section. [CREF3]Requiring annotation collection even when the vocabulary is declared with a value of false is atypical, but necessary to ensure that the best practice of performing application-level validation is possible even when assertion evaluation is not implemented. Since "format" has always been a part of this specification, requiring implementations to be aware of it even with a false vocabulary declaration is deemed to not be a burden.

    -

    -7.2.2. As an assertion

    -

    Regardless of the boolean value of the vocabulary declaration, an implementation that can evaluate "format" as an assertion MUST provide options to enable and disable such evaluation. The assertion evaluation behavior when the option is not explicitly specified depends on the vocabulary declaration's boolean value.

    -

    When implementing this entire specification, this vocabulary MUST be supported with a value of false (but see details below), and MAY be supported with a value of true.

    -

    When the vocabulary is declared with a value of false, an implementation: [CREF4]This matches the current reality of implementations, which provide widely varying levels of validation, including no validation at all, for some or all format attributes. It is also designed to encourage relying only on the annotation behavior and performing semantic validation in the application, which is the recommended best practice.

    - -
      -
    • MUST NOT evaluate "format" as an assertion unless it is explicitly configured to do so;
    • -
    • SHOULD provide an implementation-specific best effort validation for each format attribute defined below;
    • -
    • MAY choose to implement validation of any or all format attributes as a no-op by always producing a validation result of true;
    • -
    • SHOULD document its level of support for validation.
    • -
    - -

    -

    When the vocabulary is declared with a value of true, an implementation that supports this form of the vocabulary: [CREF5]The expectation is that for simple formats such as date-time, syntactic validation will be thorough. For a complex format such as email addresses, which are the amalgamation of various standards and numerous adjustments over time, with obscure and/or obsolete rules that may or may not be restricted by other applications making use of the value, a minimal validation is sufficient. For example, an instance string that does not contain an "@" is clearly not a valid email address, and an "email" or "hostname" containing characters outside of 7-bit ASCII is likewise clearly invalid.

    - -
      -
    • MUST evaluate "format" as an assertion unless it is explicitly configured not to do so;
    • -
    • MUST implement syntactic validation for all format attributes defined in this specification, and for any additional format attributes that it recognizes, such that there exist possible instance values of the correct type that will fail validation.
    • -
    - -

    The requirement for minimal validation of format attributes is intentionally vague and permissive, due to the complexity involved in many of the attributes. Note in particular that the requirement is limited to syntactic checking; it is not to be expected that an implementation would send an email, attempt to connect to a URL, or otherwise check the existence of an entity identified by a format instance.

    -

    It is RECOMMENDED that implementations use a common parsing library for each format, or a well-known regular expression. Implementations SHOULD clearly document how and to what degree each format attribute is validated.

    -

    The standard core and validation meta-schema includes this vocabulary in its "$vocabulary" keyword with a value of false, since by default implementations are not required to support this keyword as an assertion. Supporting the format vocabulary with a value of true is understood to greatly increase code size and in some cases execution time, and will not be appropriate for all implementations.

    -

    -7.2.3. Custom format attributes

    -

    Implementations MAY support custom format attributes. Save for agreement between parties, schema authors SHALL NOT expect a peer implementation to support such custom format attributes. An implementation MUST NOT fail validation or cease processing due to an unknown format attribute. When treating "format" as an annotation, implementations SHOULD collect both known and unknown format attribute values.

    -

    Vocabularies do not support specifically declaring different value sets for keywords. Due to this limitation, and the historically uneven implementation of this keyword, it is RECOMMENDED to define additional keywords in a custom vocabulary rather than additional format attributes if interoperability is desired.

    -

    -7.3. Defined Formats

    -

    -7.3.1. Dates, Times, and Duration

    -

    These attributes apply to string instances.

    -

    Date and time format names are derived from RFC 3339, section 5.6. The duration format is from the ISO 8601 ABNF as given in Appendix A of RFC 3339.

    -

    Implementations supporting formats SHOULD implement support for the following attributes:

    - -
    -
    date-time:
    -
    A string instance is valid against this attribute if it is a valid representation according to the "date-time" production.
    -
    date:
    -
    A string instance is valid against this attribute if it is a valid representation according to the "full-date" production.
    -
    time:
    -
    A string instance is valid against this attribute if it is a valid representation according to the "full-time" production.
    -
    duration:
    -
    A string instance is valid against this attribute if it is a valid representation according to the "duration" production.
    -
    - -

    -

    Implementations MAY support additional attributes using the other production names defined in that section. If "full-date" or "full-time" are implemented, the corresponding short form ("date" or "time" respectively) MUST be implemented, and MUST behave identically. Implementations SHOULD NOT define extension attributes with any name matching an RFC 3339 production unless it validates according to the rules of that production. [CREF6]There is not currently consensus on the need for supporting all RFC 3339 formats, so this approach of reserving the namespace will encourage experimentation without committing to the entire set. Either the format implementation requirements will become more flexible in general, or these will likely either be promoted to fully specified attributes or dropped.

    -

    -7.3.2. Email Addresses

    -

    These attributes apply to string instances.

    -

    A string instance is valid against these attributes if it is a valid Internet email address as follows:

    - -
    -
    email:
    -
    As defined by RFC 5322, section 3.4.1.
    -
    idn-email:
    -
    As defined by RFC 6531
    -
    - -

    Note that all strings valid against the "email" attribute are also valid against the "idn-email" attribute.

    -

    -7.3.3. Hostnames

    -

    These attributes apply to string instances.

    -

    A string instance is valid against these attributes if it is a valid representation for an Internet hostname as follows:

    - -
    -
    hostname:
    -
    As defined by RFC 1123, section 2.1, including host names produced using the Punycode algorithm specified in RFC 5891, section 4.4.
    -
    idn-hostname:
    -
    As defined by either RFC 1123 as for hostname, or an internationalized hostname as defined by RFC 5890, section 2.3.2.3.
    -
    - -

    Note that all strings valid against the "hostname" attribute are also valid against the "idn-hostname" attribute.

    -

    -7.3.4. IP Addresses

    -

    These attributes apply to string instances.

    -

    A string instance is valid against these attributes if it is a valid representation of an IP address as follows:

    - -
    -
    ipv4:
    -
    An IPv4 address according to the "dotted-quad" ABNF syntax as defined in RFC 2673, section 3.2.
    -
    ipv6:
    -
    An IPv6 address as defined in RFC 4291, section 2.2.
    -
    - -

    -

    -7.3.5. Resource Identifiers

    -

    These attributes apply to string instances.

    -

    - -
    -
    uri:
    -
    A string instance is valid against this attribute if it is a valid URI, according to [RFC3986].
    -
    uri-reference:
    -
    A string instance is valid against this attribute if it is a valid URI Reference (either a URI or a relative-reference), according to [RFC3986].
    -
    iri:
    -
    A string instance is valid against this attribute if it is a valid IRI, according to [RFC3987].
    -
    iri-reference:
    -
    A string instance is valid against this attribute if it is a valid IRI Reference (either an IRI or a relative-reference), according to [RFC3987].
    -
    uuid:
    -
    A string instance is valid against this attribute if it is a valid string representation of a UUID, according to [RFC4122].
    -
    - -

    -

    Note that all valid URIs are valid IRIs, and all valid URI References are also valid IRI References.

    -

    Note also that the "uuid" format is for plain UUIDs, not UUIDs in URNs. An example is "f81d4fae-7dec-11d0-a765-00a0c91e6bf6". For UUIDs as URNs, use the "uri" format, with a "pattern" regular expression of "^urn:uuid:" to indicate the URI scheme and URN namespace.

    -

    -7.3.6. uri-template

    -

    This attribute applies to string instances.

    -

    A string instance is valid against this attribute if it is a valid URI Template (of any level), according to [RFC6570].

    -

    Note that URI Templates may be used for IRIs; there is no separate IRI Template specification.

    -

    -7.3.7. JSON Pointers

    -

    These attributes apply to string instances.

    -

    - -
    -
    json-pointer:
    -
    A string instance is valid against this attribute if it is a valid JSON string representation of a JSON Pointer, according to RFC 6901, section 5.
    -
    relative-json-pointer:
    -
    A string instance is valid against this attribute if it is a valid Relative JSON Pointer.
    -
    - -

    To allow for both absolute and relative JSON Pointers, use "anyOf" or "oneOf" to indicate support for either format.

    -

    -7.3.8. regex

    -

    This attribute applies to string instances.

    -

    A regular expression, which SHOULD be valid according to the ECMA 262 regular expression dialect.

    -

    Implementations that validate formats MUST accept at least the subset of ECMA 262 defined in the Regular Expressions section of this specification, and SHOULD accept all valid ECMA 262 expressions.

    -

    -8. A Vocabulary for the Contents of String-Encoded Data -

    -

    -8.1. Foreword

    -

    Annotations defined in this section indicate that an instance contains non-JSON data encoded in a JSON string.

    -

    These properties provide additional information required to interpret JSON data as rich multimedia documents. They describe the type of content, how it is encoded, and/or how it may be validated. They do not function as validation assertions; a malformed string-encoded document MUST NOT cause the containing instance to be considered invalid.

    -

    Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

    -

    The current URI for this vocabulary, known as the Content vocabulary, is: <https://json-schema.org/draft/2019-09/vocab/content>.

    -

    The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-09/meta/content>.

    -

    -8.2. Implementation Requirements

    -

    Due to security and performance concerns, as well as the open-ended nature of possible content types, implementations MUST NOT automatically decode, parse, and/or validate the string contents by default. This additionally supports the use case of embedded documents intended for processing by a different consumer than that which processed the containing document.

    -

    All keywords in this section apply only to strings, and have no effect on other data types.

    -

    Implementations MAY offer the ability to decode, parse, and/or validate the string contents automatically. However, it MUST NOT perform these operations by default, and MUST provide the validation result of each string-encoded document separately from the enclosing document. This process SHOULD be equivalent to fully evaluating the instance against the original schema, followed by using the annotations to decode, parse, and/or validate each string-encoded document. [CREF7]For now, the exact mechanism of performing and returning parsed data and/or validation results from such an automatic decoding, parsing, and validating feature is left unspecified. Should such a feature prove popular, it may be specified more thoroughly in a future draft.

    -

    See also the Security Considerations sections for possible vulnerabilities introduced by automatically processing the instance string according to these keywords.

    -

    -8.3. contentEncoding

    -

    If the instance value is a string, this property defines that the string SHOULD be interpreted as binary data and decoded using the encoding named by this property.

    -

    Possible values for this property are listed in RFC 2045, Sec 6.1 and RFC 4648. For "base64", which is defined in both RFCs, the definition in RFC 4648, which removes line length limitations, SHOULD be used, as various other specifications have mandated different lengths. Note that line lengths within a string can be constrained using the "pattern" keyword.

    -

    If this keyword is absent, but "contentMediaType" is present, this indicates that the media type could be encoded into UTF-8 like any other JSON string value, and does not require additional decoding.

    -

    The value of this property MUST be a string.

    -

    -8.4. contentMediaType

    -

    If the instance is a string, this property indicates the media type of the contents of the string. If "contentEncoding" is present, this property describes the decoded string.

    -

    The value of this property MUST be a string, which MUST be a media type, as defined by RFC 2046.

    -

    -8.5. contentSchema

    -

    If the instance is a string, and if "contentMediaType" is present, this property contains a schema which describes the structure of the string.

    -

    This keyword MAY be used with any media type that can be mapped into JSON Schema's data model.

    -

    The value of this property SHOULD be ignored if "contentMediaType" is not present.

    -

    -8.6. Example

    -

    Here is an example schema, illustrating the use of "contentEncoding" and "contentMediaType":

    -
    -
    -{
    -    "type": "string",
    -    "contentEncoding": "base64",
    -    "contentMediaType": "image/png"
    -}
    -
    -                    
    -

    Instances described by this schema are expected to be strings, and their values should be interpretable as base64-encoded PNG images.

    -

    Another example:

    -
    -
    -{
    -    "type": "string",
    -    "contentMediaType": "text/html"
    -}
    -
    -                    
    -

    Instances described by this schema are expected to be strings containing HTML, using whatever character set the JSON string was decoded into. Per section 8.1 of RFC 8259, outside of an entirely closed system, this MUST be UTF-8.

    -

    This example describes a JWT that is MACed using the HMAC SHA-256 algorithm, and requires the "iss" and "exp" fields in its claim set.

    -
    -
    -{
    -    "type": "string",
    -    "contentMediaType": "application/jwt",
    -    "contentSchema": {
    -        "type": "array",
    -        "minItems": 2,
    -        "items": [
    -            {
    -                "const": {
    -                    "typ": "JWT",
    -                    "alg": "HS256"
    -                }
    -            },
    -            {
    -                "type": "object",
    -                "required": ["iss", "exp"],
    -                "properties": {
    -                    "iss": {"type": "string"},
    -                    "exp": {"type": "integer"}
    -                }
    -            }
    -        ]
    -    }
    -}
    -                    
    -

    Note that "contentEncoding" does not appear. While the "application/jwt" media type makes use of base64url encoding, that is defined by the media type, which determines how the JWT string is decoded into a list of two JSON data structures: first the header, and then the payload. Since the JWT media type ensures that the JWT can be represented in a JSON string, there is no need for further encoding or decoding.

    -

    -9. A Vocabulary for Basic Meta-Data Annotations

    -

    These general-purpose annotation keywords provide commonly used information for documentation and user interface display purposes. They are not intended to form a comprehensive set of features. Rather, additional vocabularies can be defined for more complex annotation-based applications.

    -

    Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

    -

    The current URI for this vocabulary, known as the Meta-Data vocabulary, is: <https://json-schema.org/draft/2019-09/vocab/meta-data>.

    -

    The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-09/meta/meta-data>.

    -

    -9.1. "title" and "description"

    -

    The value of both of these keywords MUST be a string.

    -

    Both of these keywords can be used to decorate a user interface with information about the data produced by this user interface. A title will preferably be short, whereas a description will provide explanation about the purpose of the instance described by this schema.

    -

    -9.2. "default"

    -

    There are no restrictions placed on the value of this keyword. When multiple occurrences of this keyword are applicable to a single sub-instance, implementations SHOULD remove duplicates.

    -

    This keyword can be used to supply a default JSON value associated with a particular schema. It is RECOMMENDED that a default value be valid against the associated schema.

    -

    -9.3. "deprecated"

    -

    The value of this keyword MUST be a boolean. When multiple occurrences of this keyword are applicable to a single sub-instance, applications SHOULD consider the instance location to be deprecated if any occurrence specifies a true value.

    -

    If "deprecated" has a value of boolean true, it indicates that applications SHOULD refrain from usage of the declared property. It MAY mean the property is going to be removed in the future.

    -

    A root schema containing "deprecated" with a value of true indicates that the entire resource being described MAY be removed in the future.

    -

    When the "deprecated" keyword is applied to an item in an array by means of "items", if "items" is a single schema, the deprecation relates to the whole array, while if "items" is an array of schemas, the deprecation relates to the corrosponding item according to the subschemas position.

    -

    Omitting this keyword has the same behavior as a value of false.

    -

    -9.4. "readOnly" and "writeOnly"

    -

    The value of these keywords MUST be a boolean. When multiple occurrences of these keywords are applicable to a single sub-instance, the resulting behavior SHOULD be as for a true value if any occurrence specifies a true value, and SHOULD be as for a false value otherwise.

    -

    If "readOnly" has a value of boolean true, it indicates that the value of the instance is managed exclusively by the owning authority, and attempts by an application to modify the value of this property are expected to be ignored or rejected by that owning authority.

    -

    An instance document that is marked as "readOnly for the entire document MAY be ignored if sent to the owning authority, or MAY result in an error, at the authority's discretion.

    -

    If "writeOnly" has a value of boolean true, it indicates that the value is never present when the instance is retrieved from the owning authority. It can be present when sent to the owning authority to update or create the document (or the resource it represents), but it will not be included in any updated or newly created version of the instance.

    -

    An instance document that is marked as "writeOnly" for the entire document MAY be returned as a blank document of some sort, or MAY produce an error upon retrieval, or have the retrieval request ignored, at the authority's discretion.

    -

    For example, "readOnly" would be used to mark a database-generated serial number as read-only, while "writeOnly" would be used to mark a password input field.

    -

    These keywords can be used to assist in user interface instance generation. In particular, an application MAY choose to use a widget that hides input values as they are typed for write-only fields.

    -

    Omitting these keywords has the same behavior as values of false.

    -

    -9.5. "examples"

    -

    The value of this keyword MUST be an array. There are no restrictions placed on the values within the array. When multiple occurrences of this keyword are applicable to a single sub-instance, implementations MUST provide a flat array of all values rather than an array of arrays.

    -

    This keyword can be used to provide sample JSON values associated with a particular schema, for the purpose of illustrating usage. It is RECOMMENDED that these values be valid against the associated schema.

    -

    Implementations MAY use the value(s) of "default", if present, as an additional example. If "examples" is absent, "default" MAY still be used in this manner.

    -

    -10. Security Considerations -

    -

    JSON Schema validation defines a vocabulary for JSON Schema core and concerns all the security considerations listed there.

    -

    JSON Schema validation allows the use of Regular Expressions, which have numerous different (often incompatible) implementations. Some implementations allow the embedding of arbitrary code, which is outside the scope of JSON Schema and MUST NOT be permitted. Regular expressions can often also be crafted to be extremely expensive to compute (with so-called "catastrophic backtracking"), resulting in a denial-of-service attack.

    -

    Implementations that support validating or otherwise evaluating instance string data based on "contentEncoding" and/or "contentMediaType" are at risk of evaluating data in an unsafe way based on misleading information. Applications can mitigate this risk by only performing such processing when a relationship between the schema and instance is established (e.g., they share the same authority).

    -

    Processing a media type or encoding is subject to the security considerations of that media type or encoding. For example, the security considerations of RFC 4329 Scripting Media Types apply when processing JavaScript or ECMAScript encoded within a JSON string.

    -

    -11. References

    -

    -11.1. Normative References

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    [ecma262]"ECMA 262 specification"
    [json-schema] -Wright, A. and H. Andrews, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-handrews-json-schema-02, November 2017.
    [relative-json-pointer] -Luff, G. and H. Andrews, "Relative JSON Pointers", Internet-Draft draft-handrews-relative-json-pointer-01, November 2017.
    [RFC1123] -Braden, R., "Requirements for Internet Hosts - Application and Support", STD 3, RFC 1123, DOI 10.17487/RFC1123, October 1989.
    [RFC2045] -Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", RFC 2045, DOI 10.17487/RFC2045, November 1996.
    [RFC2046] -Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types", RFC 2046, DOI 10.17487/RFC2046, November 1996.
    [RFC2119] -Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.
    [RFC2673] -Crawford, M., "Binary Labels in the Domain Name System", RFC 2673, DOI 10.17487/RFC2673, August 1999.
    [RFC3339] -Klyne, G. and C. Newman, "Date and Time on the Internet: Timestamps", RFC 3339, DOI 10.17487/RFC3339, July 2002.
    [RFC3986] -Berners-Lee, T., Fielding, R. and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, January 2005.
    [RFC3987] -Duerst, M. and M. Suignard, "Internationalized Resource Identifiers (IRIs)", RFC 3987, DOI 10.17487/RFC3987, January 2005.
    [RFC4122] -Leach, P., Mealling, M. and R. Salz, "A Universally Unique IDentifier (UUID) URN Namespace", RFC 4122, DOI 10.17487/RFC4122, July 2005.
    [RFC4291] -Hinden, R. and S. Deering, "IP Version 6 Addressing Architecture", RFC 4291, DOI 10.17487/RFC4291, February 2006.
    [RFC4648] -Josefsson, S., "The Base16, Base32, and Base64 Data Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006.
    [RFC5322] -Resnick, P., "Internet Message Format", RFC 5322, DOI 10.17487/RFC5322, October 2008.
    [RFC5890] -Klensin, J., "Internationalized Domain Names for Applications (IDNA): Definitions and Document Framework", RFC 5890, DOI 10.17487/RFC5890, August 2010.
    [RFC5891] -Klensin, J., "Internationalized Domain Names in Applications (IDNA): Protocol", RFC 5891, DOI 10.17487/RFC5891, August 2010.
    [RFC6531] -Yao, J. and W. Mao, "SMTP Extension for Internationalized Email", RFC 6531, DOI 10.17487/RFC6531, February 2012.
    [RFC6570] -Gregorio, J., Fielding, R., Hadley, M., Nottingham, M. and D. Orchard, "URI Template", RFC 6570, DOI 10.17487/RFC6570, March 2012.
    [RFC6901] -Bryan, P., Zyp, K. and M. Nottingham, "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, April 2013.
    [RFC8259] -Bray, T., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, December 2017.
    -

    -11.2. Informative References

    - - - -
    [RFC4329] -Hoehrmann, B., "Scripting Media Types", RFC 4329, DOI 10.17487/RFC4329, April 2006.
    -

    -Appendix A. Keywords Moved from Validation to Core

    -

    Several keywords have been moved from this document into the Core Specification as of this draft, in some cases with re-naming or other changes. This affects the following former validation keywords:

    - -
    -
    "definitions"
    -
    Renamed to "$defs" to match "$ref" and be shorter to type. Schema vocabulary authors SHOULD NOT define a "definitions" keyword with different behavior in order to avoid invalidating schemas that still use the older name. While "definitions" is absent in the single-vocabulary meta-schemas referenced by this document, it remains present in the default meta-schema, and implementations SHOULD assume that "$defs" and "definitions" have the same behavior when that meta-schema is used.
    -
    "allOf", "anyOf", "oneOf", "not", "if", "then", "else", "items", "additionalItems", "contains", "propertyNames", "properties", "patternProperties", "additionalProperties"
    -
    All of these keywords apply subschemas to the instance and combine their results, without asserting any conditions of their own. Without assertion keywords, these applicators can only cause assertion failures by using the false boolean schema, or by inverting the result of the true boolean schema (or equivalent schema objects). For this reason, they are better defined as a generic mechanism on which validation, hyper-schema, and extension vocabularies can all be based.
    -
    "dependencies"
    -
    This keyword had two different modes of behavior, which made it relatively challenging to implement and reason about. The schema form has been moved to Core and renamed to "dependentSchemas", as part of the applicator vocabulary. It is analogous to "properties", except that instead of applying its subschema to the property value, it applies it to the object containing the property. The property name array form is retained here and renamed to "dependentRequired", as it is an assertion which is a shortcut for the conditional use of the "required" assertion keyword.
    -
    - -

    -

    -Appendix B. Acknowledgments

    -

    Thanks to Gary Court, Francis Galiegue, Kris Zyp, and Geraint Luff for their work on the initial drafts of JSON Schema.

    -

    Thanks to Jason Desrosiers, Daniel Perrett, Erik Wilde, Ben Hutton, Evgeny Poberezkin, Brad Bowman, Gowry Sankar, Donald Pipowitch, Dave Finlay, and Denis Laxalde for their submissions and patches to the document.

    -

    -Appendix C. ChangeLog

    -

    [CREF8]This section to be removed before leaving Internet-Draft status.

    -

    - -
    -
    draft-handrews-json-schema-validation-02
    -
    -
      -
    • Grouped keywords into formal vocabuarlies
    • -
    • Update "format" implementation requirements in terms of vocabularies
    • -
    • By default, "format" MUST NOT be validated, although validation can be enabled
    • -
    • A vocabulary declaration can be used to require "format" validation
    • -
    • Moved "definitions" to the core spec as "$defs"
    • -
    • Moved applicator keywords to the core spec
    • -
    • Renamed the array form of "dependencies" to "dependentRequired", moved the schema form to the core spec
    • -
    • Specified all "content*" keywords as annotations, not assertions
    • -
    • Added "contentSchema" to allow applying a schema to a string-encoded document
    • -
    • Also allow RFC 4648 encodings in "contentEncoding"
    • -
    • Added "minContains" and "maxContains"
    • -
    • Update RFC reference for "hostname" and "idn-hostname"
    • -
    • Add "uuid" and "duration" formats
    • -
    -

    -
    -
    draft-handrews-json-schema-validation-01
    -
    -
      -
    • This draft is purely a clarification with no functional changes
    • -
    • Provided the general principle behind ignoring annotations under "not" and similar cases
    • -
    • Clarified "if"/"then"/"else" validation interactions
    • -
    • Clarified "if"/"then"/"else" behavior for annotation
    • -
    • Minor formatting and cross-referencing improvements
    • -
    -

    -
    -
    draft-handrews-json-schema-validation-00
    -
    -
      -
    • Added "if"/"then"/"else"
    • -
    • Classify keywords as assertions or annotations per the core spec
    • -
    • Warn of possibly removing "dependencies" in the future
    • -
    • Grouped validation keywords into sub-sections for readability
    • -
    • Moved "readOnly" from hyper-schema to validation meta-data
    • -
    • Added "writeOnly"
    • -
    • Added string-encoded media section, with former hyper-schema "media" keywords
    • -
    • Restored "regex" format (removal was unintentional)
    • -
    • Added "date" and "time" formats, and reserved additional RFC 3339 format names
    • -
    • I18N formats: "iri", "iri-reference", "idn-hostname", "idn-email"
    • -
    • Clarify that "json-pointer" format means string encoding, not URI fragment
    • -
    • Fixed typo that inverted the meaning of "minimum" and "exclusiveMinimum"
    • -
    • Move format syntax references into Normative References
    • -
    • JSON is a normative requirement
    • -
    -

    -
    -
    draft-wright-json-schema-validation-01
    -
    -
      -
    • Standardized on hyphenated format names with full words ("uriref" becomes "uri-reference")
    • -
    • Add the formats "uri-template" and "json-pointer"
    • -
    • Changed "exclusiveMaximum"/"exclusiveMinimum" from boolean modifiers of "maximum"/"minimum" to independent numeric fields.
    • -
    • Split the additionalItems/items into two sections
    • -
    • Reworked properties/patternProperties/additionalProperties definition
    • -
    • Added "examples" keyword
    • -
    • Added "contains" keyword
    • -
    • Allow empty "required" and "dependencies" arrays
    • -
    • Fixed "type" reference to primitive types
    • -
    • Added "const" keyword
    • -
    • Added "propertyNames" keyword
    • -
    -

    -
    -
    draft-wright-json-schema-validation-00
    -
    -
      -
    • Added additional security considerations
    • -
    • Removed reference to "latest version" meta-schema, use numbered version instead
    • -
    • Rephrased many keyword definitions for brevity
    • -
    • Added "uriref" format that also allows relative URI references
    • -
    -

    -
    -
    draft-fge-json-schema-validation-00
    -
    -
      -
    • Initial draft.
    • -
    • Salvaged from draft v3.
    • -
    • Redefine the "required" keyword.
    • -
    • Remove "extends", "disallow"
    • -
    • Add "anyOf", "allOf", "oneOf", "not", "definitions", "minProperties", "maxProperties".
    • -
    • "dependencies" member values can no longer be single strings; at least one element is required in a property dependency array.
    • -
    • Rename "divisibleBy" to "multipleOf".
    • -
    • "type" arrays can no longer have schemas; remove "any" as a possible value.
    • -
    • Rework the "format" section; make support optional.
    • -
    • "format": remove attributes "phone", "style", "color"; rename "ip-address" to "ipv4"; add references for all attributes.
    • -
    • Provide algorithms to calculate schema(s) for array/object instances.
    • -
    • Add interoperability considerations.
    • -
    -

    -
    -
    - -

    -

    Authors' Addresses

    -
    -
    - - Austin Wright (editor) - - - - - - - - - - - - - EMail: aaa@bzfx.net - -
    -
    -
    - - Henry Andrews (editor) - - - - - - - - - - - - - EMail: andrews_henry@yahoo.com - -
    -
    -
    - - Ben Hutton (editor) - - - Wellcome Sanger Institute - - - - - - - - - - EMail: bh7@sanger.ac.uk - -URI: https://jsonschema.dev - -
    -
    - - - diff --git a/latest/json-schema-validation.md b/latest/json-schema-validation.md new file mode 100644 index 00000000..16e6414a --- /dev/null +++ b/latest/json-schema-validation.md @@ -0,0 +1,4 @@ +--- +redirect_to: "/draft/2019-09/json-schema-validation.html" +title: "JSON Schema Validation: A Vocabulary for Structural Validation of JSON" +--- diff --git a/latest/relative-json-pointer.html b/latest/relative-json-pointer.html deleted file mode 100644 index 5710a004..00000000 --- a/latest/relative-json-pointer.html +++ /dev/null @@ -1,687 +0,0 @@ - - - - - - - Relative JSON Pointers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Internet Engineering Task ForceG. Luff
    Internet-Draft
    Intended status: InformationalH. Andrews, Ed.
    Expires: March 20, 2020September 17, 2019
    - -

    Relative JSON Pointers
    - draft-handrews-relative-json-pointer-02

    - -

    Abstract

    -

    JSON Pointer is a syntax for specifying locations in a JSON document, starting from the document root. This document defines an extension to the JSON Pointer syntax, allowing relative locations from within the document.

    -

    Status of This Memo

    -

    This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

    -

    Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

    -

    Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

    -

    This Internet-Draft will expire on March 20, 2020.

    -

    Copyright Notice

    -

    Copyright (c) 2019 IETF Trust and the persons identified as the document authors. All rights reserved.

    -

    This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

    - - -
    -

    Table of Contents

    - - -

    -1. Introduction

    -

    JSON Pointer (RFC 6901) is a syntax for specifying locations in a JSON document, starting from the document root. This document defines a related syntax allowing identification of relative locations from within the document.

    -

    -2. Conventions and Terminology

    -

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

    -

    -3. Syntax

    -

    A Relative JSON Pointer is a Unicode string in UTF-8 encoding (see RFC 8259, Section 8), comprising a non-negative integer, followed by either a '#' (%x23) character or a JSON Pointer (RFC 6901).

    -

    The separation between the integer prefix and the JSON Pointer will always be unambiguous, because a JSON Pointer must be either zero- length or start with a '/' (%x2F). Similarly, a JSON Pointer will never be ambiguous with the '#'.

    -

    The ABNF syntax of a Relative JSON Pointer is:

    -
    -
    -   relative-json-pointer =  non-negative-integer &lt;json-pointer&gt;
    -   relative-json-pointer =/ non-negative-integer "#"
    -   non-negative-integer      =  %x30 / %x31-39 *( %x30-39 )
    -           ; "0", or digits without a leading "0"
    -
    -                
    -

    where <json-pointer> follows the production defined in RFC 6901, Section 3 ("Syntax").

    -

    -

    -4. Evaluation

    -

    Evaluation of a Relative JSON Pointer begins with a reference to a value within a JSON document, and completes with either a value within that document, a string corresponding to an object member, or integer value representing an array index.

    -

    Evaluation begins by processing the non-negative-integer prefix. This can be found by taking the longest continuous sequence of decimal digits available, starting from the beginning of the string, taking the decimal numerical value. If this value is more than zero, then the following steps are repeated that number of times: RFC 6901, Section 4 ("Evaluation"), with the modification that the initial reference being used is the reference currently being held (which may not be root of the document).

    - -
      -
    • If the current referenced value is the root of the document, then evaluation fails (see below).
    • -
    • If the referenced value is an item within an array, then the new referenced value is that array.
    • -
    • If the referenced value is an object member within an object, then the new referenced value is that object.
    • -
    - -

    If the remainder of the Relative JSON Pointer is a JSON Pointer, then evaluation proceeds as per

    -

    Otherwise (when the remainder of the Relative JSON Pointer is the character '#'), the final result is determined as follows:

    - -
      -
    • If the current referenced value is the root of the document, then evaluation fails (see below).
    • -
    • If the referenced value is an item within an array, then the final evaluation result is the value's index position within the array.
    • -
    • If the referenced value is an object member within an object, then the new referenced value is the corresponding member name.
    • -
    - -

    -

    -5. JSON String Representation

    -

    The concerns surrounding JSON String representation of a Relative JSON Pointer are identical to those laid out in RFC 6901, Section 5.

    -

    -5.1. Examples

    -

    For example, given the JSON document:

    -
    -
    -                      {
    -                         "foo": ["bar", "baz"],
    -                         "highly": {
    -                            "nested": {
    -                               "objects": true
    -                            }
    -                         }
    -                      }
    -
    -                    
    -

    Starting from the value "baz" (inside "foo"), the following JSON strings evaluate to the accompanying values:

    -
    -
    -                  "0"                         "baz"
    -                  "1/0"                       "bar"
    -                  "2/highly/nested/objects"   true
    -                  "0#"                        1
    -                  "1#"                        "foo"
    -
    -                    
    -

    Starting from the value {"objects":true} (corresponding to the member key "nested"), the following JSON strings evaluate to the accompanying values:

    -
    -
    -                "0/objects"                 true
    -                "1/nested/objects"          true
    -                "2/foo/0"                   "bar"
    -                "0#"                        "nested"
    -                "1#"                        "highly"
    -
    -                    
    -

    -6. Non-use in URI Fragment Identifiers

    -

    Unlike a JSON Pointer, a Relative JSON Pointer can not be used in a URI fragment identifier. Such fragments specify exact positions within a document, and therefore Relative JSON Pointers are not suitable.

    -

    -7. Error Handling

    -

    In the event of an error condition, evaluation of the JSON Pointer fails to complete.

    -

    Evaluation may fail due to invalid syntax, or referencing a non- existent value. This specification does not define how errors are handled. An application of JSON Relative Pointer SHOULD specify the impact and handling of each type of error.

    -

    -8. Relationship to JSON Pointer

    -

    Relative JSON Pointers are intended as a companion to JSON Pointers. Applications MUST specify the use of each syntax separately. Defining either JSON Pointer or Relative JSON Pointer as an acceptable syntax does not imply that the other syntax is also acceptable.

    -

    -9. Acknowledgements

    -

    The language and structure of this specification are based heavily on [RFC6901], sometimes quoting it outright.

    -

    This draft remains primarily as written and published by Geraint Luff, with only minor subsequent alterations under new editorship.

    -

    -10. Security Considerations

    -

    Evaluation of a given Relative JSON Pointer is not guaranteed to reference an actual JSON value. Applications using Relative JSON Pointer should anticipate this situation by defining how a pointer that does not resolve ought to be handled.

    -

    As part of processing, a composite data structure may be assembled from multiple JSON documents (in part or in full). In such cases, applications SHOULD ensure that a Relative JSON Pointer does not evaluate to a value outside the document for which is was written.

    -

    Note that JSON pointers can contain the NUL (Unicode U+0000) character. Care is needed not to misinterpret this character in programming languages that use NUL to mark the end of a string.

    -

    -11. References

    -

    -11.1. Normative References

    - - - - - - - - - -
    [RFC2119] -Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.
    [RFC6901] -Bryan, P., Zyp, K. and M. Nottingham, "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, April 2013.
    -

    -11.2. Informative References

    - - - -
    [RFC8259] -Bray, T., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, December 2017.
    -

    -Appendix A. ChangeLog

    -

    [CREF1]This section to be removed before leaving Internet-Draft status.

    -

    - -
    -
    draft-handrews-relative-json-pointer-02
    -
    -
    • Update to the latest JSON RFC
    -

    -
    -
    draft-handrews-relative-json-pointer-01
    -
    -
    • The initial number is "non-negative", not "positive"
    -

    -
    -
    draft-handrews-relative-json-pointer-00
    -
    -
      -
    • Revived draft with identical wording and structure.
    • -
    • Clarified how to use alongside JSON Pointer.
    • -
    -

    -
    -
    draft-luff-relative-json-pointer-00
    -
    -
    • Initial draft.
    -

    -
    -
    - -

    -

    Authors' Addresses

    -
    -
    - - Geraint Luff - - - - - - - Cambridge, - - - - UK - - EMail: luffgd@gmail.com - -
    -
    -
    - - Henry Andrews (editor) - - - - - - - - - - - - - EMail: andrews_henry@yahoo.com - -
    -
    - - - diff --git a/latest/relative-json-pointer.md b/latest/relative-json-pointer.md new file mode 100644 index 00000000..a49854a4 --- /dev/null +++ b/latest/relative-json-pointer.md @@ -0,0 +1,4 @@ +--- +redirect_to: "/draft/2019-09/relative-json-pointer.html" +title: "Relative JSON Pointers" +--- From 96b5569c315b76f0820cae34691bb4865f980f52 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 29 Oct 2019 22:35:56 -0700 Subject: [PATCH 016/311] Redirect the standard vocabulary URIs We've already had one person confused that these URIs 404, even though the spec says to expect that. Let's generate HTML stubs to redirect to the appropriate spec section for each vocabulary (or the whole spec for Hyper-Schema). No media type restrictions are given at this time for vocabulary documents, so having HTML here is fine. Jekyll (at least the local version, production sometimes differs) will do the redirect on URIs without the .html suffix, which is what we need. It will also do it with .html, but I think that's fine. --- draft/2019-09/vocab/applicator.md | 4 ++++ draft/2019-09/vocab/content.md | 4 ++++ draft/2019-09/vocab/core.md | 4 ++++ draft/2019-09/vocab/format.md | 4 ++++ draft/2019-09/vocab/hyper-schema.md | 4 ++++ draft/2019-09/vocab/meta-data.md | 4 ++++ draft/2019-09/vocab/validation.md | 4 ++++ 7 files changed, 28 insertions(+) create mode 100644 draft/2019-09/vocab/applicator.md create mode 100644 draft/2019-09/vocab/content.md create mode 100644 draft/2019-09/vocab/core.md create mode 100644 draft/2019-09/vocab/format.md create mode 100644 draft/2019-09/vocab/hyper-schema.md create mode 100644 draft/2019-09/vocab/meta-data.md create mode 100644 draft/2019-09/vocab/validation.md diff --git a/draft/2019-09/vocab/applicator.md b/draft/2019-09/vocab/applicator.md new file mode 100644 index 00000000..805aab89 --- /dev/null +++ b/draft/2019-09/vocab/applicator.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2019-09/json-schema-core.html#rfc.section.9 +title: A Vocabulary for Applying Subschemas +--- diff --git a/draft/2019-09/vocab/content.md b/draft/2019-09/vocab/content.md new file mode 100644 index 00000000..804bf910 --- /dev/null +++ b/draft/2019-09/vocab/content.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2019-09/json-schema-validation.html#rfc.section.8 +title: A Vocabulary for the Contents of String-Encoded Data +--- diff --git a/draft/2019-09/vocab/core.md b/draft/2019-09/vocab/core.md new file mode 100644 index 00000000..f850b759 --- /dev/null +++ b/draft/2019-09/vocab/core.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2019-09/json-schema-core.html#rfc.section.8 +title: The JSON Schema Core Vocabulary +--- diff --git a/draft/2019-09/vocab/format.md b/draft/2019-09/vocab/format.md new file mode 100644 index 00000000..b54f986b --- /dev/null +++ b/draft/2019-09/vocab/format.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2019-09/json-schema-validation.html#rfc.section.7 +title: A Vocabulary for Semantic Content with "format" +--- diff --git a/draft/2019-09/vocab/hyper-schema.md b/draft/2019-09/vocab/hyper-schema.md new file mode 100644 index 00000000..e32c8bfd --- /dev/null +++ b/draft/2019-09/vocab/hyper-schema.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2019-09/json-schema-hypermedia.html +title: "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON" +--- diff --git a/draft/2019-09/vocab/meta-data.md b/draft/2019-09/vocab/meta-data.md new file mode 100644 index 00000000..5531a5cf --- /dev/null +++ b/draft/2019-09/vocab/meta-data.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2019-09/json-schema-validation.html#rfc.section.9 +title: A Vocabulary for Basic Meta-Data Annotations +--- diff --git a/draft/2019-09/vocab/validation.md b/draft/2019-09/vocab/validation.md new file mode 100644 index 00000000..24e3df3f --- /dev/null +++ b/draft/2019-09/vocab/validation.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2019-09/json-schema-validation.html#rfc.section.6 +title: A Vocabulary for Structural Validation +--- From 98336e0c23bc62e5dc84d51ecbc8a7fa80ee89fe Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 29 Oct 2019 22:42:33 -0700 Subject: [PATCH 017/311] Redirect unversioned meta-schemas This replaces these with HTML stubs that will use a meta refresh tag and canonical link to perform a redirect. If there's code out there assuming that these exist and are JSON, then that code will be confused by receiving HTML. Although we do say that you can't assume these things are actually hosted. Not sure this is what anyone had in mind, though. --- hyper-schema | 1 - hyper-schema.md | 3 +++ links | 1 - links.md | 3 +++ schema | 1 - schema.md | 3 +++ 6 files changed, 9 insertions(+), 3 deletions(-) delete mode 120000 hyper-schema create mode 100644 hyper-schema.md delete mode 120000 links create mode 100644 links.md delete mode 120000 schema create mode 100644 schema.md diff --git a/hyper-schema b/hyper-schema deleted file mode 120000 index a43db6b4..00000000 --- a/hyper-schema +++ /dev/null @@ -1 +0,0 @@ -draft-07/hyper-schema \ No newline at end of file diff --git a/hyper-schema.md b/hyper-schema.md new file mode 100644 index 00000000..d57e3c3f --- /dev/null +++ b/hyper-schema.md @@ -0,0 +1,3 @@ +--- +redirect_to: /draft/2019-09/hyper-schema +--- diff --git a/links b/links deleted file mode 120000 index cd24f5b4..00000000 --- a/links +++ /dev/null @@ -1 +0,0 @@ -draft-07/links \ No newline at end of file diff --git a/links.md b/links.md new file mode 100644 index 00000000..c67e9a3b --- /dev/null +++ b/links.md @@ -0,0 +1,3 @@ +--- +redirect_to: /draft/2019-09/links +--- diff --git a/schema b/schema deleted file mode 120000 index c0362a35..00000000 --- a/schema +++ /dev/null @@ -1 +0,0 @@ -draft-07/schema \ No newline at end of file diff --git a/schema.md b/schema.md new file mode 100644 index 00000000..e433ffa8 --- /dev/null +++ b/schema.md @@ -0,0 +1,3 @@ +--- +redirect_to: /draft/2019-09/schema +--- From fb1cd59a3da7eae8bcfdd88e61d23109c1bbd78f Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 29 Oct 2019 23:38:24 -0700 Subject: [PATCH 018/311] Add some explanation for redirects Because some of it is weird, and when redirecting for the JSON files, getting HTML is surprising. --- _layouts/redirect.html | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 _layouts/redirect.html diff --git a/_layouts/redirect.html b/_layouts/redirect.html new file mode 100644 index 00000000..03f78506 --- /dev/null +++ b/_layouts/redirect.html @@ -0,0 +1,20 @@ + + + + Redirecting… + + + +

    Redirecting…

    +

    + Several redirections on json-schema.org are special cases: +

    +
      +
    • The unversioned meta-schema URIs should no longer be used.
    • +
    • The vocabularies are represented by their specification text.
    • +
    • The "latest" specification URIs are for convenice of browser + bookmarking only.
    • +
    + Click here if you are not redirected. + + From 7d53bd24c13521d4915bdf56ebe2a468eea80d0a Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Wed, 30 Oct 2019 09:32:38 -0700 Subject: [PATCH 019/311] Examples test should still be on draft-07 This is an excellent example of why using the unversioned schema URI / path is a bad idea. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 205d3479..bb139d44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,4 @@ before_script: - PATH="./node_modules/.bin/:$PATH" script: - bundle exec jekyll build -- ajv test -s schema -d "learn/examples/*.json" --valid +- ajv test -s draft-07/schema -d "learn/examples/*.json" --valid From 650b8b6fec23a59c411da1e8c5973d522f3b6e50 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 2 Nov 2019 03:32:39 +0000 Subject: [PATCH 020/311] Bump nokogiri from 1.8.2 to 1.10.5 Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.8.2 to 1.10.5. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/master/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.8.2...v1.10.5) Signed-off-by: dependabot[bot] --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e808f71d..b13a08f8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -199,7 +199,7 @@ GEM rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) mercenary (0.3.6) - mini_portile2 (2.3.0) + mini_portile2 (2.4.0) minima (2.4.1) jekyll (~> 3.5) jekyll-feed (~> 0.9) @@ -207,8 +207,8 @@ GEM minitest (5.11.3) multipart-post (2.0.0) net-dns (0.8.0) - nokogiri (1.8.2) - mini_portile2 (~> 2.3.0) + nokogiri (1.10.5) + mini_portile2 (~> 2.4.0) octokit (4.8.0) sawyer (~> 0.8.0, >= 0.5.3) pathutil (0.16.1) From 47c407d71d7e9ace65b24524b4c05cee72b18062 Mon Sep 17 00:00:00 2001 From: Steve Hu Date: Thu, 7 Nov 2019 20:50:04 -0500 Subject: [PATCH 021/311] add networknt json-schema-validator in Java --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 7692ed83..eb597dc9 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -89,6 +89,12 @@ date-draft: draft: [7, 6, 4] license: Apache License 2.0 + - name: networknt/json-schema-validator + url: https://github.com/networknt/json-schema-validator + notes: + date-draft: + draft: [7, 6, 4] + license: Apache License 2.0 - name: Kotlin implementations: - name: Medeia-validator From dd7fe24540bf41bac212c1f58b122b2317152222 Mon Sep 17 00:00:00 2001 From: Steve Hu Date: Thu, 7 Nov 2019 20:56:49 -0500 Subject: [PATCH 022/311] add OpenAPI 3.0 support and Jackson parser --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index eb597dc9..22beb2da 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -91,7 +91,7 @@ license: Apache License 2.0 - name: networknt/json-schema-validator url: https://github.com/networknt/json-schema-validator - notes: + notes: Support OpenAPI 3.0 with Jackson parser date-draft: draft: [7, 6, 4] license: Apache License 2.0 From 3a3544914cd22e78a5e1360daa2f4ea0aa9b472f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2019 19:13:40 +0000 Subject: [PATCH 023/311] Bump rubyzip from 1.2.1 to 2.0.0 Bumps [rubyzip](https://github.com/rubyzip/rubyzip) from 1.2.1 to 2.0.0. - [Release notes](https://github.com/rubyzip/rubyzip/releases) - [Changelog](https://github.com/rubyzip/rubyzip/blob/master/Changelog.md) - [Commits](https://github.com/rubyzip/rubyzip/compare/v1.2.1...v2.0.0) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index b13a08f8..5802c946 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -221,7 +221,7 @@ GEM ruby-enum (0.7.2) i18n ruby_dep (1.5.0) - rubyzip (1.2.1) + rubyzip (2.0.0) safe_yaml (1.0.4) sass (3.5.6) sass-listen (~> 4.0.0) From e4fd78fdad4452b1576ec7584fedfb82bdc3b791 Mon Sep 17 00:00:00 2001 From: Steve Hu Date: Tue, 12 Nov 2019 14:55:32 -0500 Subject: [PATCH 024/311] remove networknt/json-schema-validator from the obsolete list --- _data/validator-libraries-obsolete.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/_data/validator-libraries-obsolete.yml b/_data/validator-libraries-obsolete.yml index 0d19362e..f0bece60 100644 --- a/_data/validator-libraries-obsolete.yml +++ b/_data/validator-libraries-obsolete.yml @@ -73,11 +73,6 @@ url: https://github.com/java-json-tools/json-schema-validator draft: [4] license: LGPLv3 - - name: json-schema-validator - url: https://github.com/networknt/json-schema-validator - notes: - draft: [4] - license: Apache License 2.0 - name: JavaScript implementations: - name: jsonschema From d4fb50dfd95c1ce5ede3e56bd5553ade891176d9 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Wed, 20 Nov 2019 12:49:04 +0000 Subject: [PATCH 025/311] changed discussion to join our slack --- _includes/header.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/_includes/header.html b/_includes/header.html index 295d14bc..a63449c6 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -25,9 +25,7 @@ {{ my_page.title | escape }} {%- endif -%} {% endfor -%} - - Discussion - + Join our Slack {%- endif -%} From 82f1592b8391912c9d89da987c54e16e2cc39188 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 16 Jan 2020 12:25:34 +0000 Subject: [PATCH 026/311] Update draft-7 metaschema to include `writeOnly`. Update draft-7 submodule for updated metaschema as per https://github.com/json-schema-org/json-schema-spec/issues/770 --- _includes/draft-07 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/draft-07 b/_includes/draft-07 index 4e016d92..6e2b4251 160000 --- a/_includes/draft-07 +++ b/_includes/draft-07 @@ -1 +1 @@ -Subproject commit 4e016d927839ed264f8d182abe9dc18a7e7a2c62 +Subproject commit 6e2b42516dc7e8845c980d284c61bd44c9f95cd2 From a1decc4a5e089670e482f194a5ed4192e337f8fc Mon Sep 17 00:00:00 2001 From: Jacob Horbulyk Date: Fri, 24 Jan 2020 10:24:59 +0100 Subject: [PATCH 027/311] Add @adobe/jsonschema2md as an implementation. --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index 9ee00aaa..97a23ee7 100644 --- a/implementations.md +++ b/implementations.md @@ -123,6 +123,7 @@ Hyper-Schema - JavaScript - [@cloudflare/doca](https://github.com/cloudflare/json-schema-tools/tree/master/workspaces/doca) ([JSON Schema Tools](https://github.com/cloudflare/json-schema-tools)), _draft-04, -06, -07, and Doca extensions_ (UI forthcoming) + - [@adobe/jsonschema2md](https://github.com/adobe/jsonschema2md) makes it easier by providing a number of scripts that can turn JSON Schema files into readable Markdown documentation that is ready for consumption on GitHub or processed using Jekyll or other static site generators. _JSON Schema 2019-09_ - Python - [FastAPI](https://github.com/tiangolo/fastapi) (MIT) is an API framework based on Python 3.6+ types that generates **OpenAPI 3** schemas, including **JSON Schemas** for all the models declared. From 331fe72ba8c741e454d7cc3c719ca0e823bd51b6 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Fri, 24 Jan 2020 15:22:46 +0000 Subject: [PATCH 028/311] jsonschema2md only has paritial draft 2019-09 support Great going though! =D --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 97a23ee7..313b9a32 100644 --- a/implementations.md +++ b/implementations.md @@ -123,7 +123,7 @@ Hyper-Schema - JavaScript - [@cloudflare/doca](https://github.com/cloudflare/json-schema-tools/tree/master/workspaces/doca) ([JSON Schema Tools](https://github.com/cloudflare/json-schema-tools)), _draft-04, -06, -07, and Doca extensions_ (UI forthcoming) - - [@adobe/jsonschema2md](https://github.com/adobe/jsonschema2md) makes it easier by providing a number of scripts that can turn JSON Schema files into readable Markdown documentation that is ready for consumption on GitHub or processed using Jekyll or other static site generators. _JSON Schema 2019-09_ + - [@adobe/jsonschema2md](https://github.com/adobe/jsonschema2md) makes it easier by providing a number of scripts that can turn JSON Schema files into readable Markdown documentation that is ready for consumption on GitHub or processed using Jekyll or other static site generators. _JSON Schema 2019-09_ ([partial](https://github.com/adobe/jsonschema2md/blob/master/schemasupport.md)) - Python - [FastAPI](https://github.com/tiangolo/fastapi) (MIT) is an API framework based on Python 3.6+ types that generates **OpenAPI 3** schemas, including **JSON Schemas** for all the models declared. From ac9df3cec19b6b2709583bdc456e02fb4306782e Mon Sep 17 00:00:00 2001 From: Neil Pankey Date: Fri, 24 Jan 2020 15:42:40 -0800 Subject: [PATCH 029/311] Update validator-libraries-modern.yml Adds `yajsv` command line tool which wraps https://github.com/xeipuuv/gojsonschema --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 22beb2da..ec744a45 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -201,3 +201,9 @@ date-draft: draft: [6, 4] notes: can be used with YAML and many other formats besides JSON + - name: yajsv + license: MIT + url: 'https://github.com/neilpa/yajsv' + date-draft: + draft: [7, 6, 4] + notes: wraps https://github.com/xeipuuv/gojsonschema From 2b66900189e6ab71c68172aa5417f823bd9c83f2 Mon Sep 17 00:00:00 2001 From: Neil Pankey Date: Fri, 24 Jan 2020 15:47:54 -0800 Subject: [PATCH 030/311] Update validator-libraries-modern.yml Fix inline link --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index ec744a45..c43ef6a7 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -206,4 +206,4 @@ url: 'https://github.com/neilpa/yajsv' date-draft: draft: [7, 6, 4] - notes: wraps https://github.com/xeipuuv/gojsonschema + notes: wraps [xeipuuv/gojsonschema](https://github.com/xeipuuv/gojsonschema) From 52f19082f61d1b88820d9ca594d3d9959c11d9a7 Mon Sep 17 00:00:00 2001 From: Octavian Date: Thu, 6 Feb 2020 09:02:23 +0200 Subject: [PATCH 031/311] Update implementations.md Added "Oxygen JSON Editor" in the supported editors. This support is available since 2018 (https://www.oxygenxml.com/xml_editor/whatisnew20.1.html#20.1JSON), and is continuously improved. --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index 313b9a32..0feab37c 100644 --- a/implementations.md +++ b/implementations.md @@ -273,6 +273,7 @@ _None currently support draft-06 or later._ _TODO: Sort by draft support._ +- [Oxygen JSON Editor] (https://www.oxygenxml.com/xml_editor/json.html) - JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema. - [Altova XMLSpy 2019r3](https://www.altova.com/xmlspy-xml-editor#json_schema) - *Graphical JSON Schema editor for draft-06 and draft-7, as well as validation of JSON files based on JSON Schema* - [Liquid XML Studio 2016](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON schema editor for draft 4, context sensitive intellisense for JSON documents.* - [Visual Studio 2013](https://www.visualstudio.com/) - *Auto-completion and tooltips based on JSON schema draft 3 and draft 4* From 44122dec4983768fc45bfa82050e2374dc631570 Mon Sep 17 00:00:00 2001 From: Octavian Date: Thu, 6 Feb 2020 11:43:32 +0200 Subject: [PATCH 032/311] Update implementations.md Corrected the link --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 0feab37c..0f0d5c34 100644 --- a/implementations.md +++ b/implementations.md @@ -273,7 +273,7 @@ _None currently support draft-06 or later._ _TODO: Sort by draft support._ -- [Oxygen JSON Editor] (https://www.oxygenxml.com/xml_editor/json.html) - JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema. +- [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema. - [Altova XMLSpy 2019r3](https://www.altova.com/xmlspy-xml-editor#json_schema) - *Graphical JSON Schema editor for draft-06 and draft-7, as well as validation of JSON files based on JSON Schema* - [Liquid XML Studio 2016](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON schema editor for draft 4, context sensitive intellisense for JSON documents.* - [Visual Studio 2013](https://www.visualstudio.com/) - *Auto-completion and tooltips based on JSON schema draft 3 and draft 4* From 6115e3001701d56afdbe0b25f7c3881fb10fd62b Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 6 Feb 2020 11:18:23 +0000 Subject: [PATCH 033/311] Move to bottom Putting yours at the top might be a bit rude. Ah well. Fixed. --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 0f0d5c34..716a4887 100644 --- a/implementations.md +++ b/implementations.md @@ -273,7 +273,6 @@ _None currently support draft-06 or later._ _TODO: Sort by draft support._ -- [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema. - [Altova XMLSpy 2019r3](https://www.altova.com/xmlspy-xml-editor#json_schema) - *Graphical JSON Schema editor for draft-06 and draft-7, as well as validation of JSON files based on JSON Schema* - [Liquid XML Studio 2016](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON schema editor for draft 4, context sensitive intellisense for JSON documents.* - [Visual Studio 2013](https://www.visualstudio.com/) - *Auto-completion and tooltips based on JSON schema draft 3 and draft 4* @@ -286,6 +285,7 @@ _TODO: Sort by draft support._ - [Eclipse IDE](https://www.eclipse.org/downloads/eclipse-packages) - *Rich JSON edition supporting schema for instantaneous validation and error reporting, completion, documentation.* - [WebStorm](https://www.jetbrains.com/webstorm/), [IntelliJ IDEA](https://www.jetbrains.com/idea/), and other [JetBrains IDEs](https://www.jetbrains.com/products.html?fromMenu#type=ide) - *Code completion, documentation, and validation for JSON and YAML files using JSON Schema* - [JsonDraft](https://jsondraft.com/) - *Tree view JSON and JSON Schema editor online. Create and Save reusable components, Share JSON.* +- [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* Schema Repositories From 2b47c857ab33a7f4ba65c80c400ff770056f667c Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 6 Feb 2020 11:15:47 -0800 Subject: [PATCH 034/311] Add mention of the Perl jSON::Validator library --- _data/validator-libraries-modern.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index c43ef6a7..e119286d 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -122,6 +122,14 @@ date-draft: draft: [6] license: MIT +- name: Perl + implementations: + - name: JSON::Validator + url: https://github.com/mojolicious/json-validator + notes: + date-draft: + draft: [7, 6, 4] + license: "The Artistic License 2.0 (GPL Compatible)" - name: PHP implementations: - name: Opis Json Schema From 08b830fe5069283f0ea37c40556fa63e8b6c69a9 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Mon, 24 Feb 2020 13:01:08 +0000 Subject: [PATCH 035/311] Fixes https://github.com/json-schema-org/json-schema-org.github.io/issues/185 Update ajv-cli which now allows for argument to prevent adding the provided schema to the index. Previously the provided schema, draft-07 meta-schema, was being added, and ajv checks if the schema is unique according to it's provided ... of course this caused problems. Put in ajv-cli RP to allow new argument --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb139d44..724b3497 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,8 @@ sudo: false node_js: - node before_script: -- npm install ajv-cli +- npm install ajv-cli@3.1.0 - PATH="./node_modules/.bin/:$PATH" script: - bundle exec jekyll build -- ajv test -s draft-07/schema -d "learn/examples/*.json" --valid +- ajv test -s draft-07/schema -d "learn/examples/*.json" --valid --add-used-schema=false From 369646dc918c78d19ad9ecede71c88e3b344c3ab Mon Sep 17 00:00:00 2001 From: slisaasquatch Date: Thu, 5 Mar 2020 11:37:55 -0800 Subject: [PATCH 036/311] Add saasquatch/json-schema-inferrer --- implementations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implementations.md b/implementations.md index 716a4887..966381d0 100644 --- a/implementations.md +++ b/implementations.md @@ -165,6 +165,8 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e #### From data +- Java + - [saasquatch/json-schema-inferrer](https://github.com/saasquatch/json-schema-inferrer) _draft-07, -06, -04_ (Apache 2.0) - Java library for inferring JSON Schemas from one or multiple JSON samples. - Scala - [Schema Guru](https://github.com/snowplow/schema-guru) (Apache 2.0) - CLI util, Spark Job and Web UI for deriving JSON Schemas out of corpus of JSON instances; see issue [178](https://github.com/snowplow/schema-guru/issues/178) for progress towards draft-06+ support - Online (web tool) From e9ff19f6f83267dc9ba72c7f0a84eaf9afd36230 Mon Sep 17 00:00:00 2001 From: Michael Becker <7737034+elbakerino@users.noreply.github.com> Date: Sat, 14 Mar 2020 19:26:01 +0100 Subject: [PATCH 037/311] add understanding ling to learn page --- learn/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/learn/index.md b/learn/index.md index 058d46e1..32716050 100644 --- a/learn/index.md +++ b/learn/index.md @@ -11,3 +11,4 @@ title: Learn * [calendar.schema.json](./examples/calendar.schema.json) * [card.schema.json](./examples/card.schema.json) * [geographical-location.schema.json](./examples/geographical-location.schema.json) +* [Understanding JSON Schema](/understanding-json-schema/) From fd256487cde3ee2d8a6f6eb21e9f8e1b1534b98d Mon Sep 17 00:00:00 2001 From: Carsten Wickner <11309681+CarstenWickner@users.noreply.github.com> Date: Sun, 15 Mar 2020 23:26:27 +0100 Subject: [PATCH 038/311] chore: mention draft 2019-09 support of generator --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 716a4887..ee3cc582 100644 --- a/implementations.md +++ b/implementations.md @@ -159,7 +159,7 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - Python - [Pydantic](https://pydantic-docs.helpmanual.io/) (MIT) - generates schemas from Python models based on Python 3.6+ type hints. - Java - - [jsonschema-generator](https://github.com/victools/jsonschema-generator) (Apache 2.0) - generates schemas from Java types *supports Draft 7* + - [jsonschema-generator](https://github.com/victools/jsonschema-generator) (Apache 2.0) - generates schemas from Java types *supports Draft 7 and Draft 2019-09* - Scala - [scala-jsonschema](https://github.com/andyglow/scala-jsonschema) (Apache 2.0) - generates schemad out of Scala case classes From fba0fa1561d36ca91c5b9f49089819e48a17c941 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 19 Mar 2020 14:23:05 +0000 Subject: [PATCH 039/311] implementations: spectral --- implementations.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 716a4887..f3930409 100644 --- a/implementations.md +++ b/implementations.md @@ -297,4 +297,5 @@ Schema Repositories Schema Linter ------------- -- [json-schema-linter](https://www.json-schema-linter.com/) - Lint/validate/parse json-schema itself and find out out typo, missing properties, missing required keys etc. Supports draft 4, 6, and 7. +- [json-schema-linter](https://www.json-schema-linter.com/) - Lint/validate/parse json-schema itself, and find typos, missing properties, missing required keys, etc. Supports draft 4, 6, and 7. +- [Stoplight Spectral](https://stoplight.io/open-source/spectral) - A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v2/v3 and JSON Schema. Supports draft 4, 6, and 7. From 2d3e1452e9299c118b4147b331e173c84fe6e2dc Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 19 Mar 2020 14:54:55 +0000 Subject: [PATCH 040/311] sorted editors by draft --- implementations.md | 13 ++----------- obsolete-implementations.md | 7 ------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/implementations.md b/implementations.md index 716a4887..3fde11d8 100644 --- a/implementations.md +++ b/implementations.md @@ -271,22 +271,13 @@ _None currently support draft-06 or later._ #### Editors -_TODO: Sort by draft support._ - - [Altova XMLSpy 2019r3](https://www.altova.com/xmlspy-xml-editor#json_schema) - *Graphical JSON Schema editor for draft-06 and draft-7, as well as validation of JSON files based on JSON Schema* -- [Liquid XML Studio 2016](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON schema editor for draft 4, context sensitive intellisense for JSON documents.* -- [Visual Studio 2013](https://www.visualstudio.com/) - *Auto-completion and tooltips based on JSON schema draft 3 and draft 4* - [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator with context sensitive entry-helpers and sample data generation based on JSON schema. Support for draft 4, draft 6 and draft 7.* -- [ReSharper 2016.1](https://www.jetbrains.com/resharper/) - *code completion, inspections and quick fixes for JSON schema in Visual Studio 2010 - 2015, including support for JSON Path and regular expressions for schema editing* +- [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. +- [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* - [Visual Studio Code](https://code.visualstudio.com/) - *Schema driven code completion, hovers and validation for editing JSON files (including schemas)* -- [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* -- [JSON Schema Editor](https://json-schema-editor.tangramjs.com) - *An intuitive editor for JSON schema online* -- [JSON Editor](https://json-editor.tangramjs.com) - *An online, schema-aware editor for JSON document* - [Eclipse IDE](https://www.eclipse.org/downloads/eclipse-packages) - *Rich JSON edition supporting schema for instantaneous validation and error reporting, completion, documentation.* - [WebStorm](https://www.jetbrains.com/webstorm/), [IntelliJ IDEA](https://www.jetbrains.com/idea/), and other [JetBrains IDEs](https://www.jetbrains.com/products.html?fromMenu#type=ide) - *Code completion, documentation, and validation for JSON and YAML files using JSON Schema* -- [JsonDraft](https://jsondraft.com/) - *Tree view JSON and JSON Schema editor online. Create and Save reusable components, Share JSON.* -- [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* - Schema Repositories ------------------- diff --git a/obsolete-implementations.md b/obsolete-implementations.md index fcb22a07..8c968caf 100644 --- a/obsolete-implementations.md +++ b/obsolete-implementations.md @@ -195,17 +195,10 @@ Various levels of support for UI generation primarily from the validation vocabu Editors ------- -_TODO: Sort by draft support._ - - [Liquid XML Studio 2016](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON schema editor for draft 4, context sensitive intellisense for JSON documents.* - [Visual Studio 2013](http://www.visualstudio.com/) - *Auto-completion and tooltips based on JSON schema draft 3 and draft 4* -- [JSONBuddy](http://www.json-buddy.com/) - *Grid-style JSON editor and context sensitive entry-helpers based on JSON schema* -- [ReSharper 2016.1](https://www.jetbrains.com/resharper/) - *code completion, inspections and quick fixes for JSON schema in Visual Studio 2010 - 2015, including support for JSON Path and regular expressions for schema editing* -- [Visual Studio Code](https://code.visualstudio.com/) - *Schema driven code completion, hovers and validation for editing JSON files (including schemas)* -- [JSONEditor Online](http://jsoneditoronline.org) - *View, edit, format, and validate JSON online* - [JSON Schema Editor](https://json-schema-editor.tangramjs.com) - *An intuitive editor for JSON schema online* - [JSON Editor](https://json-editor.tangramjs.com) - *An online, schema-aware editor for JSON document* -- [Eclipse IDE](https://www.eclipse.org/downloads/eclipse-packages) - *Rich JSON edition supporting schema for instantaneous validation and error reporting, completion, documentation.* Compatibility ------------- From 0eecc9c6e682fcd7cda3f1968458e789f6b295c5 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 19 Mar 2020 15:00:08 +0000 Subject: [PATCH 041/311] added stoplight studio --- implementations.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 3fde11d8..e8a8e9fd 100644 --- a/implementations.md +++ b/implementations.md @@ -272,9 +272,10 @@ _None currently support draft-06 or later._ #### Editors - [Altova XMLSpy 2019r3](https://www.altova.com/xmlspy-xml-editor#json_schema) - *Graphical JSON Schema editor for draft-06 and draft-7, as well as validation of JSON files based on JSON Schema* -- [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator with context sensitive entry-helpers and sample data generation based on JSON schema. Support for draft 4, draft 6 and draft 7.* +- [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator with context sensitive entry-helpers and sample data generation based on JSON schema. Support for draft-4, draft-6 and draft-7.* - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* +- [Stoplight Studio](https://stoplight.io/) - *JSON Schema IDE (text-based and GUI) with support for JSON/YAML linting, which can also be based on JSON Schema rules via Spectral. Support for draft-4, draft-6 and draft-7.* - [Visual Studio Code](https://code.visualstudio.com/) - *Schema driven code completion, hovers and validation for editing JSON files (including schemas)* - [Eclipse IDE](https://www.eclipse.org/downloads/eclipse-packages) - *Rich JSON edition supporting schema for instantaneous validation and error reporting, completion, documentation.* - [WebStorm](https://www.jetbrains.com/webstorm/), [IntelliJ IDEA](https://www.jetbrains.com/idea/), and other [JetBrains IDEs](https://www.jetbrains.com/products.html?fromMenu#type=ide) - *Code completion, documentation, and validation for JSON and YAML files using JSON Schema* From 2d2bdeeb40d8ab8b3cb685f4eccd6cff219320bb Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 19 Mar 2020 15:13:44 +0000 Subject: [PATCH 042/311] oops added resharper back --- implementations.md | 2 +- obsolete-implementations.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index e8a8e9fd..a7c18937 100644 --- a/implementations.md +++ b/implementations.md @@ -277,8 +277,8 @@ _None currently support draft-06 or later._ - [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* - [Stoplight Studio](https://stoplight.io/) - *JSON Schema IDE (text-based and GUI) with support for JSON/YAML linting, which can also be based on JSON Schema rules via Spectral. Support for draft-4, draft-6 and draft-7.* - [Visual Studio Code](https://code.visualstudio.com/) - *Schema driven code completion, hovers and validation for editing JSON files (including schemas)* -- [Eclipse IDE](https://www.eclipse.org/downloads/eclipse-packages) - *Rich JSON edition supporting schema for instantaneous validation and error reporting, completion, documentation.* - [WebStorm](https://www.jetbrains.com/webstorm/), [IntelliJ IDEA](https://www.jetbrains.com/idea/), and other [JetBrains IDEs](https://www.jetbrains.com/products.html?fromMenu#type=ide) - *Code completion, documentation, and validation for JSON and YAML files using JSON Schema* +- [Eclipse IDE](https://www.eclipse.org/downloads/eclipse-packages) - *Rich JSON edition supporting schema for instantaneous validation and error reporting, completion, documentation.* Schema Repositories ------------------- diff --git a/obsolete-implementations.md b/obsolete-implementations.md index 8c968caf..b06aaf1c 100644 --- a/obsolete-implementations.md +++ b/obsolete-implementations.md @@ -196,6 +196,7 @@ Editors ------- - [Liquid XML Studio 2016](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON schema editor for draft 4, context sensitive intellisense for JSON documents.* +- [ReSharper 2016.1](https://www.jetbrains.com/resharper/) - *code completion, inspections and quick fixes for JSON schema in Visual Studio 2010 - 2015, including support for JSON Path and regular expressions for schema editing. Support for draft-4* - [Visual Studio 2013](http://www.visualstudio.com/) - *Auto-completion and tooltips based on JSON schema draft 3 and draft 4* - [JSON Schema Editor](https://json-schema-editor.tangramjs.com) - *An intuitive editor for JSON schema online* - [JSON Editor](https://json-editor.tangramjs.com) - *An online, schema-aware editor for JSON document* From 47dd5e570ee7da0e1fd1d037801db14f7617f97f Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 19 Mar 2020 15:17:48 +0000 Subject: [PATCH 043/311] webstorm storming ahead --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index a7c18937..9f6edc96 100644 --- a/implementations.md +++ b/implementations.md @@ -277,7 +277,7 @@ _None currently support draft-06 or later._ - [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* - [Stoplight Studio](https://stoplight.io/) - *JSON Schema IDE (text-based and GUI) with support for JSON/YAML linting, which can also be based on JSON Schema rules via Spectral. Support for draft-4, draft-6 and draft-7.* - [Visual Studio Code](https://code.visualstudio.com/) - *Schema driven code completion, hovers and validation for editing JSON files (including schemas)* -- [WebStorm](https://www.jetbrains.com/webstorm/), [IntelliJ IDEA](https://www.jetbrains.com/idea/), and other [JetBrains IDEs](https://www.jetbrains.com/products.html?fromMenu#type=ide) - *Code completion, documentation, and validation for JSON and YAML files using JSON Schema* +- [WebStorm](https://www.jetbrains.com/webstorm/), [IntelliJ IDEA](https://www.jetbrains.com/idea/), and other [JetBrains IDEs](https://www.jetbrains.com/products.html?fromMenu#type=ide) - *Code completion, documentation, and validation for JSON and YAML files using JSON Schema. Support for draft-4, draft-6, and draft-7.* - [Eclipse IDE](https://www.eclipse.org/downloads/eclipse-packages) - *Rich JSON edition supporting schema for instantaneous validation and error reporting, completion, documentation.* Schema Repositories From e8fc0925a2e2f94c9cbf09f010cbe1d23207648c Mon Sep 17 00:00:00 2001 From: Andreas Eberhart <61732435+aeberhart@users.noreply.github.com> Date: Tue, 24 Mar 2020 16:43:51 +0100 Subject: [PATCH 044/311] Add Dashjoin JSON Schema Form to Web UI generation --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index a5aeb010..ce574c30 100644 --- a/implementations.md +++ b/implementations.md @@ -213,6 +213,7 @@ Various levels of support for UI generation primarily from the validation vocabu - [Angular Schema Form](https://github.com/json-schema-form/angular-schema-form) (MIT) - [Angular2 Schema Form](https://github.com/makinacorpus/angular2-schema-form) *unrelated to Angular Schema Form* (MIT) - [Angular6-json-schema-form](https://github.com/hamzahamidi/Angular6-json-schema-form) (MIT) + - [Dashjoin JSON Schema Form](https://github.com/dashjoin/json-schema-form) (Apache 2) - [JSON Editor](https://github.com/json-editor/json-editor) (MIT) - [JSON Form (joshfire)](https://github.com/joshfire/jsonform) (joshfire) (MIT) - [Json Forms (brutusin)](https://github.com/brutusin/json-forms) (brutusin) (MIT) From baf1dac7e41e0675cf2cb0e4b35112f3a4868a53 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Wed, 8 Apr 2020 12:39:17 +0100 Subject: [PATCH 045/311] Fix bug in applicator meta-schema. https://github.com/json-schema-org/json-schema-spec/pull/883 --- _includes/draft/2019-09 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/draft/2019-09 b/_includes/draft/2019-09 index b47f567e..cc296f05 160000 --- a/_includes/draft/2019-09 +++ b/_includes/draft/2019-09 @@ -1 +1 @@ -Subproject commit b47f567e1ef87ae16b69aeb8c3084729a22c9bce +Subproject commit cc296f05b8938a9ffb5ffce7f7a50c2805b2647f From 274913a99145b19fced1d1f6b94c73699feeeb8e Mon Sep 17 00:00:00 2001 From: Dmitry Dygalo Date: Wed, 15 Apr 2020 17:25:26 +0200 Subject: [PATCH 046/311] Add `jsonschema-rs` to Rust implementations --- _data/validator-libraries-modern.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index e119286d..35580b44 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -166,6 +166,14 @@ date-draft: draft: [7, 6, 4] license: MIT +- name: Rust + implementations: + - name: jsonschema-rs + url: https://github.com/Stranger6667/jsonschema-rs + notes: Fast due to compiling schema into a validation tree + date-draft: + draft: [7, 6] + license: MIT - name: Objective-C implementations: - name: DSJSONSchemaValidation From dabf6b144a45110d13aee035f1571093f2771a96 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Thu, 16 Apr 2020 21:18:49 -0700 Subject: [PATCH 047/311] Add Hyperjump JSV to implementations --- _data/validator-libraries-modern.yml | 11 +++++++++++ implementations.md | 3 +++ 2 files changed, 14 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index e119286d..172fa76d 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -117,6 +117,12 @@ date-draft: draft: [6, 4] license: MIT + - name: Hyperjump JSV + url: https://github.com/jdesrosiers/json-schema + notes: "Built for Node.js and browsers. Includes support for custom vocabularies." + date-draft: [2019-09] + draft: [7, 6, 4] + license: MIT - name: vue-vuelidate-jsonschema url: https://github.com/mokkabonna/vue-vuelidate-jsonschema date-draft: @@ -184,6 +190,11 @@ license: MIT - name: Web (Online) implementations: + - name: Hyperjump JSV + url: https://json-schema.hyperjump.io + date-draft: [2019-09] + draft: [7, 6, 4] + notes: Supports multiple schemas and multiple instances - name: JSON Schema Validator url: https://www.jsonschemavalidator.net/ date-draft: diff --git a/implementations.md b/implementations.md index ce574c30..cceecd49 100644 --- a/implementations.md +++ b/implementations.md @@ -239,6 +239,9 @@ the utility, and decided on a case-by-case basis. - JavaScript - [json-schema-ref-parser](https://github.com/BigstickCarpet/json-schema-ref-parser) (MIT) Tools for dereferencing non-cyclic schemas, bundling referenced schemas into a single file, and other `$ref` processing. - [@cloudflare/json-schema-walker](https://github.com/cloudflare/json-schema-tools/tree/master/workspaces/json-schema-walker) ([JSON Schema Tools](https://github.com/cloudflare/json-schema-tools)), _draft-07, -06, -04, and Cloudflare's Doca extensions_ Walks schemas and runs pre- and post-walk callbacks. Can modify schemas in place. (BSD-3-Clause) + - [@hyperjump/json-schema-core](https://github.com/jdesrosiers/json-schema-core) + (MIT) Tools for working with schemas that handle identifiers and + references. Build vocabularies and other JSON Schema based tools. #### Schema to Schema From efe15158c97fbc930934d122125a7e5a3aaac8b9 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Tue, 21 Apr 2020 15:41:10 +0100 Subject: [PATCH 048/311] online tools are not obsolete --- obsolete-implementations.md | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/obsolete-implementations.md b/obsolete-implementations.md index b06aaf1c..2950d504 100644 --- a/obsolete-implementations.md +++ b/obsolete-implementations.md @@ -60,13 +60,6 @@ Validators - -### Online - -- [JSON Schema Lint](http://jsonschemalint.com/) - validate against your own schemas -- [SchemaStore.org](http://schemastore.org/validator/) - validate against common JSON Schemas -- [quicktype.io](https://app.quicktype.io/#l=schema) - infer JSON Schema from samples, and generate TypeScript, C++, go, Java, C#, Swift, etc. types from JSON Schema - ### Command Line @@ -129,7 +122,7 @@ Hyper-Schema {% endfor %} -Schema generators +Schema Generators ----------------- - Python @@ -151,7 +144,7 @@ Generators from schemas - JavaScript - [json-schema-generator](https://github.com/json-schema-faker) (MIT) - JSON-Schema + fake data generators -Data parsing and code generation +Data Parsing and Code Generation -------------------------------- - Delphi @@ -168,9 +161,9 @@ Data parsing and code generation - Swift - [Bric-à-brac](https://github.com/glimpseio/BricBrac) (MIT) - generates idiomatic swift structs and parser/serializer from JSON schemas - Golang - - [gojsonschema](https://github.com/andy-zhangtao/gojsonschema)(Apache 2.0) - golang package for generating golang struct *supports Draft 4*. [Demo](http://json.golang.chinazt.cc) + - [gojsonschema](https://github.com/andy-zhangtao/gojsonschema)(Apache 2.0) - golang package for generating golang struct *support for Draft 4*. [Demo](http://json.golang.chinazt.cc) -UI generation +UI Generation ------------- _TODO: Sort by draft support._ From 68f2321c2901db8a0138fbefe5d27e35ee06d756 Mon Sep 17 00:00:00 2001 From: Henrik Mohr Date: Thu, 23 Apr 2020 14:28:53 +0200 Subject: [PATCH 049/311] Add generator luposlip/json-schema Clojure library that infers JSON Schemas based on (Clojure) data, and validates data based on them as well. --- implementations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implementations.md b/implementations.md index 8b9b502b..f52a41d3 100644 --- a/implementations.md +++ b/implementations.md @@ -167,6 +167,8 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - Scala - [Schema Guru](https://github.com/snowplow/schema-guru) (Apache 2.0) - CLI util, Spark Job and Web UI for deriving JSON Schemas out of corpus of JSON instances; see issue [178](https://github.com/snowplow/schema-guru/issues/178) for progress towards draft-06+ support +- Clojure + - [luposlip/json-schema](https://github.com/luposlip/json-schema) (Apache 2.0) - infer JSON Schema from Clojure data - Online (web tool) - [jsonschema.net](https://www.jsonschema.net/) - generates schemas from example data - [quicktype.io](https://app.quicktype.io/#l=schema) - infer JSON Schema from samples, and generate TypeScript, C++, go, Java, C#, Swift, etc. types from JSON Schema From cfe270e66cccdef8f46f9c2bac2ac7483525453b Mon Sep 17 00:00:00 2001 From: Jeremy Danyow Date: Thu, 7 May 2020 21:58:03 -0700 Subject: [PATCH 050/311] @cfworker/json-schema A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, and 2019-09. Cloudflare workers do not have APIs required by Ajv schema compilation (eval or new Function(code)). Validators that don't use code generation are not up to date with the current spec so I built yet another validator... @cfworker/json-schema is currently the fastest among validators which do not use code generation (eval/new function): https://github.com/ebdrup/json-schema-benchmark#performance Pretty comparable to jsck and z-schema which do use code generation. --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 172fa76d..6211eb44 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -128,6 +128,12 @@ date-draft: draft: [6] license: MIT + - name: @cfworker/json-schema + url: https://github.com/cfworker/cfworker/blob/master/packages/json-schema/README.md + notes: "Built for Cloudflare workers, browsers, and Node.js" + date-draft: [2019-09] + draft: [7, 6, 4] + license: MIT - name: Perl implementations: - name: JSON::Validator From 089c026be758e2358050dde1a577442595306203 Mon Sep 17 00:00:00 2001 From: Jeremy Danyow Date: Thu, 7 May 2020 22:08:40 -0700 Subject: [PATCH 051/311] add quotes --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 6211eb44..23ca57c5 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -128,7 +128,7 @@ date-draft: draft: [6] license: MIT - - name: @cfworker/json-schema + - name: '@cfworker/json-schema' url: https://github.com/cfworker/cfworker/blob/master/packages/json-schema/README.md notes: "Built for Cloudflare workers, browsers, and Node.js" date-draft: [2019-09] From 6c0cd88c055764614662c429e8d096959b948a82 Mon Sep 17 00:00:00 2001 From: Jeremy Danyow Date: Thu, 7 May 2020 22:11:42 -0700 Subject: [PATCH 052/311] double quotes --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 23ca57c5..dabbb891 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -128,7 +128,7 @@ date-draft: draft: [6] license: MIT - - name: '@cfworker/json-schema' + - name: "@cfworker/json-schema" url: https://github.com/cfworker/cfworker/blob/master/packages/json-schema/README.md notes: "Built for Cloudflare workers, browsers, and Node.js" date-draft: [2019-09] From 3e390c4f2863f9294f4c0d4ce52d11c48aa0b485 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 21 May 2020 14:55:28 -0700 Subject: [PATCH 053/311] add link to Perl implementation JSON::Schema::Draft201909 --- _data/validator-libraries-modern.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 172fa76d..14f06c70 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -136,6 +136,11 @@ date-draft: draft: [7, 6, 4] license: "The Artistic License 2.0 (GPL Compatible)" + - name: JSON::Schema::Draft201909 + url: https://github.com/karenetheridge/JSON-Schema-Draft201909 + notes: + date-draft: [2019-09] + license: "GNU General Public License, Version 1 + The Artistic License 1.0" - name: PHP implementations: - name: Opis Json Schema From 52babefda0ed7c243a647753f971e6bc12aedabe Mon Sep 17 00:00:00 2001 From: Shawn Silverman Date: Thu, 28 May 2020 02:17:54 -0700 Subject: [PATCH 054/311] Add Snow validator to Java section --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index dabbb891..48ae29af 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -95,6 +95,12 @@ date-draft: draft: [7, 6, 4] license: Apache License 2.0 + - name: Snow + url: https://github.com/ssilverman/snowy-json + notes: Uses Maven for the project, and Gson and Guava under the hood. + date-draft: [2019-09] + draft: [7, 6] + license: GNU Affero General Public License v3.0 - name: Kotlin implementations: - name: Medeia-validator From 58e00c02713a6b1a5c469a6189a99b94b594e742 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 28 May 2020 22:38:57 +0100 Subject: [PATCH 055/311] Bop. Given 2019-09 support, lets put it at the top --- _data/validator-libraries-modern.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 48ae29af..a7b2c2b6 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -77,6 +77,12 @@ notes: includes custom validator support, rich error returns - name: Java implementations: + - name: Snow + url: https://github.com/ssilverman/snowy-json + notes: Uses Maven for the project, and Gson and Guava under the hood. + date-draft: [2019-09] + draft: [7, 6] + license: GNU Affero General Public License v3.0 - name: everit-org/json-schema url: https://github.com/everit-org/json-schema notes: @@ -95,12 +101,6 @@ date-draft: draft: [7, 6, 4] license: Apache License 2.0 - - name: Snow - url: https://github.com/ssilverman/snowy-json - notes: Uses Maven for the project, and Gson and Guava under the hood. - date-draft: [2019-09] - draft: [7, 6] - license: GNU Affero General Public License v3.0 - name: Kotlin implementations: - name: Medeia-validator From 594392001377724e1059eb0cbb54e2bcd4a69ce6 Mon Sep 17 00:00:00 2001 From: Okie Othsam Date: Sun, 31 May 2020 12:11:39 +0200 Subject: [PATCH 056/311] add yacg to implementations.md --- implementations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implementations.md b/implementations.md index 8b9b502b..6066af88 100644 --- a/implementations.md +++ b/implementations.md @@ -199,6 +199,8 @@ are the only keywords that changed. - [quicktype.io](https://app.quicktype.io/#l=schema) - infer JSON Schema from samples, and generate TypeScript, C++, go, Java, C#, Swift, etc. types from JSON Schema - PHP - [php-code-builder](https://github.com/swaggest/php-code-builder)(MIT) - generates PHP mapping structures defined by JSON schema using [swaggest/json-schema](https://github.com/swaggest/php-json-schema) *supports Draft 7* +- Python + - [yacg](https://github.com/OkieOth/yacg) (MIT) - parse JSON Schema and OpenApi files to build a meta model from them. This meta model can be used in Mako templates to generate source code, other schemas or plantUml. - Rust - [schemafy](https://github.com/Marwes/schemafy/) - generates Rust types and serialization code from a JSON schema. *supports Draft 4* From c41232833df4ccf796ff7bce9a1356b0850377e9 Mon Sep 17 00:00:00 2001 From: Andreas Eberhart <61732435+aeberhart@users.noreply.github.com> Date: Fri, 5 Jun 2020 18:23:07 +0200 Subject: [PATCH 057/311] Add Editors section under Schema generators --- implementations.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/implementations.md b/implementations.md index 8b9b502b..24f1ec82 100644 --- a/implementations.md +++ b/implementations.md @@ -171,6 +171,9 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - [jsonschema.net](https://www.jsonschema.net/) - generates schemas from example data - [quicktype.io](https://app.quicktype.io/#l=schema) - infer JSON Schema from samples, and generate TypeScript, C++, go, Java, C#, Swift, etc. types from JSON Schema +#### Editors + +- [dashjoin.github.io](https://dashjoin.github.io/#/schema) - allows creating basic JSON schema interactively, good tool for learning & education, does not support advanced JSON schema constructs Generators from schemas ----------------------- From dbe6cd6d694d230bbaf958d40ae836e002907bec Mon Sep 17 00:00:00 2001 From: Tristan Penman Date: Wed, 10 Jun 2020 14:51:44 +1000 Subject: [PATCH 058/311] Add valijson validator to C++ section --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 29e41a7e..1cad3e6c 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -31,6 +31,12 @@ date-draft: draft: [7] license: MIT + - name: Valijson + url: https://github.com/tristanpenman/valijson + notes: header-only library, works with many JSON parser implementations + date-draft: + draft: [7] + license: BSD-2-Clause - name: Clojure implementations: - name: jinx From 4068d39667b761cf7269ead68fcc9e2937a8a439 Mon Sep 17 00:00:00 2001 From: AlieksandraK Date: Wed, 10 Jun 2020 15:48:17 +0200 Subject: [PATCH 059/311] Update implementations.md It appeared that qri-io/jsonschema doesn't do code to schema generation (qri-io/jsonschema#32). Replaced it with this one https://github.com/alecthomas/jsonschema in the list of Golang code to schema generation implementations --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 8b9b502b..d936ea00 100644 --- a/implementations.md +++ b/implementations.md @@ -151,7 +151,7 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - [Json.NET](https://www.newtonsoft.com/jsonschema) (AGPL-3.0) - generates schemas from .NET types - [NJsonSchema](https://github.com/RSuter/NJsonSchema/) - (Ms-PL) - generates schemas from .NET types, see issue [574](https://github.com/RSuter/NJsonSchema/issues/574) for draft-06+ support progress - Golang - - [qri-io/jsonschema](https://github.com/qri-io/jsonschema)(MIT) - idiomatic go implementation with custom validator support, coding to and from json, rich error returns *supports Draft 7* + - [alecthomas/jsonschema](https://github.com/alecthomas/jsonschema)(MIT) - generates JSON Schemas from Go types through reflection - PHP - [Liform](https://github.com/Limenius/liform) (MIT) - generates schemas from Symfony forms - TypeScript From 5f22a78e3e4f8c7904fbe3f937e420c23166b95f Mon Sep 17 00:00:00 2001 From: Dmitry Dygalo Date: Thu, 11 Jun 2020 19:38:55 +0200 Subject: [PATCH 060/311] Update supported drafts for `jsonschema-rs` --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 22b06431..ba3afed1 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -201,7 +201,7 @@ url: https://github.com/Stranger6667/jsonschema-rs notes: Fast due to compiling schema into a validation tree date-draft: - draft: [7, 6] + draft: [7, 6, 4] license: MIT - name: Objective-C implementations: From 61306bfbf86799f899cb95b33cc3f58f63007118 Mon Sep 17 00:00:00 2001 From: Dmitry Dygalo Date: Thu, 11 Jun 2020 19:39:04 +0200 Subject: [PATCH 061/311] Add `jsonschema-rs` to the Python implementations --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index ba3afed1..de34e707 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -187,6 +187,12 @@ date-draft: draft: [7, 6, 4] license: BSD-3-Clause + - name: jsonschema-rs + url: https://github.com/Stranger6667/jsonschema-rs/python + notes: Python bindings to Rust's jsonschema crate + date-draft: + draft: [7, 6, 4] + license: MIT - name: Ruby implementations: - name: JSONSchemer From 8352ba10ec243db9295e2fd9a99c9e1fcbaf936b Mon Sep 17 00:00:00 2001 From: Andreas Eberhart <61732435+aeberhart@users.noreply.github.com> Date: Thu, 11 Jun 2020 21:21:07 +0200 Subject: [PATCH 062/311] moved Dashjoin JSON Schema Editor to correct sec. --- implementations.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/implementations.md b/implementations.md index 24f1ec82..d73211c3 100644 --- a/implementations.md +++ b/implementations.md @@ -171,10 +171,6 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - [jsonschema.net](https://www.jsonschema.net/) - generates schemas from example data - [quicktype.io](https://app.quicktype.io/#l=schema) - infer JSON Schema from samples, and generate TypeScript, C++, go, Java, C#, Swift, etc. types from JSON Schema -#### Editors - -- [dashjoin.github.io](https://dashjoin.github.io/#/schema) - allows creating basic JSON schema interactively, good tool for learning & education, does not support advanced JSON schema constructs - Generators from schemas ----------------------- @@ -279,6 +275,7 @@ _None currently support draft-06 or later._ #### Editors - [Altova XMLSpy 2019r3](https://www.altova.com/xmlspy-xml-editor#json_schema) - *Graphical JSON Schema editor for draft-06 and draft-7, as well as validation of JSON files based on JSON Schema* +- [Dashjoin JSON Schema editor](https://dashjoin.github.io/#/schema) - allows creating basic JSON schema interactively, good tool for learning & education, does not support advanced JSON schema constructs - [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator with context sensitive entry-helpers and sample data generation based on JSON schema. Support for draft-4, draft-6 and draft-7.* - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* From 8fb1b9acfc67a2b4f065ab82cbb60bbbac1659a9 Mon Sep 17 00:00:00 2001 From: AlieksandraK Date: Thu, 11 Jun 2020 22:11:30 +0200 Subject: [PATCH 063/311] Update implementations.md Removed implementation reference --- implementations.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/implementations.md b/implementations.md index d936ea00..b9f1d969 100644 --- a/implementations.md +++ b/implementations.md @@ -150,8 +150,6 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - .NET - [Json.NET](https://www.newtonsoft.com/jsonschema) (AGPL-3.0) - generates schemas from .NET types - [NJsonSchema](https://github.com/RSuter/NJsonSchema/) - (Ms-PL) - generates schemas from .NET types, see issue [574](https://github.com/RSuter/NJsonSchema/issues/574) for draft-06+ support progress -- Golang - - [alecthomas/jsonschema](https://github.com/alecthomas/jsonschema)(MIT) - generates JSON Schemas from Go types through reflection - PHP - [Liform](https://github.com/Limenius/liform) (MIT) - generates schemas from Symfony forms - TypeScript From adfee0a687ad1632a686b5c64db6b9dea572cdbe Mon Sep 17 00:00:00 2001 From: Matt Novenstern Date: Tue, 16 Jun 2020 19:28:51 -0400 Subject: [PATCH 064/311] Add common lisp json-schema to implementations list --- _data/validator-libraries-modern.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 22b06431..3e14b9e7 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -49,6 +49,13 @@ date-draft: draft: [7] license: Apache License, Version 2.0 +- name: Common Lisp + implementations: + - name: json-schema + url: https://github.com/fisxoj/json-schema + date-draft: + draft: [4, 6, 7, 2019-09] + license: LGPL - name: Elixir implementations: - name: Elixir JSON Schema validator From 381db90b7dd73b57aa3329ec484e6ee393898ab7 Mon Sep 17 00:00:00 2001 From: Matt Novenstern Date: Tue, 16 Jun 2020 19:33:07 -0400 Subject: [PATCH 065/311] Learned what the date-draft key does! --- _data/validator-libraries-modern.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 3e14b9e7..78abc87f 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -53,8 +53,8 @@ implementations: - name: json-schema url: https://github.com/fisxoj/json-schema - date-draft: - draft: [4, 6, 7, 2019-09] + date-draft: [2019-09] + draft: [4, 6, 7] license: LGPL - name: Elixir implementations: From dece259aaaab7511539435c8755fd66c08e299a2 Mon Sep 17 00:00:00 2001 From: Andreas Eberhart <61732435+aeberhart@users.noreply.github.com> Date: Sat, 20 Jun 2020 00:01:08 +0200 Subject: [PATCH 066/311] Added draft support information --- implementations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/implementations.md b/implementations.md index d73211c3..df36b163 100644 --- a/implementations.md +++ b/implementations.md @@ -212,7 +212,7 @@ Various levels of support for UI generation primarily from the validation vocabu - [Angular Schema Form](https://github.com/json-schema-form/angular-schema-form) (MIT) - [Angular2 Schema Form](https://github.com/makinacorpus/angular2-schema-form) *unrelated to Angular Schema Form* (MIT) - [Angular6-json-schema-form](https://github.com/hamzahamidi/Angular6-json-schema-form) (MIT) - - [Dashjoin JSON Schema Form](https://github.com/dashjoin/json-schema-form) (Apache 2) + - [Dashjoin JSON Schema Form](https://github.com/dashjoin/json-schema-form) (Apache 2) *draft-06 (minus oneOf, anyOf, allOf, not)* - [JSON Editor](https://github.com/json-editor/json-editor) (MIT) - [JSON Form (joshfire)](https://github.com/joshfire/jsonform) (joshfire) (MIT) - [Json Forms (brutusin)](https://github.com/brutusin/json-forms) (brutusin) (MIT) @@ -275,7 +275,7 @@ _None currently support draft-06 or later._ #### Editors - [Altova XMLSpy 2019r3](https://www.altova.com/xmlspy-xml-editor#json_schema) - *Graphical JSON Schema editor for draft-06 and draft-7, as well as validation of JSON files based on JSON Schema* -- [Dashjoin JSON Schema editor](https://dashjoin.github.io/#/schema) - allows creating basic JSON schema interactively, good tool for learning & education, does not support advanced JSON schema constructs +- [Dashjoin JSON Schema editor](https://dashjoin.github.io/#/schema) - *Graphical online JSON Schema editor for draft-06 (minus oneOf, anyOf, allOf, not). The generated schema can be tested immediately via a form that is driven by it.* - [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator with context sensitive entry-helpers and sample data generation based on JSON schema. Support for draft-4, draft-6 and draft-7.* - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* From 83b639ca13e9be3609858fd2098eff062b945e67 Mon Sep 17 00:00:00 2001 From: rusty kay <2297143+feep@users.noreply.github.com> Date: Fri, 26 Jun 2020 09:05:17 -0700 Subject: [PATCH 067/311] Add `2019-09` to qri-io --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 1e3e9341..f7013603 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -84,7 +84,7 @@ license: BSD-3-Clause - name: qri-io/jsonschema url: https://github.com/qri-io/jsonschema - date-draft: + date-draft: [2019-09] draft: [7] license: MIT notes: includes custom validator support, rich error returns From f6d3052609ad2453e153a3e392ac212b32be29fe Mon Sep 17 00:00:00 2001 From: Shawn Silverman Date: Sat, 27 Jun 2020 20:43:53 -0700 Subject: [PATCH 068/311] Update Snow validator notes --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index f7013603..fcbd9021 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -92,7 +92,7 @@ implementations: - name: Snow url: https://github.com/ssilverman/snowy-json - notes: Uses Maven for the project, and Gson and Guava under the hood. + notes: Uses Maven for the project and Gson under the hood. date-draft: [2019-09] draft: [7, 6] license: GNU Affero General Public License v3.0 From 289a2e259745cc5854618f41e70fe25e06d61586 Mon Sep 17 00:00:00 2001 From: Francesco Guardiani Date: Tue, 7 Jul 2020 15:41:48 +0200 Subject: [PATCH 069/311] Add Vert.x Json Schema among the implementations --- _data/validator-libraries-modern.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index fcbd9021..8a9b20fc 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -90,6 +90,13 @@ notes: includes custom validator support, rich error returns - name: Java implementations: + - name: Vert.x Json Schema + url: https://github.com/eclipse-vertx/vertx-json-schema + notes: Validator for Eclipse Vert.x project JSON types. + date-draft: [] + draft: [7] + license: Apache License, Version 2.0 + notes: includes custom keywords support, custom dialect support, asynchronous validation - name: Snow url: https://github.com/ssilverman/snowy-json notes: Uses Maven for the project and Gson under the hood. From 39c293091a345fb173efa2f883e8831dadab801e Mon Sep 17 00:00:00 2001 From: Francesco Guardiani Date: Thu, 9 Jul 2020 11:01:06 +0200 Subject: [PATCH 070/311] Update validator-libraries-modern.yml --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 8a9b20fc..6ac9c213 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -93,7 +93,7 @@ - name: Vert.x Json Schema url: https://github.com/eclipse-vertx/vertx-json-schema notes: Validator for Eclipse Vert.x project JSON types. - date-draft: [] + date-draft: [2019-09] draft: [7] license: Apache License, Version 2.0 notes: includes custom keywords support, custom dialect support, asynchronous validation From 3871e030918e6ce9db934c60a5769b0d4e68b5c0 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Tue, 21 Jul 2020 21:49:07 +0100 Subject: [PATCH 071/311] Add carbon ads --- .gitignore | 1 + _config.yml | 2 +- _layouts/default.html | 23 ++++++++++++++ assets/main.scss | 72 +++++++++++++++++++++++++++++++++++++++++++ index.md | 2 +- 5 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 _layouts/default.html diff --git a/.gitignore b/.gitignore index 582ed7b5..6fe13fcd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .sass-cache/ _site/ node_modules/ +.vscode/ diff --git a/_config.yml b/_config.yml index d5aeeab0..3a16502f 100644 --- a/_config.yml +++ b/_config.yml @@ -18,7 +18,7 @@ title: JSON Schema description: The home of JSON Schema baseurl: "" # the subpath of your site, e.g. /blog url: "" # the base hostname & protocol for your site -#twitter_username: jekyllrb +twitter_username: jsonschema github_username: json-schema-org google_analytics: UA-99695987-1 diff --git a/_layouts/default.html b/_layouts/default.html new file mode 100644 index 00000000..751e0dcc --- /dev/null +++ b/_layouts/default.html @@ -0,0 +1,23 @@ + + + + {%- include head.html -%} + + + + {%- include header.html -%} + +
    + {% if page.url != "/" %} + + {% endif %} +
    + {{ content }} +
    +
    + + {%- include footer.html -%} + + + + diff --git a/assets/main.scss b/assets/main.scss index 045e2314..397c5d80 100644 --- a/assets/main.scss +++ b/assets/main.scss @@ -48,3 +48,75 @@ code { // minima.scss overrides $spacing-unit: 10px !default; $content-width: 960px !default; + +// Carbon ads + +#carbonads { + max-width: 300px; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif; + display: flex; + position: fixed; + right: 30px; + top: 90px; + font-size: 12px; + line-height: 1.45; + box-shadow: 0 0 17px rgba(0,0,0,.2); +} + +@media (max-width: 1199.98px) { + #carbonads { + display: block; + position: relative; + right: unset; + top: unset; + margin: auto; + margin-bottom: 30px; + overflow: hidden; + max-width: 728px; + font-size: 24px; + box-sizing: content-box; + } +} + +#carbonads > span { + position: relative; + display: block; + padding: 10px; + border-radius: 4px; + background-color: #fff; + box-shadow: 0 1px 3px hsla(0, 0%, 0%, .05); +} + +#carbonads .carbon-wrap { + display: flex; +} + +#carbonads .carbon-img { + margin-right: 10px; + line-height: 1; +} + +#carbonads .carbon-text { + margin-bottom: 12px; + color: #637381; + text-decoration: none; +} + +#carbonads .carbon-poweredby { + position: absolute; + bottom: 10px; + left: 152px; + color: #c5cdd0; + text-decoration: none; + text-transform: uppercase; + letter-spacing: .5px; + font-weight: 500; + font-size: 8px; + line-height: 1; +} + +@media only screen and (min-width: 320px) and (max-width: 759px) { + .carbon-text { + font-size: 14px; + } +} diff --git a/index.md b/index.md index a67a09bb..5fe4b646 100644 --- a/index.md +++ b/index.md @@ -1,5 +1,5 @@ --- -layout: page +layout: default title: JSON Schema permalink: / --- From 9726922abab08aefc7a6f28181837be9ea591050 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 23 Jul 2020 17:18:38 +0100 Subject: [PATCH 072/311] Modify ad style --- assets/main.scss | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/assets/main.scss b/assets/main.scss index 397c5d80..e2534d8e 100644 --- a/assets/main.scss +++ b/assets/main.scss @@ -60,7 +60,9 @@ $content-width: 960px !default; top: 90px; font-size: 12px; line-height: 1.45; - box-shadow: 0 0 17px rgba(0,0,0,.2); + background-color: #f9f9f9; + border: 1px dashed; + border-color: #cacaca; } @media (max-width: 1199.98px) { @@ -83,8 +85,6 @@ $content-width: 960px !default; display: block; padding: 10px; border-radius: 4px; - background-color: #fff; - box-shadow: 0 1px 3px hsla(0, 0%, 0%, .05); } #carbonads .carbon-wrap { @@ -111,10 +111,14 @@ $content-width: 960px !default; text-transform: uppercase; letter-spacing: .5px; font-weight: 500; - font-size: 8px; + font-size: 10px; line-height: 1; } +#carbonads .carbon-poweredby:hover { + color: #637381; +} + @media only screen and (min-width: 320px) and (max-width: 759px) { .carbon-text { font-size: 14px; From 4c4721ac93f3e7d42efb4a23e325b67557e6fd9e Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Sat, 25 Jul 2020 15:32:18 +0100 Subject: [PATCH 073/311] modified advert positition and media query --- assets/main.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/main.scss b/assets/main.scss index e2534d8e..39e9a030 100644 --- a/assets/main.scss +++ b/assets/main.scss @@ -56,7 +56,7 @@ $content-width: 960px !default; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif; display: flex; position: fixed; - right: 30px; + right: 10px; top: 90px; font-size: 12px; line-height: 1.45; @@ -65,7 +65,7 @@ $content-width: 960px !default; border-color: #cacaca; } -@media (max-width: 1199.98px) { +@media (max-width: 1420px) { #carbonads { display: block; position: relative; From 725dfb191b9fe90e02b06b1e92a8b69378bf1fe2 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Sun, 2 Aug 2020 16:59:27 +1200 Subject: [PATCH 074/311] Update validator-libraries-modern.yml --- _data/validator-libraries-modern.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index fcbd9021..a6a5f306 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -3,7 +3,7 @@ implementations: - name: Json.NET Schema url: https://www.newtonsoft.com/jsonschema - date-draft: + date-draft: [2019-09] draft: [7, 6, 4, 3] license: "AGPL-3.0-only" - name: Manatee.Json @@ -241,7 +241,7 @@ notes: Supports multiple schemas and multiple instances - name: JSON Schema Validator url: https://www.jsonschemavalidator.net/ - date-draft: + date-draft: [2019-09] draft: [7, 6, 4, 3] - name: JSON Schema Lint url: http://jsonschemalint.com/ From 9af5abe7bb2983289cba96b6e8f3a5e4642cb391 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Sat, 15 Aug 2020 15:46:53 +0100 Subject: [PATCH 075/311] Fixes meta-schema issues for draft `2019-09` as per https://github.com/json-schema-org/json-schema-spec/pull/968 --- _includes/draft/2019-09 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/draft/2019-09 b/_includes/draft/2019-09 index cc296f05..03fe369b 160000 --- a/_includes/draft/2019-09 +++ b/_includes/draft/2019-09 @@ -1 +1 @@ -Subproject commit cc296f05b8938a9ffb5ffce7f7a50c2805b2647f +Subproject commit 03fe369b6192bcd6052e96bac8a5b0cfd15d5c07 From 645f333238176363ae950160406c2f5bf66d5aad Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Sun, 30 Aug 2020 14:15:51 +1200 Subject: [PATCH 076/311] added JsonSchema.Net --- _data/validator-libraries-modern.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index a6a5f306..45f2c77f 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -6,6 +6,11 @@ date-draft: [2019-09] draft: [7, 6, 4, 3] license: "AGPL-3.0-only" + - name: JsonSchema.Net + url: https://github.com/gregsdennis/json-everything + date-draft: [2019-09] + draft: [7, 6] + license: MIT - name: Manatee.Json url: https://github.com/gregsdennis/Manatee.Json date-draft: [2019-09] From 0ab12dfdb650dcac62d53e3c4bf78a43180a2076 Mon Sep 17 00:00:00 2001 From: Austin Wright Date: Mon, 14 Sep 2020 19:32:16 -0700 Subject: [PATCH 077/311] Make spec links more obvious Also remove "New Draft" notice which is about a year old now --- index.md | 6 +----- specification.md | 16 +--------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/index.md b/index.md index 5fe4b646..b83a7330 100644 --- a/index.md +++ b/index.md @@ -4,11 +4,7 @@ title: JSON Schema permalink: / --- -**NEW DRAFT PUBLISHED!** -{: style="color:red; font-size: 200%; text-align: center;"} - -The current version is [2019-09](specification.html)! -{: style="color:gray; font-size: 150%; text-align: center;"} +The current version is *[2019-09](specification.html)*! **JSON Schema** is a vocabulary that allows you to **annotate** and **validate** JSON documents. diff --git a/specification.md b/specification.md index 469da8a0..7edd5d0c 100644 --- a/specification.md +++ b/specification.md @@ -5,21 +5,7 @@ permalink: /specification.html title: Specification --- -**NEW DRAFT PUBLISHED!** -{: style="color:red; font-size: 200%; text-align: center;"} - -The current version is 2019-09! -{: style="color:gray; font-size: 150%; text-align: center;"} - -* TOC -{:toc} - -Draft numbering ---------------- - -The latest Internet-Drafts at the IETF are the **draft-handrews-json-schema\*-02** documents, which correspond to the **2019-09** meta-schemas. These were published on **2019-09-16**. - -For a full explanation of both the IETF and meta-schema numbering schemes, how they correspond, and why we are now using the date-based `2019-09` rather than `draft-08`, see the [Specification Links](specification-links.html) page. +The current version is *2019-09*! Specification documents ----------------------- From 78e85b53b53606c8fe4048014c3045b03bc3bfbb Mon Sep 17 00:00:00 2001 From: Austin Wright Date: Tue, 15 Sep 2020 17:12:55 -0700 Subject: [PATCH 078/311] Update index.md Co-authored-by: Ben Hutton --- index.md | 1 - 1 file changed, 1 deletion(-) diff --git a/index.md b/index.md index b83a7330..c7128a8b 100644 --- a/index.md +++ b/index.md @@ -4,7 +4,6 @@ title: JSON Schema permalink: / --- -The current version is *[2019-09](specification.html)*! **JSON Schema** is a vocabulary that allows you to **annotate** and **validate** JSON documents. From c91e60f2a6f4eded8089c19e742750b3ab24a7d2 Mon Sep 17 00:00:00 2001 From: Michael Becker <7737034+elbakerino@users.noreply.github.com> Date: Fri, 18 Sep 2020 21:46:48 +0200 Subject: [PATCH 079/311] Add UI Schema to implementations; Added @ui-schema/ui-schema under ui generation and the corresponding live editor at editors. --- implementations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implementations.md b/implementations.md index 7ca2e0ee..a3d85907 100644 --- a/implementations.md +++ b/implementations.md @@ -225,6 +225,7 @@ Various levels of support for UI generation primarily from the validation vocabu - [React JSON Schema Form (mozilla)](https://github.com/mozilla-services/react-jsonschema-form) (Apache 2) - [React Schema Form (networknt)](https://github.com/networknt/react-schema-form) (MIT) - [uniforms (Vazco)](https://github.com/vazco/uniforms) (MIT) + - [UI Schema for React](https://github.com/ui-schema/ui-schema) (MIT) *2019-09 / draft-08, -07, -06, -04 (incompatible `type=integer`)* #### Data from schemas @@ -284,6 +285,7 @@ _None currently support draft-06 or later._ - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* - [Stoplight Studio](https://stoplight.io/) - *JSON Schema IDE (text-based and GUI) with support for JSON/YAML linting, which can also be based on JSON Schema rules via Spectral. Support for draft-4, draft-6 and draft-7.* +- [UI Schema Live Editor](https://ui-schema.bemit.codes/examples/Simple-Demo) *Schema drive live editor with optional ui keywords, creates a form and validates the data with the given schema, supports 2019-09 / draft-08, -07, -06, -04 (incompatible `type=integer`)* - [Visual Studio Code](https://code.visualstudio.com/) - *Schema driven code completion, hovers and validation for editing JSON files (including schemas)* - [WebStorm](https://www.jetbrains.com/webstorm/), [IntelliJ IDEA](https://www.jetbrains.com/idea/), and other [JetBrains IDEs](https://www.jetbrains.com/products.html?fromMenu#type=ide) - *Code completion, documentation, and validation for JSON and YAML files using JSON Schema. Support for draft-4, draft-6, and draft-7.* - [Eclipse IDE](https://www.eclipse.org/downloads/eclipse-packages) - *Rich JSON edition supporting schema for instantaneous validation and error reporting, completion, documentation.* From 0062500a5e3d103288047517052ded8c4832b3a9 Mon Sep 17 00:00:00 2001 From: Michael Becker <7737034+elbakerino@users.noreply.github.com> Date: Fri, 18 Sep 2020 21:49:09 +0200 Subject: [PATCH 080/311] typo fix; --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index a3d85907..467bbbe5 100644 --- a/implementations.md +++ b/implementations.md @@ -285,7 +285,7 @@ _None currently support draft-06 or later._ - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* - [Stoplight Studio](https://stoplight.io/) - *JSON Schema IDE (text-based and GUI) with support for JSON/YAML linting, which can also be based on JSON Schema rules via Spectral. Support for draft-4, draft-6 and draft-7.* -- [UI Schema Live Editor](https://ui-schema.bemit.codes/examples/Simple-Demo) *Schema drive live editor with optional ui keywords, creates a form and validates the data with the given schema, supports 2019-09 / draft-08, -07, -06, -04 (incompatible `type=integer`)* +- [UI Schema Live Editor](https://ui-schema.bemit.codes/examples/Simple-Demo) *Schema driven live editor with optional ui keywords, creates a form and validates the data with the given schema, supports 2019-09 / draft-08, -07, -06, -04 (incompatible `type=integer`)* - [Visual Studio Code](https://code.visualstudio.com/) - *Schema driven code completion, hovers and validation for editing JSON files (including schemas)* - [WebStorm](https://www.jetbrains.com/webstorm/), [IntelliJ IDEA](https://www.jetbrains.com/idea/), and other [JetBrains IDEs](https://www.jetbrains.com/products.html?fromMenu#type=ide) - *Code completion, documentation, and validation for JSON and YAML files using JSON Schema. Support for draft-4, draft-6, and draft-7.* - [Eclipse IDE](https://www.eclipse.org/downloads/eclipse-packages) - *Rich JSON edition supporting schema for instantaneous validation and error reporting, completion, documentation.* From 6f3d8adc8bf3d826eb8081395c697c8eb7cf0e50 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Fri, 18 Sep 2020 21:15:52 +0100 Subject: [PATCH 081/311] Remove UI Schema Live Editor from the list of editors I do not feel this is a JSON Schema editor. --- implementations.md | 1 - 1 file changed, 1 deletion(-) diff --git a/implementations.md b/implementations.md index 467bbbe5..b3f81a74 100644 --- a/implementations.md +++ b/implementations.md @@ -285,7 +285,6 @@ _None currently support draft-06 or later._ - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* - [Stoplight Studio](https://stoplight.io/) - *JSON Schema IDE (text-based and GUI) with support for JSON/YAML linting, which can also be based on JSON Schema rules via Spectral. Support for draft-4, draft-6 and draft-7.* -- [UI Schema Live Editor](https://ui-schema.bemit.codes/examples/Simple-Demo) *Schema driven live editor with optional ui keywords, creates a form and validates the data with the given schema, supports 2019-09 / draft-08, -07, -06, -04 (incompatible `type=integer`)* - [Visual Studio Code](https://code.visualstudio.com/) - *Schema driven code completion, hovers and validation for editing JSON files (including schemas)* - [WebStorm](https://www.jetbrains.com/webstorm/), [IntelliJ IDEA](https://www.jetbrains.com/idea/), and other [JetBrains IDEs](https://www.jetbrains.com/products.html?fromMenu#type=ide) - *Code completion, documentation, and validation for JSON and YAML files using JSON Schema. Support for draft-4, draft-6, and draft-7.* - [Eclipse IDE](https://www.eclipse.org/downloads/eclipse-packages) - *Rich JSON edition supporting schema for instantaneous validation and error reporting, completion, documentation.* From b5725d286e2baea005cb5b6cb4451f129af9715b Mon Sep 17 00:00:00 2001 From: Jack Smith Date: Sat, 3 Oct 2020 16:13:19 +0100 Subject: [PATCH 082/311] Add statham to implementations/codegen/python --- implementations.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 7ca2e0ee..971abd59 100644 --- a/implementations.md +++ b/implementations.md @@ -201,7 +201,8 @@ are the only keywords that changed. - PHP - [php-code-builder](https://github.com/swaggest/php-code-builder)(MIT) - generates PHP mapping structures defined by JSON schema using [swaggest/json-schema](https://github.com/swaggest/php-json-schema) *supports Draft 7* - Python - - [yacg](https://github.com/OkieOth/yacg) (MIT) - parse JSON Schema and OpenApi files to build a meta model from them. This meta model can be used in Mako templates to generate source code, other schemas or plantUml. + - [yacg](https://github.com/OkieOth/yacg) (MIT) - parse JSON Schema and OpenApi files to build a meta model from them. This meta model can be used in Mako templates to generate source code, other schemas or plantUml. + - [statham](https://github.com/jacksmith15/statham-schema) (MIT) - generate type-annotated models from JSON Schema documents. - Rust - [schemafy](https://github.com/Marwes/schemafy/) - generates Rust types and serialization code from a JSON schema. *supports Draft 4* From 1ca645f629f16de4a534bf833e7b3923ddd99ac1 Mon Sep 17 00:00:00 2001 From: Relequestual Date: Mon, 5 Oct 2020 21:24:39 +0100 Subject: [PATCH 083/311] Fixes #357 Update draft-6 meta-schema as per latest fix: https://github.com/json-schema-org/json-schema-spec/pull/704 --- _includes/draft-06 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/draft-06 b/_includes/draft-06 index 00e25c02..59ed5f6f 160000 --- a/_includes/draft-06 +++ b/_includes/draft-06 @@ -1 +1 @@ -Subproject commit 00e25c022514788dbb9161d52b70024f2646cfb5 +Subproject commit 59ed5f6fc6f6386e23ca51d7f31d7fe9cf696713 From d2595bac7ebf240c88291b4081fe15decbbe781e Mon Sep 17 00:00:00 2001 From: Jim Blackler Date: Fri, 23 Oct 2020 19:44:20 +0100 Subject: [PATCH 084/311] Update validator-libraries-modern.yml --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 45f2c77f..bdd8c10d 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -119,6 +119,12 @@ date-draft: draft: [7, 6, 4] license: Apache License 2.0 + - name: jsonschemafriend + url: https://github.com/jimblackler/jsonschematypes/tree/master/library + notes: + date-draft: [2019-09] + draft: [7, 6, 4, 3] + license: Apache License 2.0 - name: Kotlin implementations: - name: Medeia-validator From 42d3c8000bf54981922f1779e596e8c5f196b5e6 Mon Sep 17 00:00:00 2001 From: Jim Blackler Date: Fri, 23 Oct 2020 19:57:21 +0100 Subject: [PATCH 085/311] Add my projects to code and data generators. --- implementations.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/implementations.md b/implementations.md index 971abd59..381b3fd1 100644 --- a/implementations.md +++ b/implementations.md @@ -196,6 +196,7 @@ are the only keywords that changed. - [json-schema-to-elm](https://github.com/dragonwasrobot/json-schema-to-elm) - generates Elm types, JSON decoders+encoders, and fuzz tests from one or more JSON Schema files, using [dragonwasrobot/json_schema](https://github.com/dragonwasrobot/json_schema) *supports Draft 7* - Java - [jsonCodeGen](https://github.com/schlothauer-wauer/jsoncodegen) (MIT) - Groovy based generation tasks from JSON schema. Already includes templates/generators for Java Beans, Swagger specification files and PlantUML diagrams. + - [jsongenerator](https://github.com/jimblackler/jsonschematypes/tree/master/codegen) *JSON Schema 2019-09, draft-07, -06, -04, -03* (Apache-2.0) - Online (web tool) - [quicktype.io](https://app.quicktype.io/#l=schema) - infer JSON Schema from samples, and generate TypeScript, C++, go, Java, C#, Swift, etc. types from JSON Schema - PHP @@ -205,6 +206,8 @@ are the only keywords that changed. - [statham](https://github.com/jacksmith15/statham-schema) (MIT) - generate type-annotated models from JSON Schema documents. - Rust - [schemafy](https://github.com/Marwes/schemafy/) - generates Rust types and serialization code from a JSON schema. *supports Draft 4* +- TypeScript + - [jsongenerator](https://github.com/jimblackler/jsonschematypes/tree/master/codegen) *JSON Schema 2019-09, draft-07, -06, -04, -03* (Apache-2.0) #### Web UI generation @@ -231,6 +234,8 @@ Various levels of support for UI generation primarily from the validation vocabu - Python - [hypothesis-jsonschema](https://github.com/Zac-HD/hypothesis-jsonschema) (MPL) *draft-07, -06, -04*; takes any schema, even with complex and interacting constraints, and returns a [Hypothesis](https://hypothesis.works/) strategy which can generate valid documents for testing. +- Java + - [jsongenerator](https://github.com/jimblackler/jsongenerator) *JSON Schema 2019-09, draft-07, -06, -04, -03* (Apache-2.0) Utilities --------- From e47a74f2e821cd7cfe34058ad32e1034d0e59718 Mon Sep 17 00:00:00 2001 From: Jim Blackler Date: Sat, 24 Oct 2020 13:55:13 +0100 Subject: [PATCH 086/311] Update validator-libraries-modern.yml --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index bdd8c10d..1962e75e 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -120,7 +120,7 @@ draft: [7, 6, 4] license: Apache License 2.0 - name: jsonschemafriend - url: https://github.com/jimblackler/jsonschematypes/tree/master/library + url: https://github.com/jimblackler/jsonschemafriend notes: date-draft: [2019-09] draft: [7, 6, 4, 3] From dafc80f8a487469b5636959a6803914c80b42e82 Mon Sep 17 00:00:00 2001 From: Peter Wall Date: Sun, 25 Oct 2020 21:06:28 +1100 Subject: [PATCH 087/311] Please consider adding json-kotlin-schema and -codegen to the implementation list --- _data/validator-libraries-modern.yml | 6 ++++++ implementations.md | 2 ++ 2 files changed, 8 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 45f2c77f..6c37bd84 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -127,6 +127,12 @@ date-draft: draft: [7, 6, 4] license: Apache License 2.0 + - name: json-kotlin-schema + url: https://github.com/pwall567/json-kotlin-schema + notes: Kotlin implementation of JSON Schema + date-draft: [2019-09] + draft: [7] + license: MIT - name: JavaScript implementations: - name: ajv diff --git a/implementations.md b/implementations.md index 971abd59..9e44db92 100644 --- a/implementations.md +++ b/implementations.md @@ -196,6 +196,8 @@ are the only keywords that changed. - [json-schema-to-elm](https://github.com/dragonwasrobot/json-schema-to-elm) - generates Elm types, JSON decoders+encoders, and fuzz tests from one or more JSON Schema files, using [dragonwasrobot/json_schema](https://github.com/dragonwasrobot/json_schema) *supports Draft 7* - Java - [jsonCodeGen](https://github.com/schlothauer-wauer/jsoncodegen) (MIT) - Groovy based generation tasks from JSON schema. Already includes templates/generators for Java Beans, Swagger specification files and PlantUML diagrams. +- Kotlin + - [json-kotlin-schema-codegen](https://github.com/pwall567/json-kotlin-schema-codegen) (MIT) - Generates Kotlin data classes from JSON Schema. - Online (web tool) - [quicktype.io](https://app.quicktype.io/#l=schema) - infer JSON Schema from samples, and generate TypeScript, C++, go, Java, C#, Swift, etc. types from JSON Schema - PHP From 69758f56d5f1af39c6e378f38ca49bb2803ed7d9 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 12 Nov 2020 13:43:52 +0000 Subject: [PATCH 088/311] Add draft 2020-11-rc-0 preview documents for easy viewing --- .../preview/2020-11-rc-0/jsonschema-core.html | 2542 +++++++++++++++++ .../2020-11-rc-0/jsonschema-validation.html | 1411 +++++++++ 2 files changed, 3953 insertions(+) create mode 100644 draft/preview/2020-11-rc-0/jsonschema-core.html create mode 100644 draft/preview/2020-11-rc-0/jsonschema-validation.html diff --git a/draft/preview/2020-11-rc-0/jsonschema-core.html b/draft/preview/2020-11-rc-0/jsonschema-core.html new file mode 100644 index 00000000..3d7d2bad --- /dev/null +++ b/draft/preview/2020-11-rc-0/jsonschema-core.html @@ -0,0 +1,2542 @@ + + + + + + + JSON Schema: A Media Type for Describing JSON Documents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Internet Engineering Task ForceA. Wright, Ed.
    Internet-Draft
    Intended status: InformationalH. Andrews, Ed.
    Expires: May 16, 2021
    B. Hutton, Ed.
    G. Dennis
    November 12, 2020
    + +

    JSON Schema: A Media Type for Describing JSON Documents
    + draft-bhutton-json-schema-00

    + +

    Abstract

    +

    JSON Schema defines the media type "application/schema+json", a JSON-based format for describing the structure of JSON data. JSON Schema asserts what a JSON document must look like, ways to extract information from it, and how to interact with it. The "application/schema-instance+json" media type provides additional feature-rich integration with "application/schema+json" beyond what can be offered for "application/json" documents.

    +

    Note to Readers

    +

    This document a pre-release identified as JSON Schema draft 2020-11-rc-0.

    +

    The issues list for this draft can be found at <https://github.com/json-schema-org/json-schema-spec/issues>.

    +

    For additional information, see <https://json-schema.org/>.

    +

    To provide feedback, use this issue tracker, the communication methods listed on the homepage, or email the document editors.

    +

    Status of This Memo

    +

    This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

    +

    Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

    +

    Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

    +

    This Internet-Draft will expire on May 16, 2021.

    +

    Copyright Notice

    +

    Copyright (c) 2020 IETF Trust and the persons identified as the document authors. All rights reserved.

    +

    This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

    + + +
    +

    Table of Contents

    + + +

    +1. Introduction

    +

    JSON Schema is a JSON media type for defining the structure of JSON data. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data.

    +

    This specification defines JSON Schema core terminology and mechanisms, including pointing to another JSON Schema by reference, dereferencing a JSON Schema reference, specifying the vocabulary being used, and defining the expected output.

    +

    Other specifications define the vocabularies that perform assertions about validation, linking, annotation, navigation, and interaction.

    +

    +2. Conventions and Terminology

    +

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

    +

    The terms "JSON", "JSON text", "JSON value", "member", "element", "object", "array", "number", "string", "boolean", "true", "false", and "null" in this document are to be interpreted as defined in RFC 8259.

    +

    +3. Overview

    +

    This document proposes a new media type "application/schema+json" to identify a JSON Schema for describing JSON data. It also proposes a further optional media type, "application/schema-instance+json", to provide additional integration features. JSON Schemas are themselves JSON documents. This, and related specifications, define keywords allowing authors to describe JSON data in several ways.

    +

    JSON Schema uses keywords to assert constraints on JSON instances or annotate those instances with additional information. Additional keywords are used to apply assertions and annotations to more complex JSON data structures, or based on some sort of condition.

    +

    To facilitate re-use, keywords can be organized into vocabularies. A vocabulary consists of a list of keywords, together with their syntax and semantics. A set of vocabularies identified by a meta-schema is known as a dialect.

    +

    JSON Schema can be extended either by defining additional vocabularies, or less formally by defining additional keywords outside of any vocabulary. Unrecognized individual keywords simply have their values collected as annotations, while the behavior with respect to an unrecognized vocabulary can be controlled when declaring which vocabularies are in use.

    +

    This document defines a core vocabulary that MUST be supported by any implementation, and cannot be disabled. Its keywords are each prefixed with a "$" character to emphasize their required nature. This vocabulary is essential to the functioning of the "application/schema+json" media type, and is used to bootstrap the loading of other vocabularies.

    +

    Additionally, this document defines a RECOMMENDED vocabulary of keywords for applying subschemas conditionally, and for applying subschemas to the contents of objects and arrays. Either this vocabulary or one very much like it is required to write schemas for non-trivial JSON instances, whether those schemas are intended for assertion validation, annotation, or both. While not part of the required core vocabulary, for maximum interoperability this additional vocabulary is included in this document and its use is strongly encouraged.

    +

    Further vocabularies for purposes such as structural validation or hypermedia annotation are defined in other documents. These other documents each define a dialect collecting the standard sets of vocabularies needed to write schemas for that document's purpose.

    +

    +4. Definitions

    +

    +4.1. JSON Document

    +

    A JSON document is an information resource (series of octets) described by the application/json media type.

    +

    In JSON Schema, the terms "JSON document", "JSON text", and "JSON value" are interchangeable because of the data model it defines.

    +

    JSON Schema is only defined over JSON documents. However, any document or memory structure that can be parsed into or processed according to the JSON Schema data model can be interpreted against a JSON Schema, including media types like CBOR.

    +

    +4.2. Instance

    +

    A JSON document to which a schema is applied is known as an "instance".

    +

    JSON Schema is defined over "application/json" or compatible documents, including media types with the "+json" structured syntax suffix.

    +

    Among these, this specification defines the "application/schema-instance+json" media type which defines handling for fragments in the URI, and the "schema" media type parameter.

    +

    +4.2.1. Instance Data Model

    +

    JSON Schema interprets documents according to a data model. A JSON value interpreted according to this data model is called an "instance".

    +

    An instance has one of six primitive types, and a range of possible values depending on the type:

    + +
    +
    null:
    +
    A JSON "null" value
    +
    boolean:
    +
    A "true" or "false" value, from the JSON "true" or "false" value
    +
    object:
    +
    An unordered set of properties mapping a string to an instance, from the JSON "object" value
    +
    array:
    +
    An ordered list of instances, from the JSON "array" value
    +
    number:
    +
    An arbitrary-precision, base-10 decimal number value, from the JSON "number" value
    +
    string:
    +
    A string of Unicode code points, from the JSON "string" value
    +
    + +

    +

    Whitespace and formatting concerns, including different lexical representations of numbers that are equal within the data model, are thus outside the scope of JSON Schema. JSON Schema vocabularies that wish to work with such differences in lexical representations SHOULD define keywords to precisely interpret formatted strings within the data model rather than relying on having the original JSON representation Unicode characters available.

    +

    Since an object cannot have two properties with the same key, behavior for a JSON document that tries to define two properties with the same key in a single object is undefined.

    +

    Note that JSON Schema vocabularies are free to define their own extended type system. This should not be confused with the core data model types defined here. As an example, "integer" is a reasonable type for a vocabulary to define as a value for a keyword, but the data model makes no distinction between integers and other numbers.

    +

    +4.2.2. Instance Equality

    +

    Two JSON instances are said to be equal if and only if they are of the same type and have the same value according to the data model. Specifically, this means:

    + +
      +
    • both are null; or
    • +
    • both are true; or
    • +
    • both are false; or
    • +
    • both are strings, and are the same codepoint-for-codepoint; or
    • +
    • both are numbers, and have the same mathematical value; or
    • +
    • both are arrays, and have an equal value item-for-item; or
    • +
    • both are objects, and each property in one has exactly one property with a key equal to the other's, and that other property has an equal value.
    • +
    + +

    +

    Implied in this definition is that arrays must be the same length, objects must have the same number of members, properties in objects are unordered, there is no way to define multiple properties with the same key, and mere formatting differences (indentation, placement of commas, trailing zeros) are insignificant.

    +

    +4.2.3. Non-JSON Instances

    +

    It is possible to use JSON Schema with a superset of the JSON Schema data model, where an instance may be outside any of the six JSON data types.

    +

    In this case, annotations still apply; but validation keywords will not be useful, as they will always pass or always fail.

    +

    A custom vocabulary may define support for a superset of the core data model. The schema itself may only be expressible in this superset; for example, to make use of the "const" keyword.

    +

    +4.3. JSON Schema Documents +

    +

    A JSON Schema document, or simply a schema, is a JSON document used to describe an instance. A schema can itself be interpreted as an instance, but SHOULD always be given the media type "application/schema+json" rather than "application/schema-instance+json". The "application/schema+json" media type is defined to offer a superset of the media type parameter and fragment identifier syntax and semantics provided by "application/schema-instance+json".

    +

    A JSON Schema MUST be an object or a boolean.

    +

    +4.3.1. JSON Schema Objects and Keywords

    +

    Object properties that are applied to the instance are called keywords, or schema keywords. Broadly speaking, keywords fall into one of five categories:

    + +
    +
    identifiers:
    +
    control schema identification through setting the schema's canonical URI and/or changing how the base URI is determined
    +
    assertions:
    +
    produce a boolean result when applied to an instance
    +
    annotations:
    +
    attach information to an instance for application use
    +
    applicators:
    +
    apply one or more subschemas to a particular location in the instance, and combine or modify their results
    +
    reserved locations:
    +
    do not directly affect results, but reserve a place for a specific purpose to ensure interoperability
    +
    + +

    +

    Keywords may fall into multiple categories, although applicators SHOULD only produce assertion results based on their subschemas' results. They should not define additional constraints independent of their subschemas.

    +

    Keywords within the same schema object are referred to as adjacent keywords.

    +

    Extension keywords, meaning those defined outside of this document and its companions, are free to define other behaviors as well.

    +

    A JSON Schema MAY contain properties which are not schema keywords. Unknown keywords SHOULD be treated as annotations, where the value of the keyword is the value of the annotation.

    +

    An empty schema is a JSON Schema with no properties, or only unknown properties.

    +

    +4.3.2. Boolean JSON Schemas

    +

    The boolean schema values "true" and "false" are trivial schemas that always produce themselves as assertions results, regardless of the instance value. They never produce annotation results.

    +

    These boolean schemas exist to clarify schema author intent and facilitate schema processing optimizations. They behave identically to the following schema objects (where "not" is part of the subschema application vocabulary defined in this document).

    + +
    +
    true:
    +
    Always passes validation, as if the empty schema {}
    +
    false:
    +
    Always fails validation, as if the schema { "not": {} }
    +
    + +

    While the empty schema object is unambiguous, there are many possible equivalents to the "false" schema. Using the boolean values ensures that the intent is clear to both human readers and implementations.

    +

    +4.3.3. Schema Vocabularies

    +

    A schema vocabulary, or simply a vocabulary, is a set of keywords, their syntax, and their semantics. A vocabulary is generally organized around a particular purpose. Different uses of JSON Schema, such as validation, hypermedia, or user interface generation, will involve different sets of vocabularies.

    +

    Vocabularies are the primary unit of re-use in JSON Schema, as schema authors can indicate what vocabularies are required or optional in order to process the schema. Since vocabularies are identified by URIs in the meta-schema, generic implementations can load extensions to support previously unknown vocabularies. While keywords can be supported outside of any vocabulary, there is no analogous mechanism to indicate individual keyword usage.

    +

    +4.3.4. Meta-Schemas

    +

    A schema that itself describes a schema is called a meta-schema. Meta-schemas are used to validate JSON Schemas and specify which vocabularies they are using.

    +

    Typically, a meta-schema will specify a set of vocabularies, and validate schemas that conform to the syntax of those vocabularies. However, meta-schemas and vocabularies are separate in order to allow meta-schemas to validate schema conformance more strictly or more loosely than the vocabularies' specifications call for. Meta-schemas may also describe and validate additional keywords that are not part of a formal vocabulary.

    +

    +4.3.5. Root Schema and Subschemas and Resources +

    +

    A JSON Schema resource is a schema which is canonically identified by an absolute URI.

    +

    The root schema is the schema that comprises the entire JSON document in question. The root schema is always a schema resource, where the URI is determined as described in section 9.1.1.

    +

    Some keywords take schemas themselves, allowing JSON Schemas to be nested:

    +
    +
    +{
    +    "title": "root",
    +    "items": {
    +        "title": "array item"
    +    }
    +}
    +
    +                        
    +

    In this example document, the schema titled "array item" is a subschema, and the schema titled "root" is the root schema.

    +

    As with the root schema, a subschema is either an object or a boolean.

    +

    As discussed in section 8.2.1, a JSON Schema document can contain multiple JSON Schema resources. When used without qualification, the term "root schema" refers to the document's root schema. In some cases, resource root schemas are discussed. A resource's root schema is its top-level schema object, which would also be a document root schema if the resource were to be extracted to a standalone JSON Schema document.

    +

    Whether multiple schema resources are embedded or linked with a reference, they are processed in the same way, with the same available behaviors.

    +

    +5. Fragment Identifiers +

    +

    In accordance with section 3.1 of RFC 6839, the syntax and semantics of fragment identifiers specified for any +json media type SHOULD be as specified for "application/json". (At publication of this document, there is no fragment identification syntax defined for "application/json".)

    +

    Additionally, the "application/schema+json" media type supports two fragment identifier structures: plain names and JSON Pointers. The "application/schema-instance+json" media type supports one fragment identifier structure: JSON Pointers.

    +

    The use of JSON Pointers as URI fragment identifiers is described in RFC 6901. For "application/schema+json", which supports two fragment identifier syntaxes, fragment identifiers matching the JSON Pointer syntax, including the empty string, MUST be interpreted as JSON Pointer fragment identifiers.

    +

    Per the W3C's best practices for fragment identifiers, plain name fragment identifiers in "application/schema+json" are reserved for referencing locally named schemas. All fragment identifiers that do not match the JSON Pointer syntax MUST be interpreted as plain name fragment identifiers.

    +

    Defining and referencing a plain name fragment identifier within an "application/schema+json" document are specified in the "$anchor" keyword section.

    +

    +

    +6. General Considerations

    +

    +6.1. Range of JSON Values

    +

    An instance may be any valid JSON value as defined by JSON. JSON Schema imposes no restrictions on type: JSON Schema can describe any JSON value, including, for example, null.

    +

    +6.2. Programming Language Independence +

    +

    JSON Schema is programming language agnostic, and supports the full range of values described in the data model. Be aware, however, that some languages and JSON parsers may not be able to represent in memory the full range of values describable by JSON.

    +

    +6.3. Mathematical Integers +

    +

    Some programming languages and parsers use different internal representations for floating point numbers than they do for integers.

    +

    For consistency, integer JSON numbers SHOULD NOT be encoded with a fractional part.

    +

    +6.4. Regular Expressions +

    +

    Keywords MAY use regular expressions to express constraints, or constrain the instance value to be a regular expression. These regular expressions SHOULD be valid according to the regular expression dialect described in ECMA-262, section 21.2.1.

    +

    Regular expressions SHOULD be built with the "u" flag (or equivilent) to provide Unicode support, or processed in such a way which provides Unicode as defined by ECMA-262.

    +

    Furthermore, given the high disparity in regular expression constructs support, schema authors SHOULD limit themselves to the following regular expression tokens:

    + +
      +
    • individual Unicode characters, as defined by the JSON specification;
    • +
    • simple character classes ([abc]), range character classes ([a-z]);
    • +
    • complemented character classes ([^abc], [^a-z]);
    • +
    • simple quantifiers: "+" (one or more), "*" (zero or more), "?" (zero or one), and their lazy versions ("+?", "*?", "??");
    • +
    • range quantifiers: "{x}" (exactly x occurrences), "{x,y}" (at least x, at most y, occurrences), {x,} (x occurrences or more), and their lazy versions;
    • +
    • the beginning-of-input ("^") and end-of-input ("$") anchors;
    • +
    • simple grouping ("(...)") and alternation ("|").
    • +
    + +

    +

    Finally, implementations MUST NOT take regular expressions to be anchored, neither at the beginning nor at the end. This means, for instance, the pattern "es" matches "expression".

    +

    +6.5. Extending JSON Schema +

    +

    Additional schema keywords and schema vocabularies MAY be defined by any entity. Save for explicit agreement, schema authors SHALL NOT expect these additional keywords and vocabularies to be supported by implementations that do not explicitly document such support. Implementations SHOULD treat keywords they do not support as annotations, where the value of the keyword is the value of the annotation.

    +

    Implementations MAY provide the ability to register or load handlers for vocabularies that they do not support directly. The exact mechanism for registering and implementing such handlers is implementation-dependent.

    +

    +7. Keyword Behaviors

    +

    JSON Schema keywords fall into several general behavior categories. Assertions validate that an instance satisfies constraints, producing a boolean result. Annotations attach information that applications may use in any way they see fit. Applicators apply subschemas to parts of the instance and combine their results.

    +

    Extension keywords SHOULD stay within these categories, keeping in mind that annotations in particular are extremely flexible. Complex behavior is usually better delegated to applications on the basis of annotation data than implemented directly as schema keywords. However, extension keywords MAY define other behaviors for specialized purposes.

    +

    Evaluating an instance against a schema involves processing all of the keywords in the schema against the appropriate locations within the instance. Typically, applicator keywords are processed until a schema object with no applicators (and therefore no subschemas) is reached. The appropriate location in the instance is evaluated against the assertion and annotation keywords in the schema object, and their results are gathered into the parent schema according to the rules of the applicator.

    +

    Evaluation of a parent schema object can complete once all of its subschemas have been evaluated, although in some circumstances evaluation may be short-circuited due to assertion results. When annotations are being collected, some assertion result short-circuiting is not possible due to the need to examine all subschemas for annotation collection, including those that cannot further change the assertion result.

    +

    +7.1. Lexical Scope and Dynamic Scope +

    +

    While most JSON Schema keywords can be evaluated on their own, or at most need to take into account the values or results of adjacent keywords in the same schema object, a few have more complex behavior.

    +

    The lexical scope of a keyword is determined by the nested JSON data structure of objects and arrays. The largest such scope is an entire schema document. The smallest scope is a single schema object with no subschemas.

    +

    Keywords MAY be defined with a partial value, such as a URI-reference, which must be resolved against another value, such as another URI-reference or a full URI, which is found through the lexical structure of the JSON document. The "$id", "$ref", and "$dynamicRef" core keywords, and the "base" JSON Hyper-Schema keyword, are examples of this sort of behavior.

    +

    Note that some keywords, such as "$schema", apply to the lexical scope of the entire schema resource, and therefore MUST only appear in a schema resource's root schema.

    +

    Other keywords may take into account the dynamic scope that exists during the evaluation of a schema, typically together with an instance document. The outermost dynamic scope is the root schema of the schema document in which processing begins. The path from this root schema to any particular keyword (that includes any "$ref" and "$dynamicRef" keywords that may have been resolved) is considered the keyword's "validation path." [CREF1]Or should this be the schema object at which processing begins, even if it is not a root? This has some implications for the case where "$dynamicAnchor" is only allowed in the root schema but processing begins in a subschema.

    +

    Lexical and dynamic scopes align until a reference keyword is encountered. While following the reference keyword moves processing from one lexical scope into a different one, from the perspective of dynamic scope, following reference is no different from descending into a subschema present as a value. A keyword on the far side of that reference that resolves information through the dynamic scope will consider the originating side of the reference to be their dynamic parent, rather than examining the local lexically enclosing parent.

    +

    The concept of dynamic scope is primarily used with "$dynamicRef" and "$dynamicAnchor", and should be considered an advanced feature and used with caution when defining additional keywords. It also appears when reporting errors and collected annotations, as it may be possible to revisit the same lexical scope repeatedly with different dynamic scopes. In such cases, it is important to inform the user of the dynamic path that produced the error or annotation.

    +

    +7.2. Keyword Interactions

    +

    Keyword behavior MAY be defined in terms of the annotation results of subschemas and/or adjacent keywords (keywords within the same schema object) and their subschemas. Such keywords MUST NOT result in a circular dependency. Keywords MAY modify their behavior based on the presence or absence of another keyword in the same schema object.

    +

    +7.3. Default Behaviors

    +

    A missing keyword MUST NOT produce a false assertion result, MUST NOT produce annotation results, and MUST NOT cause any other schema to be evaluated as part of its own behavioral definition. However, given that missing keywords do not contribute annotations, the lack of annotation results may indirectly change the behavior of other keywords.

    +

    In some cases, the missing keyword assertion behavior of a keyword is identical to that produced by a certain value, and keyword definitions SHOULD note such values where known. However, even if the value which produces the default behavior would produce annotation results if present, the default behavior still MUST NOT result in annotations.

    +

    Because annotation collection can add significant cost in terms of both computation and memory, implementations MAY opt out of this feature. Keywords that are specified in terms of collected annotations SHOULD describe reasonable alternate approaches when appropriate. This approach is demonstrated by the "items" and "additionalProperties" keywords in this document.

    +

    Note that when no such alternate approach is possible for a keyword, implementations that do not support annotation collections will not be able to support those keywords or vocabularies that contain them.

    +

    +7.4. Identifiers +

    +

    Identifiers set the canonical URI of a schema, or affect how such URIs are resolved in references, or both. The Core vocabulary defined in this document defines several identifying keywords, most notably "$id".

    +

    Canonical schema URIs MUST NOT change while processing an instance, but keywords that affect URI-reference resolution MAY have behavior that is only fully determined at runtime.

    +

    While custom identifier keywords are possible, vocabulary designers should take care not to disrupt the functioning of core keywords. For example, the "$dynamicAnchor" keyword in this specification limits its URI resolution effects to the matching "$dynamicRef" keyword, leaving the behavior of "$ref" undisturbed.

    +

    +7.5. Applicators +

    +

    Applicators allow for building more complex schemas than can be accomplished with a single schema object. Evaluation of an instance against a schema document begins by applying the root schema to the complete instance document. From there, keywords known as applicators are used to determine which additional schemas are applied. Such schemas may be applied in-place to the current location, or to a child location.

    +

    The schemas to be applied may be present as subschemas comprising all or part of the keyword's value. Alternatively, an applicator may refer to a schema elsewhere in the same schema document, or in a different one. The mechanism for identifying such referenced schemas is defined by the keyword.

    +

    Applicator keywords also define how subschema or referenced schema boolean assertion results are modified and/or combined to produce the boolean result of the applicator. Applicators may apply any boolean logic operation to the assertion results of subschemas, but MUST NOT introduce new assertion conditions of their own.

    +

    Annotation results are preserved along with the instance location and the location of the schema keyword, so that applications can decide how to interpret multiple values.

    +

    +7.5.1. Referenced and Referencing Schemas +

    +

    As noted in Section 7.5, an applicator keyword may refer to a schema to be applied, rather than including it as a subschema in the applicator's value. In such situations, the schema being applied is known as the referenced schema, while the schema containing the applicator keyword is the referencing schema.

    +

    While root schemas and subschemas are static concepts based on a schema's position within a schema document, referenced and referencing schemas are dynamic. Different pairs of schemas may find themselves in various referenced and referencing arrangements during the evaluation of an instance against a schema.

    +

    For some by-reference applicators, such as "$ref", the referenced schema can be determined by static analysis of the schema document's lexical scope. Others, such as "$dynamicRef" (with "$dynamicAnchor"), may make use of dynamic scoping, and therefore only be resolvable in the process of evaluating the schema with an instance.

    +

    +7.6. Assertions +

    +

    JSON Schema can be used to assert constraints on a JSON document, which either passes or fails the assertions. This approach can be used to validate conformance with the constraints, or document what is needed to satisfy them.

    +

    JSON Schema implementations produce a single boolean result when evaluating an instance against schema assertions.

    +

    An instance can only fail an assertion that is present in the schema.

    +

    +7.6.1. Assertions and Instance Primitive Types

    +

    Most assertions only constrain values within a certain primitive type. When the type of the instance is not of the type targeted by the keyword, the instance is considered to conform to the assertion.

    +

    For example, the "maxLength" keyword from the companion validation vocabulary: will only restrict certain strings (that are too long) from being valid. If the instance is a number, boolean, null, array, or object, then it is valid against this assertion.

    +

    This behavior allows keywords to be used more easily with instances that can be of multiple primitive types. The companion validation vocabulary also includes a "type" keyword which can independently restrict the instance to one or more primitive types. This allows for a concise expression of use cases such as a function that might return either a string of a certain length or a null value:

    +
    +
    +{
    +    "type": ["string", "null"],
    +    "maxLength": 255
    +}
    +
    +                        
    +

    If "maxLength" also restricted the instance type to be a string, then this would be substantially more cumbersome to express because the example as written would not actually allow null values. Each keyword is evaluated separately unless explicitly specified otherwise, so if "maxLength" restricted the instance to strings, then including "null" in "type" would not have any useful effect.

    +

    +7.7. Annotations +

    +

    JSON Schema can annotate an instance with information, whenever the instance validates against the schema object containing the annotation, and all of its parent schema objects. The information can be a simple value, or can be calculated based on the instance contents.

    +

    Annotations are attached to specific locations in an instance. Since many subschemas can be applied to any single location, applications may need to decide how to handle differing annotation values being attached to the same instance location by the same schema keyword in different schema objects.

    +

    Unlike assertion results, annotation data can take a wide variety of forms, which are provided to applications to use as they see fit. JSON Schema implementations are not expected to make use of the collected information on behalf of applications.

    +

    Unless otherwise specified, the value of an annotation keyword is the keyword's value. However, other behaviors are possible. For example, JSON Hyper-Schema's "links" keyword is a complex annotation that produces a value based in part on the instance data.

    +

    While "short-circuit" evaluation is possible for assertions, collecting annotations requires examining all schemas that apply to an instance location, even if they cannot change the overall assertion result. The only exception is that subschemas of a schema object that has failed validation MAY be skipped, as annotations are not retained for failing schemas.

    +

    +7.7.1. Collecting Annotations

    +

    Annotations are collected by keywords that explicitly define annotation-collecting behavior. Note that boolean schemas cannot produce annotations as they do not make use of keywords.

    +

    A collected annotation MUST include the following information:

    + +
      +
    • The name of the keyword that produces the annotation
    • +
    • The instance location to which it is attached, as a JSON Pointer
    • +
    • The schema location path, indicating how reference keywords such as "$ref" were followed to reach the absolute schema location.
    • +
    • The absolute schema location of the attaching keyword, as a URI. This MAY be omitted if it is the same as the schema location path from above.
    • +
    • The attached value(s)
    • +
    + +

    +

    +7.7.1.1. Distinguishing Among Multiple Values

    +

    Applications MAY make decisions on which of multiple annotation values to use based on the schema location that contributed the value. This is intended to allow flexible usage. Collecting the schema location facilitates such usage.

    +

    For example, consider this schema, which uses annotations and assertions from the Validation specification:

    +

    Note that some lines are wrapped for clarity.

    +
    +
    +{
    +    "title": "Feature list",
    +    "type": "array",
    +    "prefixItems": [
    +        {
    +            "title": "Feature A",
    +            "properties": {
    +                "enabled": {
    +                    "$ref": "#/$defs/enabledToggle",
    +                    "default": true
    +                }
    +            }
    +        },
    +        {
    +            "title": "Feature B",
    +            "properties": {
    +                "enabled": {
    +                    "description": "If set to null, Feature B
    +                                    inherits the enabled
    +                                    value from Feature A",
    +                    "$ref": "#/$defs/enabledToggle"
    +                }
    +            }
    +        }
    +    ],
    +    "$defs": {
    +        "enabledToggle": {
    +            "title": "Enabled",
    +            "description": "Whether the feature is enabled (true),
    +                            disabled (false), or under
    +                            automatic control (null)",
    +            "type": ["boolean", "null"],
    +            "default": null
    +        }
    +    }
    +}
    +
    +                            
    +

    In this example, both Feature A and Feature B make use of the re-usable "enabledToggle" schema. That schema uses the "title", "description", and "default" annotations. Therefore the application has to decide how to handle the additional "default" value for Feature A, and the additional "description" value for Feature B.

    +

    The application programmer and the schema author need to agree on the usage. For this example, let's assume that they agree that the most specific "default" value will be used, and any additional, more generic "default" values will be silently ignored. Let's also assume that they agree that all "description" text is to be used, starting with the most generic, and ending with the most specific. This requires the schema author to write descriptions that work when combined in this way.

    +

    The application can use the schema location path to determine which values are which. The values in the feature's immediate "enabled" property schema are more specific, while the values under the re-usable schema that is referenced to with "$ref" are more generic. The schema location path will show whether each value was found by crossing a "$ref" or not.

    +

    Feature A will therefore use a default value of true, while Feature B will use the generic default value of null. Feature A will only have the generic description from the "enabledToggle" schema, while Feature B will use that description, and also append its locally defined description that explains how to interpret a null value.

    +

    Note that there are other reasonable approaches that a different application might take. For example, an application may consider the presence of two different values for "default" to be an error, regardless of their schema locations.

    +

    +7.7.1.2. Annotations and Assertions

    +

    Schema objects that produce a false assertion result MUST NOT produce any annotation results, whether from their own keywords or from keywords in subschemas.

    +

    Note that the overall schema results may still include annotations collected from other schema locations. Given this schema:

    +
    +
    +{
    +    "oneOf": [
    +        {
    +            "title": "Integer Value",
    +            "type": "integer"
    +        },
    +        {
    +            "title": "String Value",
    +            "type": "string"
    +        }
    +    ]
    +}
    +
    +                            
    +

    Against the instance "This is a string", the title annotation "Integer Value" is discarded because the type assertion in that schema object fails. The title annotation "String Value" is kept, as the instance passes the string type assertions.

    +

    +7.7.1.3. Annotations and Applicators

    +

    In addition to possibly defining annotation results of their own, applicator keywords aggregate the annotations collected in their subschema(s) or referenced schema(s).

    +

    +7.8. Reserved Locations

    +

    A fourth category of keywords simply reserve a location to hold re-usable components or data of interest to schema authors that is not suitable for re-use. These keywords do not affect validation or annotation results. Their purpose in the core vocabulary is to ensure that locations are available for certain purposes and will not be redefined by extension keywords.

    +

    While these keywords do not directly affect results, as explained in section 9.4.2 unrecognized extension keywords that reserve locations for re-usable schemas may have undesirable interactions with references in certain circumstances.

    +

    +8. The JSON Schema Core Vocabulary

    +

    Keywords declared in this section, which all begin with "$", make up the JSON Schema Core vocabulary. These keywords are either required in order to process any schema or meta-schema, including those split across multiple documents, or exist to reserve keywords for purposes that require guaranteed interoperability.

    +

    The Core vocabulary MUST be considered mandatory at all times, in order to bootstrap the processing of further vocabularies. Meta-schemas that use the "$vocabulary" keyword to declare the vocabularies in use MUST explicitly list the Core vocabulary, which MUST have a value of true indicating that it is required.

    +

    The behavior of a false value for this vocabulary (and only this vocabulary) is undefined, as is the behavior when "$vocabulary" is present but the Core vocabulary is not included. However, it is RECOMMENDED that implementations detect these cases and raise an error when they occur. It is not meaningful to declare that a meta-schema optionally uses Core.

    +

    Meta-schemas that do not use "$vocabulary" MUST be considered to require the Core vocabulary as if its URI were present with a value of true.

    +

    The current URI for the Core vocabulary is: <https://json-schema.org/draft/2020-11/vocab/core>.

    +

    The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-11/meta/core>.

    +

    While the "$" prefix is not formally reserved for the Core vocabulary, it is RECOMMENDED that extension keywords (in vocabularies or otherwise) begin with a character other than "$" to avoid possible future collisions.

    +

    +8.1. Meta-Schemas and Vocabularies +

    +

    Two concepts, meta-schemas and vocabularies, are used to inform an implementation how to interpret a schema. Every schema has a meta-schema, which can be declared using the "$schema" keyword.

    +

    The meta-schema serves two purposes:

    + +
    +
    Declaring the vocabularies in use
    +
    The "$vocabulary" keyword, when it appears in a meta-schema, declares which vocabularies are available to be used in schemas that refer to that meta-schema. Vocabularies define keyword semantics, as well as their general syntax.
    +
    Describing valid schema syntax
    +
    A schema MUST successfully validate against its meta-schema, which constrains the syntax of the available keywords. The syntax described is expected to be compatible with the vocabularies declared; while it is possible to describe an incompatible syntax, such a meta-schema would be unlikely to be useful.
    +
    + +

    +

    Meta-schemas are separate from vocabularies to allow for vocabularies to be combined in different ways, and for meta-schema authors to impose additional constraints such as forbidding certain keywords, or performing unusually strict syntactical validation, as might be done during a development and testing cycle. Each vocabulary typically identifies a meta-schema consisting only of the vocabulary's keywords.

    +

    Meta-schema authoring is an advanced usage of JSON Schema, so the design of meta-schema features emphasizes flexibility over simplicity.

    +

    +8.1.1. The "$schema" Keyword +

    +

    The "$schema" keyword is both used as a JSON Schema feature set identifier and as the identifier of a resource which is itself a JSON Schema, which describes the set of valid schemas written for this particular feature set.

    +

    The value of this keyword MUST be a URI (containing a scheme) and this URI MUST be normalized. The current schema MUST be valid against the meta-schema identified by this URI.

    +

    If this URI identifies a retrievable resource, that resource SHOULD be of media type "application/schema+json".

    +

    The "$schema" keyword SHOULD be used in the document root schema object, and MAY be used in the root schema objects of embedded schema resources. It MUST NOT appear in non-resource root schema objects. If absent from the document root schema, the resulting behavior is implementation-defined.

    +

    Values for this property are defined elsewhere in this and other documents, and by other parties.

    +

    +8.1.2. The "$vocabulary" Keyword

    +

    The "$vocabulary" keyword is used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema. It is also used to indicate whether each vocabulary is required or optional, in the sense that an implementation MUST understand the required vocabularies in order to successfully process the schema.

    +

    The value of this keyword MUST be an object. The property names in the object MUST be URIs (containing a scheme) and this URI MUST be normalized. Each URI that appears as a property name identifies a specific set of keywords and their semantics.

    +

    The URI MAY be a URL, but the nature of the retrievable resource is currently undefined, and reserved for future use. Vocabulary authors MAY use the URL of the vocabulary specification, in a human-readable media type such as text/html or text/plain, as the vocabulary URI. [CREF2]Vocabulary documents may be added in forthcoming drafts. For now, identifying the keyword set is deemed sufficient as that, along with meta-schema validation, is how the current "vocabularies" work today. Any future vocabulary document format will be specified as a JSON document, so using text/html or other non-JSON formats in the meantime will not produce any future ambiguity.

    +

    The values of the object properties MUST be booleans. If the value is true, then implementations that do not recognize the vocabulary MUST refuse to process any schemas that declare this meta-schema with "$schema". If the value is false, implementations that do not recognize the vocabulary SHOULD proceed with processing such schemas.

    +

    Per 6.5, unrecognized keywords SHOULD be treated as annotations. This remains the case for keywords defined by unrecognized vocabularies. It is not currently possible to distinguish between unrecognized keywords that are defined in vocabularies from those that are not part of any vocabulary.

    +

    The "$vocabulary" keyword SHOULD be used in the root schema of any schema document intended for use as a meta-schema. It MUST NOT appear in subschemas.

    +

    The "$vocabulary" keyword MUST be ignored in schema documents that are not being processed as a meta-schema. This allows validating a meta-schema M against its own meta-schema M' without requiring the validator to understand the vocabularies declared by M.

    +

    +8.1.2.1. Default vocabularies

    +

    If "$vocabulary" is absent, an implementation MAY determine behavior based on the meta-schema if it is recognized from the URI value of the referring schema's "$schema" keyword. This is how behavior (such as Hyper-Schema usage) has been recognized prior to the existence of vocabularies.

    +

    If the meta-schema, as referenced by the schema, is not recognized, or is missing, then the behavior is implementation-defined. If the implementation proceeds with processing the schema, it MUST assume the use of the core vocabulary. If the implementation is built for a specific purpose, then it SHOULD assume the use of all of the most relevant vocabularies for that purpose.

    +

    For example, an implementation that is a validator SHOULD assume the use of all vocabularies in this specification and the companion Validation specification.

    +

    +8.1.2.2. Non-inheritability of vocabularies

    +

    Note that the processing restrictions on "$vocabulary" mean that meta-schemas that reference other meta-schemas using "$ref" or similar keywords do not automatically inherit the vocabulary declarations of those other meta-schemas. All such declarations must be repeated in the root of each schema document intended for use as a meta-schema. This is demonstrated in the example meta-schema. [CREF3]This requirement allows implementations to find all vocabulary requirement information in a single place for each meta-schema. As schema extensibility means that there are endless potential ways to combine more fine-grained meta-schemas by reference, requiring implementations to anticipate all possibilities and search for vocabularies in referenced meta-schemas would be overly burdensome.

    +

    +8.1.3. Updates to Meta-Schema and Vocabulary URIs

    +

    Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations SHOULD consider URIs dated after this specification draft and before the next to indicate the same syntax and semantics as those listed here.

    +

    +8.2. Base URI, Anchors, and Dereferencing

    +

    To differentiate between schemas in a vast ecosystem, schemas are identified by URI, and can embed references to other schemas by specifying their URI.

    +

    Several keywords can accept a relative URI-reference, or a value used to construct a relative URI-reference. For these keywords, it is necessary to establish a base URI in order to resolve the reference.

    +

    +8.2.1. The "$id" Keyword +

    +

    The "$id" keyword identifies a schema resource with its canonical URI.

    +

    Note that this URI is an identifier and not necessarily a network locator. In the case of a network-addressable URL, a schema need not be downloadable from its canonical URI.

    +

    If present, the value for this keyword MUST be a string, and MUST represent a valid URI-reference. This URI-reference SHOULD be normalized, and MUST resolve to an absolute-URI (without a fragment). Therefore, "$id" MUST NOT contain a non-empty fragment, and SHOULD NOT contain an empty fragment.

    +

    Since an empty fragment in the context of the application/schema+json media type refers to the same resource as the base URI without a fragment, an implementation MAY normalize a URI ending with an empty fragment by removing the fragment. However, schema authors SHOULD NOT rely on this behavior across implementations. [CREF4]This is primarily allowed because older meta-schemas have an empty fragment in their $id (or previously, id). A future draft may outright forbid even empty fragments in "$id".

    +

    This URI also serves as the base URI for relative URI-references in keywords within the schema resource, in accordance with RFC 3986 section 5.1.1 regarding base URIs embedded in content.

    +

    The presence of "$id" in a subschema indicates that the subschema constitutes a distinct schema resource within a single schema document. Furthermore, in accordance with RFC 3986 section 5.1.2 regarding encapsulating entities, if an "$id" in a subschema is a relative URI-reference, the base URI for resolving that reference is the URI of the parent schema resource.

    +

    If no parent schema object explicitly identifies itself as a resource with "$id", the base URI is that of the entire document, as established by the steps given in the previous section.

    +

    +8.2.1.1. Identifying the root schema

    +

    The root schema of a JSON Schema document SHOULD contain an "$id" keyword with an absolute-URI (containing a scheme, but no fragment).

    +

    +8.2.2. Defining location-independent identifiers +

    +

    Using JSON Pointer fragments requires knowledge of the structure of the schema. When writing schema documents with the intention to provide re-usable schemas, it may be preferable to use a plain name fragment that is not tied to any particular structural location. This allows a subschema to be relocated without requiring JSON Pointer references to be updated.

    +

    The "$anchor" and "$dynamicAnchor" keywords are used to specify such fragments. They are identifier keywords that can only be used to create plain name fragments, rather than absolute URIs as seen with "$id". The behavior of the created fragment is identical for both keywords.

    +

    The base URI to which the resulting fragment is appended is the canonical URI of the schema resource containing the "$anchor" or "$dynamicAnchor" in question. As discussed in the previous section, this is either the nearest "$id" in the same or parent schema object, or the base URI for the document as determined according to RFC 3986.

    +

    Separately from the usual usage of URIs, "$dynamicAnchor" indicates that the fragment is an extension point when used with the "$dynamicRef" keyword. This low-level, advanced feature makes it easier to extend recursive schemas such as the meta-schemas, without imposing any particular semantics on that extension. See the section on "$dynamicRef" for details.

    +

    In most cases, the normal fragment behavior both suffices and is more intuitive. Therefore it is RECOMMENDED that "$anchor" be used to create plain name fragments unless there is a clear need for "$dynamicAnchor".

    +

    If present, the value of this keyword MUST be a string and MUST start with a letter ([A-Za-z]) or underscore ("_"), followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), and periods ("."). This matches the US-ASCII part of XML's NCName production. [CREF5]Note that the anchor string does not include the "#" character, as it is not a URI-reference. An "$anchor": "foo" becomes the fragment "#foo" when used in a URI. See below for full examples.

    +

    The effect of specifying the same fragment name multiple times within the same resource, using any combination of "$anchor" and/or "$dynamicAnchor", is undefined. Implementations MAY raise an error if such usage is detected.

    +

    +8.2.3. Schema References +

    +

    Several keywords can be used to reference a schema which is to be applied to the current instance location. "$ref" and "$dynamicRef" are applicator keywords, applying the referenced schema to the instance.

    +

    As the values of "$ref" and "$dynamicRef" are URI References, this allows the possibility to externalise or divide a schema across multiple files, and provides the ability to validate recursive structures through self-reference.

    +

    The resolved URI produced by these keywords is not necessarily a network locator, only an identifier. A schema need not be downloadable from the address if it is a network-addressable URL, and implementations SHOULD NOT assume they should perform a network operation when they encounter a network-addressable URI.

    +

    +8.2.3.1. Direct References with "$ref" +

    +

    The "$ref" keyword is an applicator that is used to reference a statically identified schema. Its results are the results of the referenced schema. [CREF6]Note that this definition of how the results are determined means that other keywords can appear alongside of "$ref" in the same schema object.

    +

    The value of the "$ref" property MUST be a string which is a URI-Reference. Resolved against the current URI base, it produces the URI of the schema to apply. This resolution is safe to perform on schema load, as the process of evaluating an instance cannot change how the reference resolves.

    +

    +8.2.3.2. Dynamic References with "$dynamicRef" +

    +

    The "$dynamicRef" keyword is an applicator that allows for deferring the full resolution until runtime, at which point it is resolved each time it is encountered while evaluating an instance.

    +

    Together with "$dynamicAnchor", "$dynamicRef" implements a cooperative extension mechanism that is primarily useful with recursive schemas (schemas that reference themselves). Both the extension point and the runtime-determined extension target are defined with "$dynamicAnchor", and only exhibit runtime dynamic behavior when referenced with "$dynamicRef".

    +

    The value of the "$dynamicRef" property MUST be a string which is a URI-Reference. Resolved against the current URI base, it produces the URI used as the starting point for runtime resolution. This initial resolution is safe to perform on schema load.

    +

    If the initially resolved starting point URI includes a fragment that was created by the "$dynamicAnchor" keyword, the initial URI MUST be replaced by the URI (including the fragment) for the outermost schema resource in the dynamic scope that defines an identically named fragment with "$dynamicAnchor". [CREF7]Requiring both the initial and final URI fragment to be defined by "$dynamicAnchor" ensures that the more common "$anchor" never unexpectedly changes the dynamic resolution process due to a naming conflict across resources. Users of "$dynamicAnchor" are expected to be aware of the possibility of such name collisions, while users of "$anchor" are not.

    +

    Otherwise, its behavior is identical to "$ref", and no runtime resolution is needed.

    +

    For a full example using these keyword, see appendix C. [CREF8]The difference between the hyper-schema meta-schema in pre-2019 drafts and an this draft dramatically demonstrates the utility of these keywords.

    +

    +8.2.4. Schema Re-Use With "$defs" +

    +

    The "$defs" keyword reserves a location for schema authors to inline re-usable JSON Schemas into a more general schema. The keyword does not directly affect the validation result.

    +

    This keyword's value MUST be an object. Each member value of this object MUST be a valid JSON Schema.

    +

    As an example, here is a schema describing an array of positive integers, where the positive integer constraint is a subschema in "$defs":

    +
    +
    +{
    +    "type": "array",
    +    "items": { "$ref": "#/$defs/positiveInteger" },
    +    "$defs": {
    +        "positiveInteger": {
    +            "type": "integer",
    +            "exclusiveMinimum": 0
    +        }
    +    }
    +}
    +
    +                        
    +

    +8.3. Comments With "$comment"

    +

    This keyword reserves a location for comments from schema authors to readers or maintainers of the schema.

    +

    The value of this keyword MUST be a string. Implementations MUST NOT present this string to end users. Tools for editing schemas SHOULD support displaying and editing this keyword. The value of this keyword MAY be used in debug or error output which is intended for developers making use of schemas.

    +

    Schema vocabularies SHOULD allow "$comment" within any object containing vocabulary keywords. Implementations MAY assume "$comment" is allowed unless the vocabulary specifically forbids it. Vocabularies MUST NOT specify any effect of "$comment" beyond what is described in this specification.

    +

    Tools that translate other media types or programming languages to and from application/schema+json MAY choose to convert that media type or programming language's native comments to or from "$comment" values. The behavior of such translation when both native comments and "$comment" properties are present is implementation-dependent.

    +

    Implementations SHOULD treat "$comment" identically to an unknown extension keyword. They MAY strip "$comment" values at any point during processing. In particular, this allows for shortening schemas when the size of deployed schemas is a concern.

    +

    Implementations MUST NOT take any other action based on the presence, absence, or contents of "$comment" properties. In particular, the value of "$comment" MUST NOT be collected as an annotation result.

    +

    +9. Loading and Processing Schemas

    +

    +

    +9.1. Loading a Schema

    +

    +9.1.1. Initial Base URI +

    +

    RFC3986 Section 5.1 defines how to determine the default base URI of a document.

    +

    Informatively, the initial base URI of a schema is the URI at which it was found, whether that was a network location, a local filesystem, or any other situation identifiable by a URI of any known scheme.

    +

    If a schema document defines no explicit base URI with "$id" (embedded in content), the base URI is that determined per RFC 3986 section 5.

    +

    If no source is known, or no URI scheme is known for the source, a suitable implementation-specific default URI MAY be used as described in RFC 3986 Section 5.1.4. It is RECOMMENDED that implementations document any default base URI that they assume.

    +

    If a schema object is embedded in a document of another media type, then the initial base URI is determined according to the rules of that media type.

    +

    Unless the "$id" keyword described in the next section is present in the root schema, this base URI SHOULD be considered the canonical URI of the schema document's root schema resource.

    +

    +9.1.2. Loading a referenced schema

    +

    The use of URIs to identify remote schemas does not necessarily mean anything is downloaded, but instead JSON Schema implementations SHOULD understand ahead of time which schemas they will be using, and the URIs that identify them.

    +

    When schemas are downloaded, for example by a generic user-agent that doesn't know until runtime which schemas to download, see Usage for Hypermedia.

    +

    Implementations SHOULD be able to associate arbitrary URIs with an arbitrary schema and/or automatically associate a schema's "$id"-given URI, depending on the trust that the validator has in the schema. Such URIs and schemas can be supplied to an implementation prior to processing instances, or may be noted within a schema document as it is processed, producing associations as shown in appendix A.

    +

    A schema MAY (and likely will) have multiple URIs, but there is no way for a URI to identify more than one schema. When multiple schemas try to identify as the same URI, validators SHOULD raise an error condition.

    +

    +9.1.3. Detecting a Meta-Schema

    +

    Implementations MUST recognize a schema as a meta-schema if it is being examined because it was identified as such by another schema's "$schema" keyword. This means that a single schema document might sometimes be considered a regular schema, and other times be considered a meta-schema.

    +

    In the case of examining a schema which is its own meta-schema, when an implementation begins processing it as a regular schema, it is processed under those rules. However, when loaded a second time as a result of checking its own "$schema" value, it is treated as a meta-schema. So the same document is processed both ways in the course of one session.

    +

    Implementations MAY allow a schema to be explicitly passed as a meta-schema, for implementation-specific purposes, such as pre-loading a commonly used meta-schema and checking its vocabulary support requirements up front. Meta-schema authors MUST NOT expect such features to be interoperable across implementations.

    +

    +9.2. Dereferencing

    +

    Schemas can be identified by any URI that has been given to them, including a JSON Pointer or their URI given directly by "$id". In all cases, dereferencing a "$ref" reference involves first resolving its value as a URI reference against the current base URI per RFC 3986.

    +

    If the resulting URI identifies a schema within the current document, or within another schema document that has been made available to the implementation, then that schema SHOULD be used automatically.

    +

    For example, consider this schema:

    +
    +
    +{
    +    "$id": "https://example.net/root.json",
    +    "items": {
    +        "type": "array",
    +        "items": { "$ref": "#item" }
    +    },
    +    "$defs": {
    +        "single": {
    +            "$anchor": "item",
    +            "type": "object",
    +            "additionalProperties": { "$ref": "other.json" }
    +        }
    +    }
    +}
    +
    +                    
    +

    When an implementation encounters the <#/$defs/single> schema, it resolves the "$anchor" value as a fragment name against the current base URI to form <https://example.net/root.json#item>.

    +

    When an implementation then looks inside the <#/items> schema, it encounters the <#item> reference, and resolves this to <https://example.net/root.json#item>, which it has seen defined in this same document and can therefore use automatically.

    +

    When an implementation encounters the reference to "other.json", it resolves this to <https://example.net/other.json>, which is not defined in this document. If a schema with that identifier has otherwise been supplied to the implementation, it can also be used automatically. [CREF9]What should implementations do when the referenced schema is not known? Are there circumstances in which automatic network dereferencing is allowed? A same origin policy? A user-configurable option? In the case of an evolving API described by Hyper-Schema, it is expected that new schemas will be added to the system dynamically, so placing an absolute requirement of pre-loading schema documents is not feasible.

    +

    +9.2.1. JSON Pointer fragments and embedded schema resources +

    +

    Since JSON Pointer URI fragments are constructed based on the structure of the schema document, an embedded schema resource and its subschemas can be identified by JSON Pointer fragments relative to either its own canonical URI, or relative to the containing resource's URI.

    +

    Conceptually, a set of linked schema resources should behave identically whether each resource is a separate document connected with schema references, or is structured as a single document with one or more schema resources embedded as subschemas.

    +

    Since URIs involving JSON Pointer fragments relative to the parent schema resource's URI cease to be valid when the embedded schema is moved to a separate document and referenced, applications and schemas SHOULD NOT use such URIs to identify embedded schema resources or locations within them.

    +

    Consider the following schema document that contains another schema resource embedded within it:

    +
    +
    +{
    +    "$id": "https://example.com/foo",
    +    "items": {
    +        "$id": "https://example.com/bar",
    +        "additionalProperties": { }
    +    }
    +}
    +
    +                        
    +

    The URI "https://example.com/foo#/items/additionalProperties" points to the schema of the "additionalProperties" keyword in the embedded resource. The canonical URI of that schema, however, is "https://example.com/bar#/additionalProperties".

    +

    Now consider the following two schema resources linked by reference using a URI value for "$ref":

    +
    +
    +{
    +    "$id": "https://example.com/foo",
    +    "items": {
    +        "$ref": "bar"
    +    }
    +}
    +
    +{
    +    "$id": "https://example.com/bar",
    +    "additionalProperties": { }
    +}
    +
    +                        
    +

    Here we see that the canonical URI for that "additionalProperties" subschema is still valid, while the non-canonical URI with the fragment beginning with "#/items/$ref" now resolves to nothing.

    +

    Note also that "https://example.com/foo#/items" is valid in both arrangements, but resolves to a different value. This URI ends up functioning similarly to a retrieval URI for a resource. While valid, examining the resolved value and either using the "$id" (if the value is a subschema), or resolving the reference and using the "$id" of the reference target, is preferable.

    +

    An implementation MAY choose not to support addressing schemas by non-canonical URIs. As such, it is RECOMMENDED that schema authors only use canonical URIs, as using non-canonical URIs may reduce schema interoperability. [CREF10]This is to avoid requiring implementations to keep track of a whole stack of possible base URIs and JSON Pointer fragments for each, given that all but one will be fragile if the schema resources are reorganized. Some have argued that this is easy so there is no point in forbidding it, while others have argued that it complicates schema identification and should be forbidden. Feedback on this topic is encouraged.

    +

    Further examples of such non-canonical URIs, as well as the appropriate canonical URIs to use instead, are provided in appendix A.

    +

    +9.3. Compound Documents

    +

    A Compound Schema Document is defined as JSON document (sometimes called a "bundled" schema) which has multiple embedded JSON Schema Resources bundled into the same document to ease transportation.

    +

    Each embedded Schema Resource MUST be treated as an individual Schema Resource, following standard schema loading and processing requirements, including determining vocabulary support.

    +

    +9.3.1. Bundling

    +

    The bundling process for creating a Compound Schema Document is defined as taking references (such as "$ref") to an external Schema Resource and embedding the referenced Schema Resources within the referring document. Bundling is done in such a way that all URIs (used for referencing) in the base document and any referenced/embedded documents do not require altering.

    +

    Each embedded JSON Schema Resource MUST identify itself with an absolute URI using the "$id" keyword, and SHOULD make use of the "$schema" keyword to identify the dialect it is using, in the root of the schema resource.

    +

    When the Schema Resource referenced by a by-reference applicator is bundled, the Schema Resource MUST be located as a value of a "$defs" object at the containing schema's root. The key of the "$defs" for the now embedded Schema Resource MAY be the "$id" of the bundled schema or some other form of application defined unique identifer (such as a UUID). This key is not intended to be referenced in JSON Schema, but may be used by an application to aid the bundling process.

    +

    Bundled Schema Resource MUST NOT be bundled by replacing the schema object from which it was referenced, or by wrapping the Schema Resource in other applicator keywords.

    +

    In order to produce identical output, references in the containing schema document to the previously external Schema Resources MUST NOT be changed, and now resolve to a schema using the "$id" of an embedded Schema Resource. Such identical output includes validation evaluation and URIs or paths used in resulting annotations or errors.

    +

    While the bundling process will often be the main method for creating a Compound Schema Document, it is also possible and expected that some will be created by hand, potentially without individual Schema Resources existing on their own previously.

    +

    +9.3.2. Differing and Default Dialects

    +

    If multiple schema resources are present in a single document, then schema resources which do not have a "$schema" keyword in their root schema object MUST be processed as if "$schema" were present with the same value as for the immediately enclosing resource.

    +

    Since any schema that can be referenced can also be embedded, embedded schema resources MAY specify different "$schema" values from their enclosing resource.

    +

    +9.3.3. Validating

    +

    Given that a Compound Schema Document may have embedded resources which identify as using different dialects, these documents SHOULD NOT be validated by applying a meta-schema to the Compound Schema Document as an instance. It is RECOMMENDED that an alternate validation process be provided in order to validate Schema Documents. Each Schema Resource SHOULD be separately validated against its associated meta-schema. [CREF11]If you know a schema is what's being validated, you can identify if the schemas is a Compound Schema Document or not, by way of use of "$id", which identifies an embedded resource when used not at the document's root.

    +

    A Compound Schema Document in which all embedded resources identify as using the same dialect, or in which "$schema" is omitted and therefore defaults to that of the enclosing resource, MAY be validated by applying the appropriate meta-schema.

    +

    +9.4. Caveats

    +

    +9.4.1. Guarding Against Infinite Recursion

    +

    A schema MUST NOT be run into an infinite loop against an instance. For example, if two schemas "#alice" and "#bob" both have an "allOf" property that refers to the other, a naive validator might get stuck in an infinite recursive loop trying to validate the instance. Schemas SHOULD NOT make use of infinite recursive nesting like this; the behavior is undefined.

    +

    +9.4.2. References to Possible Non-Schemas +

    +

    Subschema objects (or booleans) are recognized by their use with known applicator keywords or with location-reserving keywords such as "$defs" that take one or more subschemas as a value. These keywords may be "$defs" and the standard applicators from this document, or extension keywords from a known vocabulary, or implementation-specific custom keywords.

    +

    Multi-level structures of unknown keywords are capable of introducing nested subschemas, which would be subject to the processing rules for "$id". Therefore, having a reference target in such an unrecognized structure cannot be reliably implemented, and the resulting behavior is undefined. Similarly, a reference target under a known keyword, for which the value is known not to be a schema, results in undefined behavior in order to avoid burdening implementations with the need to detect such targets. [CREF12]These scenarios are analogous to fetching a schema over HTTP but receiving a response with a Content-Type other than application/schema+json. An implementation can certainly try to interpret it as a schema, but the origin server offered no guarantee that it actually is any such thing. Therefore, interpreting it as such has security implications and may produce unpredictable results.

    +

    Note that single-level custom keywords with identical syntax and semantics to "$defs" do not allow for any intervening "$id" keywords, and therefore will behave correctly under implementations that attempt to use any reference target as a schema. However, this behavior is implementation-specific and MUST NOT be relied upon for interoperability.

    +

    +9.5. Associating Instances and Schemas

    +

    +9.5.1. Usage for Hypermedia +

    +

    JSON has been adopted widely by HTTP servers for automated APIs and robots. This section describes how to enhance processing of JSON documents in a more RESTful manner when used with protocols that support media types and Web linking.

    +

    +9.5.1.1. Linking to a Schema

    +

    It is RECOMMENDED that instances described by a schema provide a link to a downloadable JSON Schema using the link relation "describedby", as defined by Linked Data Protocol 1.0, section 8.1.

    +

    In HTTP, such links can be attached to any response using the Link header. An example of such a header would be:

    +
    +        
    +        Link: <https://example.com/my-hyper-schema>; rel="describedby"
    +        
    +                            
    +

    +9.5.1.2. Identifying a Schema via a Media Type Parameter +

    +

    Media types MAY allow for a "schema" media type parameter, which gives HTTP servers the ability to perform Content-Type Negotiation based on schema. The media-type parameter MUST be a whitespace-separated list of URIs (i.e. relative references are invalid).

    +

    When using the media type application/schema-instance+json, the "schema" parameter MUST be supplied.

    +

    When using the media type application/schema+json, the "schema" parameter MAY be supplied. If supplied, it SHOULD contain the same URI as identified by the "$schema" keyword, and MAY contain additional URIs. The "$schema" URI MUST be considered the schema's canonical meta-schema, regardless of the presence of alternative or additional meta-schemas as a media type parameter.

    +

    The schema URI is opaque and SHOULD NOT automatically be dereferenced. If the implementation does not understand the semantics of the provided schema, the implementation can instead follow the "describedby" links, if any, which may provide information on how to handle the schema. Since "schema" doesn't necessarily point to a network location, the "describedby" relation is used for linking to a downloadable schema. However, for simplicity, schema authors should make these URIs point to the same resource when possible.

    +

    In HTTP, the media-type parameter would be sent inside the Content-Type header:

    +
    +        
    +        Content-Type: application/schema-instance+json;
    +                  schema="https://example.com/my-hyper-schema"
    +        
    +                            
    +

    Multiple schemas are whitespace separated, and indicate that the instance conforms to all of the listed schemas:

    +
    +        
    +        Content-Type: application/schema-instance+json;
    +                  schema="https://example.com/alice https://example.com/bob"
    +        
    +                            
    +

    Media type parameters are also used in HTTP's Accept request header:

    +
    +        
    +        Accept: application/schema-instance+json;
    +                  schema="https://example.com/qiang https://example.com/li",
    +                application/schema-instance+json;
    +                  schema="https://example.com/kumar"
    +        
    +                            
    +

    As with Content-Type, multiple schema parameters in the same string requests an instance that conforms to all of the listed schemas.

    +

    Unlike Content-Type, Accept can contain multiple values to indicate that the client can accept several media types. In the above example, note that the two media types differ only by their schema parameter values. This requests an application/schema-instance+json representation that conforms to at least one of the identified schemas.

    +

    [CREF13]This paragraph assumes that we can register a "schema" link relation. Should we instead specify something like "tag:json-schema.org,2017:schema" for now? HTTP can also send the "schema" in a Link, though this may impact media-type semantics and Content-Type negotiation if this replaces the media-type parameter entirely:

    +
    +        
    +        Link: </alice>;rel="schema", </bob>;rel="schema"
    +        
    +                            
    +

    +9.5.1.3. Usage Over HTTP

    +

    When used for hypermedia systems over a network, HTTP is frequently the protocol of choice for distributing schemas. Misbehaving clients can pose problems for server maintainers if they pull a schema over the network more frequently than necessary, when it's instead possible to cache a schema for a long period of time.

    +

    HTTP servers SHOULD set long-lived caching headers on JSON Schemas. HTTP clients SHOULD observe caching headers and not re-request documents within their freshness period. Distributed systems SHOULD make use of a shared cache and/or caching proxy.

    +

    Clients SHOULD set or prepend a User-Agent header specific to the JSON Schema implementation or software product. Since symbols are listed in decreasing order of significance, the JSON Schema library name/version should precede the more generic HTTP library name (if any). For example:

    +
    +        
    +        User-Agent: product-name/5.4.1 so-cool-json-schema/1.0.2 curl/7.43.0
    +        
    +                            
    +

    Clients SHOULD be able to make requests with a "From" header so that server operators can contact the owner of a potentially misbehaving script.

    +

    +10. A Vocabulary for Applying Subschemas

    +

    This section defines a vocabulary of applicator keywords that are RECOMMENDED for use as the basis of other vocabularies.

    +

    Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

    +

    The current URI for this vocabulary, known as the Applicator vocabulary, is: <https://json-schema.org/draft/2020-11/vocab/applicator>.

    +

    The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-11/meta/applicator>.

    +

    Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations SHOULD consider URIs dated after this specification draft and before the next to indicate the same syntax and semantics as those listed here.

    +

    +10.1. Keyword Independence

    +

    Schema keywords typically operate independently, without affecting each other's outcomes.

    +

    For schema author convenience, there are some exceptions among the keywords in this vocabulary:

    + +
      +
    • "additionalProperties", whose behavior is defined in terms of "properties" and "patternProperties"
    • +
    • "unevaluatedProperties", whose behavior is defined in terms of annotations from "properties", "patternProperties", "additionalProperties" and itself
    • +
    • "items", whose behavior is defined in terms of "prefixItems"
    • +
    • "unevaluatedItems", whose behavior is defined in terms of annotations from "prefixItems", "items", "contains", and itself
    • +
    + +

    +

    +10.2. Keywords for Applying Subschemas in Place +

    +

    These keywords apply subschemas to the same location in the instance as the parent schema is being applied. They allow combining or modifying the subschema results in various ways.

    +

    +10.2.1. Keywords for Applying Subschemas With Logic +

    +

    These keywords correspond to logical operators for combining or modifying the boolean assertion results of the subschemas. They have no direct impact on annotation collection, although they enable the same annotation keyword to be applied to an instance location with different values. Annotation keywords define their own rules for combining such values.

    +

    +10.2.1.1. allOf +

    +

    This keyword's value MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.

    +

    An instance validates successfully against this keyword if it validates successfully against all schemas defined by this keyword's value.

    +

    +10.2.1.2. anyOf

    +

    This keyword's value MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.

    +

    An instance validates successfully against this keyword if it validates successfully against at least one schema defined by this keyword's value. Note that when annotations are being collected, all subschemas MUST be examined so that annotations are collected from each subschema that validates successfully.

    +

    +10.2.1.3. oneOf

    +

    This keyword's value MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.

    +

    An instance validates successfully against this keyword if it validates successfully against exactly one schema defined by this keyword's value.

    +

    +10.2.1.4. not +

    +

    This keyword's value MUST be a valid JSON Schema.

    +

    An instance is valid against this keyword if it fails to validate successfully against the schema defined by this keyword.

    +

    +10.2.2. Keywords for Applying Subschemas Conditionally +

    +

    Three of these keywords work together to implement conditional application of a subschema based on the outcome of another subschema. The fourth is a shortcut for a specific conditional case.

    +

    "if", "then", and "else" MUST NOT interact with each other across subschema boundaries. In other words, an "if" in one branch of an "allOf" MUST NOT have an impact on a "then" or "else" in another branch.

    +

    There is no default behavior for "if", "then", or "else" when they are not present. In particular, they MUST NOT be treated as if present with an empty schema, and when "if" is not present, both "then" and "else" MUST be entirely ignored.

    +

    +10.2.2.1. if

    +

    This keyword's value MUST be a valid JSON Schema.

    +

    This validation outcome of this keyword's subschema has no direct effect on the overall validation result. Rather, it controls which of the "then" or "else" keywords are evaluated.

    +

    Instances that successfully validate against this keyword's subschema MUST also be valid against the subschema value of the "then" keyword, if present.

    +

    Instances that fail to validate against this keyword's subschema MUST also be valid against the subschema value of the "else" keyword, if present.

    +

    If annotations are being collected, they are collected from this keyword's subschema in the usual way, including when the keyword is present without either "then" or "else".

    +

    +10.2.2.2. then

    +

    This keyword's value MUST be a valid JSON Schema.

    +

    When "if" is present, and the instance successfully validates against its subschema, then validation succeeds against this keyword if the instance also successfully validates against this keyword's subschema.

    +

    This keyword has no effect when "if" is absent, or when the instance fails to validate against its subschema. Implementations MUST NOT evaluate the instance against this keyword, for either validation or annotation collection purposes, in such cases.

    +

    +10.2.2.3. else

    +

    This keyword's value MUST be a valid JSON Schema.

    +

    When "if" is present, and the instance fails to validate against its subschema, then validation succeeds against this keyword if the instance successfully validates against this keyword's subschema.

    +

    This keyword has no effect when "if" is absent, or when the instance successfully validates against its subschema. Implementations MUST NOT evaluate the instance against this keyword, for either validation or annotation collection purposes, in such cases.

    +

    +10.2.2.4. dependentSchemas

    +

    This keyword specifies subschemas that are evaluated if the instance is an object and contains a certain property.

    +

    This keyword's value MUST be an object. Each value in the object MUST be a valid JSON Schema.

    +

    If the object key is a property in the instance, the entire instance must validate against the subschema. Its use is dependent on the presence of the property.

    +

    Omitting this keyword has the same behavior as an empty object.

    +

    +10.3. Keywords for Applying Subschemas to Child Instances

    +

    Each of these keywords defines a rule for applying its subschema(s) to child instances, specifically object properties and array items, and combining their results.

    +

    +10.3.1. Keywords for Applying Subschemas to Arrays

    +

    +10.3.1.1. prefixItems

    +

    The value of "prefixItems" MUST be a non-empty array of valid JSON Schemas.

    +

    Validation succeeds if each element of the instance validates against the schema at the same position, if any. This keyword does not constrain the length of the array. If the array is longer than this keyword's value, this keyword validates only the prefix of matching length.

    +

    This keyword produces an annotation value which is the largest index to which this keyword applied a subschema. The value MAY be a boolean true if a subschema was applied to every index of the instance, such as is produced by the "items" keyword. This annotation affects the behavior of "items" and "unevaluatedItems".

    +

    Omitting this keyword has the same assertion behavior as an empty array.

    +

    +10.3.1.2. items +

    +

    The value of "items" MUST be a valid JSON Schema.

    +

    This keyword applies its subschema to all instance elements at indexes greater than the length of the "prefixItems" array in the same schema object, as reported by the annotation result of that "prefixItems" keyword. If no such annotation result exists, "items" applies its subschema to all instance array elements. [CREF14]Note that the behavior of "items" without "prefixItems" is identical to that of the schema form of "items" in prior drafts. When "prefixItems" is present, the behavior of "items" is identical to the former "additionalItems" keyword.

    +

    If the "items" subschema is applied to any positions within the instance array, it produces an annotation result of boolean true, indicating that all remaining array elements have been evaluated against this keyword's subschema.

    +

    Omitting this keyword has the same assertion behavior as an empty schema.

    +

    Implementations MAY choose to implement or optimize this keyword in another way that produces the same effect, such as by directly checking for the presence and size of a "prefixItems" array. Implementations that do not support annotation collection MUST do so.

    +

    +10.3.1.3. contains

    +

    The value of this keyword MUST be a valid JSON Schema.

    +

    An array instance is valid against "contains" if at least one of its elements is valid against the given schema. Note that when collecting annotations, the subschema MUST be applied to every array element even after the first match has been found. This is to ensure that all possible annotations are collected.

    +

    This keyword produces an annotation value which is an array of the indexes to which this keyword validates successfully when applying its subschema, in ascending order. The value MAY be a boolean true if the subschema validated successfully when applied to every index of the instance.

    +

    +10.3.2. Keywords for Applying Subschemas to Objects

    +

    +10.3.2.1. properties

    +

    The value of "properties" MUST be an object. Each value of this object MUST be a valid JSON Schema.

    +

    Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value, the child instance for that name successfully validates against the corresponding schema.

    +

    The annotation result of this keyword is the set of instance property names matched by this keyword. Annotation results for "properties" keywords from multiple schemas applied to the same instance location are combined by taking the union of the sets.

    +

    Omitting this keyword has the same assertion behavior as an empty object.

    +

    +10.3.2.2. patternProperties

    +

    The value of "patternProperties" MUST be an object. Each property name of this object SHOULD be a valid regular expression, according to the ECMA-262 regular expression dialect. Each property value of this object MUST be a valid JSON Schema.

    +

    Validation succeeds if, for each instance name that matches any regular expressions that appear as a property name in this keyword's value, the child instance for that name successfully validates against each schema that corresponds to a matching regular expression.

    +

    The annotation result of this keyword is the set of instance property names matched by this keyword. Annotation results for "patternProperties" keywords from multiple schemas applied to the same instance location are combined by taking the union of the sets.

    +

    Omitting this keyword has the same assertion behavior as an empty object.

    +

    +10.3.2.3. additionalProperties +

    +

    The value of "additionalProperties" MUST be a valid JSON Schema.

    +

    The behavior of this keyword depends on the presence and annotation results of "properties" and "patternProperties" within the same schema object. Validation with "additionalProperties" applies only to the child values of instance names that do not appear in the annotation results of either "properties" or "patternProperties".

    +

    For all such properties, validation succeeds if the child instance validates against the "additionalProperties" schema.

    +

    The annotation result of this keyword is the set of instance property names validated by this keyword's subschema. Annotation results for "additionalProperties" keywords from multiple schemas applied to the same instance location are combined by taking the union of the sets.

    +

    Omitting this keyword has the same assertion behavior as an empty schema.

    +

    Implementations MAY choose to implement or optimize this keyword in another way that produces the same effect, such as by directly checking the names in "properties" and the patterns in "patternProperties" against the instance property set. Implementations that do not support annotation collection MUST do so.

    +

    +10.3.2.4. propertyNames

    +

    The value of "propertyNames" MUST be a valid JSON Schema.

    +

    If the instance is an object, this keyword validates if every property name in the instance validates against the provided schema. Note the property name that the schema is testing will always be a string.

    +

    Omitting this keyword has the same behavior as an empty schema.

    +

    +11. A Vocabulary for Unevaluated Locations

    +

    The purpose of these keywords is to enable schema authors to apply subschemas to array items or object properties that have not been successfully evaluated against any dynamic-scope subschema of any adjacent keywords.

    +

    These instance items or properties may have been unsuccessfully evaluated against one or more adjacent keyword subschemas, such as when an assertion in a branch of an "anyOf" fails. Such failed evaluations are not considered to contribute to whether or not the item or property has been evaluated. Only successful evaluations are considered.

    +

    Recall that adjacent keywords are keywords within the same schema object, and that the dynamic-scope subschemas include reference targets as well as lexical subschemas.

    +

    The behavior of these keywords depend on the annotation results of adjacent keywords that apply to the instance location being validated.

    +

    Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

    +

    The current URI for this vocabulary, known as the Unevaluated Applicator vocabulary, is: <https://json-schema.org/draft/2020-11/vocab/unevaluated>.

    +

    The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-11/meta/unevaluated>.

    +

    Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations SHOULD consider URIs dated after this specification draft and before the next to indicate the same syntax and semantics as those listed here.

    +

    +11.1. unevaluatedItems +

    +

    The value of "unevaluatedItems" MUST be a valid JSON Schema.

    +

    The behavior of this keyword depends on the annotation results of adjacent keywords that apply to the instance location being validated. Specifically, the annotations from "prefixItems", "items", and "contains", which can come from those keywords when they are adjacent to the "unevaluatedItems" keyword. Those two annotations, as well as "unevaluatedItems", can also result from any and all adjacent in-place applicator keywords. This includes but is not limited to the in-place applicators defined in this document.

    +

    If no relevant annotations are present, the "unevaluatedItems" subschema MUST be applied to all locations in the array. If a boolean true value is present from any of the relevant annotations, "unevaluatedItems" MUST be ignored. Otherwise, the subschema MUST be applied to any index greater than the largest annotation value for "prefixItems", which does not appear in any annotation value for "contains".

    +

    This means that "prefixItems", "items", "contains", and all in-place applicators MUST be evaluated before this keyword can be evaluated. Authors of extension keywords MUST NOT define an in-place applicator that would need to be evaluated before this keyword.

    +

    If the "unevaluatedItems" subschema is applied to any positions within the instance array, it produces an annotation result of boolean true, analogous to the behavior of "items".

    +

    Omitting this keyword has the same assertion behavior as an empty schema.

    +

    +11.2. unevaluatedProperties +

    +

    The value of "unevaluatedProperties" MUST be a valid JSON Schema.

    +

    The behavior of this keyword depends on the annotation results of adjacent keywords that apply to the instance location being validated. Specifically, the annotations from "properties", "patternProperties", and "additionalProperties", which can come from those keywords when they are adjacent to the "unevaluatedProperties" keyword. Those three annotations, as well as "unevaluatedProperties", can also result from any and all adjacent in-place applicator keywords. This includes but is not limited to the in-place applicators defined in this document.

    +

    Validation with "unevaluatedProperties" applies only to the child values of instance names that do not appear in the "properties", "patternProperties", "additionalProperties", or "unevaluatedProperties" annotation results that apply to the instance location being validated.

    +

    For all such properties, validation succeeds if the child instance validates against the "unevaluatedProperties" schema.

    +

    This means that "properties", "patternProperties", "additionalProperties", and all in-place applicators MUST be evaluated before this keyword can be evaluated. Authors of extension keywords MUST NOT define an in-place applicator that would need to be evaluated before this keyword.

    +

    The annotation result of this keyword is the set of instance property names validated by this keyword's subschema. Annotation results for "unevaluatedProperties" keywords from multiple schemas applied to the same instance location are combined by taking the union of the sets.

    +

    Omitting this keyword has the same assertion behavior as an empty schema.

    +

    +12. Output Formatting +

    +

    JSON Schema is defined to be platform-independent. As such, to increase compatibility across platforms, implementations SHOULD conform to a standard validation output format. This section describes the minimum requirements that consumers will need to properly interpret validation results.

    +

    +12.1. Format

    +

    JSON Schema output is defined using the JSON Schema data instance model as described in section 4.2.1. Implementations MAY deviate from this as supported by their specific languages and platforms, however it is RECOMMENDED that the output be convertible to the JSON format defined herein via serialization or other means.

    +

    +12.2. Output Formats

    +

    This specification defines four output formats. See the "Output Structure" section for the requirements of each format.

    + +
      +
    • Flag - A boolean which simply indicates the overall validation result with no further details.
    • +
    • Basic - Provides validation information in a flat list structure.
    • +
    • Detailed - Provides validation information in a condensed hierarchical structure based on the structure of the schema.
    • +
    • Verbose - Provides validation information in an uncondensed hierarchical structure that matches the exact structure of the schema.
    • +
    + +

    An implementation SHOULD provide at least the "flag", "basic", or "detailed" format and MAY provide the "verbose" format. If it provides one or more of the complex formats, it MUST also provide the "flag" format. Implementations SHOULD specify in their documentation which formats they support.

    +

    +12.3. Minimum Information

    +

    Beyond the simplistic "flag" output, additional information is useful to aid in debugging a schema or instance. Each sub-result SHOULD contain the information contained within this section at a minimum.

    +

    A single object that contains all of these components is considered an output unit.

    +

    Implementations MAY elect to provide additional information.

    +

    +12.3.1. Keyword Relative Location

    +

    The relative location of the validating keyword that follows the validation path. The value MUST be expressed as a JSON Pointer, and it MUST include any by-reference applicators such as "$ref" or "$dynamicRef".

    +
    +
    +#/properties/width/$ref/minimum
    +
    +                        
    +

    Note that this pointer may not be resolvable by the normal JSON Pointer process due to the inclusion of these by-reference applicator keywords.

    +

    The JSON key for this information is "keywordLocation".

    +

    +12.3.2. Keyword Absolute Location

    +

    The absolute, dereferenced location of the validating keyword. The value MUST be expressed as a full URI using the canonical URI of the relevant schema object, and it MUST NOT include by-reference applicators such as "$ref" or "$dynamicRef" as non-terminal path components. It MAY end in such keywords if the error or annotation is for that keyword, such as an unresolvable reference. [CREF15]Note that "absolute" here is in the sense of "absolute filesystem path" (meaning the complete location) rather than the "absolute-URI" terminology from RFC 3986 (meaning with scheme but without fragment). Keyword absolute locations will always have a fragment in order to identify the keyword.

    +
    +
    +https://example.com/schemas/common#/$defs/count/minimum
    +
    +                        
    +

    This information MAY be omitted only if either the relative location contains no references or if the schema does not declare an absolute URI as its "$id".

    +

    The JSON key for this information is "absoluteKeywordLocation".

    +

    +12.3.3. Instance Location

    +

    The location of the JSON value within the instance being validated. The value MUST be expressed as a JSON Pointer.

    +

    The JSON key for this information is "instanceLocation".

    +

    +12.3.4. Error or Annotation

    +

    The error or annotation that is produced by the validation.

    +

    For errors, the specific wording for the message is not defined by this specification. Implementations will need to provide this.

    +

    For annotations, each keyword that produces an annotation specifies its format. By default, it is the keyword's value.

    +

    The JSON key for failed validations is "error"; for successful validations it is "annotation".

    +

    +12.3.5. Nested Results

    +

    For the two hierarchical structures, this property will hold nested errors and annotations.

    +

    The JSON key for nested results in failed validations is "errors"; for successful validations it is "annotations". Note the plural forms, as a keyword with nested results can also have a local error or annotation.

    +

    +12.4. Output Structure

    +

    The output MUST be an object containing a boolean property named "valid". When additional information about the result is required, the output MUST also contain "errors" or "annotations" as described below.

    + +
      +
    • "valid" - a boolean value indicating the overall validation success or failure
    • +
    • "errors" - the collection of errors or annotations produced by a failed validation
    • +
    • "annotations" - the collection of errors or annotations produced by a successful validation
    • +
    + +

    For these examples, the following schema and instance will be used.

    +
    +
    +{
    +  "$id": "https://example.com/polygon",
    +  "$schema": "https://json-schema.org/draft/2020-11/schema",
    +  "$defs": {
    +    "point": {
    +      "type": "object",
    +      "properties": {
    +        "x": { "type": "number" },
    +        "y": { "type": "number" }
    +      },
    +      "additionalProperties": false,
    +      "required": [ "x", "y" ]
    +    }
    +  },
    +  "type": "array",
    +  "items": { "$ref": "#/$defs/point" },
    +  "minItems": 3
    +}
    +
    +[
    +  {
    +    "x": 2.5,
    +    "y": 1.3
    +  },
    +  {
    +    "x": 1,
    +    "z": 6.7
    +  }
    +]
    +
    +                    
    +

    This instance will fail validation and produce errors, but it's trivial to deduce examples for passing schemas that produce annotations.

    +

    Specifically, the errors it will produce are:

    + +
      +
    • The second object is missing a "y" property.
    • +
    • The second object has a disallowed "z" property.
    • +
    • There are only two objects, but three are required.
    • +
    + +

    Note that the error message wording as depicted in these examples is not a requirement of this specification. Implementations SHOULD craft error messages tailored for their audience or provide a templating mechanism that allows their users to craft their own messages.

    +

    +12.4.1. Flag

    +

    In the simplest case, merely the boolean result for the "valid" valid property needs to be fulfilled.

    +
    +
    +{
    +  "valid": false
    +}
    +
    +                        
    +

    Because no errors or annotations are returned with this format, it is RECOMMENDED that implementations use short-circuiting logic to return failure or success as soon as the outcome can be determined. For example, if an "anyOf" keyword contains five sub-schemas, and the second one passes, there is no need to check the other three. The logic can simply return with success.

    +

    +12.4.2. Basic

    +

    The "Basic" structure is a flat list of output units.

    +
    +
    +{
    +  "valid": false,
    +  "errors": [
    +    {
    +      "keywordLocation": "",
    +      "instanceLocation": "",
    +      "error": "A subschema had errors."
    +    },
    +    {
    +      "keywordLocation": "/items/$ref",
    +      "absoluteKeywordLocation":
    +        "https://example.com/polygon#/$defs/point",
    +      "instanceLocation": "/1",
    +      "error": "A subschema had errors."
    +    },
    +    {
    +      "keywordLocation": "/items/$ref/required",
    +      "absoluteKeywordLocation":
    +        "https://example.com/polygon#/$defs/point/required",
    +      "instanceLocation": "/1",
    +      "error": "Required property 'y' not found."
    +    },
    +    {
    +      "keywordLocation": "/items/$ref/additionalProperties",
    +      "absoluteKeywordLocation":
    +        "https://example.com/polygon#/$defs/point/additionalProperties",
    +      "instanceLocation": "/1/z",
    +      "error": "Additional property 'z' found but was invalid."
    +    },
    +    {
    +      "keywordLocation": "/minItems",
    +      "instanceLocation": "",
    +      "error": "Expected at least 3 items but found 2"
    +    }
    +  ]
    +}
    +
    +                        
    +

    +12.4.3. Detailed

    +

    The "Detailed" structure is based on the schema and can be more readable for both humans and machines. Having the structure organized this way makes associations between the errors more apparent. For example, the fact that the missing "y" property and the extra "z" property both stem from the same location in the instance is not immediately obvious in the "Basic" structure. In a hierarchy, the correlation is more easily identified.

    +

    The following rules govern the construction of the results object:

    + +
      +
    • All applicator keywords ("*Of", "$ref", "if"/"then"/"else", etc.) require a node.
    • +
    • Nodes that have no children are removed.
    • +
    • Nodes that have a single child are replaced by the child.
    • +
    + +

    Branch nodes do not require an error message or an annotation.

    +
    +
    +{
    +  "valid": false,
    +  "keywordLocation": "",
    +  "instanceLocation": "",
    +  "errors": [
    +    {
    +      "valid": false,
    +      "keywordLocation": "/items/$ref",
    +      "absoluteKeywordLocation":
    +        "https://example.com/polygon#/$defs/point",
    +      "instanceLocation": "/1",
    +      "errors": [
    +        {
    +          "valid": false,
    +          "keywordLocation": "/items/$ref/required",
    +          "absoluteKeywordLocation":
    +            "https://example.com/polygon#/$defs/point/required",
    +          "instanceLocation": "/1",
    +          "error": "Required property 'y' not found."
    +        },
    +        {
    +          "valid": false,
    +          "keywordLocation": "/items/$ref/additionalProperties",
    +          "absoluteKeywordLocation":
    +            "https://example.com/polygon#/$defs/point/additionalProperties",
    +          "instanceLocation": "/1/z",
    +          "error": "Additional property 'z' found but was invalid."
    +        }
    +      ]
    +    },
    +    {
    +      "valid": false,
    +      "keywordLocation": "/minItems",
    +      "instanceLocation": "",
    +      "error": "Expected at least 3 items but found 2"
    +    }
    +  ]
    +}
    +
    +                        
    +

    +12.4.4. Verbose

    +

    The "Verbose" structure is a fully realized hierarchy that exactly matches that of the schema. This structure has applications in form generation and validation where the error's location is important.

    +

    The primary difference between this and the "Detailed" structure is that all results are returned. This includes sub-schema validation results that would otherwise be removed (e.g. annotations for failed validations, successful validations inside a `not` keyword, etc.). Because of this, it is RECOMMENDED that each node also carry a `valid` property to indicate the validation result for that node.

    +

    Because this output structure can be quite large, a smaller example is given here for brevity. The URI of the full output structure of the example above is: <https://json-schema.org/draft/2020-11/output/verbose-example>.

    +
    +
    +// schema
    +{
    +  "$id": "https://example.com/polygon",
    +  "$schema": "https://json-schema.org/draft/2020-11/schema",
    +  "type": "object",
    +  "properties": {
    +    "validProp": true,
    +  },
    +  "additionalProperties": false
    +}
    +
    +// instance
    +{
    +  "validProp": 5,
    +  "disallowedProp": "value"
    +}
    +
    +// result
    +{
    +  "valid": false,
    +  "keywordLocation": "",
    +  "instanceLocation": "",
    +  "errors": [
    +    {
    +      "valid": true,
    +      "keywordLocation": "/type",
    +      "instanceLocation": ""
    +    },
    +    {
    +      "valid": true,
    +      "keywordLocation": "/properties",
    +      "instanceLocation": ""
    +    },
    +    {
    +      "valid": false,
    +      "keywordLocation": "/additionalProperties",
    +      "instanceLocation": "",
    +      "errors": [
    +        {
    +          "valid": false,
    +          "keywordLocation": "/additionalProperties",
    +          "instanceLocation": "/disallowedProp",
    +          "error": "Additional property 'disallowedProp' found but was invalid."
    +        }
    +      ]
    +    }
    +  ]
    +}
    +
    +                        
    +

    +12.4.5. Output validation schemas

    +

    For convenience, JSON Schema has been provided to validate output generated by implementations. Its URI is: <https://json-schema.org/draft/2020-11/output/schema>.

    +

    +13. Security Considerations +

    +

    Both schemas and instances are JSON values. As such, all security considerations defined in RFC 8259 apply.

    +

    Instances and schemas are both frequently written by untrusted third parties, to be deployed on public Internet servers. Validators should take care that the parsing and validating against schemas doesn't consume excessive system resources. Validators MUST NOT fall into an infinite loop.

    +

    A malicious party could cause an implementation to repeatedly collect a copy of a very large value as an annotation. Implementations SHOULD guard against excessive consumption of system resources in such a scenario.

    +

    Servers MUST ensure that malicious parties can't change the functionality of existing schemas by uploading a schema with a pre-existing or very similar "$id".

    +

    Individual JSON Schema vocabularies are liable to also have their own security considerations. Consult the respective specifications for more information.

    +

    Schema authors should take care with "$comment" contents, as a malicious implementation can display them to end-users in violation of a spec, or fail to strip them if such behavior is expected.

    +

    A malicious schema author could place executable code or other dangerous material within a "$comment". Implementations MUST NOT parse or otherwise take action based on "$comment" contents.

    +

    +14. IANA Considerations

    +

    +14.1. application/schema+json

    +

    The proposed MIME media type for JSON Schema is defined as follows:

    + +
      +
    • Type name: application
    • +
    • Subtype name: schema+json
    • +
    • Required parameters: N/A
    • +
    • Optional parameters:
      +
      schema:
      +
      A non-empty list of space-separated URIs, each identifying a JSON Schema resource. The instance SHOULD successfully validate against at least one of these meta-schemas. Non-validating meta-schemas MAY be included for purposes such as allowing clients to make use of older versions of a meta-schema as long as the runtime instance validates against that older version.
      +
      +

      +
    • +
    • Encoding considerations: Encoding considerations are identical to those specified for the "application/json" media type. See JSON.
    • +
    • Security considerations: See Section 13 above.
    • +
    • Interoperability considerations: See Sections 6.2, 6.3, and 6.4 above.
    • +
    • Fragment identifier considerations: See Section 5
    • +
    + +

    +

    +14.2. application/schema-instance+json

    +

    The proposed MIME media type for JSON Schema Instances that require a JSON Schema-specific media type is defined as follows:

    + +
      +
    • Type name: application
    • +
    • Subtype name: schema-instance+json
    • +
    • Required parameters:
      +
      schema:
      +
      A non-empty list of space-separated URIs, each identifying a JSON Schema resource. The instance SHOULD successfully validate against at least one of these schemas. Non-validating schemas MAY be included for purposes such as allowing clients to make use of older versions of a schema as long as the runtime instance validates against that older version.
      +
      +

      +
    • +
    • Encoding considerations: Encoding considerations are identical to those specified for the "application/json" media type. See JSON.
    • +
    • Security considerations: See Section 13 above.
    • +
    • Interoperability considerations: See Sections 6.2, 6.3, and 6.4 above.
    • +
    • Fragment identifier considerations: See Section 5
    • +
    + +

    +

    +15. References

    +

    +15.1. Normative References

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    [ecma262]"ECMA-262, 11th edition specification", June 2020.
    [RFC2119] +Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.
    [RFC3986] +Berners-Lee, T., Fielding, R. and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, January 2005.
    [RFC6839] +Hansen, T. and A. Melnikov, "Additional Media Type Structured Syntax Suffixes", RFC 6839, DOI 10.17487/RFC6839, January 2013.
    [RFC6901] +Bryan, P., Zyp, K. and M. Nottingham, "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, April 2013.
    [RFC8259] +Bray, T., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, December 2017.
    [W3C.REC-ldp-20150226] +Speicher, S., Arwe, J. and A. Malhotra, "Linked Data Platform 1.0", World Wide Web Consortium Recommendation REC-ldp-20150226, February 2015.
    +

    +15.2. Informative References

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    [json-hyper-schema] +Andrews, H. and A. Wright, "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON", Internet-Draft draft-handrews-json-schema-hyperschema-02, November 2017.
    [json-schema-validation] +Wright, A., Andrews, H. and B. Hutton, "JSON Schema Validation: A Vocabulary for Structural Validation of JSON", Internet-Draft draft-bhutton-json-schema-validation-00, November 2020.
    [RFC6596] +Ohye, M. and J. Kupke, "The Canonical Link Relation", RFC 6596, DOI 10.17487/RFC6596, April 2012.
    [RFC7049] +Bormann, C. and P. Hoffman, "Concise Binary Object Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, October 2013.
    [RFC7231] +Fielding, R. and J. Reschke, "Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content", RFC 7231, DOI 10.17487/RFC7231, June 2014.
    [RFC8288] +Nottingham, M., "Web Linking", RFC 8288, DOI 10.17487/RFC8288, October 2017.
    [W3C.WD-fragid-best-practices-20121025] +Tennison, J., "Best Practices for Fragment Identifiers and Media Type Definitions", World Wide Web Consortium WD WD-fragid-best-practices-20121025, October 2012.
    [xml-names] +Bray, T., Hollander, D., Layman, A. and R. Tobin, "Namespaces in XML 1.1 (Second Edition)", August 2006.
    +

    +Appendix A. Schema identification examples +

    +

    Consider the following schema, which shows "$id" being used to identify both the root schema and various subschemas, and "$anchor" being used to define plain name fragment identifiers.

    +
    +
    +{
    +    "$id": "https://example.com/root.json",
    +    "$defs": {
    +        "A": { "$anchor": "foo" },
    +        "B": {
    +            "$id": "other.json",
    +            "$defs": {
    +                "X": { "$anchor": "bar" },
    +                "Y": {
    +                    "$id": "t/inner.json",
    +                    "$anchor": "bar"
    +                }
    +            }
    +        },
    +        "C": {
    +            "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f"
    +        }
    +    }
    +}
    +
    +                
    +

    The schemas at the following URI-encoded JSON Pointers (relative to the root schema) have the following base URIs, and are identifiable by any listed URI in accordance with sections 5 and 9.2.1 above.

    +

    + +
    +
    # (document root)
    +
    +
    +
    canonical absolute-URI (and also base URI)
    +
    https://example.com/root.json
    +
    canonical URI with pointer fragment
    +
    https://example.com/root.json#
    +
    +

    +
    +
    #/$defs/A
    +
    +
    +
    base URI
    +
    https://example.com/root.json
    +
    canonical URI with plain fragment
    +
    https://example.com/root.json#foo
    +
    canonical URI with pointer fragment
    +
    https://example.com/root.json#/$defs/A
    +
    +

    +
    +
    #/$defs/B
    +
    +
    +
    base URI
    +
    https://example.com/other.json
    +
    canonical URI with pointer fragment
    +
    https://example.com/other.json#
    +
    non-canonical URI with fragment relative to root.json
    +
    https://example.com/root.json#/$defs/B
    +
    +

    +
    +
    #/$defs/B/$defs/X
    +
    +
    +
    base URI
    +
    https://example.com/other.json
    +
    canonical URI with plain fragment
    +
    https://example.com/other.json#bar
    +
    canonical URI with pointer fragment
    +
    https://example.com/other.json#/$defs/X
    +
    non-canonical URI with fragment relative to root.json
    +
    https://example.com/root.json#/$defs/B/$defs/X
    +
    +

    +
    +
    #/$defs/B/$defs/Y
    +
    +
    +
    base URI
    +
    https://example.com/t/inner.json
    +
    canonical URI with plain fragment
    +
    https://example.com/t/inner.json#bar
    +
    canonical URI with pointer fragment
    +
    https://example.com/t/inner.json#
    +
    non-canonical URI with fragment relative to other.json
    +
    https://example.com/other.json#/$defs/Y
    +
    non-canonical URI with fragment relative to root.json
    +
    https://example.com/root.json#/$defs/B/$defs/Y
    +
    +

    +
    +
    #/$defs/C
    +
    +
    +
    base URI
    +
    urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f
    +
    canonical URI with pointer fragment
    +
    urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f#
    +
    non-canonical URI with fragment relative to root.json
    +
    https://example.com/root.json#/$defs/C
    +
    +

    +
    +
    + +

    +

    +Appendix B. Manipulating schema documents and references

    +

    Various tools have been created to rearrange schema documents based on how and where references ("$ref") appear. This appendix discusses which use cases and actions are compliant with this specification.

    +

    +B.1. Bundling schema resources into a single document

    +

    A set of schema resources intended for use together can be organized with each in its own schema document, all in the same schema document, or any granularity of document grouping in between.

    +

    Numerous tools exist to perform various sorts of reference removal. A common case of this is producing a single file where all references can be resolved within that file. This is typically done to simplify distribution, or to simplify coding so that various invocations of JSON Schema libraries do not have to keep track of and load a large number of resources.

    +

    This transformation can be safely and reversibly done as long as all static references (e.g. "$ref") use URI-references that resolve to canonical URIs, and all schema resources have an absolute-URI as the "$id" in their root schema.

    +

    With these conditions met, each external resource can be copied under "$defs", without breaking any references among the resources' schema objects, and without changing any aspect of validation or annotation results. The names of the schemas under "$defs" do not affect behavior, assuming they are each unique, as they do not appear in canonical URIs for the embedded resources.

    +

    +B.2. Reference removal is not always safe

    +

    Attempting to remove all references and produce a single schema document does not, in all cases, produce a schema with identical behavior to the original form.

    +

    Since "$ref" is now treated like any other keyword, with other keywords allowed in the same schema objects, fully supporting non-recursive "$ref" removal in all cases can require relatively complex schema manipulations. It is beyond the scope of this specification to determine or provide a set of safe "$ref" removal transformations, as they depend not only on the schema structure but also on the intended usage.

    +

    +Appendix C. Example of recursive schema extension +

    +

    Consider the following two schemas describing a simple recursive tree structure, where each node in the tree can have a "data" field of any type. The first schema allows and ignores other instance properties. The second is more strict and only allows the "data" and "children" properties. An example instance with "data" misspelled as "daat" is also shown.

    +
    +
    +// tree schema, extensible
    +{
    +    "$schema": "https://json-schema.org/draft/2020-11/schema",
    +    "$id": "https://example.com/tree",
    +    "$dynamicAnchor": "node",
    +
    +    "type": "object",
    +    "properties": {
    +        "data": true,
    +        "children": {
    +            "type": "array",
    +            "items": {
    +                "$dynamicRef": "#node"
    +            }
    +        }
    +    }
    +}
    +
    +// strict-tree schema, guards against misspelled properties
    +{
    +    "$schema": "https://json-schema.org/draft/2020-11/schema",
    +    "$id": "https://example.com/strict-tree",
    +    "$dynamicAnchor": node,
    +
    +    "$ref": "tree",
    +    "unevaluatedProperties": false
    +}
    +
    +// instance with misspelled field
    +{
    +    "children": [ { "daat": 1 } ]
    +}
    +
    +                
    +

    When we load these two schemas, we will notice the "$dynamicAnchor" named "node" (note the lack of "#" as this is just the name) present in each, resulting in the following full schema URIs:

    + +
      +
    • "https://example.com/tree#node"
    • +
    • "https://example.com/strict-tree#node"
    • +
    + +

    In addition, JSON Schema implementations keep track of the fact that these fragments were created with "$dynamicAnchor".

    +

    If we apply the "strict-tree" schema to the instance, we will follow the "$ref" to the "tree" schema, examine its "children" subschema, and find the "$dynamicRef": to "#node" (note the "#" for URI fragment syntax) in its "items" subschema. That reference resolves to "https://example.com/tree#node", which is a URI with a fragment created by "$dynamicAnchor". Therefore we must examine the dynamic scope before following the reference.

    +

    At this point, the dynamic path is "#/$ref/properties/children/items/$dynamicRef", with a dynamic scope containing (from the outermost scope to the innermost):

    + +
      +
    1. "https://example.com/strict-tree#"
    2. +
    3. "https://example.com/tree#"
    4. +
    5. "https://example.com/tree#/properties/children"
    6. +
    7. "https://example.com/tree#/properties/children/items"
    8. +
    + +

    +

    Since we are looking for a plain name fragment, which can be defined anywhere within a schema resource, the JSON Pointer fragments are irrelevant to this check. That means that we can remove those fragments and eliminate consecutive duplicates, producing:

    + +
      +
    1. "https://example.com/strict-tree"
    2. +
    3. "https://example.com/tree"
    4. +
    + +

    +

    In this case, the outermost resource also has a "node" fragment defined by "$dynamicAnchor". Therefore instead of resolving the "$dynamicRef" to "https://example.com/tree#node", we resolve it to "https://example.com/strict-tree#node".

    +

    This way, the recursion in the "tree" schema recurses to the root of "strict-tree", instead of only applying "strict-tree" to the instance root, but applying "tree" to instance children.

    +

    This example shows both "$dynamicAnchor"s in the same place in each schema, specifically the resource root schema. Since plain-name fragments are independent of the JSON structure, this would work just as well if one or both of the node schema objects were moved under "$defs". It is the matching "$dynamicAnchor" values which tell us how to resolve the dynamic reference, not any sort of correlation in JSON structure.

    +

    +Appendix D. Working with vocabularies

    +

    +D.1. Best practices for vocabulary and meta-schema authors

    +

    Vocabulary authors should take care to avoid keyword name collisions if the vocabulary is intended for broad use, and potentially combined with other vocabularies. JSON Schema does not provide any formal namespacing system, but also does not constrain keyword names, allowing for any number of namespacing approaches.

    +

    Vocabularies may build on each other, such as by defining the behavior of their keywords with respect to the behavior of keywords from another vocabulary, or by using a keyword from another vocabulary with a restricted or expanded set of acceptable values. Not all such vocabulary re-use will result in a new vocabulary that is compatible with the vocabulary on which it is built. Vocabulary authors should clearly document what level of compatibility, if any, is expected.

    +

    Meta-schema authors should not use "$vocabulary" to combine multiple vocabularies that define conflicting syntax or semantics for the same keyword. As semantic conflicts are not generally detectable through schema validation, implementations are not expected to detect such conflicts. If conflicting vocabularies are declared, the resulting behavior is undefined.

    +

    Vocabulary authors should provide a meta-schema that validates the expected usage of the vocabulary's keywords on their own. Such meta-schemas should not forbid additional keywords, and must not forbid any keywords from the Core vocabulary.

    +

    It is recommended that meta-schema authors reference each vocabulary's meta-schema using the "allOf" keyword, although other mechanisms for constructing the meta-schema may be appropriate for certain use cases.

    +

    The recursive nature of meta-schemas makes the "$dynamicAnchor" and "$dynamicRef" keywords particularly useful for extending existing meta-schemas, as can be seen in the JSON Hyper-Schema meta-schema which extends the Validation meta-schema.

    +

    Meta-schemas may impose additional constraints, including describing keywords not present in any vocabulary, beyond what the meta-schemas associated with the declared vocabularies describe. This allows for restricting usage to a subset of a vocabulary, and for validating locally defined keywords not intended for re-use.

    +

    However, meta-schemas should not contradict any vocabularies that they declare, such as by requiring a different JSON type than the vocabulary expects. The resulting behavior is undefined.

    +

    Meta-schemas intended for local use, with no need to test for vocabulary support in arbitrary implementations, can safely omit "$vocabulary" entirely.

    +

    +D.2. Example meta-schema with vocabulary declarations +

    +

    This meta-schema explicitly declares both the Core and Applicator vocabularies, together with an extension vocabulary, and combines their meta-schemas with an "allOf". The extension vocabulary's meta-schema, which describes only the keywords in that vocabulary, is shown after the main example meta-schema.

    +

    The main example meta-schema also restricts the usage of the Applicator vocabulary by forbidding the keywords prefixed with "unevaluated", which are particularly complex to implement. This does not change the semantics or set of keywords defined by the Applicator vocabulary. It just ensures that schemas using this meta-schema that attempt to use the keywords prefixed with "unevaluated" will fail validation against this meta-schema.

    +

    Finally, this meta-schema describes the syntax of a keyword, "localKeyword", that is not part of any vocabulary. Presumably, the implementors and users of this meta-schema will understand the semantics of "localKeyword". JSON Schema does not define any mechanism for expressing keyword semantics outside of vocabularies, making them unsuitable for use except in a specific environment in which they are understood.

    +

    This meta-schema combines several vocabularies for general use.

    +
    +
    +{
    +  "$schema": "https://json-schema.org/draft/2020-11/schema",
    +  "$id": "https://example.com/meta/general-use-example",
    +  "$dynamicAnchor": "meta",
    +  "$vocabulary": {
    +    "https://json-schema.org/draft/2020-11/vocab/core": true,
    +    "https://json-schema.org/draft/2020-11/vocab/applicator": true,
    +    "https://json-schema.org/draft/2020-11/vocab/validation": true,
    +    "https://example.com/vocab/example-vocab": true
    +  },
    +  "allOf": [
    +    {"$ref": "https://json-schema.org/draft/2020-11/meta/core"},
    +    {"$ref": "https://json-schema.org/draft/2020-11/meta/applicator"},
    +    {"$ref": "https://json-schema.org/draft/2020-11/meta/validation"},
    +    {"$ref": "https://example.com/meta/example-vocab",
    +  ],
    +  "patternProperties": {
    +    "^unevaluated.*$": false
    +  },
    +  "properties": {
    +    "localKeyword": {
    +      "$comment": "Not in vocabulary, but validated if used",
    +      "type": "string"
    +    }
    +  }
    +}
    +
    +                    
    +

    This meta-schema describes only a single extension vocabulary.

    +
    +
    +{
    +  "$schema": "https://json-schema.org/draft/2020-11/schema",
    +  "$id": "https://example.com/meta/example-vocab",
    +  "$dynamicAnchor": "meta",
    +  "$vocabulary": {
    +    "https://example.com/vocab/example-vocab": true,
    +  },
    +  "type": ["object", "boolean"],
    +  "properties": {
    +    "minDate": {
    +      "type": "string",
    +      "pattern": "\d\d\d\d-\d\d-\d\d",
    +      "format": "date",
    +    }
    +  }
    +}
    +
    +                    
    +

    As shown above, even though each of the single-vocabulary meta-schemas referenced in the general-use meta-schema's "allOf" declares its corresponding vocabulary, this new meta-schema must re-declare them.

    +

    The standard meta-schemas that combine all vocabularies defined by the Core and Validation specification, and that combine all vocabularies defined by those specifications as well as the Hyper-Schema specification, demonstrate additional complex combinations. These URIs for these meta-schemas may be found in the Validation and Hyper-Schema specifications, respectively.

    +

    While the general-use meta-schema can validate the syntax of "minDate", it is the vocabulary that defines the logic behind the semantic meaning of "minDate". Without an understanding of the semantics (in this example, that the instance value must be a date equal to or after the date provided as the keyword's value in the schema), an implementation can only validate the syntactic usage. In this case, that means validating that it is a date-formatted string (using "pattern" to ensure that it is validated even when "format" functions purely as an annotation, as explained in the Validation specification.

    +

    +Appendix E. References and generative use cases

    +

    While the presence of references is expected to be transparent to validation results, generative use cases such as code generators and UI renderers often consider references to be semantically significant.

    +

    To make such use case-specific semantics explicit, the best practice is to create an annotation keyword for use in the same schema object alongside of a reference keyword such as "$ref".

    +

    For example, here is a hypothetical keyword for determining whether a code generator should consider the reference target to be a distinct class, and how those classes are related. Note that this example is solely for illustrative purposes, and is not intended to propose a functional code generation keyword.

    +
    +
    +{
    +    "allOf": [
    +        {
    +            "classRelation": "is-a",
    +            "$ref": "classes/base.json"
    +        },
    +        {
    +            "$ref": "fields/common.json"
    +        }
    +    ],
    +    "properties": {
    +        "foo": {
    +            "classRelation": "has-a",
    +            "$ref": "classes/foo.json"
    +        },
    +        "date": {
    +            "$ref": "types/dateStruct.json",
    +        }
    +    }
    +}
    +
    +                
    +

    Here, this schema represents some sort of object-oriented class. The first reference in the "allOf" is noted as the base class. The second is not assigned a class relationship, meaning that the code generator should combine the target's definition with this one as if no reference were involved.

    +

    Looking at the properties, "foo" is flagged as object composition, while the "date" property is not. It is simply a field with sub-fields, rather than an instance of a distinct class.

    +

    This style of usage requires the annotation to be in the same object as the reference, which must be recognizable as a reference.

    +

    +Appendix F. Acknowledgments

    +

    Thanks to Gary Court, Francis Galiegue, Kris Zyp, and Geraint Luff for their work on the initial drafts of JSON Schema.

    +

    Thanks to Jason Desrosiers, Daniel Perrett, Erik Wilde, Evgeny Poberezkin, Brad Bowman, Gowry Sankar, Donald Pipowitch, Dave Finlay, Denis Laxalde, Phil Sturgeon, Shawn Silverman, and Karen Etheridge for their submissions and patches to the document.

    +

    +Appendix G. ChangeLog

    +

    [CREF16]This section to be removed before leaving Internet-Draft status.

    +

    + +
    +
    draft-bhutton-json-schema-00
    +
    +
      +
    • "$schema" MAY change for embedded resources
    • +
    • Array-value "items" functionality is now "prefixItems"
    • +
    • "items" subsumes the old function of "additionalItems"
    • +
    • "contains" and "unevaluatedItems" interactions now specified
    • +
    • Rename $recursive* to $dynamic*
    • +
    • $dynamicAnchor defines a fragment like $anchor
    • +
    • $dynamic* (previously $recursive) no longer use runtime base URI determination
    • +
    • Define Compound Schema Documents (bundle) and processing
    • +
    • Reference ECMA-262, 11th edition for regular expression support
    • +
    • +
    • +
    • +
    +

    +
    +
    draft-handrews-json-schema-02
    +
    +
      +
    • Update to RFC 8259 for JSON specification
    • +
    • Moved "definitions" from the Validation specification here as "$defs"
    • +
    • Moved applicator keywords from the Validation specification as their own vocabulary
    • +
    • Moved the schema form of "dependencies" from the Validation specification as "dependentSchemas"
    • +
    • Formalized annotation collection
    • +
    • Specified recommended output formats
    • +
    • Defined keyword interactions in terms of annotation and assertion results
    • +
    • Added "unevaluatedProperties" and "unevaluatedItems"
    • +
    • Define "$ref" behavior in terms of the assertion, applicator, and annotation model
    • +
    • Allow keywords adjacent to "$ref"
    • +
    • Note undefined behavior for "$ref" targets involving unknown keywords
    • +
    • Add recursive referencing, primarily for meta-schema extension
    • +
    • Add the concept of formal vocabularies, and how they can be recognized through meta-schemas
    • +
    • Additional guidance on initial base URIs beyond network retrieval
    • +
    • Allow "schema" media type parameter for "application/schema+json"
    • +
    • Better explanation of media type parameters and the HTTP Accept header
    • +
    • Use "$id" to establish canonical and base absolute-URIs only, no fragments
    • +
    • Replace plain-name-fragment-only form of "$id" with "$anchor"
    • +
    • Clarified that the behavior of JSON Pointers across "$id" boundary is unreliable
    • +
    +

    +
    +
    draft-handrews-json-schema-01
    +
    +
      +
    • This draft is purely a clarification with no functional changes
    • +
    • Emphasized annotations as a primary usage of JSON Schema
    • +
    • Clarified $id by use cases
    • +
    • Exhaustive schema identification examples
    • +
    • Replaced "external referencing" with how and when an implementation might know of a schema from another document
    • +
    • Replaced "internal referencing" with how an implementation should recognized schema identifiers during parsing
    • +
    • Dereferencing the former "internal" or "external" references is always the same process
    • +
    • Minor formatting improvements
    • +
    +

    +
    +
    draft-handrews-json-schema-00
    +
    +
      +
    • Make the concept of a schema keyword vocabulary more clear
    • +
    • Note that the concept of "integer" is from a vocabulary, not the data model
    • +
    • Classify keywords as assertions or annotations and describe their general behavior
    • +
    • Explain the boolean schemas in terms of generalized assertions
    • +
    • Reserve "$comment" for non-user-visible notes about the schema
    • +
    • Wording improvements around "$id" and fragments
    • +
    • Note the challenges of extending meta-schemas with recursive references
    • +
    • Add "application/schema-instance+json" media type
    • +
    • Recommend a "schema" link relation / parameter instead of "profile"
    • +
    +

    +
    +
    draft-wright-json-schema-01
    +
    +
      +
    • Updated intro
    • +
    • Allowed for any schema to be a boolean
    • +
    • "$schema" SHOULD NOT appear in subschemas, although that may change
    • +
    • Changed "id" to "$id"; all core keywords prefixed with "$"
    • +
    • Clarify and formalize fragments for application/schema+json
    • +
    • Note applicability to formats such as CBOR that can be represented in the JSON data model
    • +
    +

    +
    +
    draft-wright-json-schema-00
    +
    +
      +
    • Updated references to JSON
    • +
    • Updated references to HTTP
    • +
    • Updated references to JSON Pointer
    • +
    • Behavior for "id" is now specified in terms of RFC3986
    • +
    • Aligned vocabulary usage for URIs with RFC3986
    • +
    • Removed reference to draft-pbryan-zyp-json-ref-03
    • +
    • Limited use of "$ref" to wherever a schema is expected
    • +
    • Added definition of the "JSON Schema data model"
    • +
    • Added additional security considerations
    • +
    • Defined use of subschema identifiers for "id"
    • +
    • Rewrote section on usage with HTTP
    • +
    • Rewrote section on usage with rel="describedBy" and rel="profile"
    • +
    • Fixed numerous invalid examples
    • +
    +

    +
    +
    draft-zyp-json-schema-04
    +
    +
      +
    • Salvaged from draft v3.
    • +
    • Split validation keywords into separate document.
    • +
    • Split hypermedia keywords into separate document.
    • +
    • Initial post-split draft.
    • +
    • Mandate the use of JSON Reference, JSON Pointer.
    • +
    • Define the role of "id". Define URI resolution scope.
    • +
    • Add interoperability considerations.
    • +
    +

    +
    +
    draft-zyp-json-schema-00
    +
    +
    • Initial draft.
    +

    +
    +
    + +

    +

    Authors' Addresses

    +
    +
    + + Austin Wright (editor) + + + + + + + + + + + + + EMail: aaa@bzfx.net + +
    +
    +
    + + Henry Andrews (editor) + + + + + + + + + + + + + EMail: andrews_henry@yahoo.com + +
    +
    +
    + + Ben Hutton (editor) + + + + + + + + + + + + + EMail: ben@jsonschema.dev + +URI: https://jsonschema.dev + +
    +
    +
    + + Greg Dennis + + + + + + + Auckland, + + + + NZ + + EMail: gregsdennis@yahoo.com + +
    +
    + + + diff --git a/draft/preview/2020-11-rc-0/jsonschema-validation.html b/draft/preview/2020-11-rc-0/jsonschema-validation.html new file mode 100644 index 00000000..0e5d80b2 --- /dev/null +++ b/draft/preview/2020-11-rc-0/jsonschema-validation.html @@ -0,0 +1,1411 @@ + + + + + + + JSON Schema Validation: A Vocabulary for Structural Validation of JSON + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Internet Engineering Task ForceA. Wright, Ed.
    Internet-Draft
    Intended status: InformationalH. Andrews, Ed.
    Expires: May 16, 2021
    B. Hutton, Ed.
    November 12, 2020
    + +

    JSON Schema Validation: A Vocabulary for Structural Validation of JSON
    + draft-bhutton-json-schema-validation-00

    + +

    Abstract

    +

    JSON Schema (application/schema+json) has several purposes, one of which is JSON instance validation. This document specifies a vocabulary for JSON Schema to describe the meaning of JSON documents, provide hints for user interfaces working with JSON data, and to make assertions about what a valid document must look like.

    +

    Note to Readers

    +

    This document a pre-release identified as JSON Schema draft 2020-11-rc-0.

    +

    The issues list for this draft can be found at <https://github.com/json-schema-org/json-schema-spec/issues>.

    +

    For additional information, see <https://json-schema.org/>.

    +

    To provide feedback, use this issue tracker, the communication methods listed on the homepage, or email the document editors.

    +

    Status of This Memo

    +

    This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

    +

    Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

    +

    Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

    +

    This Internet-Draft will expire on May 16, 2021.

    +

    Copyright Notice

    +

    Copyright (c) 2020 IETF Trust and the persons identified as the document authors. All rights reserved.

    +

    This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

    + + +
    +

    Table of Contents

    + + +

    +1. Introduction

    +

    JSON Schema can be used to require that a given JSON document (an instance) satisfies a certain number of criteria. These criteria are asserted by using keywords described in this specification. In addition, a set of keywords is also defined to assist in interactive user interface instance generation.

    +

    This specification will use the concepts, syntax, and terminology defined by the JSON Schema core specification.

    +

    +2. Conventions and Terminology

    +

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

    +

    This specification uses the term "container instance" to refer to both array and object instances. It uses the term "children instances" to refer to array elements or object member values.

    +

    Elements in an array value are said to be unique if no two elements of this array are equal.

    +

    +3. Overview

    +

    JSON Schema validation asserts constraints on the structure of instance data. An instance location that satisfies all asserted constraints is then annotated with any keywords that contain non-assertion information, such as descriptive metadata and usage hints. If all locations within the instance satisfy all asserted constraints, then the instance is said to be valid against the schema.

    +

    Each schema object is independently evaluated against each instance location to which it applies. This greatly simplifies the implementation requirements for validators by ensuring that they do not need to maintain state across the document-wide validation process.

    +

    This specification defines a set of assertion keywords, as well as a small vocabulary of metadata keywords that can be used to annotate the JSON instance with useful information. The Section 7 keyword is intended primarily as an annotation, but can optionally be used as an assertion. The Section 8 keywords are annotations for working with documents embedded as JSON strings.

    +

    +4. Interoperability Considerations

    +

    +4.1. Validation of String Instances

    +

    It should be noted that the nul character (\u0000) is valid in a JSON string. An instance to validate may contain a string value with this character, regardless of the ability of the underlying programming language to deal with such data.

    +

    +4.2. Validation of Numeric Instances

    +

    The JSON specification allows numbers with arbitrary precision, and JSON Schema does not add any such bounds. This means that numeric instances processed by JSON Schema can be arbitrarily large and/or have an arbitrarily long decimal part, regardless of the ability of the underlying programming language to deal with such data.

    +

    +4.3. Regular Expressions +

    +

    Keywords that use regular expressions, or constrain the instance value to be a regular expression, are subject to the interoperability considerations for regular expressions in the JSON Schema Core specification.

    +

    +5. Meta-Schema +

    +

    The current URI for the default JSON Schema dialect meta-schema is <https://json-schema.org/draft/2020-11/schema>. For schema author convenience, this meta-schema describes a dialect consisting of all vocabularies defined in this specification and the JSON Schema Core specification, as well as two former keywords which are reserved for a transitional period. Individual vocabulary and vocabulary meta-schema URIs are given for each section below. Certain vocabularies are optional to support, which is explained in detail in the relevant sections.

    +

    Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations SHOULD consider URIs dated after this specification draft and before the next to indicate the same syntax and semantics as those listed here.

    +

    +6. A Vocabulary for Structural Validation

    +

    Validation keywords in a schema impose requirements for successful validation of an instance. These keywords are all assertions without any annotation behavior.

    +

    Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

    +

    The current URI for this vocabulary, known as the Validation vocabulary, is: <https://json-schema.org/draft/2020-11/vocab/validation>.

    +

    The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-11/meta/validation>.

    +

    +6.1. Validation Keywords for Any Instance Type +

    +

    +6.1.1. type

    +

    The value of this keyword MUST be either a string or an array. If it is an array, elements of the array MUST be strings and MUST be unique.

    +

    String values MUST be one of the six primitive types ("null", "boolean", "object", "array", "number", or "string"), or "integer" which matches any number with a zero fractional part.

    +

    An instance validates if and only if the instance is in any of the sets listed for this keyword.

    +

    +6.1.2. enum +

    +

    The value of this keyword MUST be an array. This array SHOULD have at least one element. Elements in the array SHOULD be unique.

    +

    An instance validates successfully against this keyword if its value is equal to one of the elements in this keyword's array value.

    +

    Elements in the array might be of any type, including null.

    +

    +6.1.3. const

    +

    The value of this keyword MAY be of any type, including null.

    +

    Use of this keyword is functionally equivalent to an "enum" with a single value.

    +

    An instance validates successfully against this keyword if its value is equal to the value of the keyword.

    +

    +6.2. Validation Keywords for Numeric Instances (number and integer) +

    +

    +6.2.1. multipleOf

    +

    The value of "multipleOf" MUST be a number, strictly greater than 0.

    +

    A numeric instance is valid only if division by this keyword's value results in an integer.

    +

    +6.2.2. maximum

    +

    The value of "maximum" MUST be a number, representing an inclusive upper limit for a numeric instance.

    +

    If the instance is a number, then this keyword validates only if the instance is less than or exactly equal to "maximum".

    +

    +6.2.3. exclusiveMaximum

    +

    The value of "exclusiveMaximum" MUST be a number, representing an exclusive upper limit for a numeric instance.

    +

    If the instance is a number, then the instance is valid only if it has a value strictly less than (not equal to) "exclusiveMaximum".

    +

    +6.2.4. minimum

    +

    The value of "minimum" MUST be a number, representing an inclusive lower limit for a numeric instance.

    +

    If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to "minimum".

    +

    +6.2.5. exclusiveMinimum

    +

    The value of "exclusiveMinimum" MUST be a number, representing an exclusive lower limit for a numeric instance.

    +

    If the instance is a number, then the instance is valid only if it has a value strictly greater than (not equal to) "exclusiveMinimum".

    +

    +6.3. Validation Keywords for Strings +

    +

    +6.3.1. maxLength

    +

    The value of this keyword MUST be a non-negative integer.

    +

    A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.

    +

    The length of a string instance is defined as the number of its characters as defined by RFC 8259.

    +

    +6.3.2. minLength

    +

    The value of this keyword MUST be a non-negative integer.

    +

    A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.

    +

    The length of a string instance is defined as the number of its characters as defined by RFC 8259.

    +

    Omitting this keyword has the same behavior as a value of 0.

    +

    +6.3.3. pattern +

    +

    The value of this keyword MUST be a string. This string SHOULD be a valid regular expression, according to the ECMA-262 regular expression dialect.

    +

    A string instance is considered valid if the regular expression matches the instance successfully. Recall: regular expressions are not implicitly anchored.

    +

    +6.4. Validation Keywords for Arrays

    +

    +6.4.1. maxItems

    +

    The value of this keyword MUST be a non-negative integer.

    +

    An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword.

    +

    +6.4.2. minItems

    +

    The value of this keyword MUST be a non-negative integer.

    +

    An array instance is valid against "minItems" if its size is greater than, or equal to, the value of this keyword.

    +

    Omitting this keyword has the same behavior as a value of 0.

    +

    +6.4.3. uniqueItems

    +

    The value of this keyword MUST be a boolean.

    +

    If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.

    +

    Omitting this keyword has the same behavior as a value of false.

    +

    +6.4.4. maxContains

    +

    The value of this keyword MUST be a non-negative integer.

    +

    An array instance is valid against "maxContains" if the number of elements that are valid against the schema for "contains" is less than, or equal to, the value of this keyword.

    +

    If "contains" is not present within the same schema object, then this keyword has no effect.

    +

    +6.4.5. minContains

    +

    The value of this keyword MUST be a non-negative integer.

    +

    An array instance is valid against "minContains" if the number of elements that are valid against the schema for "contains" is greater than, or equal to, the value of this keyword.

    +

    A value of 0 is allowed, but is only useful for setting a range of occurrences from 0 to the value of "maxContains". A value of 0 with no "maxContains" causes "contains" to always pass validation.

    +

    If "contains" is not present within the same schema object, then this keyword has no effect.

    +

    Omitting this keyword has the same behavior as a value of 1.

    +

    +6.5. Validation Keywords for Objects

    +

    +6.5.1. maxProperties

    +

    The value of this keyword MUST be a non-negative integer.

    +

    An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword.

    +

    +6.5.2. minProperties

    +

    The value of this keyword MUST be a non-negative integer.

    +

    An object instance is valid against "minProperties" if its number of properties is greater than, or equal to, the value of this keyword.

    +

    Omitting this keyword has the same behavior as a value of 0.

    +

    +6.5.3. required

    +

    The value of this keyword MUST be an array. Elements of this array, if any, MUST be strings, and MUST be unique.

    +

    An object instance is valid against this keyword if every item in the array is the name of a property in the instance.

    +

    Omitting this keyword has the same behavior as an empty array.

    +

    +6.5.4. dependentRequired

    +

    The value of this keyword MUST be an object. Properties in this object, if any, MUST be arrays. Elements in each array, if any, MUST be strings, and MUST be unique.

    +

    This keyword specifies properties that are required if a specific other property is present. Their requirement is dependent on the presence of the other property.

    +

    Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value, every item in the corresponding array is also the name of a property in the instance.

    +

    Omitting this keyword has the same behavior as an empty object.

    +

    +7. A Vocabulary for Semantic Content With "format" +

    +

    +7.1. Foreword

    +

    Structural validation alone may be insufficient to allow an application to correctly utilize certain values. The "format" annotation keyword is defined to allow schema authors to convey semantic information for a fixed subset of values which are accurately described by authoritative resources, be they RFCs or other external specifications.

    +

    Implementations MAY treat "format" as an assertion in addition to an annotation, and attempt to validate the value's conformance to the specified semantics. See the Implementation Requirements below for details.

    +

    The value of this keyword is called a format attribute. It MUST be a string. A format attribute can generally only validate a given set of instance types. If the type of the instance to validate is not in this set, validation for this format attribute and instance SHOULD succeed. All format attributes defined in this section apply to strings, but a format attribute can be specified to apply to any instance types defined in the data model defined in the core JSON Schema. [CREF1]Note that the "type" keyword in this specification defines an "integer" type which is not part of the data model. Therefore a format attribute can be limited to numbers, but not specifically to integers. However, a numeric format can be used alongside the "type" keyword with a value of "integer", or could be explicitly defined to always pass if the number is not an integer, which produces essentially the same behavior as only applying to integers.

    +

    Meta-schemas that do not use "$vocabulary" SHOULD be considered to utilize this vocabulary as if its URI were present with a value of false. See the Implementation Requirements below for details.

    +

    The current URI for this vocabulary, known as the Format vocabulary, is: <https://json-schema.org/draft/2020-11/vocab/format>.

    +

    The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-11/meta/format>.

    +

    +7.2. Implementation Requirements

    +

    The "format" keyword functions as an annotation, and optionally as an assertion. [CREF2]This is due to the keyword's history, and is not in line with current keyword design principles. In order to manage this ambiguity, the "format" keyword is defined in its own separate vocabulary, as noted above. The true or false value of the vocabulary declaration governs the implementation requirements necessary to process a schema that uses "format", and the behaviors on which schema authors can rely.

    +

    +7.2.1. As an annotation

    +

    The value of format MUST be collected as an annotation, if the implementation supports annotation collection. This enables application-level validation when schema validation is unavailable or inadequate.

    +

    This requirement is not affected by the boolean value of the vocabulary declaration, nor by the configuration of "format"'s assertion behavior described in the next section. [CREF3]Requiring annotation collection even when the vocabulary is declared with a value of false is atypical, but necessary to ensure that the best practice of performing application-level validation is possible even when assertion evaluation is not implemented. Since "format" has always been a part of this specification, requiring implementations to be aware of it even with a false vocabulary declaration is deemed to not be a burden.

    +

    +7.2.2. As an assertion

    +

    Regardless of the boolean value of the vocabulary declaration, an implementation that can evaluate "format" as an assertion MUST provide options to enable and disable such evaluation. The assertion evaluation behavior when the option is not explicitly specified depends on the vocabulary declaration's boolean value.

    +

    When implementing this entire specification, this vocabulary MUST be supported with a value of false (but see details below), and MAY be supported with a value of true.

    +

    When the vocabulary is declared with a value of false, an implementation: [CREF4]This matches the current reality of implementations, which provide widely varying levels of validation, including no validation at all, for some or all format attributes. It is also designed to encourage relying only on the annotation behavior and performing semantic validation in the application, which is the recommended best practice.

    + +
      +
    • MUST NOT evaluate "format" as an assertion unless it is explicitly configured to do so;
    • +
    • SHOULD provide an implementation-specific best effort validation for each format attribute defined below;
    • +
    • MAY choose to implement validation of any or all format attributes as a no-op by always producing a validation result of true;
    • +
    • SHOULD document its level of support for validation.
    • +
    + +

    +

    When the vocabulary is declared with a value of true, an implementation that supports this form of the vocabulary: [CREF5]The expectation is that for simple formats such as date-time, syntactic validation will be thorough. For a complex format such as email addresses, which are the amalgamation of various standards and numerous adjustments over time, with obscure and/or obsolete rules that may or may not be restricted by other applications making use of the value, a minimal validation is sufficient. For example, an instance string that does not contain an "@" is clearly not a valid email address, and an "email" or "hostname" containing characters outside of 7-bit ASCII is likewise clearly invalid.

    + +
      +
    • MUST evaluate "format" as an assertion unless it is explicitly configured not to do so;
    • +
    • MUST implement syntactic validation for all format attributes defined in this specification, and for any additional format attributes that it recognizes, such that there exist possible instance values of the correct type that will fail validation.
    • +
    + +

    The requirement for minimal validation of format attributes is intentionally vague and permissive, due to the complexity involved in many of the attributes. Note in particular that the requirement is limited to syntactic checking; it is not to be expected that an implementation would send an email, attempt to connect to a URL, or otherwise check the existence of an entity identified by a format instance.

    +

    It is RECOMMENDED that implementations use a common parsing library for each format, or a well-known regular expression. Implementations SHOULD clearly document how and to what degree each format attribute is validated.

    +

    The standard core and validation meta-schema includes this vocabulary in its "$vocabulary" keyword with a value of false, since by default implementations are not required to support this keyword as an assertion. Supporting the format vocabulary with a value of true is understood to greatly increase code size and in some cases execution time, and will not be appropriate for all implementations.

    +

    +7.2.3. Custom format attributes

    +

    Implementations MAY support custom format attributes. Save for agreement between parties, schema authors SHALL NOT expect a peer implementation to support such custom format attributes. An implementation MUST NOT fail validation or cease processing due to an unknown format attribute. When treating "format" as an annotation, implementations SHOULD collect both known and unknown format attribute values.

    +

    Vocabularies do not support specifically declaring different value sets for keywords. Due to this limitation, and the historically uneven implementation of this keyword, it is RECOMMENDED to define additional keywords in a custom vocabulary rather than additional format attributes if interoperability is desired.

    +

    +7.3. Defined Formats

    +

    +7.3.1. Dates, Times, and Duration

    +

    These attributes apply to string instances.

    +

    Date and time format names are derived from RFC 3339, section 5.6. The duration format is from the ISO 8601 ABNF as given in Appendix A of RFC 3339.

    +

    Implementations supporting formats SHOULD implement support for the following attributes:

    + +
    +
    date-time:
    +
    A string instance is valid against this attribute if it is a valid representation according to the "date-time" production.
    +
    date:
    +
    A string instance is valid against this attribute if it is a valid representation according to the "full-date" production.
    +
    time:
    +
    A string instance is valid against this attribute if it is a valid representation according to the "full-time" production.
    +
    duration:
    +
    A string instance is valid against this attribute if it is a valid representation according to the "duration" production.
    +
    + +

    +

    Implementations MAY support additional attributes using the other production names defined anywhere in that RFC. If "full-date" or "full-time" are implemented, the corresponding short form ("date" or "time" respectively) MUST be implemented, and MUST behave identically. Implementations SHOULD NOT define extension attributes with any name matching an RFC 3339 production unless it validates according to the rules of that production. [CREF6]There is not currently consensus on the need for supporting all RFC 3339 formats, so this approach of reserving the namespace will encourage experimentation without committing to the entire set. Either the format implementation requirements will become more flexible in general, or these will likely either be promoted to fully specified attributes or dropped.

    +

    +7.3.2. Email Addresses

    +

    These attributes apply to string instances.

    +

    A string instance is valid against these attributes if it is a valid Internet email address as follows:

    + +
    +
    email:
    +
    As defined by the "Mailbox" ABNF rule in RFC 5321, section 4.1.2.
    +
    idn-email:
    +
    As defined by the extended "Mailbox" ABNF rule in RFC 6531, section 3.3.
    +
    + +

    Note that all strings valid against the "email" attribute are also valid against the "idn-email" attribute.

    +

    +7.3.3. Hostnames

    +

    These attributes apply to string instances.

    +

    A string instance is valid against these attributes if it is a valid representation for an Internet hostname as follows:

    + +
    +
    hostname:
    +
    As defined by RFC 1123, section 2.1, including host names produced using the Punycode algorithm specified in RFC 5891, section 4.4.
    +
    idn-hostname:
    +
    As defined by either RFC 1123 as for hostname, or an internationalized hostname as defined by RFC 5890, section 2.3.2.3.
    +
    + +

    Note that all strings valid against the "hostname" attribute are also valid against the "idn-hostname" attribute.

    +

    +7.3.4. IP Addresses

    +

    These attributes apply to string instances.

    +

    A string instance is valid against these attributes if it is a valid representation of an IP address as follows:

    + +
    +
    ipv4:
    +
    An IPv4 address according to the "dotted-quad" ABNF syntax as defined in RFC 2673, section 3.2.
    +
    ipv6:
    +
    An IPv6 address as defined in RFC 4291, section 2.2.
    +
    + +

    +

    +7.3.5. Resource Identifiers

    +

    These attributes apply to string instances.

    +

    + +
    +
    uri:
    +
    A string instance is valid against this attribute if it is a valid URI, according to [RFC3986].
    +
    uri-reference:
    +
    A string instance is valid against this attribute if it is a valid URI Reference (either a URI or a relative-reference), according to [RFC3986].
    +
    iri:
    +
    A string instance is valid against this attribute if it is a valid IRI, according to [RFC3987].
    +
    iri-reference:
    +
    A string instance is valid against this attribute if it is a valid IRI Reference (either an IRI or a relative-reference), according to [RFC3987].
    +
    uuid:
    +
    A string instance is valid against this attribute if it is a valid string representation of a UUID, according to [RFC4122].
    +
    + +

    +

    Note that all valid URIs are valid IRIs, and all valid URI References are also valid IRI References.

    +

    Note also that the "uuid" format is for plain UUIDs, not UUIDs in URNs. An example is "f81d4fae-7dec-11d0-a765-00a0c91e6bf6". For UUIDs as URNs, use the "uri" format, with a "pattern" regular expression of "^urn:uuid:" to indicate the URI scheme and URN namespace.

    +

    +7.3.6. uri-template

    +

    This attribute applies to string instances.

    +

    A string instance is valid against this attribute if it is a valid URI Template (of any level), according to [RFC6570].

    +

    Note that URI Templates may be used for IRIs; there is no separate IRI Template specification.

    +

    +7.3.7. JSON Pointers

    +

    These attributes apply to string instances.

    +

    + +
    +
    json-pointer:
    +
    A string instance is valid against this attribute if it is a valid JSON string representation of a JSON Pointer, according to RFC 6901, section 5.
    +
    relative-json-pointer:
    +
    A string instance is valid against this attribute if it is a valid Relative JSON Pointer.
    +
    + +

    To allow for both absolute and relative JSON Pointers, use "anyOf" or "oneOf" to indicate support for either format.

    +

    +7.3.8. regex

    +

    This attribute applies to string instances.

    +

    A regular expression, which SHOULD be valid according to the ECMA-262 regular expression dialect.

    +

    Implementations that validate formats MUST accept at least the subset of ECMA-262 defined in the Regular Expressions section of this specification, and SHOULD accept all valid ECMA-262 expressions.

    +

    +8. A Vocabulary for the Contents of String-Encoded Data +

    +

    +8.1. Foreword

    +

    Annotations defined in this section indicate that an instance contains non-JSON data encoded in a JSON string.

    +

    These properties provide additional information required to interpret JSON data as rich multimedia documents. They describe the type of content, how it is encoded, and/or how it may be validated. They do not function as validation assertions; a malformed string-encoded document MUST NOT cause the containing instance to be considered invalid.

    +

    Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

    +

    The current URI for this vocabulary, known as the Content vocabulary, is: <https://json-schema.org/draft/2020-11/vocab/content>.

    +

    The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-11/meta/content>.

    +

    +8.2. Implementation Requirements

    +

    Due to security and performance concerns, as well as the open-ended nature of possible content types, implementations MUST NOT automatically decode, parse, and/or validate the string contents by default. This additionally supports the use case of embedded documents intended for processing by a different consumer than that which processed the containing document.

    +

    All keywords in this section apply only to strings, and have no effect on other data types.

    +

    Implementations MAY offer the ability to decode, parse, and/or validate the string contents automatically. However, it MUST NOT perform these operations by default, and MUST provide the validation result of each string-encoded document separately from the enclosing document. This process SHOULD be equivalent to fully evaluating the instance against the original schema, followed by using the annotations to decode, parse, and/or validate each string-encoded document. [CREF7]For now, the exact mechanism of performing and returning parsed data and/or validation results from such an automatic decoding, parsing, and validating feature is left unspecified. Should such a feature prove popular, it may be specified more thoroughly in a future draft.

    +

    See also the Security Considerations sections for possible vulnerabilities introduced by automatically processing the instance string according to these keywords.

    +

    +8.3. contentEncoding

    +

    If the instance value is a string, this property defines that the string SHOULD be interpreted as binary data and decoded using the encoding named by this property.

    +

    Possible values indicating base 16, 32, and 64 encodings with several variations are listed in RFC 4648. Additionally, sections 6.7 and 6.8 of RFC 2045 provide encodings used in MIME. As "base64" is defined in both RFCs, the definition from RFC 4648 SHOULD be assumed unless the string is specifically intended for use in a MIME context. Note that all of these encodings result in strings consisting only of 7-bit ASCII characters. Therefore, this keyword has no meaning for strings containing characters outside of that range.

    +

    If this keyword is absent, but "contentMediaType" is present, this indicates that the encoding is the identity encoding, meaning that no transformation was needed in order to represent the content in a UTF-8 string.

    +

    The value of this property MUST be a string.

    +

    +8.4. contentMediaType

    +

    If the instance is a string, this property indicates the media type of the contents of the string. If "contentEncoding" is present, this property describes the decoded string.

    +

    The value of this property MUST be a string, which MUST be a media type, as defined by RFC 2046.

    +

    +8.5. contentSchema

    +

    If the instance is a string, and if "contentMediaType" is present, this property contains a schema which describes the structure of the string.

    +

    This keyword MAY be used with any media type that can be mapped into JSON Schema's data model.

    +

    The value of this property MUST be a valid JSON schema. It SHOULD be ignored if "contentMediaType" is not present.

    +

    +8.6. Example

    +

    Here is an example schema, illustrating the use of "contentEncoding" and "contentMediaType":

    +
    +
    +{
    +    "type": "string",
    +    "contentEncoding": "base64",
    +    "contentMediaType": "image/png"
    +}
    +
    +                    
    +

    Instances described by this schema are expected to be strings, and their values should be interpretable as base64-encoded PNG images.

    +

    Another example:

    +
    +
    +{
    +    "type": "string",
    +    "contentMediaType": "text/html"
    +}
    +
    +                    
    +

    Instances described by this schema are expected to be strings containing HTML, using whatever character set the JSON string was decoded into. Per section 8.1 of RFC 8259, outside of an entirely closed system, this MUST be UTF-8.

    +

    This example describes a JWT that is MACed using the HMAC SHA-256 algorithm, and requires the "iss" and "exp" fields in its claim set.

    +
    +
    +{
    +    "type": "string",
    +    "contentMediaType": "application/jwt",
    +    "contentSchema": {
    +        "type": "array",
    +        "minItems": 2,
    +        "prefixItems": [
    +            {
    +                "const": {
    +                    "typ": "JWT",
    +                    "alg": "HS256"
    +                }
    +            },
    +            {
    +                "type": "object",
    +                "required": ["iss", "exp"],
    +                "properties": {
    +                    "iss": {"type": "string"},
    +                    "exp": {"type": "integer"}
    +                }
    +            }
    +        ]
    +    }
    +}
    +                    
    +

    Note that "contentEncoding" does not appear. While the "application/jwt" media type makes use of base64url encoding, that is defined by the media type, which determines how the JWT string is decoded into a list of two JSON data structures: first the header, and then the payload. Since the JWT media type ensures that the JWT can be represented in a JSON string, there is no need for further encoding or decoding.

    +

    +9. A Vocabulary for Basic Meta-Data Annotations

    +

    These general-purpose annotation keywords provide commonly used information for documentation and user interface display purposes. They are not intended to form a comprehensive set of features. Rather, additional vocabularies can be defined for more complex annotation-based applications.

    +

    Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

    +

    The current URI for this vocabulary, known as the Meta-Data vocabulary, is: <https://json-schema.org/draft/2020-11/vocab/meta-data>.

    +

    The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-11/meta/meta-data>.

    +

    +9.1. "title" and "description"

    +

    The value of both of these keywords MUST be a string.

    +

    Both of these keywords can be used to decorate a user interface with information about the data produced by this user interface. A title will preferably be short, whereas a description will provide explanation about the purpose of the instance described by this schema.

    +

    +9.2. "default"

    +

    There are no restrictions placed on the value of this keyword. When multiple occurrences of this keyword are applicable to a single sub-instance, implementations SHOULD remove duplicates.

    +

    This keyword can be used to supply a default JSON value associated with a particular schema. It is RECOMMENDED that a default value be valid against the associated schema.

    +

    +9.3. "deprecated"

    +

    The value of this keyword MUST be a boolean. When multiple occurrences of this keyword are applicable to a single sub-instance, applications SHOULD consider the instance location to be deprecated if any occurrence specifies a true value.

    +

    If "deprecated" has a value of boolean true, it indicates that applications SHOULD refrain from usage of the declared property. It MAY mean the property is going to be removed in the future.

    +

    A root schema containing "deprecated" with a value of true indicates that the entire resource being described MAY be removed in the future.

    +

    The "deprecated" keyword applies to each instance location to which the schema object containing the keyword successfully applies. This can result in scenarios where every array item or object property is deprecated even though the containing array or object is not.

    +

    Omitting this keyword has the same behavior as a value of false.

    +

    +9.4. "readOnly" and "writeOnly"

    +

    The value of these keywords MUST be a boolean. When multiple occurrences of these keywords are applicable to a single sub-instance, the resulting behavior SHOULD be as for a true value if any occurrence specifies a true value, and SHOULD be as for a false value otherwise.

    +

    If "readOnly" has a value of boolean true, it indicates that the value of the instance is managed exclusively by the owning authority, and attempts by an application to modify the value of this property are expected to be ignored or rejected by that owning authority.

    +

    An instance document that is marked as "readOnly" for the entire document MAY be ignored if sent to the owning authority, or MAY result in an error, at the authority's discretion.

    +

    If "writeOnly" has a value of boolean true, it indicates that the value is never present when the instance is retrieved from the owning authority. It can be present when sent to the owning authority to update or create the document (or the resource it represents), but it will not be included in any updated or newly created version of the instance.

    +

    An instance document that is marked as "writeOnly" for the entire document MAY be returned as a blank document of some sort, or MAY produce an error upon retrieval, or have the retrieval request ignored, at the authority's discretion.

    +

    For example, "readOnly" would be used to mark a database-generated serial number as read-only, while "writeOnly" would be used to mark a password input field.

    +

    These keywords can be used to assist in user interface instance generation. In particular, an application MAY choose to use a widget that hides input values as they are typed for write-only fields.

    +

    Omitting these keywords has the same behavior as values of false.

    +

    +9.5. "examples"

    +

    The value of this keyword MUST be an array. There are no restrictions placed on the values within the array. When multiple occurrences of this keyword are applicable to a single sub-instance, implementations MUST provide a flat array of all values rather than an array of arrays.

    +

    This keyword can be used to provide sample JSON values associated with a particular schema, for the purpose of illustrating usage. It is RECOMMENDED that these values be valid against the associated schema.

    +

    Implementations MAY use the value(s) of "default", if present, as an additional example. If "examples" is absent, "default" MAY still be used in this manner.

    +

    +10. Security Considerations +

    +

    JSON Schema validation defines a vocabulary for JSON Schema core and concerns all the security considerations listed there.

    +

    JSON Schema validation allows the use of Regular Expressions, which have numerous different (often incompatible) implementations. Some implementations allow the embedding of arbitrary code, which is outside the scope of JSON Schema and MUST NOT be permitted. Regular expressions can often also be crafted to be extremely expensive to compute (with so-called "catastrophic backtracking"), resulting in a denial-of-service attack.

    +

    Implementations that support validating or otherwise evaluating instance string data based on "contentEncoding" and/or "contentMediaType" are at risk of evaluating data in an unsafe way based on misleading information. Applications can mitigate this risk by only performing such processing when a relationship between the schema and instance is established (e.g., they share the same authority).

    +

    Processing a media type or encoding is subject to the security considerations of that media type or encoding. For example, the security considerations of RFC 4329 Scripting Media Types apply when processing JavaScript or ECMAScript encoded within a JSON string.

    +

    +11. References

    +

    +11.1. Normative References

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    [ecma262]"ECMA-262, 11th edition specification", June 2020.
    [json-schema] +Wright, A., Andrews, H. and B. Hutton, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-bhutton-json-schema-00, November 2020.
    [relative-json-pointer] +Luff, G. and H. Andrews, "Relative JSON Pointers", Internet-Draft draft-handrews-relative-json-pointer-01, November 2017.
    [RFC1123] +Braden, R., "Requirements for Internet Hosts - Application and Support", STD 3, RFC 1123, DOI 10.17487/RFC1123, October 1989.
    [RFC2045] +Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", RFC 2045, DOI 10.17487/RFC2045, November 1996.
    [RFC2046] +Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types", RFC 2046, DOI 10.17487/RFC2046, November 1996.
    [RFC2119] +Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.
    [RFC2673] +Crawford, M., "Binary Labels in the Domain Name System", RFC 2673, DOI 10.17487/RFC2673, August 1999.
    [RFC3339] +Klyne, G. and C. Newman, "Date and Time on the Internet: Timestamps", RFC 3339, DOI 10.17487/RFC3339, July 2002.
    [RFC3986] +Berners-Lee, T., Fielding, R. and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, January 2005.
    [RFC3987] +Duerst, M. and M. Suignard, "Internationalized Resource Identifiers (IRIs)", RFC 3987, DOI 10.17487/RFC3987, January 2005.
    [RFC4122] +Leach, P., Mealling, M. and R. Salz, "A Universally Unique IDentifier (UUID) URN Namespace", RFC 4122, DOI 10.17487/RFC4122, July 2005.
    [RFC4291] +Hinden, R. and S. Deering, "IP Version 6 Addressing Architecture", RFC 4291, DOI 10.17487/RFC4291, February 2006.
    [RFC4648] +Josefsson, S., "The Base16, Base32, and Base64 Data Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006.
    [RFC5321] +Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, DOI 10.17487/RFC5321, October 2008.
    [RFC5890] +Klensin, J., "Internationalized Domain Names for Applications (IDNA): Definitions and Document Framework", RFC 5890, DOI 10.17487/RFC5890, August 2010.
    [RFC5891] +Klensin, J., "Internationalized Domain Names in Applications (IDNA): Protocol", RFC 5891, DOI 10.17487/RFC5891, August 2010.
    [RFC6531] +Yao, J. and W. Mao, "SMTP Extension for Internationalized Email", RFC 6531, DOI 10.17487/RFC6531, February 2012.
    [RFC6570] +Gregorio, J., Fielding, R., Hadley, M., Nottingham, M. and D. Orchard, "URI Template", RFC 6570, DOI 10.17487/RFC6570, March 2012.
    [RFC6901] +Bryan, P., Zyp, K. and M. Nottingham, "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, April 2013.
    [RFC8259] +Bray, T., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, December 2017.
    +

    +11.2. Informative References

    + + + +
    [RFC4329] +Hoehrmann, B., "Scripting Media Types", RFC 4329, DOI 10.17487/RFC4329, April 2006.
    +

    +Appendix A. Keywords Moved from Validation to Core

    +

    Several keywords have been moved from this document into the Core Specification as of this draft, in some cases with re-naming or other changes. This affects the following former validation keywords:

    + +
    +
    "definitions"
    +
    Renamed to "$defs" to match "$ref" and be shorter to type. Schema vocabulary authors SHOULD NOT define a "definitions" keyword with different behavior in order to avoid invalidating schemas that still use the older name. While "definitions" is absent in the single-vocabulary meta-schemas referenced by this document, it remains present in the default meta-schema, and implementations SHOULD assume that "$defs" and "definitions" have the same behavior when that meta-schema is used.
    +
    "allOf", "anyOf", "oneOf", "not", "if", "then", "else", "items", "additionalItems", "contains", "propertyNames", "properties", "patternProperties", "additionalProperties"
    +
    All of these keywords apply subschemas to the instance and combine their results, without asserting any conditions of their own. Without assertion keywords, these applicators can only cause assertion failures by using the false boolean schema, or by inverting the result of the true boolean schema (or equivalent schema objects). For this reason, they are better defined as a generic mechanism on which validation, hyper-schema, and extension vocabularies can all be based.
    +
    "dependencies"
    +
    This keyword had two different modes of behavior, which made it relatively challenging to implement and reason about. The schema form has been moved to Core and renamed to "dependentSchemas", as part of the applicator vocabulary. It is analogous to "properties", except that instead of applying its subschema to the property value, it applies it to the object containing the property. The property name array form is retained here and renamed to "dependentRequired", as it is an assertion which is a shortcut for the conditional use of the "required" assertion keyword.
    +
    + +

    +

    +Appendix B. Acknowledgments

    +

    Thanks to Gary Court, Francis Galiegue, Kris Zyp, and Geraint Luff for their work on the initial drafts of JSON Schema.

    +

    Thanks to Jason Desrosiers, Daniel Perrett, Erik Wilde, Evgeny Poberezkin, Brad Bowman, Gowry Sankar, Donald Pipowitch, Dave Finlay, Denis Laxalde, Phil Sturgeon, Shawn Silverman, and Karen Etheridge for their submissions and patches to the document.

    +

    +Appendix C. ChangeLog

    +

    [CREF8]This section to be removed before leaving Internet-Draft status.

    +

    + +
    +
    draft-bhutton-json-schema-validation-00
    +
    +
      +
    • Correct email format RFC reference to 5321 instead of 5322
    • +
    • Clarified the set and meaning of "contentEncoding" values
    • +
    • Reference ECMA-262, 11th edition for regular expression support
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    +

    +
    +
    draft-handrews-json-schema-validation-02
    +
    +
      +
    • Grouped keywords into formal vocabularies
    • +
    • Update "format" implementation requirements in terms of vocabularies
    • +
    • By default, "format" MUST NOT be validated, although validation can be enabled
    • +
    • A vocabulary declaration can be used to require "format" validation
    • +
    • Moved "definitions" to the core spec as "$defs"
    • +
    • Moved applicator keywords to the core spec
    • +
    • Renamed the array form of "dependencies" to "dependentRequired", moved the schema form to the core spec
    • +
    • Specified all "content*" keywords as annotations, not assertions
    • +
    • Added "contentSchema" to allow applying a schema to a string-encoded document
    • +
    • Also allow RFC 4648 encodings in "contentEncoding"
    • +
    • Added "minContains" and "maxContains"
    • +
    • Update RFC reference for "hostname" and "idn-hostname"
    • +
    • Add "uuid" and "duration" formats
    • +
    +

    +
    +
    draft-handrews-json-schema-validation-01
    +
    +
      +
    • This draft is purely a clarification with no functional changes
    • +
    • Provided the general principle behind ignoring annotations under "not" and similar cases
    • +
    • Clarified "if"/"then"/"else" validation interactions
    • +
    • Clarified "if"/"then"/"else" behavior for annotation
    • +
    • Minor formatting and cross-referencing improvements
    • +
    +

    +
    +
    draft-handrews-json-schema-validation-00
    +
    +
      +
    • Added "if"/"then"/"else"
    • +
    • Classify keywords as assertions or annotations per the core spec
    • +
    • Warn of possibly removing "dependencies" in the future
    • +
    • Grouped validation keywords into sub-sections for readability
    • +
    • Moved "readOnly" from hyper-schema to validation meta-data
    • +
    • Added "writeOnly"
    • +
    • Added string-encoded media section, with former hyper-schema "media" keywords
    • +
    • Restored "regex" format (removal was unintentional)
    • +
    • Added "date" and "time" formats, and reserved additional RFC 3339 format names
    • +
    • I18N formats: "iri", "iri-reference", "idn-hostname", "idn-email"
    • +
    • Clarify that "json-pointer" format means string encoding, not URI fragment
    • +
    • Fixed typo that inverted the meaning of "minimum" and "exclusiveMinimum"
    • +
    • Move format syntax references into Normative References
    • +
    • JSON is a normative requirement
    • +
    +

    +
    +
    draft-wright-json-schema-validation-01
    +
    +
      +
    • Standardized on hyphenated format names with full words ("uriref" becomes "uri-reference")
    • +
    • Add the formats "uri-template" and "json-pointer"
    • +
    • Changed "exclusiveMaximum"/"exclusiveMinimum" from boolean modifiers of "maximum"/"minimum" to independent numeric fields.
    • +
    • Split the additionalItems/items into two sections
    • +
    • Reworked properties/patternProperties/additionalProperties definition
    • +
    • Added "examples" keyword
    • +
    • Added "contains" keyword
    • +
    • Allow empty "required" and "dependencies" arrays
    • +
    • Fixed "type" reference to primitive types
    • +
    • Added "const" keyword
    • +
    • Added "propertyNames" keyword
    • +
    +

    +
    +
    draft-wright-json-schema-validation-00
    +
    +
      +
    • Added additional security considerations
    • +
    • Removed reference to "latest version" meta-schema, use numbered version instead
    • +
    • Rephrased many keyword definitions for brevity
    • +
    • Added "uriref" format that also allows relative URI references
    • +
    +

    +
    +
    draft-fge-json-schema-validation-00
    +
    +
      +
    • Initial draft.
    • +
    • Salvaged from draft v3.
    • +
    • Redefine the "required" keyword.
    • +
    • Remove "extends", "disallow"
    • +
    • Add "anyOf", "allOf", "oneOf", "not", "definitions", "minProperties", "maxProperties".
    • +
    • "dependencies" member values can no longer be single strings; at least one element is required in a property dependency array.
    • +
    • Rename "divisibleBy" to "multipleOf".
    • +
    • "type" arrays can no longer have schemas; remove "any" as a possible value.
    • +
    • Rework the "format" section; make support optional.
    • +
    • "format": remove attributes "phone", "style", "color"; rename "ip-address" to "ipv4"; add references for all attributes.
    • +
    • Provide algorithms to calculate schema(s) for array/object instances.
    • +
    • Add interoperability considerations.
    • +
    +

    +
    +
    + +

    +

    Authors' Addresses

    +
    +
    + + Austin Wright (editor) + + + + + + + + + + + + + EMail: aaa@bzfx.net + +
    +
    +
    + + Henry Andrews (editor) + + + + + + + + + + + + + EMail: andrews_henry@yahoo.com + +
    +
    +
    + + Ben Hutton (editor) + + + + + + + + + + + + + EMail: ben@jsonschema.dev + +URI: https://jsonschema.dev + +
    +
    + + + From 36f2728265a61959374a581131e4ded3ff24b040 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Sat, 14 Nov 2020 13:14:33 +0000 Subject: [PATCH 089/311] Update ajv information --- _data/validator-libraries-modern.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 45f2c77f..8c6d86fc 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -130,9 +130,9 @@ - name: JavaScript implementations: - name: ajv - url: https://github.com/epoberezkin/ajv - notes: "for Node.js and browsers - supports [custom keywords](https://github.com/epoberezkin/ajv-keywords) and [$data reference](https://github.com/json-schema-org/json-schema-spec/issues/51)" - date-draft: + url: https://github.com/ajv-validator/ajv + notes: "for Node.js and browsers - supports [user-defined keywords](https://github.com/ajv-validator/ajv/blob/master/docs/keywords.md) and [$data reference](https://github.com/json-schema-org/json-schema-spec/issues/51)" + date-draft: [2019-09] draft: [7, 6, 4] license: MIT - name: djv From ae71927993006af61044f17fdf8437c77133f00c Mon Sep 17 00:00:00 2001 From: Relequestual Date: Tue, 1 Dec 2020 16:22:41 +0000 Subject: [PATCH 090/311] Update to include 2020-12-rc-1 for core, validation, and relative JSON pointer --- .../jsonschema-core.html | 226 +++--- .../jsonschema-validation.html | 103 ++- .../2020-12-rc-1/relative-json-pointer.html | 732 ++++++++++++++++++ work-in-progress/index.md | 13 +- 4 files changed, 894 insertions(+), 180 deletions(-) rename draft/preview/{2020-11-rc-0 => 2020-12-rc-1}/jsonschema-core.html (92%) rename draft/preview/{2020-11-rc-0 => 2020-12-rc-1}/jsonschema-validation.html (90%) create mode 100644 draft/preview/2020-12-rc-1/relative-json-pointer.html diff --git a/draft/preview/2020-11-rc-0/jsonschema-core.html b/draft/preview/2020-12-rc-1/jsonschema-core.html similarity index 92% rename from draft/preview/2020-11-rc-0/jsonschema-core.html rename to draft/preview/2020-12-rc-1/jsonschema-core.html index 3d7d2bad..9efd5fe4 100644 --- a/draft/preview/2020-11-rc-0/jsonschema-core.html +++ b/draft/preview/2020-12-rc-1/jsonschema-core.html @@ -408,6 +408,7 @@ + @@ -482,12 +483,12 @@ - + - + @@ -511,7 +512,7 @@ H. Andrews, Ed. -Expires: May 16, 2021 +Expires: June 4, 2021 @@ -528,7 +529,7 @@ -November 12, 2020 +December 1, 2020 @@ -541,7 +542,7 @@

    Abstract

    JSON Schema defines the media type "application/schema+json", a JSON-based format for describing the structure of JSON data. JSON Schema asserts what a JSON document must look like, ways to extract information from it, and how to interact with it. The "application/schema-instance+json" media type provides additional feature-rich integration with "application/schema+json" beyond what can be offered for "application/json" documents.

    Note to Readers

    -

    This document a pre-release identified as JSON Schema draft 2020-11-rc-0.

    +

    This document a pre-release identified as JSON Schema draft 2020-12-rc-1.

    The issues list for this draft can be found at <https://github.com/json-schema-org/json-schema-spec/issues>.

    For additional information, see <https://json-schema.org/>.

    To provide feedback, use this issue tracker, the communication methods listed on the homepage, or email the document editors.

    @@ -549,7 +550,7 @@

    Status of This Memo

    This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

    Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

    Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

    -

    This Internet-Draft will expire on May 16, 2021.

    +

    This Internet-Draft will expire on June 4, 2021.

    Copyright Notice

    Copyright (c) 2020 IETF Trust and the persons identified as the document authors. All rights reserved.

    This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

    @@ -627,6 +628,8 @@

    Table of Contents

  • 7.8. Reserved Locations
  • +
  • 7.9. Loading Instance Data +
  • 8. The JSON Schema Core Vocabulary
    • 8.1. Meta-Schemas and Vocabularies @@ -778,7 +781,7 @@

      Table of Contents

      1. Introduction

      JSON Schema is a JSON media type for defining the structure of JSON data. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data.

      -

      This specification defines JSON Schema core terminology and mechanisms, including pointing to another JSON Schema by reference, dereferencing a JSON Schema reference, specifying the vocabulary being used, and defining the expected output.

      +

      This specification defines JSON Schema core terminology and mechanisms, including pointing to another JSON Schema by reference, dereferencing a JSON Schema reference, specifying the dialect being used, specifying a dialect's vocabulary requirements, and defining the expected output.

      Other specifications define the vocabularies that perform assertions about validation, linking, annotation, navigation, and interaction.

      2. Conventions and Terminology

      @@ -788,7 +791,7 @@

      3. Overview

      This document proposes a new media type "application/schema+json" to identify a JSON Schema for describing JSON data. It also proposes a further optional media type, "application/schema-instance+json", to provide additional integration features. JSON Schemas are themselves JSON documents. This, and related specifications, define keywords allowing authors to describe JSON data in several ways.

      JSON Schema uses keywords to assert constraints on JSON instances or annotate those instances with additional information. Additional keywords are used to apply assertions and annotations to more complex JSON data structures, or based on some sort of condition.

      -

      To facilitate re-use, keywords can be organized into vocabularies. A vocabulary consists of a list of keywords, together with their syntax and semantics. A set of vocabularies identified by a meta-schema is known as a dialect.

      +

      To facilitate re-use, keywords can be organized into vocabularies. A vocabulary consists of a list of keywords, together with their syntax and semantics. A dialect is defined as a set of vocabularies and their required support identified in a meta-schema.

      JSON Schema can be extended either by defining additional vocabularies, or less formally by defining additional keywords outside of any vocabulary. Unrecognized individual keywords simply have their values collected as annotations, while the behavior with respect to an unrecognized vocabulary can be controlled when declaring which vocabularies are in use.

      This document defines a core vocabulary that MUST be supported by any implementation, and cannot be disabled. Its keywords are each prefixed with a "$" character to emphasize their required nature. This vocabulary is essential to the functioning of the "application/schema+json" media type, and is used to bootstrap the loading of other vocabularies.

      Additionally, this document defines a RECOMMENDED vocabulary of keywords for applying subschemas conditionally, and for applying subschemas to the contents of objects and arrays. Either this vocabulary or one very much like it is required to write schemas for non-trivial JSON instances, whether those schemas are intended for assertion validation, annotation, or both. While not part of the required core vocabulary, for maximum interoperability this additional vocabulary is included in this document and its use is strongly encouraged.

      @@ -804,7 +807,7 @@

      4.2. Instance

      A JSON document to which a schema is applied is known as an "instance".

      JSON Schema is defined over "application/json" or compatible documents, including media types with the "+json" structured syntax suffix.

      -

      Among these, this specification defines the "application/schema-instance+json" media type which defines handling for fragments in the URI, and the "schema" media type parameter.

      +

      Among these, this specification defines the "application/schema-instance+json" media type which defines handling for fragments in the URI.

      4.2.1. Instance Data Model

      JSON Schema interprets documents according to a data model. A JSON value interpreted according to this data model is called an "instance".

      @@ -848,12 +851,12 @@

      4.2.3. Non-JSON Instances

      It is possible to use JSON Schema with a superset of the JSON Schema data model, where an instance may be outside any of the six JSON data types.

      -

      In this case, annotations still apply; but validation keywords will not be useful, as they will always pass or always fail.

      +

      In this case, annotations still apply; but most validation keywords will not be useful, as they will always pass or always fail.

      A custom vocabulary may define support for a superset of the core data model. The schema itself may only be expressible in this superset; for example, to make use of the "const" keyword.

      4.3. JSON Schema Documents

      -

      A JSON Schema document, or simply a schema, is a JSON document used to describe an instance. A schema can itself be interpreted as an instance, but SHOULD always be given the media type "application/schema+json" rather than "application/schema-instance+json". The "application/schema+json" media type is defined to offer a superset of the media type parameter and fragment identifier syntax and semantics provided by "application/schema-instance+json".

      +

      A JSON Schema document, or simply a schema, is a JSON document used to describe an instance. A schema can itself be interpreted as an instance, but SHOULD always be given the media type "application/schema+json" rather than "application/schema-instance+json". The "application/schema+json" media type is defined to offer a superset of the fragment identifier syntax and semantics provided by "application/schema-instance+json".

      A JSON Schema MUST be an object or a boolean.

      4.3.1. JSON Schema Objects and Keywords

      @@ -874,13 +877,13 @@

      Keywords may fall into multiple categories, although applicators SHOULD only produce assertion results based on their subschemas' results. They should not define additional constraints independent of their subschemas.

      -

      Keywords within the same schema object are referred to as adjacent keywords.

      +

      Keywords which are properties within the same schema object are referred to as adjacent keywords.

      Extension keywords, meaning those defined outside of this document and its companions, are free to define other behaviors as well.

      A JSON Schema MAY contain properties which are not schema keywords. Unknown keywords SHOULD be treated as annotations, where the value of the keyword is the value of the annotation.

      An empty schema is a JSON Schema with no properties, or only unknown properties.

      4.3.2. Boolean JSON Schemas

      -

      The boolean schema values "true" and "false" are trivial schemas that always produce themselves as assertions results, regardless of the instance value. They never produce annotation results.

      +

      The boolean schema values "true" and "false" are trivial schemas that always produce themselves as assertion results, regardless of the instance value. They never produce annotation results.

      These boolean schemas exist to clarify schema author intent and facilitate schema processing optimizations. They behave identically to the following schema objects (where "not" is part of the subschema application vocabulary defined in this document).

      @@ -946,7 +949,7 @@

      6.4. Regular Expressions

      Keywords MAY use regular expressions to express constraints, or constrain the instance value to be a regular expression. These regular expressions SHOULD be valid according to the regular expression dialect described in ECMA-262, section 21.2.1.

      -

      Regular expressions SHOULD be built with the "u" flag (or equivilent) to provide Unicode support, or processed in such a way which provides Unicode as defined by ECMA-262.

      +

      Regular expressions SHOULD be built with the "u" flag (or equivalent) to provide Unicode support, or processed in such a way which provides Unicode as defined by ECMA-262.

      Furthermore, given the high disparity in regular expression constructs support, schema authors SHOULD limit themselves to the following regular expression tokens:

        @@ -979,8 +982,8 @@

        The lexical scope of a keyword is determined by the nested JSON data structure of objects and arrays. The largest such scope is an entire schema document. The smallest scope is a single schema object with no subschemas.

        Keywords MAY be defined with a partial value, such as a URI-reference, which must be resolved against another value, such as another URI-reference or a full URI, which is found through the lexical structure of the JSON document. The "$id", "$ref", and "$dynamicRef" core keywords, and the "base" JSON Hyper-Schema keyword, are examples of this sort of behavior.

        Note that some keywords, such as "$schema", apply to the lexical scope of the entire schema resource, and therefore MUST only appear in a schema resource's root schema.

        -

        Other keywords may take into account the dynamic scope that exists during the evaluation of a schema, typically together with an instance document. The outermost dynamic scope is the root schema of the schema document in which processing begins. The path from this root schema to any particular keyword (that includes any "$ref" and "$dynamicRef" keywords that may have been resolved) is considered the keyword's "validation path." [CREF1]Or should this be the schema object at which processing begins, even if it is not a root? This has some implications for the case where "$dynamicAnchor" is only allowed in the root schema but processing begins in a subschema.

        -

        Lexical and dynamic scopes align until a reference keyword is encountered. While following the reference keyword moves processing from one lexical scope into a different one, from the perspective of dynamic scope, following reference is no different from descending into a subschema present as a value. A keyword on the far side of that reference that resolves information through the dynamic scope will consider the originating side of the reference to be their dynamic parent, rather than examining the local lexically enclosing parent.

        +

        Other keywords may take into account the dynamic scope that exists during the evaluation of a schema. The outermost dynamic scope is the root schema of the schema document in which processing begins. The path from this root schema to any particular keyword (that includes any "$ref" and "$dynamicRef" keywords that may have been resolved) is considered the keyword's "validation path."

        +

        Lexical and dynamic scopes align until a reference keyword is encountered. While following the reference keyword moves processing from one lexical scope into a different one, from the perspective of dynamic scope, following a reference is no different from descending into a subschema present as a value. A keyword on the far side of that reference that resolves information through the dynamic scope will consider the originating side of the reference to be their dynamic parent, rather than examining the local lexically enclosing parent.

        The concept of dynamic scope is primarily used with "$dynamicRef" and "$dynamicAnchor", and should be considered an advanced feature and used with caution when defining additional keywords. It also appears when reporting errors and collected annotations, as it may be possible to revisit the same lexical scope repeatedly with different dynamic scopes. In such cases, it is important to inform the user of the dynamic path that produced the error or annotation.

        7.2. Keyword Interactions

        @@ -995,7 +998,7 @@

        7.4. Identifiers

        Identifiers set the canonical URI of a schema, or affect how such URIs are resolved in references, or both. The Core vocabulary defined in this document defines several identifying keywords, most notably "$id".

        -

        Canonical schema URIs MUST NOT change while processing an instance, but keywords that affect URI-reference resolution MAY have behavior that is only fully determined at runtime.

        +

        Canonical schema URIs MUST NOT change while processing an instance, but keywords that affect URI-reference resolution MAY have behavior that is only fully determined dynamically.

        While custom identifier keywords are possible, vocabulary designers should take care not to disrupt the functioning of core keywords. For example, the "$dynamicAnchor" keyword in this specification limits its URI resolution effects to the matching "$dynamicRef" keyword, leaving the behavior of "$ref" undisturbed.

        7.5. Applicators @@ -1009,7 +1012,7 @@

        As noted in Section 7.5, an applicator keyword may refer to a schema to be applied, rather than including it as a subschema in the applicator's value. In such situations, the schema being applied is known as the referenced schema, while the schema containing the applicator keyword is the referencing schema.

        While root schemas and subschemas are static concepts based on a schema's position within a schema document, referenced and referencing schemas are dynamic. Different pairs of schemas may find themselves in various referenced and referencing arrangements during the evaluation of an instance against a schema.

        -

        For some by-reference applicators, such as "$ref", the referenced schema can be determined by static analysis of the schema document's lexical scope. Others, such as "$dynamicRef" (with "$dynamicAnchor"), may make use of dynamic scoping, and therefore only be resolvable in the process of evaluating the schema with an instance.

        +

        For some by-reference applicators, such as "$ref", the referenced schema can be determined by static analysis of the schema document's lexical scope. Others, such as "$dynamicRef" (with "$dynamicAnchor"), are only resolvable with knowledge of all the schemas in it's dynamic scope.

        7.6. Assertions

        @@ -1130,14 +1133,19 @@

        7.8. Reserved Locations

        A fourth category of keywords simply reserve a location to hold re-usable components or data of interest to schema authors that is not suitable for re-use. These keywords do not affect validation or annotation results. Their purpose in the core vocabulary is to ensure that locations are available for certain purposes and will not be redefined by extension keywords.

        While these keywords do not directly affect results, as explained in section 9.4.2 unrecognized extension keywords that reserve locations for re-usable schemas may have undesirable interactions with references in certain circumstances.

        +

        +7.9. Loading Instance Data

        +

        While none of the vocabularies defined as part of this or the associated documents define a keyword which may target and/or load instance data, it is possible that other vocabularies may wish to do so.

        +

        Keywords MAY be defined to use JSON Pointers or Relative JSON Pointers to examine parts of an instance outside the current evaluation location.

        +

        Keywords that allow adjusting the location using a Relative JSON Pointer SHOULD default to using the current location if a default is desireable.

        8. The JSON Schema Core Vocabulary

        Keywords declared in this section, which all begin with "$", make up the JSON Schema Core vocabulary. These keywords are either required in order to process any schema or meta-schema, including those split across multiple documents, or exist to reserve keywords for purposes that require guaranteed interoperability.

        The Core vocabulary MUST be considered mandatory at all times, in order to bootstrap the processing of further vocabularies. Meta-schemas that use the "$vocabulary" keyword to declare the vocabularies in use MUST explicitly list the Core vocabulary, which MUST have a value of true indicating that it is required.

        The behavior of a false value for this vocabulary (and only this vocabulary) is undefined, as is the behavior when "$vocabulary" is present but the Core vocabulary is not included. However, it is RECOMMENDED that implementations detect these cases and raise an error when they occur. It is not meaningful to declare that a meta-schema optionally uses Core.

        Meta-schemas that do not use "$vocabulary" MUST be considered to require the Core vocabulary as if its URI were present with a value of true.

        -

        The current URI for the Core vocabulary is: <https://json-schema.org/draft/2020-11/vocab/core>.

        -

        The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-11/meta/core>.

        +

        The current URI for the Core vocabulary is: <https://json-schema.org/draft/2020-12/vocab/core>.

        +

        The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-12/meta/core>.

        While the "$" prefix is not formally reserved for the Core vocabulary, it is RECOMMENDED that extension keywords (in vocabularies or otherwise) begin with a character other than "$" to avoid possible future collisions.

        8.1. Meta-Schemas and Vocabularies @@ -1158,17 +1166,17 @@

        8.1.1. The "$schema" Keyword

        -

        The "$schema" keyword is both used as a JSON Schema feature set identifier and as the identifier of a resource which is itself a JSON Schema, which describes the set of valid schemas written for this particular feature set.

        +

        The "$schema" keyword is both used as a JSON Schema dialect identifier and as the identifier of a resource which is itself a JSON Schema, which describes the set of valid schemas written for this particular dialect.

        The value of this keyword MUST be a URI (containing a scheme) and this URI MUST be normalized. The current schema MUST be valid against the meta-schema identified by this URI.

        If this URI identifies a retrievable resource, that resource SHOULD be of media type "application/schema+json".

        The "$schema" keyword SHOULD be used in the document root schema object, and MAY be used in the root schema objects of embedded schema resources. It MUST NOT appear in non-resource root schema objects. If absent from the document root schema, the resulting behavior is implementation-defined.

        Values for this property are defined elsewhere in this and other documents, and by other parties.

        8.1.2. The "$vocabulary" Keyword

        -

        The "$vocabulary" keyword is used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema. It is also used to indicate whether each vocabulary is required or optional, in the sense that an implementation MUST understand the required vocabularies in order to successfully process the schema.

        +

        The "$vocabulary" keyword is used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema. It is also used to indicate whether each vocabulary is required or optional, in the sense that an implementation MUST understand the required vocabularies in order to successfully process the schema. Together, this information forms a dialect. Any vocabulary that is understood by the implementation MUST be processed in a manner consistent with the semantic definitions contained within the vocabulary.

        The value of this keyword MUST be an object. The property names in the object MUST be URIs (containing a scheme) and this URI MUST be normalized. Each URI that appears as a property name identifies a specific set of keywords and their semantics.

        -

        The URI MAY be a URL, but the nature of the retrievable resource is currently undefined, and reserved for future use. Vocabulary authors MAY use the URL of the vocabulary specification, in a human-readable media type such as text/html or text/plain, as the vocabulary URI. [CREF2]Vocabulary documents may be added in forthcoming drafts. For now, identifying the keyword set is deemed sufficient as that, along with meta-schema validation, is how the current "vocabularies" work today. Any future vocabulary document format will be specified as a JSON document, so using text/html or other non-JSON formats in the meantime will not produce any future ambiguity.

        -

        The values of the object properties MUST be booleans. If the value is true, then implementations that do not recognize the vocabulary MUST refuse to process any schemas that declare this meta-schema with "$schema". If the value is false, implementations that do not recognize the vocabulary SHOULD proceed with processing such schemas.

        +

        The URI MAY be a URL, but the nature of the retrievable resource is currently undefined, and reserved for future use. Vocabulary authors MAY use the URL of the vocabulary specification, in a human-readable media type such as text/html or text/plain, as the vocabulary URI. [CREF1]Vocabulary documents may be added in forthcoming drafts. For now, identifying the keyword set is deemed sufficient as that, along with meta-schema validation, is how the current "vocabularies" work today. Any future vocabulary document format will be specified as a JSON document, so using text/html or other non-JSON formats in the meantime will not produce any future ambiguity.

        +

        The values of the object properties MUST be booleans. If the value is true, then implementations that do not recognize the vocabulary MUST refuse to process any schemas that declare this meta-schema with "$schema". If the value is false, implementations that do not recognize the vocabulary SHOULD proceed with processing such schemas. The value has no impact if the implementation understands the vocabulary.

        Per 6.5, unrecognized keywords SHOULD be treated as annotations. This remains the case for keywords defined by unrecognized vocabularies. It is not currently possible to distinguish between unrecognized keywords that are defined in vocabularies from those that are not part of any vocabulary.

        The "$vocabulary" keyword SHOULD be used in the root schema of any schema document intended for use as a meta-schema. It MUST NOT appear in subschemas.

        The "$vocabulary" keyword MUST be ignored in schema documents that are not being processed as a meta-schema. This allows validating a meta-schema M against its own meta-schema M' without requiring the validator to understand the vocabularies declared by M.

        @@ -1179,7 +1187,7 @@

        For example, an implementation that is a validator SHOULD assume the use of all vocabularies in this specification and the companion Validation specification.

        8.1.2.2. Non-inheritability of vocabularies

        -

        Note that the processing restrictions on "$vocabulary" mean that meta-schemas that reference other meta-schemas using "$ref" or similar keywords do not automatically inherit the vocabulary declarations of those other meta-schemas. All such declarations must be repeated in the root of each schema document intended for use as a meta-schema. This is demonstrated in the example meta-schema. [CREF3]This requirement allows implementations to find all vocabulary requirement information in a single place for each meta-schema. As schema extensibility means that there are endless potential ways to combine more fine-grained meta-schemas by reference, requiring implementations to anticipate all possibilities and search for vocabularies in referenced meta-schemas would be overly burdensome.

        +

        Note that the processing restrictions on "$vocabulary" mean that meta-schemas that reference other meta-schemas using "$ref" or similar keywords do not automatically inherit the vocabulary declarations of those other meta-schemas. All such declarations must be repeated in the root of each schema document intended for use as a meta-schema. This is demonstrated in the example meta-schema. [CREF2]This requirement allows implementations to find all vocabulary requirement information in a single place for each meta-schema. As schema extensibility means that there are endless potential ways to combine more fine-grained meta-schemas by reference, requiring implementations to anticipate all possibilities and search for vocabularies in referenced meta-schemas would be overly burdensome.

        8.1.3. Updates to Meta-Schema and Vocabulary URIs

        Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations SHOULD consider URIs dated after this specification draft and before the next to indicate the same syntax and semantics as those listed here.

        @@ -1193,7 +1201,7 @@

        The "$id" keyword identifies a schema resource with its canonical URI.

        Note that this URI is an identifier and not necessarily a network locator. In the case of a network-addressable URL, a schema need not be downloadable from its canonical URI.

        If present, the value for this keyword MUST be a string, and MUST represent a valid URI-reference. This URI-reference SHOULD be normalized, and MUST resolve to an absolute-URI (without a fragment). Therefore, "$id" MUST NOT contain a non-empty fragment, and SHOULD NOT contain an empty fragment.

        -

        Since an empty fragment in the context of the application/schema+json media type refers to the same resource as the base URI without a fragment, an implementation MAY normalize a URI ending with an empty fragment by removing the fragment. However, schema authors SHOULD NOT rely on this behavior across implementations. [CREF4]This is primarily allowed because older meta-schemas have an empty fragment in their $id (or previously, id). A future draft may outright forbid even empty fragments in "$id".

        +

        Since an empty fragment in the context of the application/schema+json media type refers to the same resource as the base URI without a fragment, an implementation MAY normalize a URI ending with an empty fragment by removing the fragment. However, schema authors SHOULD NOT rely on this behavior across implementations. [CREF3]This is primarily allowed because older meta-schemas have an empty fragment in their $id (or previously, id). A future draft may outright forbid even empty fragments in "$id".

        This URI also serves as the base URI for relative URI-references in keywords within the schema resource, in accordance with RFC 3986 section 5.1.1 regarding base URIs embedded in content.

        The presence of "$id" in a subschema indicates that the subschema constitutes a distinct schema resource within a single schema document. Furthermore, in accordance with RFC 3986 section 5.1.2 regarding encapsulating entities, if an "$id" in a subschema is a relative URI-reference, the base URI for resolving that reference is the URI of the parent schema resource.

        If no parent schema object explicitly identifies itself as a resource with "$id", the base URI is that of the entire document, as established by the steps given in the previous section.

        @@ -1204,11 +1212,11 @@

        8.2.2. Defining location-independent identifiers

        Using JSON Pointer fragments requires knowledge of the structure of the schema. When writing schema documents with the intention to provide re-usable schemas, it may be preferable to use a plain name fragment that is not tied to any particular structural location. This allows a subschema to be relocated without requiring JSON Pointer references to be updated.

        -

        The "$anchor" and "$dynamicAnchor" keywords are used to specify such fragments. They are identifier keywords that can only be used to create plain name fragments, rather than absolute URIs as seen with "$id". The behavior of the created fragment is identical for both keywords.

        +

        The "$anchor" and "$dynamicAnchor" keywords are used to specify such fragments. They are identifier keywords that can only be used to create plain name fragments, rather than absolute URIs as seen with "$id".

        The base URI to which the resulting fragment is appended is the canonical URI of the schema resource containing the "$anchor" or "$dynamicAnchor" in question. As discussed in the previous section, this is either the nearest "$id" in the same or parent schema object, or the base URI for the document as determined according to RFC 3986.

        Separately from the usual usage of URIs, "$dynamicAnchor" indicates that the fragment is an extension point when used with the "$dynamicRef" keyword. This low-level, advanced feature makes it easier to extend recursive schemas such as the meta-schemas, without imposing any particular semantics on that extension. See the section on "$dynamicRef" for details.

        In most cases, the normal fragment behavior both suffices and is more intuitive. Therefore it is RECOMMENDED that "$anchor" be used to create plain name fragments unless there is a clear need for "$dynamicAnchor".

        -

        If present, the value of this keyword MUST be a string and MUST start with a letter ([A-Za-z]) or underscore ("_"), followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), and periods ("."). This matches the US-ASCII part of XML's NCName production. [CREF5]Note that the anchor string does not include the "#" character, as it is not a URI-reference. An "$anchor": "foo" becomes the fragment "#foo" when used in a URI. See below for full examples.

        +

        If present, the value of this keyword MUST be a string and MUST start with a letter ([A-Za-z]) or underscore ("_"), followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), and periods ("."). This matches the US-ASCII part of XML's NCName production. [CREF4]Note that the anchor string does not include the "#" character, as it is not a URI-reference. An "$anchor": "foo" becomes the fragment "#foo" when used in a URI. See below for full examples.

        The effect of specifying the same fragment name multiple times within the same resource, using any combination of "$anchor" and/or "$dynamicAnchor", is undefined. Implementations MAY raise an error if such usage is detected.

        8.2.3. Schema References @@ -1219,17 +1227,17 @@

        8.2.3.1. Direct References with "$ref"

        -

        The "$ref" keyword is an applicator that is used to reference a statically identified schema. Its results are the results of the referenced schema. [CREF6]Note that this definition of how the results are determined means that other keywords can appear alongside of "$ref" in the same schema object.

        -

        The value of the "$ref" property MUST be a string which is a URI-Reference. Resolved against the current URI base, it produces the URI of the schema to apply. This resolution is safe to perform on schema load, as the process of evaluating an instance cannot change how the reference resolves.

        +

        The "$ref" keyword is an applicator that is used to reference a statically identified schema. Its results are the results of the referenced schema. [CREF5]Note that this definition of how the results are determined means that other keywords can appear alongside of "$ref" in the same schema object.

        +

        The value of the "$ref" keyword MUST be a string which is a URI-Reference. Resolved against the current URI base, it produces the URI of the schema to apply. This resolution is safe to perform on schema load as neither other schemas nor the instance can change how the reference resolves.

        8.2.3.2. Dynamic References with "$dynamicRef"

        -

        The "$dynamicRef" keyword is an applicator that allows for deferring the full resolution until runtime, at which point it is resolved each time it is encountered while evaluating an instance.

        -

        Together with "$dynamicAnchor", "$dynamicRef" implements a cooperative extension mechanism that is primarily useful with recursive schemas (schemas that reference themselves). Both the extension point and the runtime-determined extension target are defined with "$dynamicAnchor", and only exhibit runtime dynamic behavior when referenced with "$dynamicRef".

        -

        The value of the "$dynamicRef" property MUST be a string which is a URI-Reference. Resolved against the current URI base, it produces the URI used as the starting point for runtime resolution. This initial resolution is safe to perform on schema load.

        -

        If the initially resolved starting point URI includes a fragment that was created by the "$dynamicAnchor" keyword, the initial URI MUST be replaced by the URI (including the fragment) for the outermost schema resource in the dynamic scope that defines an identically named fragment with "$dynamicAnchor". [CREF7]Requiring both the initial and final URI fragment to be defined by "$dynamicAnchor" ensures that the more common "$anchor" never unexpectedly changes the dynamic resolution process due to a naming conflict across resources. Users of "$dynamicAnchor" are expected to be aware of the possibility of such name collisions, while users of "$anchor" are not.

        -

        Otherwise, its behavior is identical to "$ref", and no runtime resolution is needed.

        -

        For a full example using these keyword, see appendix C. [CREF8]The difference between the hyper-schema meta-schema in pre-2019 drafts and an this draft dramatically demonstrates the utility of these keywords.

        +

        The "$dynamicRef" keyword is an applicator that is used to reference a dynamically identified schema.

        +

        Together with "$dynamicAnchor", "$dynamicRef" implements a cooperative extension mechanism that is primarily useful with recursive schemas (schemas that reference themselves). Both the extension point and the extension target are defined with "$dynamicAnchor", and only exhibit dynamic behavior when referenced with "$dynamicRef".

        +

        The value of the "$dynamicRef" property MUST be a string which is a URI-Reference. Resolved against the current URI base, it produces the URI used as the starting point for resolution. This initial resolution is safe to perform on schema load.

        +

        If the initially resolved starting point URI includes a fragment that was created by the "$dynamicAnchor" keyword, the initial URI MUST be replaced by the URI (including the fragment) for the outermost schema resource in the dynamic scope that defines an identically named fragment with "$dynamicAnchor".

        +

        Otherwise, its behavior is identical to "$ref", and no dynamic resolution is needed.

        +

        For a full example using these keyword, see appendix C. [CREF6]The difference between the hyper-schema meta-schema in pre-2019 drafts and an this draft dramatically demonstrates the utility of these keywords.

        8.2.4. Schema Re-Use With "$defs"

        @@ -1256,7 +1264,7 @@

        The value of this keyword MUST be a string. Implementations MUST NOT present this string to end users. Tools for editing schemas SHOULD support displaying and editing this keyword. The value of this keyword MAY be used in debug or error output which is intended for developers making use of schemas.

        Schema vocabularies SHOULD allow "$comment" within any object containing vocabulary keywords. Implementations MAY assume "$comment" is allowed unless the vocabulary specifically forbids it. Vocabularies MUST NOT specify any effect of "$comment" beyond what is described in this specification.

        Tools that translate other media types or programming languages to and from application/schema+json MAY choose to convert that media type or programming language's native comments to or from "$comment" values. The behavior of such translation when both native comments and "$comment" properties are present is implementation-dependent.

        -

        Implementations SHOULD treat "$comment" identically to an unknown extension keyword. They MAY strip "$comment" values at any point during processing. In particular, this allows for shortening schemas when the size of deployed schemas is a concern.

        +

        Implementations MAY strip "$comment" values at any point during processing. In particular, this allows for shortening schemas when the size of deployed schemas is a concern.

        Implementations MUST NOT take any other action based on the presence, absence, or contents of "$comment" properties. In particular, the value of "$comment" MUST NOT be collected as an annotation result.

        9. Loading and Processing Schemas

        @@ -1308,7 +1316,7 @@

        When an implementation encounters the <#/$defs/single> schema, it resolves the "$anchor" value as a fragment name against the current base URI to form <https://example.net/root.json#item>.

        When an implementation then looks inside the <#/items> schema, it encounters the <#item> reference, and resolves this to <https://example.net/root.json#item>, which it has seen defined in this same document and can therefore use automatically.

        -

        When an implementation encounters the reference to "other.json", it resolves this to <https://example.net/other.json>, which is not defined in this document. If a schema with that identifier has otherwise been supplied to the implementation, it can also be used automatically. [CREF9]What should implementations do when the referenced schema is not known? Are there circumstances in which automatic network dereferencing is allowed? A same origin policy? A user-configurable option? In the case of an evolving API described by Hyper-Schema, it is expected that new schemas will be added to the system dynamically, so placing an absolute requirement of pre-loading schema documents is not feasible.

        +

        When an implementation encounters the reference to "other.json", it resolves this to <https://example.net/other.json>, which is not defined in this document. If a schema with that identifier has otherwise been supplied to the implementation, it can also be used automatically. [CREF7]What should implementations do when the referenced schema is not known? Are there circumstances in which automatic network dereferencing is allowed? A same origin policy? A user-configurable option? In the case of an evolving API described by Hyper-Schema, it is expected that new schemas will be added to the system dynamically, so placing an absolute requirement of pre-loading schema documents is not feasible.

        9.2.1. JSON Pointer fragments and embedded schema resources

        @@ -1346,27 +1354,28 @@

        Here we see that the canonical URI for that "additionalProperties" subschema is still valid, while the non-canonical URI with the fragment beginning with "#/items/$ref" now resolves to nothing.

        Note also that "https://example.com/foo#/items" is valid in both arrangements, but resolves to a different value. This URI ends up functioning similarly to a retrieval URI for a resource. While valid, examining the resolved value and either using the "$id" (if the value is a subschema), or resolving the reference and using the "$id" of the reference target, is preferable.

        -

        An implementation MAY choose not to support addressing schemas by non-canonical URIs. As such, it is RECOMMENDED that schema authors only use canonical URIs, as using non-canonical URIs may reduce schema interoperability. [CREF10]This is to avoid requiring implementations to keep track of a whole stack of possible base URIs and JSON Pointer fragments for each, given that all but one will be fragile if the schema resources are reorganized. Some have argued that this is easy so there is no point in forbidding it, while others have argued that it complicates schema identification and should be forbidden. Feedback on this topic is encouraged.

        +

        An implementation MAY choose not to support addressing schemas by non-canonical URIs. As such, it is RECOMMENDED that schema authors only use canonical URIs, as using non-canonical URIs may reduce schema interoperability. [CREF8]This is to avoid requiring implementations to keep track of a whole stack of possible base URIs and JSON Pointer fragments for each, given that all but one will be fragile if the schema resources are reorganized. Some have argued that this is easy so there is no point in forbidding it, while others have argued that it complicates schema identification and should be forbidden. Feedback on this topic is encouraged.

        Further examples of such non-canonical URIs, as well as the appropriate canonical URIs to use instead, are provided in appendix A.

        9.3. Compound Documents

        -

        A Compound Schema Document is defined as JSON document (sometimes called a "bundled" schema) which has multiple embedded JSON Schema Resources bundled into the same document to ease transportation.

        +

        A Compound Schema Document is defined as a JSON document (sometimes called a "bundled" schema) which has multiple embedded JSON Schema Resources bundled into the same document to ease transportation.

        Each embedded Schema Resource MUST be treated as an individual Schema Resource, following standard schema loading and processing requirements, including determining vocabulary support.

        9.3.1. Bundling

        -

        The bundling process for creating a Compound Schema Document is defined as taking references (such as "$ref") to an external Schema Resource and embedding the referenced Schema Resources within the referring document. Bundling is done in such a way that all URIs (used for referencing) in the base document and any referenced/embedded documents do not require altering.

        -

        Each embedded JSON Schema Resource MUST identify itself with an absolute URI using the "$id" keyword, and SHOULD make use of the "$schema" keyword to identify the dialect it is using, in the root of the schema resource.

        -

        When the Schema Resource referenced by a by-reference applicator is bundled, the Schema Resource MUST be located as a value of a "$defs" object at the containing schema's root. The key of the "$defs" for the now embedded Schema Resource MAY be the "$id" of the bundled schema or some other form of application defined unique identifer (such as a UUID). This key is not intended to be referenced in JSON Schema, but may be used by an application to aid the bundling process.

        -

        Bundled Schema Resource MUST NOT be bundled by replacing the schema object from which it was referenced, or by wrapping the Schema Resource in other applicator keywords.

        -

        In order to produce identical output, references in the containing schema document to the previously external Schema Resources MUST NOT be changed, and now resolve to a schema using the "$id" of an embedded Schema Resource. Such identical output includes validation evaluation and URIs or paths used in resulting annotations or errors.

        -

        While the bundling process will often be the main method for creating a Compound Schema Document, it is also possible and expected that some will be created by hand, potentially without individual Schema Resources existing on their own previously.

        +

        The bundling process for creating a Compound Schema Document is defined as taking references (such as "$ref") to an external Schema Resource and embedding the referenced Schema Resources within the referring document. Bundling SHOULD be done in such a way that all URIs (used for referencing) in the base document and any referenced/embedded documents do not require altering.

        +

        Each embedded JSON Schema Resource MUST identify itself with a URI using the "$id" keyword, and SHOULD make use of the "$schema" keyword to identify the dialect it is using, in the root of the schema resource. It is RECOMMENDED that the URI identifier value of "$id" be an Absolute URI.

        +

        When the Schema Resource referenced by a by-reference applicator is bundled, it is RECOMMENDED that the Schema Resource be located as a value of a "$defs" object at the containing schema's root. The key of the "$defs" for the now embedded Schema Resource MAY be the "$id" of the bundled schema or some other form of application defined unique identifer (such as a UUID). This key is not intended to be referenced in JSON Schema, but may be used by an application to aid the bundling process.

        +

        A Schema Resource MAY be embedded in a location other than "$defs" where the location is defined as a schema value.

        +

        A Bundled Schema Resource MUST NOT be bundled by replacing the schema object from which it was referenced, or by wrapping the Schema Resource in other applicator keywords.

        +

        In order to produce identical output, references in the containing schema document to the previously external Schema Resources MUST NOT be changed, and now resolve to a schema using the "$id" of an embedded Schema Resource. Such identical output includes validation evaluation and URIs or paths used in resulting annotations or errors.

        +

        While the bundling process will often be the main method for creating a Compound Schema Document, it is also possible and expected that some will be created by hand, potentially without individual Schema Resources existing on their own previously.

        9.3.2. Differing and Default Dialects

        -

        If multiple schema resources are present in a single document, then schema resources which do not have a "$schema" keyword in their root schema object MUST be processed as if "$schema" were present with the same value as for the immediately enclosing resource.

        -

        Since any schema that can be referenced can also be embedded, embedded schema resources MAY specify different "$schema" values from their enclosing resource.

        +

        When multiple schema resources are present in a single document, schema resources which do not define with which dialect they should be processed MUST be processed with the same dialect as the enclosing resource.

        +

        Since any schema that can be referenced can also be embedded, embedded schema resources MAY specify different processing dialects using the "$schema" values from their enclosing resource.

        9.3.3. Validating

        -

        Given that a Compound Schema Document may have embedded resources which identify as using different dialects, these documents SHOULD NOT be validated by applying a meta-schema to the Compound Schema Document as an instance. It is RECOMMENDED that an alternate validation process be provided in order to validate Schema Documents. Each Schema Resource SHOULD be separately validated against its associated meta-schema. [CREF11]If you know a schema is what's being validated, you can identify if the schemas is a Compound Schema Document or not, by way of use of "$id", which identifies an embedded resource when used not at the document's root.

        +

        Given that a Compound Schema Document may have embedded resources which identify as using different dialects, these documents SHOULD NOT be validated by applying a meta-schema to the Compound Schema Document as an instance. It is RECOMMENDED that an alternate validation process be provided in order to validate Schema Documents. Each Schema Resource SHOULD be separately validated against its associated meta-schema. [CREF9]If you know a schema is what's being validated, you can identify if the schemas is a Compound Schema Document or not, by way of use of "$id", which identifies an embedded resource when used not at the document's root.

        A Compound Schema Document in which all embedded resources identify as using the same dialect, or in which "$schema" is omitted and therefore defaults to that of the enclosing resource, MAY be validated by applying the appropriate meta-schema.

        9.4. Caveats

        @@ -1377,7 +1386,7 @@

        9.4.2. References to Possible Non-Schemas

        Subschema objects (or booleans) are recognized by their use with known applicator keywords or with location-reserving keywords such as "$defs" that take one or more subschemas as a value. These keywords may be "$defs" and the standard applicators from this document, or extension keywords from a known vocabulary, or implementation-specific custom keywords.

        -

        Multi-level structures of unknown keywords are capable of introducing nested subschemas, which would be subject to the processing rules for "$id". Therefore, having a reference target in such an unrecognized structure cannot be reliably implemented, and the resulting behavior is undefined. Similarly, a reference target under a known keyword, for which the value is known not to be a schema, results in undefined behavior in order to avoid burdening implementations with the need to detect such targets. [CREF12]These scenarios are analogous to fetching a schema over HTTP but receiving a response with a Content-Type other than application/schema+json. An implementation can certainly try to interpret it as a schema, but the origin server offered no guarantee that it actually is any such thing. Therefore, interpreting it as such has security implications and may produce unpredictable results.

        +

        Multi-level structures of unknown keywords are capable of introducing nested subschemas, which would be subject to the processing rules for "$id". Therefore, having a reference target in such an unrecognized structure cannot be reliably implemented, and the resulting behavior is undefined. Similarly, a reference target under a known keyword, for which the value is known not to be a schema, results in undefined behavior in order to avoid burdening implementations with the need to detect such targets. [CREF10]These scenarios are analogous to fetching a schema over HTTP but receiving a response with a Content-Type other than application/schema+json. An implementation can certainly try to interpret it as a schema, but the origin server offered no guarantee that it actually is any such thing. Therefore, interpreting it as such has security implications and may produce unpredictable results.

        Note that single-level custom keywords with identical syntax and semantics to "$defs" do not allow for any intervening "$id" keywords, and therefore will behave correctly under implementations that attempt to use any reference target as a schema. However, this behavior is implementation-specific and MUST NOT be relied upon for interoperability.

        9.5. Associating Instances and Schemas

        @@ -1395,60 +1404,22 @@

        -9.5.1.2. Identifying a Schema via a Media Type Parameter -

        -

        Media types MAY allow for a "schema" media type parameter, which gives HTTP servers the ability to perform Content-Type Negotiation based on schema. The media-type parameter MUST be a whitespace-separated list of URIs (i.e. relative references are invalid).

        -

        When using the media type application/schema-instance+json, the "schema" parameter MUST be supplied.

        -

        When using the media type application/schema+json, the "schema" parameter MAY be supplied. If supplied, it SHOULD contain the same URI as identified by the "$schema" keyword, and MAY contain additional URIs. The "$schema" URI MUST be considered the schema's canonical meta-schema, regardless of the presence of alternative or additional meta-schemas as a media type parameter.

        -

        The schema URI is opaque and SHOULD NOT automatically be dereferenced. If the implementation does not understand the semantics of the provided schema, the implementation can instead follow the "describedby" links, if any, which may provide information on how to handle the schema. Since "schema" doesn't necessarily point to a network location, the "describedby" relation is used for linking to a downloadable schema. However, for simplicity, schema authors should make these URIs point to the same resource when possible.

        -

        In HTTP, the media-type parameter would be sent inside the Content-Type header:

        -
        -        
        -        Content-Type: application/schema-instance+json;
        -                  schema="https://example.com/my-hyper-schema"
        -        
        -                            
        -

        Multiple schemas are whitespace separated, and indicate that the instance conforms to all of the listed schemas:

        -
        -        
        -        Content-Type: application/schema-instance+json;
        -                  schema="https://example.com/alice https://example.com/bob"
        -        
        -                            
        -

        Media type parameters are also used in HTTP's Accept request header:

        -
        -        
        -        Accept: application/schema-instance+json;
        -                  schema="https://example.com/qiang https://example.com/li",
        -                application/schema-instance+json;
        -                  schema="https://example.com/kumar"
        -        
        -                            
        -

        As with Content-Type, multiple schema parameters in the same string requests an instance that conforms to all of the listed schemas.

        -

        Unlike Content-Type, Accept can contain multiple values to indicate that the client can accept several media types. In the above example, note that the two media types differ only by their schema parameter values. This requests an application/schema-instance+json representation that conforms to at least one of the identified schemas.

        -

        [CREF13]This paragraph assumes that we can register a "schema" link relation. Should we instead specify something like "tag:json-schema.org,2017:schema" for now? HTTP can also send the "schema" in a Link, though this may impact media-type semantics and Content-Type negotiation if this replaces the media-type parameter entirely:

        -
        -        
        -        Link: </alice>;rel="schema", </bob>;rel="schema"
        -        
        -                            
        -

        -9.5.1.3. Usage Over HTTP

        -

        When used for hypermedia systems over a network, HTTP is frequently the protocol of choice for distributing schemas. Misbehaving clients can pose problems for server maintainers if they pull a schema over the network more frequently than necessary, when it's instead possible to cache a schema for a long period of time.

        -

        HTTP servers SHOULD set long-lived caching headers on JSON Schemas. HTTP clients SHOULD observe caching headers and not re-request documents within their freshness period. Distributed systems SHOULD make use of a shared cache and/or caching proxy.

        -

        Clients SHOULD set or prepend a User-Agent header specific to the JSON Schema implementation or software product. Since symbols are listed in decreasing order of significance, the JSON Schema library name/version should precede the more generic HTTP library name (if any). For example:

        +9.5.1.2. Usage Over HTTP +

        When used for hypermedia systems over a network, HTTP is frequently the protocol of choice for distributing schemas. Misbehaving clients can pose problems for server maintainers if they pull a schema over the network more frequently than necessary, when it's instead possible to cache a schema for a long period of time.

        +

        HTTP servers SHOULD set long-lived caching headers on JSON Schemas. HTTP clients SHOULD observe caching headers and not re-request documents within their freshness period. Distributed systems SHOULD make use of a shared cache and/or caching proxy.

        +

        Clients SHOULD set or prepend a User-Agent header specific to the JSON Schema implementation or software product. Since symbols are listed in decreasing order of significance, the JSON Schema library name/version should precede the more generic HTTP library name (if any). For example:

                 
                 User-Agent: product-name/5.4.1 so-cool-json-schema/1.0.2 curl/7.43.0
                 
                                     
        -

        Clients SHOULD be able to make requests with a "From" header so that server operators can contact the owner of a potentially misbehaving script.

        +

        Clients SHOULD be able to make requests with a "From" header so that server operators can contact the owner of a potentially misbehaving script.

        10. A Vocabulary for Applying Subschemas

        This section defines a vocabulary of applicator keywords that are RECOMMENDED for use as the basis of other vocabularies.

        Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

        -

        The current URI for this vocabulary, known as the Applicator vocabulary, is: <https://json-schema.org/draft/2020-11/vocab/applicator>.

        -

        The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-11/meta/applicator>.

        +

        The current URI for this vocabulary, known as the Applicator vocabulary, is: <https://json-schema.org/draft/2020-12/vocab/applicator>.

        +

        The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-12/meta/applicator>.

        Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations SHOULD consider URIs dated after this specification draft and before the next to indicate the same syntax and semantics as those listed here.

        10.1. Keyword Independence

        @@ -1467,6 +1438,7 @@

        10.2. Keywords for Applying Subschemas in Place

        These keywords apply subschemas to the same location in the instance as the parent schema is being applied. They allow combining or modifying the subschema results in various ways.

        +

        Subschemas of these keywords evaluate the instance completely independently such that the results of one such subschema MUST NOT impact the results of sibling subschemas. Therefore subschemas may be applied in any order.

        10.2.1. Keywords for Applying Subschemas With Logic

        @@ -1533,15 +1505,16 @@

        10.3.1.2. items

        The value of "items" MUST be a valid JSON Schema.

        -

        This keyword applies its subschema to all instance elements at indexes greater than the length of the "prefixItems" array in the same schema object, as reported by the annotation result of that "prefixItems" keyword. If no such annotation result exists, "items" applies its subschema to all instance array elements. [CREF14]Note that the behavior of "items" without "prefixItems" is identical to that of the schema form of "items" in prior drafts. When "prefixItems" is present, the behavior of "items" is identical to the former "additionalItems" keyword.

        +

        This keyword applies its subschema to all instance elements at indexes greater than the length of the "prefixItems" array in the same schema object, as reported by the annotation result of that "prefixItems" keyword. If no such annotation result exists, "items" applies its subschema to all instance array elements. [CREF11]Note that the behavior of "items" without "prefixItems" is identical to that of the schema form of "items" in prior drafts. When "prefixItems" is present, the behavior of "items" is identical to the former "additionalItems" keyword.

        If the "items" subschema is applied to any positions within the instance array, it produces an annotation result of boolean true, indicating that all remaining array elements have been evaluated against this keyword's subschema.

        Omitting this keyword has the same assertion behavior as an empty schema.

        Implementations MAY choose to implement or optimize this keyword in another way that produces the same effect, such as by directly checking for the presence and size of a "prefixItems" array. Implementations that do not support annotation collection MUST do so.

        10.3.1.3. contains

        The value of this keyword MUST be a valid JSON Schema.

        -

        An array instance is valid against "contains" if at least one of its elements is valid against the given schema. Note that when collecting annotations, the subschema MUST be applied to every array element even after the first match has been found. This is to ensure that all possible annotations are collected.

        -

        This keyword produces an annotation value which is an array of the indexes to which this keyword validates successfully when applying its subschema, in ascending order. The value MAY be a boolean true if the subschema validated successfully when applied to every index of the instance.

        +

        An array instance is valid against "contains" if at least one of its elements is valid against the given schema. The subschema MUST be applied to every array element even after the first match has been found, in order to collect annotations for use by other keywords. This is to ensure that all possible annotations are collected.

        +

        Logically, the validation result of applying the value subschema to each item in the array MUST be ORed with "false", resulting in an overall validation result.

        +

        This keyword produces an annotation value which is an array of the indexes to which this keyword validates successfully when applying its subschema, in ascending order. The value MAY be a boolean "true" if the subschema validated successfully when applied to every index of the instance. If the instance array this keywords subschema is applicable to is empty, the annotation value MUST NOT be missing.

        10.3.2. Keywords for Applying Subschemas to Objects

        @@ -1574,12 +1547,13 @@

        11. A Vocabulary for Unevaluated Locations

        The purpose of these keywords is to enable schema authors to apply subschemas to array items or object properties that have not been successfully evaluated against any dynamic-scope subschema of any adjacent keywords.

        These instance items or properties may have been unsuccessfully evaluated against one or more adjacent keyword subschemas, such as when an assertion in a branch of an "anyOf" fails. Such failed evaluations are not considered to contribute to whether or not the item or property has been evaluated. Only successful evaluations are considered.

        -

        Recall that adjacent keywords are keywords within the same schema object, and that the dynamic-scope subschemas include reference targets as well as lexical subschemas.

        -

        The behavior of these keywords depend on the annotation results of adjacent keywords that apply to the instance location being validated.

        -

        Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

        -

        The current URI for this vocabulary, known as the Unevaluated Applicator vocabulary, is: <https://json-schema.org/draft/2020-11/vocab/unevaluated>.

        -

        The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-11/meta/unevaluated>.

        -

        Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations SHOULD consider URIs dated after this specification draft and before the next to indicate the same syntax and semantics as those listed here.

        +

        If an item in an array or an object property is "successfully evaluated", it is logically considered to be valid in terms of the representation of the object or array that's expected. For example if a subschema represents a car, which requires between 2-4 wheels, and the value of "wheels" is 6, the instance object is not "evaluated" to be a car, and the "wheels" property is considered "unevaluated (successfully as a known thing)", and does not retain any annotations.

        +

        Recall that adjacent keywords are keywords within the same schema object, and that the dynamic-scope subschemas include reference targets as well as lexical subschemas.

        +

        The behavior of these keywords depend on the annotation results of adjacent keywords that apply to the instance location being validated.

        +

        Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

        +

        The current URI for this vocabulary, known as the Unevaluated Applicator vocabulary, is: <https://json-schema.org/draft/2020-12/vocab/unevaluated>.

        +

        The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-12/meta/unevaluated>.

        +

        Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations SHOULD consider URIs dated after this specification draft and before the next to indicate the same syntax and semantics as those listed here.

        11.1. unevaluatedItems

        @@ -1635,7 +1609,7 @@

        The JSON key for this information is "keywordLocation".

        12.3.2. Keyword Absolute Location

        -

        The absolute, dereferenced location of the validating keyword. The value MUST be expressed as a full URI using the canonical URI of the relevant schema object, and it MUST NOT include by-reference applicators such as "$ref" or "$dynamicRef" as non-terminal path components. It MAY end in such keywords if the error or annotation is for that keyword, such as an unresolvable reference. [CREF15]Note that "absolute" here is in the sense of "absolute filesystem path" (meaning the complete location) rather than the "absolute-URI" terminology from RFC 3986 (meaning with scheme but without fragment). Keyword absolute locations will always have a fragment in order to identify the keyword.

        +

        The absolute, dereferenced location of the validating keyword. The value MUST be expressed as a full URI using the canonical URI of the relevant schema object, and it MUST NOT include by-reference applicators such as "$ref" or "$dynamicRef" as non-terminal path components. It MAY end in such keywords if the error or annotation is for that keyword, such as an unresolvable reference. [CREF12]Note that "absolute" here is in the sense of "absolute filesystem path" (meaning the complete location) rather than the "absolute-URI" terminology from RFC 3986 (meaning with scheme but without fragment). Keyword absolute locations will always have a fragment in order to identify the keyword.

         
         https://example.com/schemas/common#/$defs/count/minimum
        @@ -1672,7 +1646,7 @@ 

        { "$id": "https://example.com/polygon", - "$schema": "https://json-schema.org/draft/2020-11/schema", + "$schema": "https://json-schema.org/draft/2020-12/schema", "$defs": { "point": { "type": "object", @@ -1823,13 +1797,13 @@

        12.4.4. Verbose

        The "Verbose" structure is a fully realized hierarchy that exactly matches that of the schema. This structure has applications in form generation and validation where the error's location is important.

        The primary difference between this and the "Detailed" structure is that all results are returned. This includes sub-schema validation results that would otherwise be removed (e.g. annotations for failed validations, successful validations inside a `not` keyword, etc.). Because of this, it is RECOMMENDED that each node also carry a `valid` property to indicate the validation result for that node.

        -

        Because this output structure can be quite large, a smaller example is given here for brevity. The URI of the full output structure of the example above is: <https://json-schema.org/draft/2020-11/output/verbose-example>.

        +

        Because this output structure can be quite large, a smaller example is given here for brevity. The URI of the full output structure of the example above is: <https://json-schema.org/draft/2020-12/output/verbose-example>.

         
         // schema
         {
           "$id": "https://example.com/polygon",
        -  "$schema": "https://json-schema.org/draft/2020-11/schema",
        +  "$schema": "https://json-schema.org/draft/2020-12/schema",
           "type": "object",
           "properties": {
             "validProp": true,
        @@ -1878,7 +1852,7 @@ 

        12.4.5. Output validation schemas

        -

        For convenience, JSON Schema has been provided to validate output generated by implementations. Its URI is: <https://json-schema.org/draft/2020-11/output/schema>.

        +

        For convenience, JSON Schema has been provided to validate output generated by implementations. Its URI is: <https://json-schema.org/draft/2020-12/output/schema>.

        13. Security Considerations

        @@ -1983,7 +1957,7 @@

        [json-schema-validation] -Wright, A., Andrews, H. and B. Hutton, "JSON Schema Validation: A Vocabulary for Structural Validation of JSON", Internet-Draft draft-bhutton-json-schema-validation-00, November 2020. +Wright, A., Andrews, H. and B. Hutton, "JSON Schema Validation: A Vocabulary for Structural Validation of JSON", Internet-Draft draft-bhutton-json-schema-validation-00, December 2020. [RFC6596] @@ -2147,7 +2121,7 @@

        // tree schema, extensible { - "$schema": "https://json-schema.org/draft/2020-11/schema", + "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://example.com/tree", "$dynamicAnchor": "node", @@ -2165,9 +2139,9 @@

        // strict-tree schema, guards against misspelled properties { - "$schema": "https://json-schema.org/draft/2020-11/schema", + "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://example.com/strict-tree", - "$dynamicAnchor": node, + "$dynamicAnchor": "node", "$ref": "tree", "unevaluatedProperties": false @@ -2232,19 +2206,19 @@

         
         {
        -  "$schema": "https://json-schema.org/draft/2020-11/schema",
        +  "$schema": "https://json-schema.org/draft/2020-12/schema",
           "$id": "https://example.com/meta/general-use-example",
           "$dynamicAnchor": "meta",
           "$vocabulary": {
        -    "https://json-schema.org/draft/2020-11/vocab/core": true,
        -    "https://json-schema.org/draft/2020-11/vocab/applicator": true,
        -    "https://json-schema.org/draft/2020-11/vocab/validation": true,
        +    "https://json-schema.org/draft/2020-12/vocab/core": true,
        +    "https://json-schema.org/draft/2020-12/vocab/applicator": true,
        +    "https://json-schema.org/draft/2020-12/vocab/validation": true,
             "https://example.com/vocab/example-vocab": true
           },
           "allOf": [
        -    {"$ref": "https://json-schema.org/draft/2020-11/meta/core"},
        -    {"$ref": "https://json-schema.org/draft/2020-11/meta/applicator"},
        -    {"$ref": "https://json-schema.org/draft/2020-11/meta/validation"},
        +    {"$ref": "https://json-schema.org/draft/2020-12/meta/core"},
        +    {"$ref": "https://json-schema.org/draft/2020-12/meta/applicator"},
        +    {"$ref": "https://json-schema.org/draft/2020-12/meta/validation"},
             {"$ref": "https://example.com/meta/example-vocab",
           ],
           "patternProperties": {
        @@ -2263,7 +2237,7 @@ 

         
         {
        -  "$schema": "https://json-schema.org/draft/2020-11/schema",
        +  "$schema": "https://json-schema.org/draft/2020-12/schema",
           "$id": "https://example.com/meta/example-vocab",
           "$dynamicAnchor": "meta",
           "$vocabulary": {
        @@ -2321,7 +2295,7 @@ 

        Thanks to Jason Desrosiers, Daniel Perrett, Erik Wilde, Evgeny Poberezkin, Brad Bowman, Gowry Sankar, Donald Pipowitch, Dave Finlay, Denis Laxalde, Phil Sturgeon, Shawn Silverman, and Karen Etheridge for their submissions and patches to the document.

        Appendix G. ChangeLog

        -

        [CREF16]This section to be removed before leaving Internet-Draft status.

        +

        [CREF13]This section to be removed before leaving Internet-Draft status.

        @@ -2337,7 +2311,7 @@

      • $dynamic* (previously $recursive) no longer use runtime base URI determination
      • Define Compound Schema Documents (bundle) and processing
      • Reference ECMA-262, 11th edition for regular expression support
      • -
      • +
      • Remove media type parameters
      @@ -2527,14 +2501,16 @@

      Authors' Addresses

      - Auckland, + - NZ + EMail: gregsdennis@yahoo.com +URI: https://github.com/gregsdennis + diff --git a/draft/preview/2020-11-rc-0/jsonschema-validation.html b/draft/preview/2020-12-rc-1/jsonschema-validation.html similarity index 90% rename from draft/preview/2020-11-rc-0/jsonschema-validation.html rename to draft/preview/2020-12-rc-1/jsonschema-validation.html index 0e5d80b2..f203d3ec 100644 --- a/draft/preview/2020-11-rc-0/jsonschema-validation.html +++ b/draft/preview/2020-12-rc-1/jsonschema-validation.html @@ -408,11 +408,11 @@ - + - - + + @@ -446,12 +446,12 @@ - + - + @@ -475,7 +475,7 @@ H. Andrews, Ed. -Expires: May 16, 2021 +Expires: June 4, 2021 @@ -484,7 +484,7 @@ -November 12, 2020 +December 1, 2020 @@ -497,7 +497,7 @@

      Abstract

      JSON Schema (application/schema+json) has several purposes, one of which is JSON instance validation. This document specifies a vocabulary for JSON Schema to describe the meaning of JSON documents, provide hints for user interfaces working with JSON data, and to make assertions about what a valid document must look like.

      Note to Readers

      -

      This document a pre-release identified as JSON Schema draft 2020-11-rc-0.

      +

      This document a pre-release identified as JSON Schema draft 2020-12-rc-1.

      The issues list for this draft can be found at <https://github.com/json-schema-org/json-schema-spec/issues>.

      For additional information, see <https://json-schema.org/>.

      To provide feedback, use this issue tracker, the communication methods listed on the homepage, or email the document editors.

      @@ -505,7 +505,7 @@

      Status of This Memo

      This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

      Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

      Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

      -

      This Internet-Draft will expire on May 16, 2021.

      +

      This Internet-Draft will expire on June 4, 2021.

      Copyright Notice

      Copyright (c) 2020 IETF Trust and the persons identified as the document authors. All rights reserved.

      This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

      @@ -583,15 +583,15 @@

      Table of Contents

    • 6.5.4. dependentRequired
    • -
  • 7. A Vocabulary for Semantic Content With "format" +
  • 7. Vocabularies for Semantic Content With "format"
    • 7.1. Foreword
    • 7.2. Implementation Requirements
    • -
      • 7.2.1. As an annotation +
        • 7.2.1. Format-Annotation Vocabulary
        • -
        • 7.2.2. As an assertion +
        • 7.2.2. Format-Assertion Vocabulary
        • 7.2.3. Custom format attributes
        • @@ -688,14 +688,14 @@

          5. Meta-Schema

          -

          The current URI for the default JSON Schema dialect meta-schema is <https://json-schema.org/draft/2020-11/schema>. For schema author convenience, this meta-schema describes a dialect consisting of all vocabularies defined in this specification and the JSON Schema Core specification, as well as two former keywords which are reserved for a transitional period. Individual vocabulary and vocabulary meta-schema URIs are given for each section below. Certain vocabularies are optional to support, which is explained in detail in the relevant sections.

          +

          The current URI for the default JSON Schema dialect meta-schema is <https://json-schema.org/draft/2020-12/schema>. For schema author convenience, this meta-schema describes a dialect consisting of all vocabularies defined in this specification and the JSON Schema Core specification, as well as two former keywords which are reserved for a transitional period. Individual vocabulary and vocabulary meta-schema URIs are given for each section below. Certain vocabularies are optional to support, which is explained in detail in the relevant sections.

          Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations SHOULD consider URIs dated after this specification draft and before the next to indicate the same syntax and semantics as those listed here.

          6. A Vocabulary for Structural Validation

          Validation keywords in a schema impose requirements for successful validation of an instance. These keywords are all assertions without any annotation behavior.

          Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

          -

          The current URI for this vocabulary, known as the Validation vocabulary, is: <https://json-schema.org/draft/2020-11/vocab/validation>.

          -

          The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-11/meta/validation>.

          +

          The current URI for this vocabulary, known as the Validation vocabulary, is: <https://json-schema.org/draft/2020-12/vocab/validation>.

          +

          The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-12/meta/validation>.

          6.1. Validation Keywords for Any Instance Type

          @@ -776,14 +776,14 @@

          6.4.4. maxContains

          The value of this keyword MUST be a non-negative integer.

          -

          An array instance is valid against "maxContains" if the number of elements that are valid against the schema for "contains" is less than, or equal to, the value of this keyword.

          -

          If "contains" is not present within the same schema object, then this keyword has no effect.

          +

          If "contains" is not present within the same schema object, then this keyword has no effect.

          +

          An array instance is valid against "maxContains" if its value is less than or equal to, the array length of the annotation result from an adjacent "contains" keyword where the annotation is an array, or the length of the instance array where the annotation is "true".

          6.4.5. minContains

          The value of this keyword MUST be a non-negative integer.

          -

          An array instance is valid against "minContains" if the number of elements that are valid against the schema for "contains" is greater than, or equal to, the value of this keyword.

          -

          A value of 0 is allowed, but is only useful for setting a range of occurrences from 0 to the value of "maxContains". A value of 0 with no "maxContains" causes "contains" to always pass validation.

          -

          If "contains" is not present within the same schema object, then this keyword has no effect.

          +

          If "contains" is not present within the same schema object, then this keyword has no effect.

          +

          An array instance is valid against "minContains" if its value is greater than or equal to, the array length of the annotation result from an adjacent "contains" keyword where the annotation is an array, or the length of the instance array where the annotation is "true".

          +

          A value of 0 is allowed, but is only useful for setting a range of occurrences from 0 to the value of "maxContains". A value of 0 with no "maxContains" causes "contains" to always pass validation.

          Omitting this keyword has the same behavior as a value of 1.

          6.5. Validation Keywords for Objects

          @@ -808,50 +808,47 @@

          Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value, every item in the corresponding array is also the name of a property in the instance.

          Omitting this keyword has the same behavior as an empty object.

          -7. A Vocabulary for Semantic Content With "format" +7. Vocabularies for Semantic Content With "format"

          7.1. Foreword

          -

          Structural validation alone may be insufficient to allow an application to correctly utilize certain values. The "format" annotation keyword is defined to allow schema authors to convey semantic information for a fixed subset of values which are accurately described by authoritative resources, be they RFCs or other external specifications.

          -

          Implementations MAY treat "format" as an assertion in addition to an annotation, and attempt to validate the value's conformance to the specified semantics. See the Implementation Requirements below for details.

          -

          The value of this keyword is called a format attribute. It MUST be a string. A format attribute can generally only validate a given set of instance types. If the type of the instance to validate is not in this set, validation for this format attribute and instance SHOULD succeed. All format attributes defined in this section apply to strings, but a format attribute can be specified to apply to any instance types defined in the data model defined in the core JSON Schema. [CREF1]Note that the "type" keyword in this specification defines an "integer" type which is not part of the data model. Therefore a format attribute can be limited to numbers, but not specifically to integers. However, a numeric format can be used alongside the "type" keyword with a value of "integer", or could be explicitly defined to always pass if the number is not an integer, which produces essentially the same behavior as only applying to integers.

          -

          Meta-schemas that do not use "$vocabulary" SHOULD be considered to utilize this vocabulary as if its URI were present with a value of false. See the Implementation Requirements below for details.

          -

          The current URI for this vocabulary, known as the Format vocabulary, is: <https://json-schema.org/draft/2020-11/vocab/format>.

          -

          The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-11/meta/format>.

          +

          Structural validation alone may be insufficient to allow an application to correctly utilize certain values. The "format" annotation keyword is defined to allow schema authors to convey semantic information for a fixed subset of values which are accurately described by authoritative resources, be they RFCs or other external specifications.

          +

          The value of this keyword is called a format attribute. It MUST be a string. A format attribute can generally only validate a given set of instance types. If the type of the instance to validate is not in this set, validation for this format attribute and instance SHOULD succeed. All format attributes defined in this section apply to strings, but a format attribute can be specified to apply to any instance types defined in the data model defined in the core JSON Schema. [CREF1]Note that the "type" keyword in this specification defines an "integer" type which is not part of the data model. Therefore a format attribute can be limited to numbers, but not specifically to integers. However, a numeric format can be used alongside the "type" keyword with a value of "integer", or could be explicitly defined to always pass if the number is not an integer, which produces essentially the same behavior as only applying to integers.

          +

          The current URI for this vocabulary, known as the Format-Annotation vocabulary, is: <https://json-schema.org/draft/2020-12/vocab/format-annotation>. The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-12/meta/format-annotation>. Implementing support for this vocabulary is REQUIRED.

          +

          In addition to the Format-Annotation vocabulary, a secondary vocabulary is available for custom meta-schemas that defines "format" as an assertion. The URI for the Format-Assertion vocabulary, is: <https://json-schema.org/draft/2020-12/vocab/format-assertion>. The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-12/meta/format-assertion>. Implementing support for the Format-Assertion vocabulary is OPTIONAL.

          +

          Specifying both the Format-Annotation and the Format-Assertion vocabularies is functionally equivalent to specifying only the Format-Assertion vocabulary since its requirements are a superset of the Format-Annotation vocabulary.

          7.2. Implementation Requirements

          -

          The "format" keyword functions as an annotation, and optionally as an assertion. [CREF2]This is due to the keyword's history, and is not in line with current keyword design principles. In order to manage this ambiguity, the "format" keyword is defined in its own separate vocabulary, as noted above. The true or false value of the vocabulary declaration governs the implementation requirements necessary to process a schema that uses "format", and the behaviors on which schema authors can rely.

          +

          The "format" keyword functions as defined by the vocabulary which is referenced.

          -7.2.1. As an annotation

          -

          The value of format MUST be collected as an annotation, if the implementation supports annotation collection. This enables application-level validation when schema validation is unavailable or inadequate.

          -

          This requirement is not affected by the boolean value of the vocabulary declaration, nor by the configuration of "format"'s assertion behavior described in the next section. [CREF3]Requiring annotation collection even when the vocabulary is declared with a value of false is atypical, but necessary to ensure that the best practice of performing application-level validation is possible even when assertion evaluation is not implemented. Since "format" has always been a part of this specification, requiring implementations to be aware of it even with a false vocabulary declaration is deemed to not be a burden.

          -

          -7.2.2. As an assertion

          -

          Regardless of the boolean value of the vocabulary declaration, an implementation that can evaluate "format" as an assertion MUST provide options to enable and disable such evaluation. The assertion evaluation behavior when the option is not explicitly specified depends on the vocabulary declaration's boolean value.

          -

          When implementing this entire specification, this vocabulary MUST be supported with a value of false (but see details below), and MAY be supported with a value of true.

          -

          When the vocabulary is declared with a value of false, an implementation: [CREF4]This matches the current reality of implementations, which provide widely varying levels of validation, including no validation at all, for some or all format attributes. It is also designed to encourage relying only on the annotation behavior and performing semantic validation in the application, which is the recommended best practice.

          +7.2.1. Format-Annotation Vocabulary +

          The value of format MUST be collected as an annotation, if the implementation supports annotation collection. This enables application-level validation when schema validation is unavailable or inadequate.

          +

          Implementations MAY still treat "format" as an assertion in addition to an annotation and attempt to validate the value's conformance to the specified semantics. The implementation MUST provide options to enable and disable such evaluation and MUST be disabled by default. Implementations SHOULD document their level of support for such validation. [CREF2]Specifying the Format-Annotation vocabulary and enabling validation in an implementation should not be viewed as being equivalent to specifying the Format-Assertion vocabulary since implementations are not required to provide full validation support when the Format-Assertion vocabulary is not specified.

          +

          When the implementation is configured for assertion behavior, it: [CREF3]This matches the current reality of implementations, which provide widely varying levels of validation, including no validation at all, for some or all format attributes. It is also designed to encourage relying only on the annotation behavior and performing semantic validation in the application, which is the recommended best practice.

            -
          • MUST NOT evaluate "format" as an assertion unless it is explicitly configured to do so;
          • SHOULD provide an implementation-specific best effort validation for each format attribute defined below;
          • MAY choose to implement validation of any or all format attributes as a no-op by always producing a validation result of true;
          • -
          • SHOULD document its level of support for validation.

          -

          When the vocabulary is declared with a value of true, an implementation that supports this form of the vocabulary: [CREF5]The expectation is that for simple formats such as date-time, syntactic validation will be thorough. For a complex format such as email addresses, which are the amalgamation of various standards and numerous adjustments over time, with obscure and/or obsolete rules that may or may not be restricted by other applications making use of the value, a minimal validation is sufficient. For example, an instance string that does not contain an "@" is clearly not a valid email address, and an "email" or "hostname" containing characters outside of 7-bit ASCII is likewise clearly invalid.

          +

          +7.2.2. Format-Assertion Vocabulary

          +

          When the Format-Assertion vocabulary is declared with a value of true, implementations MUST provide full validation support for all of the formats defined by this specificaion. Implementations that cannot provide full validation support MUST refuse to process the schema.

          +

          An implementation that supports the Format-Assertion vocabulary: [CREF4]The expectation is that for simple formats such as date-time, syntactic validation will be thorough. For a complex format such as email addresses, which are the amalgamation of various standards and numerous adjustments over time, with obscure and/or obsolete rules that may or may not be restricted by other applications making use of the value, a minimal validation is sufficient. For example, an instance string that does not contain an "@" is clearly not a valid email address, and an "email" or "hostname" containing characters outside of 7-bit ASCII is likewise clearly invalid.

            -
          • MUST evaluate "format" as an assertion unless it is explicitly configured not to do so;
          • +
          • MUST still collect "format" as an annotation if the implementation supports annotation collection;
          • +
          • MUST evaluate "format" as an assertion;
          • MUST implement syntactic validation for all format attributes defined in this specification, and for any additional format attributes that it recognizes, such that there exist possible instance values of the correct type that will fail validation.

          The requirement for minimal validation of format attributes is intentionally vague and permissive, due to the complexity involved in many of the attributes. Note in particular that the requirement is limited to syntactic checking; it is not to be expected that an implementation would send an email, attempt to connect to a URL, or otherwise check the existence of an entity identified by a format instance.

          -

          It is RECOMMENDED that implementations use a common parsing library for each format, or a well-known regular expression. Implementations SHOULD clearly document how and to what degree each format attribute is validated.

          -

          The standard core and validation meta-schema includes this vocabulary in its "$vocabulary" keyword with a value of false, since by default implementations are not required to support this keyword as an assertion. Supporting the format vocabulary with a value of true is understood to greatly increase code size and in some cases execution time, and will not be appropriate for all implementations.

          +

          It is RECOMMENDED that implementations use a common parsing library for each format, or a well-known regular expression. Implementations SHOULD clearly document how and to what degree each format attribute is validated.

          +

          The standard core and validation meta-schema includes this vocabulary in its "$vocabulary" keyword with a value of false, since by default implementations are not required to support this keyword as an assertion. Supporting the format vocabulary with a value of true is understood to greatly increase code size and in some cases execution time, and will not be appropriate for all implementations.

          7.2.3. Custom format attributes

          -

          Implementations MAY support custom format attributes. Save for agreement between parties, schema authors SHALL NOT expect a peer implementation to support such custom format attributes. An implementation MUST NOT fail validation or cease processing due to an unknown format attribute. When treating "format" as an annotation, implementations SHOULD collect both known and unknown format attribute values.

          +

          Implementations MAY support custom format attributes. Save for agreement between parties, schema authors SHALL NOT expect a peer implementation to support such custom format attributes. An implementation MUST NOT fail to collect unknown formats as annotations. When the Format-Assertion vocabulary is specified, implementations MUST fail upon encountering unknown formats.

          Vocabularies do not support specifically declaring different value sets for keywords. Due to this limitation, and the historically uneven implementation of this keyword, it is RECOMMENDED to define additional keywords in a custom vocabulary rather than additional format attributes if interoperability is desired.

          7.3. Defined Formats

          @@ -873,7 +870,7 @@

          -

          Implementations MAY support additional attributes using the other production names defined anywhere in that RFC. If "full-date" or "full-time" are implemented, the corresponding short form ("date" or "time" respectively) MUST be implemented, and MUST behave identically. Implementations SHOULD NOT define extension attributes with any name matching an RFC 3339 production unless it validates according to the rules of that production. [CREF6]There is not currently consensus on the need for supporting all RFC 3339 formats, so this approach of reserving the namespace will encourage experimentation without committing to the entire set. Either the format implementation requirements will become more flexible in general, or these will likely either be promoted to fully specified attributes or dropped.

          +

          Implementations MAY support additional attributes using the other production names defined anywhere in that RFC. If "full-date" or "full-time" are implemented, the corresponding short form ("date" or "time" respectively) MUST be implemented, and MUST behave identically. Implementations SHOULD NOT define extension attributes with any name matching an RFC 3339 production unless it validates according to the rules of that production. [CREF5]There is not currently consensus on the need for supporting all RFC 3339 formats, so this approach of reserving the namespace will encourage experimentation without committing to the entire set. Either the format implementation requirements will become more flexible in general, or these will likely either be promoted to fully specified attributes or dropped.

          7.3.2. Email Addresses

          These attributes apply to string instances.

          @@ -965,13 +962,13 @@

          Annotations defined in this section indicate that an instance contains non-JSON data encoded in a JSON string.

          These properties provide additional information required to interpret JSON data as rich multimedia documents. They describe the type of content, how it is encoded, and/or how it may be validated. They do not function as validation assertions; a malformed string-encoded document MUST NOT cause the containing instance to be considered invalid.

          Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

          -

          The current URI for this vocabulary, known as the Content vocabulary, is: <https://json-schema.org/draft/2020-11/vocab/content>.

          -

          The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-11/meta/content>.

          +

          The current URI for this vocabulary, known as the Content vocabulary, is: <https://json-schema.org/draft/2020-12/vocab/content>.

          +

          The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-12/meta/content>.

          8.2. Implementation Requirements

          Due to security and performance concerns, as well as the open-ended nature of possible content types, implementations MUST NOT automatically decode, parse, and/or validate the string contents by default. This additionally supports the use case of embedded documents intended for processing by a different consumer than that which processed the containing document.

          All keywords in this section apply only to strings, and have no effect on other data types.

          -

          Implementations MAY offer the ability to decode, parse, and/or validate the string contents automatically. However, it MUST NOT perform these operations by default, and MUST provide the validation result of each string-encoded document separately from the enclosing document. This process SHOULD be equivalent to fully evaluating the instance against the original schema, followed by using the annotations to decode, parse, and/or validate each string-encoded document. [CREF7]For now, the exact mechanism of performing and returning parsed data and/or validation results from such an automatic decoding, parsing, and validating feature is left unspecified. Should such a feature prove popular, it may be specified more thoroughly in a future draft.

          +

          Implementations MAY offer the ability to decode, parse, and/or validate the string contents automatically. However, it MUST NOT perform these operations by default, and MUST provide the validation result of each string-encoded document separately from the enclosing document. This process SHOULD be equivalent to fully evaluating the instance against the original schema, followed by using the annotations to decode, parse, and/or validate each string-encoded document. [CREF6]For now, the exact mechanism of performing and returning parsed data and/or validation results from such an automatic decoding, parsing, and validating feature is left unspecified. Should such a feature prove popular, it may be specified more thoroughly in a future draft.

          See also the Security Considerations sections for possible vulnerabilities introduced by automatically processing the instance string according to these keywords.

          8.3. contentEncoding

          @@ -1044,8 +1041,8 @@

          9. A Vocabulary for Basic Meta-Data Annotations

          These general-purpose annotation keywords provide commonly used information for documentation and user interface display purposes. They are not intended to form a comprehensive set of features. Rather, additional vocabularies can be defined for more complex annotation-based applications.

          Meta-schemas that do not use "$vocabulary" SHOULD be considered to require this vocabulary as if its URI were present with a value of true.

          -

          The current URI for this vocabulary, known as the Meta-Data vocabulary, is: <https://json-schema.org/draft/2020-11/vocab/meta-data>.

          -

          The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-11/meta/meta-data>.

          +

          The current URI for this vocabulary, known as the Meta-Data vocabulary, is: <https://json-schema.org/draft/2020-12/vocab/meta-data>.

          +

          The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-12/meta/meta-data>.

          9.1. "title" and "description"

          The value of both of these keywords MUST be a string.

          @@ -1095,12 +1092,12 @@

          [json-schema] -Wright, A., Andrews, H. and B. Hutton, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-bhutton-json-schema-00, November 2020. +Wright, A., Andrews, H., Hutton, B. and G. Dennis, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-bhutton-json-schema-00, December 2020. [relative-json-pointer] -Luff, G. and H. Andrews, "Relative JSON Pointers", Internet-Draft draft-handrews-relative-json-pointer-01, November 2017. +Luff, G., Andrews, H. and B. Hutton, "Relative JSON Pointers", Internet-Draft draft-handrews-relative-json-pointer-01, December 2020. [RFC1123] @@ -1220,7 +1217,7 @@

          Thanks to Jason Desrosiers, Daniel Perrett, Erik Wilde, Evgeny Poberezkin, Brad Bowman, Gowry Sankar, Donald Pipowitch, Dave Finlay, Denis Laxalde, Phil Sturgeon, Shawn Silverman, and Karen Etheridge for their submissions and patches to the document.

          Appendix C. ChangeLog

          -

          [CREF8]This section to be removed before leaving Internet-Draft status.

          +

          [CREF7]This section to be removed before leaving Internet-Draft status.

          @@ -1230,7 +1227,7 @@

        • Correct email format RFC reference to 5321 instead of 5322
        • Clarified the set and meaning of "contentEncoding" values
        • Reference ECMA-262, 11th edition for regular expression support
        • -
        • +
        • Split "format" into an annotation only vocabulary and an assertion vocabulary
        • diff --git a/draft/preview/2020-12-rc-1/relative-json-pointer.html b/draft/preview/2020-12-rc-1/relative-json-pointer.html new file mode 100644 index 00000000..d1fd75de --- /dev/null +++ b/draft/preview/2020-12-rc-1/relative-json-pointer.html @@ -0,0 +1,732 @@ + + + + + + + Relative JSON Pointers + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
          Internet Engineering Task ForceG. Luff
          Internet-Draft
          Intended status: InformationalH. Andrews, Ed.
          Expires: June 4, 2021
          B. Hutton, Ed.
          December 1, 2020
          + +

          Relative JSON Pointers
          + draft-bhutton-relative-json-pointer-00

          + +

          Abstract

          +

          JSON Pointer is a syntax for specifying locations in a JSON document, starting from the document root. This document defines an extension to the JSON Pointer syntax, allowing relative locations from within the document.

          +

          Status of This Memo

          +

          This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

          +

          Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

          +

          Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

          +

          This Internet-Draft will expire on June 4, 2021.

          +

          Copyright Notice

          +

          Copyright (c) 2020 IETF Trust and the persons identified as the document authors. All rights reserved.

          +

          This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

          + + +
          +

          Table of Contents

          + + +

          +1. Introduction

          +

          JSON Pointer (RFC 6901) is a syntax for specifying locations in a JSON document, starting from the document root. This document defines a related syntax allowing identification of relative locations from within the document.

          +

          +2. Conventions and Terminology

          +

          The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

          +

          +3. Syntax

          +

          A Relative JSON Pointer is a Unicode string in UTF-8 encoding (see RFC 8259, Section 8), comprising a non-negative integer, followed by either a '#' (%x23) character or a JSON Pointer (RFC 6901).

          +

          The separation between the integer prefix and the JSON Pointer will always be unambiguous, because a JSON Pointer must be either zero- length or start with a '/' (%x2F). Similarly, a JSON Pointer will never be ambiguous with the '#'.

          +

          The ABNF syntax of a Relative JSON Pointer is:

          +
          +
          +   relative-json-pointer =  non-negative-integer <json-pointer>
          +   relative-json-pointer =/ non-negative-integer "#"
          +   non-negative-integer      =  %x30 / %x31-39 *( %x30-39 )
          +           ; "0", or digits without a leading "0"
          +
          +                
          +

          where <json-pointer> follows the production defined in RFC 6901, Section 3 ("Syntax").

          +

          +

          +4. Evaluation

          +

          Evaluation of a Relative JSON Pointer begins with a reference to a value within a JSON document, and completes with either a value within that document, a string corresponding to an object member, or integer value representing an array index.

          +

          Evaluation begins by processing the non-negative-integer prefix. This can be found by taking the longest continuous sequence of decimal digits available, starting from the beginning of the string, taking the decimal numerical value. If this value is more than zero, then the following steps are repeated that number of times:

          + +
            +
          • If the current referenced value is the root of the document, then evaluation fails (see below).
          • +
          • If the referenced value is an item within an array, then the new referenced value is that array.
          • +
          • If the referenced value is an object member within an object, then the new referenced value is that object.
          • +
          + +

          +

          If the next character is a plus ("+") or minus ("-"), followed by another continuous sequence of decimal digits, the following steps are taken using the decimal numeric value of that plus or minus sign and decimal sequence:

          + +
            +
          • If the current referenced value is not an item of an array, then evaluation fails (see below).
          • +
          • If the referenced value is an item of an array, then the new referenced value is the item of the array indexed by adding the decimal value (which may be negative), to the index of the current referenced value.
          • +
          + +

          +

          If the remainder of the Relative JSON Pointer is a JSON Pointer, then evaluation proceeds as per RFC 6901, Section 5 with the modification that the initial reference being used is the reference currently being held (which may not be root of the document).

          +

          Otherwise (when the remainder of the Relative JSON Pointer is the character '#'), the final result is determined as follows:

          + +
            +
          • If the current referenced value is the root of the document, then evaluation fails (see below).
          • +
          • If the referenced value is an item within an array, then the final evaluation result is the value's index position within the array.
          • +
          • If the referenced value is an object member within an object, then the new referenced value is the corresponding member name.
          • +
          + +

          +

          +5. JSON String Representation

          +

          The concerns surrounding JSON String representation of a Relative JSON Pointer are identical to those laid out in RFC 6901, Section 5.

          +

          +5.1. Examples

          +

          For example, given the JSON document:

          +
          +
          +                      {
          +                         "foo": ["bar", "baz"],
          +                         "highly": {
          +                            "nested": {
          +                               "objects": true
          +                            }
          +                         }
          +                      }
          +
          +                    
          +

          Starting from the value "baz" (inside "foo"), the following JSON strings evaluate to the accompanying values:

          +
          +
          +                  "0"                         "baz"
          +                  "1/0"                       "bar"
          +                  "2/highly/nested/objects"   true
          +                  "0#"                        1
          +                  "1#"                        "foo"
          +
          +                    
          +

          Starting from the value {"objects":true} (corresponding to the member key "nested"), the following JSON strings evaluate to the accompanying values:

          +
          +
          +                "0/objects"                 true
          +                "1/nested/objects"          true
          +                "2/foo/0"                   "bar"
          +                "0#"                        "nested"
          +                "1#"                        "highly"
          +
          +                    
          +

          +6. Non-use in URI Fragment Identifiers

          +

          Unlike a JSON Pointer, a Relative JSON Pointer can not be used in a URI fragment identifier. Such fragments specify exact positions within a document, and therefore Relative JSON Pointers are not suitable.

          +

          +7. Error Handling

          +

          In the event of an error condition, evaluation of the JSON Pointer fails to complete.

          +

          Evaluation may fail due to invalid syntax, or referencing a non- existent value. This specification does not define how errors are handled. An application of JSON Relative Pointer SHOULD specify the impact and handling of each type of error.

          +

          +8. Relationship to JSON Pointer

          +

          Relative JSON Pointers are intended as a companion to JSON Pointers. Applications MUST specify the use of each syntax separately. Defining either JSON Pointer or Relative JSON Pointer as an acceptable syntax does not imply that the other syntax is also acceptable.

          +

          +9. Acknowledgements

          +

          The language and structure of this specification are based heavily on [RFC6901], sometimes quoting it outright.

          +

          This draft remains primarily as written and published by Geraint Luff, with only minor subsequent alterations under new editorship.

          +

          +10. Security Considerations

          +

          Evaluation of a given Relative JSON Pointer is not guaranteed to reference an actual JSON value. Applications using Relative JSON Pointer should anticipate this situation by defining how a pointer that does not resolve ought to be handled.

          +

          As part of processing, a composite data structure may be assembled from multiple JSON documents (in part or in full). In such cases, applications SHOULD ensure that a Relative JSON Pointer does not evaluate to a value outside the document for which is was written.

          +

          Note that JSON pointers can contain the NUL (Unicode U+0000) character. Care is needed not to misinterpret this character in programming languages that use NUL to mark the end of a string.

          +

          +11. References

          +

          +11.1. Normative References

          + + + + + + + + + +
          [RFC2119] +Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.
          [RFC6901] +Bryan, P., Zyp, K. and M. Nottingham, "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, April 2013.
          +

          +11.2. Informative References

          + + + +
          [RFC8259] +Bray, T., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, December 2017.
          +

          +Appendix A. ChangeLog

          +

          [CREF1]This section to be removed before leaving Internet-Draft status.

          +

          + +
          +
          draft-handrews-relative-json-pointer-03
          +
          +
          • Add array forward and backward index manipulation
          +

          +
          +
          draft-handrews-relative-json-pointer-02
          +
          +
          • Update to the latest JSON RFC
          +

          +
          +
          draft-handrews-relative-json-pointer-01
          +
          +
          • The initial number is "non-negative", not "positive"
          +

          +
          +
          draft-handrews-relative-json-pointer-00
          +
          +
            +
          • Revived draft with identical wording and structure.
          • +
          • Clarified how to use alongside JSON Pointer.
          • +
          +

          +
          +
          draft-luff-relative-json-pointer-00
          +
          +
          • Initial draft.
          +

          +
          +
          + +

          +

          Authors' Addresses

          +
          +
          + + Geraint Luff + + + + + + + Cambridge, + + + + UK + + EMail: luffgd@gmail.com + +
          +
          +
          + + Henry Andrews (editor) + + + + + + + + + + + + + EMail: andrews_henry@yahoo.com + +
          +
          +
          + + Ben Hutton (editor) + + + + + + + + + + + + + EMail: ben@jsonschema.dev + +URI: https://jsonschema.dev + +
          +
          + + + diff --git a/work-in-progress/index.md b/work-in-progress/index.md index 4455aec4..7d9b243c 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -7,8 +7,17 @@ permalink: /work-in-progress * TOC {:toc} -Draft 2019-09 has been [published](/specification.html)! +Draft 2020-12 is in the final review period. +Publication is scheduled for 2020-12-08. -This page will remain blank until the next draft nears completion. +At this point, the specification is feature locked, but please do file any issues or reach us immediatly on the JSON Schema Slack. + +Spec preview documents: + +Core: https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-core.html +Validation: https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-validation.html +Relative JSON Pointer: https://json-schema.org/draft/preview/2020-12-rc-1/relative-json-pointer.html + +HyperSchema is not included in this upcoming draft and is on hiatus. See the [GitHub repository](https://github.com/json-schema-org/json-schema-spec) for ongoing spec work. From 7286151e4ffcdd8c7902ad66875cd9aa2c9f26bc Mon Sep 17 00:00:00 2001 From: Relequestual Date: Tue, 1 Dec 2020 16:36:22 +0000 Subject: [PATCH 091/311] Fix links --- work-in-progress/index.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/work-in-progress/index.md b/work-in-progress/index.md index 7d9b243c..69fda1ba 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -14,9 +14,11 @@ At this point, the specification is feature locked, but please do file any issue Spec preview documents: -Core: https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-core.html -Validation: https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-validation.html -Relative JSON Pointer: https://json-schema.org/draft/preview/2020-12-rc-1/relative-json-pointer.html +Core: [https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-core.html] + +Validation: [https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-validation.html] + +Relative JSON Pointer: [https://json-schema.org/draft/preview/2020-12-rc-1/relative-json-pointer.html] HyperSchema is not included in this upcoming draft and is on hiatus. From c62aea1cf141c552f190dc094a7667cdfb7993c9 Mon Sep 17 00:00:00 2001 From: Relequestual Date: Tue, 1 Dec 2020 16:38:33 +0000 Subject: [PATCH 092/311] Properly fix links --- work-in-progress/index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/work-in-progress/index.md b/work-in-progress/index.md index 69fda1ba..27bf8014 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -10,15 +10,15 @@ permalink: /work-in-progress Draft 2020-12 is in the final review period. Publication is scheduled for 2020-12-08. -At this point, the specification is feature locked, but please do file any issues or reach us immediatly on the JSON Schema Slack. +At this point, the specification is feature locked, but please do file any issues via Github or reach us immediatly on the JSON Schema Slack. Spec preview documents: -Core: [https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-core.html] +Core: [https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-core.html](https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-core.html) -Validation: [https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-validation.html] +Validation: [https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-validation.html](https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-validation.html) -Relative JSON Pointer: [https://json-schema.org/draft/preview/2020-12-rc-1/relative-json-pointer.html] +Relative JSON Pointer: [https://json-schema.org/draft/preview/2020-12-rc-1/relative-json-pointer.html](https://json-schema.org/draft/preview/2020-12-rc-1/relative-json-pointer.html) HyperSchema is not included in this upcoming draft and is on hiatus. From 3ae1b0794ac1208e9519f3a2fbab47713a2d0279 Mon Sep 17 00:00:00 2001 From: restspace <75081878+restspace@users.noreply.github.com> Date: Wed, 16 Dec 2020 22:51:31 +0000 Subject: [PATCH 093/311] Add restspace/schema-form to Implementations/Web UI generation --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index 971abd59..51c7fd27 100644 --- a/implementations.md +++ b/implementations.md @@ -225,6 +225,7 @@ Various levels of support for UI generation primarily from the validation vocabu - [Liform-react](https://github.com/Limenius/liform-react) (MIT) - [React JSON Schema Form (mozilla)](https://github.com/mozilla-services/react-jsonschema-form) (Apache 2) - [React Schema Form (networknt)](https://github.com/networknt/react-schema-form) (MIT) + - [Restspace Schema Form](https://github.com/restspace/schema-form) (MIT) - [uniforms (Vazco)](https://github.com/vazco/uniforms) (MIT) #### Data from schemas From 140c7e89981c8f83d97de5736e1933b9f3173706 Mon Sep 17 00:00:00 2001 From: danielaparker Date: Mon, 18 Jan 2021 22:13:32 -0500 Subject: [PATCH 094/311] jsoncons supports JSON Schema Draft 7 --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 8c6d86fc..dc9f9022 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -42,6 +42,12 @@ date-draft: draft: [7] license: BSD-2-Clause + - name: jsoncons + url: https://github.com/danielaparker/jsoncons/blob/master/doc/ref/jsonschema/jsonschema.md + notes: Header-only library + date-draft: + draft: [7] + license: Boost Software License 1.0 - name: Clojure implementations: - name: jinx From 6d93e2be8b5f96a692d6d93a290f1f55e70e15ea Mon Sep 17 00:00:00 2001 From: Vipin Tanna <6302771+vip-git@users.noreply.github.com> Date: Mon, 25 Jan 2021 03:17:54 +0100 Subject: [PATCH 095/311] Update implementations.md --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index 971abd59..8d9714cf 100644 --- a/implementations.md +++ b/implementations.md @@ -224,6 +224,7 @@ Various levels of support for UI generation primarily from the validation vocabu - [JSONForms (jsonforms.io)](https://jsonforms.io/) (EclipseSource) (MIT) - [Liform-react](https://github.com/Limenius/liform-react) (MIT) - [React JSON Schema Form (mozilla)](https://github.com/mozilla-services/react-jsonschema-form) (Apache 2) + - [React Json Schema Form (Mui)](https://github.com/vip-git/react-jsonschema-form-material-ui) (MIT) - [React Schema Form (networknt)](https://github.com/networknt/react-schema-form) (MIT) - [uniforms (Vazco)](https://github.com/vazco/uniforms) (MIT) From c1564d6368d77f42644f5ece7ee8d245049a0d0f Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 28 Jan 2021 16:16:52 +0000 Subject: [PATCH 096/311] Move new implementation Only fair to add it to the END of the list for the same draft support. --- _data/validator-libraries-modern.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 6ac9c213..1ddbd7de 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -90,6 +90,12 @@ notes: includes custom validator support, rich error returns - name: Java implementations: + - name: Snow + url: https://github.com/ssilverman/snowy-json + notes: Uses Maven for the project and Gson under the hood. + date-draft: [2019-09] + draft: [7, 6] + license: GNU Affero General Public License v3.0 - name: Vert.x Json Schema url: https://github.com/eclipse-vertx/vertx-json-schema notes: Validator for Eclipse Vert.x project JSON types. @@ -97,12 +103,6 @@ draft: [7] license: Apache License, Version 2.0 notes: includes custom keywords support, custom dialect support, asynchronous validation - - name: Snow - url: https://github.com/ssilverman/snowy-json - notes: Uses Maven for the project and Gson under the hood. - date-draft: [2019-09] - draft: [7, 6] - license: GNU Affero General Public License v3.0 - name: everit-org/json-schema url: https://github.com/everit-org/json-schema notes: From fd4f35af2860d5c6fc96b7f70294b5a703c90176 Mon Sep 17 00:00:00 2001 From: Relequestual Date: Fri, 29 Jan 2021 22:55:32 +0000 Subject: [PATCH 097/311] Add submodule for 2020-12 --- .gitmodules | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitmodules b/.gitmodules index f975f8f1..3ac879c1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,3 +26,7 @@ [submodule "_includes/draft/2019-09"] path = _includes/draft/2019-09 url = https://github.com/json-schema-org/json-schema-spec.git +[submodule "_includes/draft/2020-12"] + path = _includes/draft/2020-12 + url = https://github.com/json-schema-org/json-schema-spec.git + branch = 2020-12 From 148196eef18b4c14691df8e54693df582eec3d4c Mon Sep 17 00:00:00 2001 From: Relequestual Date: Fri, 29 Jan 2021 22:57:11 +0000 Subject: [PATCH 098/311] Add documents for draft 2020-12 --- Gemfile.lock | 2 +- .../json-schema-core.html} | 114 ++++++++++-------- .../json-schema-validation.html} | 21 ++-- draft/2020-12/meta/applicator | 1 + draft/2020-12/meta/content | 1 + draft/2020-12/meta/core | 1 + draft/2020-12/meta/format | 1 + draft/2020-12/meta/format-annotation | 1 + draft/2020-12/meta/format-assertion | 1 + draft/2020-12/meta/meta-data | 1 + draft/2020-12/meta/unevaluated | 1 + draft/2020-12/meta/validation | 1 + draft/2020-12/output/schema | 1 + draft/2020-12/output/verbose-example | 1 + .../relative-json-pointer.html | 15 ++- draft/2020-12/release-notes.md | 8 ++ draft/2020-12/schema | 1 + draft/2020-12/vocab/applicator.md | 4 + draft/2020-12/vocab/content.md | 4 + draft/2020-12/vocab/core.md | 4 + draft/2020-12/vocab/format-annotation.md | 4 + draft/2020-12/vocab/format-assertion.md | 4 + draft/2020-12/vocab/meta-data.md | 4 + draft/2020-12/vocab/unevaluated.md | 4 + draft/2020-12/vocab/validation.md | 4 + work-in-progress/index.md | 15 +-- 26 files changed, 133 insertions(+), 86 deletions(-) rename draft/{preview/2020-12-rc-1/jsonschema-core.html => 2020-12/json-schema-core.html} (97%) rename draft/{preview/2020-12-rc-1/jsonschema-validation.html => 2020-12/json-schema-validation.html} (98%) create mode 100644 draft/2020-12/meta/applicator create mode 100644 draft/2020-12/meta/content create mode 100644 draft/2020-12/meta/core create mode 100644 draft/2020-12/meta/format create mode 100644 draft/2020-12/meta/format-annotation create mode 100644 draft/2020-12/meta/format-assertion create mode 100644 draft/2020-12/meta/meta-data create mode 100644 draft/2020-12/meta/unevaluated create mode 100644 draft/2020-12/meta/validation create mode 100644 draft/2020-12/output/schema create mode 100644 draft/2020-12/output/verbose-example rename draft/{preview/2020-12-rc-1 => 2020-12}/relative-json-pointer.html (97%) create mode 100644 draft/2020-12/release-notes.md create mode 100644 draft/2020-12/schema create mode 100644 draft/2020-12/vocab/applicator.md create mode 100644 draft/2020-12/vocab/content.md create mode 100644 draft/2020-12/vocab/core.md create mode 100644 draft/2020-12/vocab/format-annotation.md create mode 100644 draft/2020-12/vocab/format-assertion.md create mode 100644 draft/2020-12/vocab/meta-data.md create mode 100644 draft/2020-12/vocab/unevaluated.md create mode 100644 draft/2020-12/vocab/validation.md diff --git a/Gemfile.lock b/Gemfile.lock index 5802c946..3e8e182a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -247,4 +247,4 @@ DEPENDENCIES github-pages BUNDLED WITH - 1.16.1 + 2.2.7 diff --git a/draft/preview/2020-12-rc-1/jsonschema-core.html b/draft/2020-12/json-schema-core.html similarity index 97% rename from draft/preview/2020-12-rc-1/jsonschema-core.html rename to draft/2020-12/json-schema-core.html index 9efd5fe4..3feb6057 100644 --- a/draft/preview/2020-12-rc-1/jsonschema-core.html +++ b/draft/2020-12/json-schema-core.html @@ -445,8 +445,9 @@ - - + + + @@ -488,7 +489,7 @@ - + @@ -512,7 +513,7 @@ H. Andrews, Ed. -Expires: June 4, 2021 +Expires: August 1, 2021 @@ -529,7 +530,7 @@ -December 1, 2020 +January 28, 2020 @@ -542,7 +543,6 @@

          Abstract

          JSON Schema defines the media type "application/schema+json", a JSON-based format for describing the structure of JSON data. JSON Schema asserts what a JSON document must look like, ways to extract information from it, and how to interact with it. The "application/schema-instance+json" media type provides additional feature-rich integration with "application/schema+json" beyond what can be offered for "application/json" documents.

          Note to Readers

          -

          This document a pre-release identified as JSON Schema draft 2020-12-rc-1.

          The issues list for this draft can be found at <https://github.com/json-schema-org/json-schema-spec/issues>.

          For additional information, see <https://json-schema.org/>.

          To provide feedback, use this issue tracker, the communication methods listed on the homepage, or email the document editors.

          @@ -550,7 +550,7 @@

          Status of This Memo

          This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

          Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

          Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

          -

          This Internet-Draft will expire on June 4, 2021.

          +

          This Internet-Draft will expire on August 1, 2021.

          Copyright Notice

          Copyright (c) 2020 IETF Trust and the persons identified as the document authors. All rights reserved.

          This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

          @@ -702,9 +702,11 @@

          Table of Contents

    • 11. A Vocabulary for Unevaluated Locations
    • -
      • 11.1. unevaluatedItems +
      • 12. Output Formatting
      • @@ -949,7 +951,7 @@

        6.4. Regular Expressions

        Keywords MAY use regular expressions to express constraints, or constrain the instance value to be a regular expression. These regular expressions SHOULD be valid according to the regular expression dialect described in ECMA-262, section 21.2.1.

        -

        Regular expressions SHOULD be built with the "u" flag (or equivalent) to provide Unicode support, or processed in such a way which provides Unicode as defined by ECMA-262.

        +

        Regular expressions SHOULD be built with the "u" flag (or equivalent) to provide Unicode support, or processed in such a way which provides Unicode support as defined by ECMA-262.

        Furthermore, given the high disparity in regular expression constructs support, schema authors SHOULD limit themselves to the following regular expression tokens:

          @@ -982,7 +984,7 @@

          The lexical scope of a keyword is determined by the nested JSON data structure of objects and arrays. The largest such scope is an entire schema document. The smallest scope is a single schema object with no subschemas.

          Keywords MAY be defined with a partial value, such as a URI-reference, which must be resolved against another value, such as another URI-reference or a full URI, which is found through the lexical structure of the JSON document. The "$id", "$ref", and "$dynamicRef" core keywords, and the "base" JSON Hyper-Schema keyword, are examples of this sort of behavior.

          Note that some keywords, such as "$schema", apply to the lexical scope of the entire schema resource, and therefore MUST only appear in a schema resource's root schema.

          -

          Other keywords may take into account the dynamic scope that exists during the evaluation of a schema. The outermost dynamic scope is the root schema of the schema document in which processing begins. The path from this root schema to any particular keyword (that includes any "$ref" and "$dynamicRef" keywords that may have been resolved) is considered the keyword's "validation path."

          +

          Other keywords may take into account the dynamic scope that exists during the evaluation of a schema, typically together with an instance document. The outermost dynamic scope is the schema object at which processing begins, even if it is not a schema resource root. The path from this root schema to any particular keyword (that includes any "$ref" and "$dynamicRef" keywords that may have been resolved) is considered the keyword's "validation path."

          Lexical and dynamic scopes align until a reference keyword is encountered. While following the reference keyword moves processing from one lexical scope into a different one, from the perspective of dynamic scope, following a reference is no different from descending into a subschema present as a value. A keyword on the far side of that reference that resolves information through the dynamic scope will consider the originating side of the reference to be their dynamic parent, rather than examining the local lexically enclosing parent.

          The concept of dynamic scope is primarily used with "$dynamicRef" and "$dynamicAnchor", and should be considered an advanced feature and used with caution when defining additional keywords. It also appears when reporting errors and collected annotations, as it may be possible to revisit the same lexical scope repeatedly with different dynamic scopes. In such cases, it is important to inform the user of the dynamic path that produced the error or annotation.

          @@ -998,7 +1000,7 @@

          7.4. Identifiers

          Identifiers set the canonical URI of a schema, or affect how such URIs are resolved in references, or both. The Core vocabulary defined in this document defines several identifying keywords, most notably "$id".

          -

          Canonical schema URIs MUST NOT change while processing an instance, but keywords that affect URI-reference resolution MAY have behavior that is only fully determined dynamically.

          +

          Canonical schema URIs MUST NOT change while processing an instance, but keywords that affect URI-reference resolution MAY have behavior that is only fully determined at runtime.

          While custom identifier keywords are possible, vocabulary designers should take care not to disrupt the functioning of core keywords. For example, the "$dynamicAnchor" keyword in this specification limits its URI resolution effects to the matching "$dynamicRef" keyword, leaving the behavior of "$ref" undisturbed.

          7.5. Applicators @@ -1012,7 +1014,7 @@

          As noted in Section 7.5, an applicator keyword may refer to a schema to be applied, rather than including it as a subschema in the applicator's value. In such situations, the schema being applied is known as the referenced schema, while the schema containing the applicator keyword is the referencing schema.

          While root schemas and subschemas are static concepts based on a schema's position within a schema document, referenced and referencing schemas are dynamic. Different pairs of schemas may find themselves in various referenced and referencing arrangements during the evaluation of an instance against a schema.

          -

          For some by-reference applicators, such as "$ref", the referenced schema can be determined by static analysis of the schema document's lexical scope. Others, such as "$dynamicRef" (with "$dynamicAnchor"), are only resolvable with knowledge of all the schemas in it's dynamic scope.

          +

          For some by-reference applicators, such as "$ref", the referenced schema can be determined by static analysis of the schema document's lexical scope. Others, such as "$dynamicRef" (with "$dynamicAnchor"), may make use of dynamic scoping, and therefore only be resolvable in the process of evaluating the schema with an instance.

          7.6. Assertions

          @@ -1228,15 +1230,15 @@

          8.2.3.1. Direct References with "$ref"

          The "$ref" keyword is an applicator that is used to reference a statically identified schema. Its results are the results of the referenced schema. [CREF5]Note that this definition of how the results are determined means that other keywords can appear alongside of "$ref" in the same schema object.

          -

          The value of the "$ref" keyword MUST be a string which is a URI-Reference. Resolved against the current URI base, it produces the URI of the schema to apply. This resolution is safe to perform on schema load as neither other schemas nor the instance can change how the reference resolves.

          +

          The value of the "$ref" keyword MUST be a string which is a URI-Reference. Resolved against the current URI base, it produces the URI of the schema to apply. This resolution is safe to perform on schema load, as the process of evaluating an instance cannot change how the reference resolves.

          8.2.3.2. Dynamic References with "$dynamicRef"

          -

          The "$dynamicRef" keyword is an applicator that is used to reference a dynamically identified schema.

          -

          Together with "$dynamicAnchor", "$dynamicRef" implements a cooperative extension mechanism that is primarily useful with recursive schemas (schemas that reference themselves). Both the extension point and the extension target are defined with "$dynamicAnchor", and only exhibit dynamic behavior when referenced with "$dynamicRef".

          -

          The value of the "$dynamicRef" property MUST be a string which is a URI-Reference. Resolved against the current URI base, it produces the URI used as the starting point for resolution. This initial resolution is safe to perform on schema load.

          +

          The "$dynamicRef" keyword is an applicator that allows for deferring the full resolution until runtime, at which point it is resolved each time it is encountered while evaluating an instance.

          +

          Together with "$dynamicAnchor", "$dynamicRef" implements a cooperative extension mechanism that is primarily useful with recursive schemas (schemas that reference themselves). Both the extension point and the runtime-determined extension target are defined with "$dynamicAnchor", and only exhibit runtime dynamic behavior when referenced with "$dynamicRef".

          +

          The value of the "$dynamicRef" property MUST be a string which is a URI-Reference. Resolved against the current URI base, it produces the URI used as the starting point for runtime resolution. This initial resolution is safe to perform on schema load.

          If the initially resolved starting point URI includes a fragment that was created by the "$dynamicAnchor" keyword, the initial URI MUST be replaced by the URI (including the fragment) for the outermost schema resource in the dynamic scope that defines an identically named fragment with "$dynamicAnchor".

          -

          Otherwise, its behavior is identical to "$ref", and no dynamic resolution is needed.

          +

          Otherwise, its behavior is identical to "$ref", and no runtime resolution is needed.

          For a full example using these keyword, see appendix C. [CREF6]The difference between the hyper-schema meta-schema in pre-2019 drafts and an this draft dramatically demonstrates the utility of these keywords.

          8.2.4. Schema Re-Use With "$defs" @@ -1283,7 +1285,7 @@

          9.1.2. Loading a referenced schema

          The use of URIs to identify remote schemas does not necessarily mean anything is downloaded, but instead JSON Schema implementations SHOULD understand ahead of time which schemas they will be using, and the URIs that identify them.

          -

          When schemas are downloaded, for example by a generic user-agent that doesn't know until runtime which schemas to download, see Usage for Hypermedia.

          +

          When schemas are downloaded, for example by a generic user-agent that does not know until runtime which schemas to download, see Usage for Hypermedia.

          Implementations SHOULD be able to associate arbitrary URIs with an arbitrary schema and/or automatically associate a schema's "$id"-given URI, depending on the trust that the validator has in the schema. Such URIs and schemas can be supplied to an implementation prior to processing instances, or may be noted within a schema document as it is processed, producing associations as shown in appendix A.

          A schema MAY (and likely will) have multiple URIs, but there is no way for a URI to identify more than one schema. When multiple schemas try to identify as the same URI, validators SHOULD raise an error condition.

          @@ -1428,9 +1430,8 @@

          • "additionalProperties", whose behavior is defined in terms of "properties" and "patternProperties"
          • -
          • "unevaluatedProperties", whose behavior is defined in terms of annotations from "properties", "patternProperties", "additionalProperties" and itself
          • "items", whose behavior is defined in terms of "prefixItems"
          • -
          • "unevaluatedItems", whose behavior is defined in terms of annotations from "prefixItems", "items", "contains", and itself
          • +
          • "contains", whose behavior is defined in terms of "minContains"

          @@ -1514,20 +1515,20 @@

          The value of this keyword MUST be a valid JSON Schema.

          An array instance is valid against "contains" if at least one of its elements is valid against the given schema. The subschema MUST be applied to every array element even after the first match has been found, in order to collect annotations for use by other keywords. This is to ensure that all possible annotations are collected.

          Logically, the validation result of applying the value subschema to each item in the array MUST be ORed with "false", resulting in an overall validation result.

          -

          This keyword produces an annotation value which is an array of the indexes to which this keyword validates successfully when applying its subschema, in ascending order. The value MAY be a boolean "true" if the subschema validated successfully when applied to every index of the instance. If the instance array this keywords subschema is applicable to is empty, the annotation value MUST NOT be missing.

          +

          This keyword produces an annotation value which is an array of the indexes to which this keyword validates successfully when applying its subschema, in ascending order. The value MAY be a boolean "true" if the subschema validates successfully when applied to every index of the instance. The annotation MUST be present if the instance array to which this keyword's schema applies is empty.

          10.3.2. Keywords for Applying Subschemas to Objects

          10.3.2.1. properties

          The value of "properties" MUST be an object. Each value of this object MUST be a valid JSON Schema.

          Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value, the child instance for that name successfully validates against the corresponding schema.

          -

          The annotation result of this keyword is the set of instance property names matched by this keyword. Annotation results for "properties" keywords from multiple schemas applied to the same instance location are combined by taking the union of the sets.

          +

          The annotation result of this keyword is the set of instance property names matched by this keyword.

          Omitting this keyword has the same assertion behavior as an empty object.

          10.3.2.2. patternProperties

          The value of "patternProperties" MUST be an object. Each property name of this object SHOULD be a valid regular expression, according to the ECMA-262 regular expression dialect. Each property value of this object MUST be a valid JSON Schema.

          Validation succeeds if, for each instance name that matches any regular expressions that appear as a property name in this keyword's value, the child instance for that name successfully validates against each schema that corresponds to a matching regular expression.

          -

          The annotation result of this keyword is the set of instance property names matched by this keyword. Annotation results for "patternProperties" keywords from multiple schemas applied to the same instance location are combined by taking the union of the sets.

          +

          The annotation result of this keyword is the set of instance property names matched by this keyword.

          Omitting this keyword has the same assertion behavior as an empty object.

          10.3.2.3. additionalProperties @@ -1535,7 +1536,7 @@

          The value of "additionalProperties" MUST be a valid JSON Schema.

          The behavior of this keyword depends on the presence and annotation results of "properties" and "patternProperties" within the same schema object. Validation with "additionalProperties" applies only to the child values of instance names that do not appear in the annotation results of either "properties" or "patternProperties".

          For all such properties, validation succeeds if the child instance validates against the "additionalProperties" schema.

          -

          The annotation result of this keyword is the set of instance property names validated by this keyword's subschema. Annotation results for "additionalProperties" keywords from multiple schemas applied to the same instance location are combined by taking the union of the sets.

          +

          The annotation result of this keyword is the set of instance property names validated by this keyword's subschema.

          Omitting this keyword has the same assertion behavior as an empty schema.

          Implementations MAY choose to implement or optimize this keyword in another way that produces the same effect, such as by directly checking the names in "properties" and the patterns in "patternProperties" against the instance property set. Implementations that do not support annotation collection MUST do so.

          @@ -1555,24 +1556,34 @@

          The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2020-12/meta/unevaluated>.

          Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations SHOULD consider URIs dated after this specification draft and before the next to indicate the same syntax and semantics as those listed here.

          -11.1. unevaluatedItems -

          -

          The value of "unevaluatedItems" MUST be a valid JSON Schema.

          -

          The behavior of this keyword depends on the annotation results of adjacent keywords that apply to the instance location being validated. Specifically, the annotations from "prefixItems", "items", and "contains", which can come from those keywords when they are adjacent to the "unevaluatedItems" keyword. Those two annotations, as well as "unevaluatedItems", can also result from any and all adjacent in-place applicator keywords. This includes but is not limited to the in-place applicators defined in this document.

          -

          If no relevant annotations are present, the "unevaluatedItems" subschema MUST be applied to all locations in the array. If a boolean true value is present from any of the relevant annotations, "unevaluatedItems" MUST be ignored. Otherwise, the subschema MUST be applied to any index greater than the largest annotation value for "prefixItems", which does not appear in any annotation value for "contains".

          -

          This means that "prefixItems", "items", "contains", and all in-place applicators MUST be evaluated before this keyword can be evaluated. Authors of extension keywords MUST NOT define an in-place applicator that would need to be evaluated before this keyword.

          -

          If the "unevaluatedItems" subschema is applied to any positions within the instance array, it produces an annotation result of boolean true, analogous to the behavior of "items".

          -

          Omitting this keyword has the same assertion behavior as an empty schema.

          +11.1. Keyword Independence +

          Schema keywords typically operate independently, without affecting each other's outcomes. However, the keywords in this vocabulary are notable exceptions:

          + +
            +
          • "unevaluatedItems", whose behavior is defined in terms of annotations from "prefixItems", "items", "contains", and itself
          • +
          • "unevaluatedProperties", whose behavior is defined in terms of annotations from "properties", "patternProperties", "additionalProperties" and itself
          • +
          + +

          -11.2. unevaluatedProperties +11.2. unevaluatedItems +

          +

          The value of "unevaluatedItems" MUST be a valid JSON Schema.

          +

          The behavior of this keyword depends on the annotation results of adjacent keywords that apply to the instance location being validated. Specifically, the annotations from "prefixItems", "items", and "contains", which can come from those keywords when they are adjacent to the "unevaluatedItems" keyword. Those three annotations, as well as "unevaluatedItems", can also result from any and all adjacent in-place applicator keywords. This includes but is not limited to the in-place applicators defined in this document.

          +

          If no relevant annotations are present, the "unevaluatedItems" subschema MUST be applied to all locations in the array. If a boolean true value is present from any of the relevant annotations, "unevaluatedItems" MUST be ignored. Otherwise, the subschema MUST be applied to any index greater than the largest annotation value for "prefixItems", which does not appear in any annotation value for "contains".

          +

          This means that "prefixItems", "items", "contains", and all in-place applicators MUST be evaluated before this keyword can be evaluated. Authors of extension keywords MUST NOT define an in-place applicator that would need to be evaluated after this keyword.

          +

          If the "unevaluatedItems" subschema is applied to any positions within the instance array, it produces an annotation result of boolean true, analogous to the behavior of "items".

          +

          Omitting this keyword has the same assertion behavior as an empty schema.

          +

          +11.3. unevaluatedProperties

          -

          The value of "unevaluatedProperties" MUST be a valid JSON Schema.

          -

          The behavior of this keyword depends on the annotation results of adjacent keywords that apply to the instance location being validated. Specifically, the annotations from "properties", "patternProperties", and "additionalProperties", which can come from those keywords when they are adjacent to the "unevaluatedProperties" keyword. Those three annotations, as well as "unevaluatedProperties", can also result from any and all adjacent in-place applicator keywords. This includes but is not limited to the in-place applicators defined in this document.

          -

          Validation with "unevaluatedProperties" applies only to the child values of instance names that do not appear in the "properties", "patternProperties", "additionalProperties", or "unevaluatedProperties" annotation results that apply to the instance location being validated.

          -

          For all such properties, validation succeeds if the child instance validates against the "unevaluatedProperties" schema.

          -

          This means that "properties", "patternProperties", "additionalProperties", and all in-place applicators MUST be evaluated before this keyword can be evaluated. Authors of extension keywords MUST NOT define an in-place applicator that would need to be evaluated before this keyword.

          -

          The annotation result of this keyword is the set of instance property names validated by this keyword's subschema. Annotation results for "unevaluatedProperties" keywords from multiple schemas applied to the same instance location are combined by taking the union of the sets.

          -

          Omitting this keyword has the same assertion behavior as an empty schema.

          +

          The value of "unevaluatedProperties" MUST be a valid JSON Schema.

          +

          The behavior of this keyword depends on the annotation results of adjacent keywords that apply to the instance location being validated. Specifically, the annotations from "properties", "patternProperties", and "additionalProperties", which can come from those keywords when they are adjacent to the "unevaluatedProperties" keyword. Those three annotations, as well as "unevaluatedProperties", can also result from any and all adjacent in-place applicator keywords. This includes but is not limited to the in-place applicators defined in this document.

          +

          Validation with "unevaluatedProperties" applies only to the child values of instance names that do not appear in the "properties", "patternProperties", "additionalProperties", or "unevaluatedProperties" annotation results that apply to the instance location being validated.

          +

          For all such properties, validation succeeds if the child instance validates against the "unevaluatedProperties" schema.

          +

          This means that "properties", "patternProperties", "additionalProperties", and all in-place applicators MUST be evaluated before this keyword can be evaluated. Authors of extension keywords MUST NOT define an in-place applicator that would need to be evaluated after this keyword.

          +

          The annotation result of this keyword is the set of instance property names validated by this keyword's subschema.

          +

          Omitting this keyword has the same assertion behavior as an empty schema.

          12. Output Formatting

          @@ -1591,7 +1602,7 @@

        • Verbose - Provides validation information in an uncondensed hierarchical structure that matches the exact structure of the schema.
        -

        An implementation SHOULD provide at least the "flag", "basic", or "detailed" format and MAY provide the "verbose" format. If it provides one or more of the complex formats, it MUST also provide the "flag" format. Implementations SHOULD specify in their documentation which formats they support.

        +

        An implementation SHOULD provide at least one of the "flag", "basic", or "detailed" format and MAY provide the "verbose" format. If it provides one or more of the "detailed" or "verbose" formats, it MUST also provide the "flag" format. Implementations SHOULD specify in their documentation which formats they support.

        12.3. Minimum Information

        Beyond the simplistic "flag" output, additional information is useful to aid in debugging a schema or instance. Each sub-result SHOULD contain the information contained within this section at a minimum.

        @@ -1609,13 +1620,13 @@

        The JSON key for this information is "keywordLocation".

        12.3.2. Keyword Absolute Location

        -

        The absolute, dereferenced location of the validating keyword. The value MUST be expressed as a full URI using the canonical URI of the relevant schema object, and it MUST NOT include by-reference applicators such as "$ref" or "$dynamicRef" as non-terminal path components. It MAY end in such keywords if the error or annotation is for that keyword, such as an unresolvable reference. [CREF12]Note that "absolute" here is in the sense of "absolute filesystem path" (meaning the complete location) rather than the "absolute-URI" terminology from RFC 3986 (meaning with scheme but without fragment). Keyword absolute locations will always have a fragment in order to identify the keyword.

        +

        The absolute, dereferenced location of the validating keyword. The value MUST be expressed as a full URI using the canonical URI of the relevant schema object, and it MUST NOT include by-reference applicators such as "$ref" or "$dynamicRef" as non-terminal path components. It MAY end in such keywords if the error or annotation is for that keyword, such as an unresolvable reference. [CREF12]Note that "absolute" here is in the sense of "absolute filesystem path" (meaning the complete location) rather than the "absolute-URI" terminology from RFC 3986 (meaning with scheme but without fragment). Keyword absolute locations will have a fragment in order to identify the keyword.

         
         https://example.com/schemas/common#/$defs/count/minimum
         
                                 
        -

        This information MAY be omitted only if either the relative location contains no references or if the schema does not declare an absolute URI as its "$id".

        +

        This information MAY be omitted only if either the dynamic scope did not pass over a reference or if the schema does not declare an absolute URI as its "$id".

        The JSON key for this information is "absoluteKeywordLocation".

        12.3.3. Instance Location

        @@ -1857,9 +1868,9 @@

        13. Security Considerations

        Both schemas and instances are JSON values. As such, all security considerations defined in RFC 8259 apply.

        -

        Instances and schemas are both frequently written by untrusted third parties, to be deployed on public Internet servers. Validators should take care that the parsing and validating against schemas doesn't consume excessive system resources. Validators MUST NOT fall into an infinite loop.

        +

        Instances and schemas are both frequently written by untrusted third parties, to be deployed on public Internet servers. Validators should take care that the parsing and validating against schemas does not consume excessive system resources. Validators MUST NOT fall into an infinite loop.

        A malicious party could cause an implementation to repeatedly collect a copy of a very large value as an annotation. Implementations SHOULD guard against excessive consumption of system resources in such a scenario.

        -

        Servers MUST ensure that malicious parties can't change the functionality of existing schemas by uploading a schema with a pre-existing or very similar "$id".

        +

        Servers MUST ensure that malicious parties cannot change the functionality of existing schemas by uploading a schema with a pre-existing or very similar "$id".

        Individual JSON Schema vocabularies are liable to also have their own security considerations. Consult the respective specifications for more information.

        Schema authors should take care with "$comment" contents, as a malicious implementation can display them to end-users in violation of a spec, or fail to strip them if such behavior is expected.

        A malicious schema author could place executable code or other dangerous material within a "$comment". Implementations MUST NOT parse or otherwise take action based on "$comment" contents.

        @@ -2190,7 +2201,7 @@

        Vocabulary authors should take care to avoid keyword name collisions if the vocabulary is intended for broad use, and potentially combined with other vocabularies. JSON Schema does not provide any formal namespacing system, but also does not constrain keyword names, allowing for any number of namespacing approaches.

        Vocabularies may build on each other, such as by defining the behavior of their keywords with respect to the behavior of keywords from another vocabulary, or by using a keyword from another vocabulary with a restricted or expanded set of acceptable values. Not all such vocabulary re-use will result in a new vocabulary that is compatible with the vocabulary on which it is built. Vocabulary authors should clearly document what level of compatibility, if any, is expected.

        Meta-schema authors should not use "$vocabulary" to combine multiple vocabularies that define conflicting syntax or semantics for the same keyword. As semantic conflicts are not generally detectable through schema validation, implementations are not expected to detect such conflicts. If conflicting vocabularies are declared, the resulting behavior is undefined.

        -

        Vocabulary authors should provide a meta-schema that validates the expected usage of the vocabulary's keywords on their own. Such meta-schemas should not forbid additional keywords, and must not forbid any keywords from the Core vocabulary.

        +

        Vocabulary authors SHOULD provide a meta-schema that validates the expected usage of the vocabulary's keywords on their own. Such meta-schemas SHOULD not forbid additional keywords, and MUST not forbid any keywords from the Core vocabulary.

        It is recommended that meta-schema authors reference each vocabulary's meta-schema using the "allOf" keyword, although other mechanisms for constructing the meta-schema may be appropriate for certain use cases.

        The recursive nature of meta-schemas makes the "$dynamicAnchor" and "$dynamicRef" keywords particularly useful for extending existing meta-schemas, as can be seen in the JSON Hyper-Schema meta-schema which extends the Validation meta-schema.

        Meta-schemas may impose additional constraints, including describing keywords not present in any vocabulary, beyond what the meta-schemas associated with the declared vocabularies describe. This allows for restricting usage to a subset of a vocabulary, and for validating locally defined keywords not intended for re-use.

        @@ -2200,7 +2211,7 @@

        D.2. Example meta-schema with vocabulary declarations

        This meta-schema explicitly declares both the Core and Applicator vocabularies, together with an extension vocabulary, and combines their meta-schemas with an "allOf". The extension vocabulary's meta-schema, which describes only the keywords in that vocabulary, is shown after the main example meta-schema.

        -

        The main example meta-schema also restricts the usage of the Applicator vocabulary by forbidding the keywords prefixed with "unevaluated", which are particularly complex to implement. This does not change the semantics or set of keywords defined by the Applicator vocabulary. It just ensures that schemas using this meta-schema that attempt to use the keywords prefixed with "unevaluated" will fail validation against this meta-schema.

        +

        The main example meta-schema also restricts the usage of the Unevaluated vocabulary by forbidding the keywords prefixed with "unevaluated", which are particularly complex to implement. This does not change the semantics or set of keywords defined by the other vocabularies. It just ensures that schemas using this meta-schema that attempt to use the keywords prefixed with "unevaluated" will fail validation against this meta-schema.

        Finally, this meta-schema describes the syntax of a keyword, "localKeyword", that is not part of any vocabulary. Presumably, the implementors and users of this meta-schema will understand the semantics of "localKeyword". JSON Schema does not define any mechanism for expressing keyword semantics outside of vocabularies, making them unsuitable for use except in a specific environment in which they are understood.

        This meta-schema combines several vocabularies for general use.

        @@ -2222,7 +2233,7 @@ 

        {"$ref": "https://example.com/meta/example-vocab", ], "patternProperties": { - "^unevaluated.*$": false + "^unevaluated": false }, "properties": { "localKeyword": { @@ -2311,9 +2322,10 @@

      • $dynamic* (previously $recursive) no longer use runtime base URI determination
      • Define Compound Schema Documents (bundle) and processing
      • Reference ECMA-262, 11th edition for regular expression support
      • +
      • Regular expression should support unicode
      • Remove media type parameters
      • -
      • -
      • +
      • Specify Unknown keywords are collected as annotations
      • +
      • Moved "unevaluatedItems" and "unevaluatedProperties" from core into their own vocabulary

      diff --git a/draft/preview/2020-12-rc-1/jsonschema-validation.html b/draft/2020-12/json-schema-validation.html similarity index 98% rename from draft/preview/2020-12-rc-1/jsonschema-validation.html rename to draft/2020-12/json-schema-validation.html index f203d3ec..e573655f 100644 --- a/draft/preview/2020-12-rc-1/jsonschema-validation.html +++ b/draft/2020-12/json-schema-validation.html @@ -451,7 +451,7 @@ - + @@ -475,7 +475,7 @@ H. Andrews, Ed. -Expires: June 4, 2021 +Expires: August 1, 2021 @@ -484,7 +484,7 @@ -December 1, 2020 +January 28, 2020 @@ -497,7 +497,6 @@

      Abstract

      JSON Schema (application/schema+json) has several purposes, one of which is JSON instance validation. This document specifies a vocabulary for JSON Schema to describe the meaning of JSON documents, provide hints for user interfaces working with JSON data, and to make assertions about what a valid document must look like.

      Note to Readers

      -

      This document a pre-release identified as JSON Schema draft 2020-12-rc-1.

      The issues list for this draft can be found at <https://github.com/json-schema-org/json-schema-spec/issues>.

      For additional information, see <https://json-schema.org/>.

      To provide feedback, use this issue tracker, the communication methods listed on the homepage, or email the document editors.

      @@ -505,7 +504,7 @@

      Status of This Memo

      This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

      Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

      Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

      -

      This Internet-Draft will expire on June 4, 2021.

      +

      This Internet-Draft will expire on August 1, 2021.

      Copyright Notice

      Copyright (c) 2020 IETF Trust and the persons identified as the document authors. All rights reserved.

      This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

      @@ -777,12 +776,12 @@

      6.4.4. maxContains

      The value of this keyword MUST be a non-negative integer.

      If "contains" is not present within the same schema object, then this keyword has no effect.

      -

      An array instance is valid against "maxContains" if its value is less than or equal to, the array length of the annotation result from an adjacent "contains" keyword where the annotation is an array, or the length of the instance array where the annotation is "true".

      +

      An instance array is valid against "maxContains" in two ways, depending on the form of the annotation result of an adjacent "contains" keyword. The first way is if the annotation result is an array and the length of that array is less than or equal to the "maxContains" value. The second way is if the annotation result is a boolean "true" and the instance array length is less than or equal to the "maxContains" value.

      6.4.5. minContains

      The value of this keyword MUST be a non-negative integer.

      If "contains" is not present within the same schema object, then this keyword has no effect.

      -

      An array instance is valid against "minContains" if its value is greater than or equal to, the array length of the annotation result from an adjacent "contains" keyword where the annotation is an array, or the length of the instance array where the annotation is "true".

      +

      An instance array is valid against "minContains" in two ways, depending on the form of the annotation result of an adjacent "contains" keyword. The first way is if the annotation result is an array and the length of that array is greater than or equal to the "minContains" value. The second way is if the annotation result is a boolean "true" and the instance array length is greater than or equal to the "minContains" value.

      A value of 0 is allowed, but is only useful for setting a range of occurrences from 0 to the value of "maxContains". A value of 0 with no "maxContains" causes "contains" to always pass validation.

      Omitting this keyword has the same behavior as a value of 1.

      @@ -1228,13 +1227,7 @@

    • Clarified the set and meaning of "contentEncoding" values
    • Reference ECMA-262, 11th edition for regular expression support
    • Split "format" into an annotation only vocabulary and an assertion vocabulary
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • +
    • Clarify "deprecated" when applicable to arrays

    diff --git a/draft/2020-12/meta/applicator b/draft/2020-12/meta/applicator new file mode 100644 index 00000000..8fd44f54 --- /dev/null +++ b/draft/2020-12/meta/applicator @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/applicator.json \ No newline at end of file diff --git a/draft/2020-12/meta/content b/draft/2020-12/meta/content new file mode 100644 index 00000000..784c2c5e --- /dev/null +++ b/draft/2020-12/meta/content @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/content.json \ No newline at end of file diff --git a/draft/2020-12/meta/core b/draft/2020-12/meta/core new file mode 100644 index 00000000..acdf0634 --- /dev/null +++ b/draft/2020-12/meta/core @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/core.json \ No newline at end of file diff --git a/draft/2020-12/meta/format b/draft/2020-12/meta/format new file mode 100644 index 00000000..fa372ff7 --- /dev/null +++ b/draft/2020-12/meta/format @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/format.json \ No newline at end of file diff --git a/draft/2020-12/meta/format-annotation b/draft/2020-12/meta/format-annotation new file mode 100644 index 00000000..9470a37e --- /dev/null +++ b/draft/2020-12/meta/format-annotation @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/format-annotaion.json \ No newline at end of file diff --git a/draft/2020-12/meta/format-assertion b/draft/2020-12/meta/format-assertion new file mode 100644 index 00000000..b31c612b --- /dev/null +++ b/draft/2020-12/meta/format-assertion @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/format-assertion.json \ No newline at end of file diff --git a/draft/2020-12/meta/meta-data b/draft/2020-12/meta/meta-data new file mode 100644 index 00000000..49e5296e --- /dev/null +++ b/draft/2020-12/meta/meta-data @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/meta-data.json \ No newline at end of file diff --git a/draft/2020-12/meta/unevaluated b/draft/2020-12/meta/unevaluated new file mode 100644 index 00000000..fbd3c938 --- /dev/null +++ b/draft/2020-12/meta/unevaluated @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/unevaluated.json \ No newline at end of file diff --git a/draft/2020-12/meta/validation b/draft/2020-12/meta/validation new file mode 100644 index 00000000..90f062f1 --- /dev/null +++ b/draft/2020-12/meta/validation @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/validation.json \ No newline at end of file diff --git a/draft/2020-12/output/schema b/draft/2020-12/output/schema new file mode 100644 index 00000000..efe176a0 --- /dev/null +++ b/draft/2020-12/output/schema @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/output/schema.json \ No newline at end of file diff --git a/draft/2020-12/output/verbose-example b/draft/2020-12/output/verbose-example new file mode 100644 index 00000000..38f31932 --- /dev/null +++ b/draft/2020-12/output/verbose-example @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/output/verbose-example.json \ No newline at end of file diff --git a/draft/preview/2020-12-rc-1/relative-json-pointer.html b/draft/2020-12/relative-json-pointer.html similarity index 97% rename from draft/preview/2020-12-rc-1/relative-json-pointer.html rename to draft/2020-12/relative-json-pointer.html index d1fd75de..fe44bd8a 100644 --- a/draft/preview/2020-12-rc-1/relative-json-pointer.html +++ b/draft/2020-12/relative-json-pointer.html @@ -397,7 +397,7 @@ - + @@ -421,7 +421,7 @@ H. Andrews, Ed. -Expires: June 4, 2021 +Expires: August 1, 2021 @@ -430,7 +430,7 @@ -December 1, 2020 +January 28, 2020 @@ -446,7 +446,7 @@

    Status of This Memo

    This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

    Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

    Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

    -

    This Internet-Draft will expire on June 4, 2021.

    +

    This Internet-Draft will expire on August 1, 2021.

    Copyright Notice

    Copyright (c) 2020 IETF Trust and the persons identified as the document authors. All rights reserved.

    This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

    @@ -505,8 +505,9 @@

    The ABNF syntax of a Relative JSON Pointer is:

     
    -   relative-json-pointer =  non-negative-integer <json-pointer>
    +   relative-json-pointer =  non-negative-integer [index-manipulation] <json-pointer>
        relative-json-pointer =/ non-negative-integer "#"
    +   index-manipulation    =  ("+" / "-") non-negative-integer
        non-negative-integer      =  %x30 / %x31-39 *( %x30-39 )
                ; "0", or digits without a leading "0"
     
    @@ -566,8 +567,10 @@ 

    "0" "baz" "1/0" "bar" + "0-1" "bar" "2/highly/nested/objects" true "0#" 1 + "0-1#" 0 "1#" "foo"

    @@ -629,7 +632,7 @@

    -
    draft-handrews-relative-json-pointer-03
    +
    draft-bhutton-relative-json-pointer-00
    • Add array forward and backward index manipulation

    diff --git a/draft/2020-12/release-notes.md b/draft/2020-12/release-notes.md new file mode 100644 index 00000000..ed8cfc6e --- /dev/null +++ b/draft/2020-12/release-notes.md @@ -0,0 +1,8 @@ +--- +title: JSON Schema 2020-12 Release Notes +layout: page +--- + +_NOTE: This page is still being written._ + +You can find a minimal changelog at the end of the specification documents themselves. \ No newline at end of file diff --git a/draft/2020-12/schema b/draft/2020-12/schema new file mode 100644 index 00000000..70e58e37 --- /dev/null +++ b/draft/2020-12/schema @@ -0,0 +1 @@ +../../_includes/draft/2020-12/schema.json \ No newline at end of file diff --git a/draft/2020-12/vocab/applicator.md b/draft/2020-12/vocab/applicator.md new file mode 100644 index 00000000..93c75bcb --- /dev/null +++ b/draft/2020-12/vocab/applicator.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2020-12/json-schema-core.html#rfc.section.10 +title: A Vocabulary for Applying Subschemas +--- diff --git a/draft/2020-12/vocab/content.md b/draft/2020-12/vocab/content.md new file mode 100644 index 00000000..b60a25c4 --- /dev/null +++ b/draft/2020-12/vocab/content.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2020-12/json-schema-validation.html#rfc.section.8 +title: A Vocabulary for the Contents of String-Encoded Data +--- diff --git a/draft/2020-12/vocab/core.md b/draft/2020-12/vocab/core.md new file mode 100644 index 00000000..dca0cbed --- /dev/null +++ b/draft/2020-12/vocab/core.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2020-12/json-schema-core.html#rfc.section.8 +title: The JSON Schema Core Vocabulary +--- diff --git a/draft/2020-12/vocab/format-annotation.md b/draft/2020-12/vocab/format-annotation.md new file mode 100644 index 00000000..ff0e1aa8 --- /dev/null +++ b/draft/2020-12/vocab/format-annotation.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2020-12/json-schema-validation.html#rfc.section.7 +title: A Vocabulary for Semantic Content with "format" as annotations +--- diff --git a/draft/2020-12/vocab/format-assertion.md b/draft/2020-12/vocab/format-assertion.md new file mode 100644 index 00000000..fe9640eb --- /dev/null +++ b/draft/2020-12/vocab/format-assertion.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2020-12/json-schema-validation.html#rfc.section.7 +title: A Vocabulary for Semantic Content with "format" as assertions +--- diff --git a/draft/2020-12/vocab/meta-data.md b/draft/2020-12/vocab/meta-data.md new file mode 100644 index 00000000..0fb58ffa --- /dev/null +++ b/draft/2020-12/vocab/meta-data.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2020-12/json-schema-validation.html#rfc.section.9 +title: A Vocabulary for Basic Meta-Data Annotations +--- diff --git a/draft/2020-12/vocab/unevaluated.md b/draft/2020-12/vocab/unevaluated.md new file mode 100644 index 00000000..0ff02bc1 --- /dev/null +++ b/draft/2020-12/vocab/unevaluated.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2020-12/json-schema-core.html#rfc.section.11 +title: A Vocabulary for Unevaluated Locations +--- diff --git a/draft/2020-12/vocab/validation.md b/draft/2020-12/vocab/validation.md new file mode 100644 index 00000000..e03833e4 --- /dev/null +++ b/draft/2020-12/vocab/validation.md @@ -0,0 +1,4 @@ +--- +redirect_to: /draft/2020-12/json-schema-validation.html#rfc.section.6 +title: A Vocabulary for Structural Validation +--- diff --git a/work-in-progress/index.md b/work-in-progress/index.md index 27bf8014..f2cf1e87 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -7,19 +7,6 @@ permalink: /work-in-progress * TOC {:toc} -Draft 2020-12 is in the final review period. -Publication is scheduled for 2020-12-08. - -At this point, the specification is feature locked, but please do file any issues via Github or reach us immediatly on the JSON Schema Slack. - -Spec preview documents: - -Core: [https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-core.html](https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-core.html) - -Validation: [https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-validation.html](https://json-schema.org/draft/preview/2020-12-rc-1/jsonschema-validation.html) - -Relative JSON Pointer: [https://json-schema.org/draft/preview/2020-12-rc-1/relative-json-pointer.html](https://json-schema.org/draft/preview/2020-12-rc-1/relative-json-pointer.html) - -HyperSchema is not included in this upcoming draft and is on hiatus. +We're working towards draft 2021-NN. See the [GitHub repository](https://github.com/json-schema-org/json-schema-spec) for ongoing spec work. From 9f02305ed06c88f8f66d610d07b5579eeae4408a Mon Sep 17 00:00:00 2001 From: Relequestual Date: Fri, 29 Jan 2021 22:59:01 +0000 Subject: [PATCH 099/311] Add updated submodule for 2020-12 --- _includes/draft/2020-12 | 1 + 1 file changed, 1 insertion(+) create mode 160000 _includes/draft/2020-12 diff --git a/_includes/draft/2020-12 b/_includes/draft/2020-12 new file mode 160000 index 00000000..0e08f035 --- /dev/null +++ b/_includes/draft/2020-12 @@ -0,0 +1 @@ +Subproject commit 0e08f03573753bebe2841023dd6fcc822490ea07 From 43a571a3a611f2827953c23037ee318d75e003f5 Mon Sep 17 00:00:00 2001 From: Relequestual Date: Wed, 3 Feb 2021 23:36:18 +0000 Subject: [PATCH 100/311] Updated all pages for draft 2020-12 --- README.md | 30 ++++++++++++++- hyper-schema.md | 3 -- index.md | 63 +++++++++++++++++++++----------- latest/json-schema-core.md | 2 +- latest/json-schema-hypermedia.md | 4 -- latest/json-schema-validation.md | 2 +- latest/relative-json-pointer.md | 2 +- specification-links.md | 56 +++++++++++++++++++++++----- specification.md | 55 ++++++++++++++-------------- 9 files changed, 147 insertions(+), 70 deletions(-) delete mode 100644 hyper-schema.md delete mode 100644 latest/json-schema-hypermedia.md diff --git a/README.md b/README.md index d15bb072..72766976 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,36 @@ For the current status of issues and pull requests, please see the following bad [![Available](https://img.shields.io/github/issues/json-schema-org/json-schema-org.github.io/Status:%20Available.svg?color=brightgreen)](https://github.com/json-schema-org/json-schema-org.github.io/issues?q=is%3Aopen+is%3Aissue+label%3A%22Status%3A+Available%22) [![In Progress](https://img.shields.io/github/issues/json-schema-org/json-schema-org.github.io/Status:%20In%20Progress.svg)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Status:%20In%20Progress) [![Review Needed](https://img.shields.io/github/issues/json-schema-org/json-schema-org.github.io/Status:%20Review%20Needed.svg)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Status%3A%20Review%20Needed) [![Critical](https://img.shields.io/github/issues/json-schema-org/json-schema-org.github.io/Priority:%20Critical.svg?color=critical -)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Priority%3A%20Critical) [![High](https://img.shields.io/github/issues/json-schema-org/json-schema-org.github.io/Priority:%20High.svg?color=important)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Priority%3A%20High) [![Medium](https://img.shields.io/github/issues/json-schema-org/json-schema-org.github.io/Priority:%20Medium.svg)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Priority%3A%20Medium) [![Low](https://img.shields.io/github/issues/json-schema-org/json-schema-org.github.io/Priority:%20Low.svg)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Priority%3A%20Low) +)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Priority%3A%20Critical) [![High](https://img.shields.io/github/issues/json-schema-org/json-schema-org.github.io/Priority:%20High.svg?color=important)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Priority%3A%20High) [![Medium](https://img.shields.io/github/issues/json-schema-org/json-schema-org.github.io/Priority:%20Medium.svg)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Priority%3A%20Medium) [![Low](https://img.shields.io/github/issues/json-schema-org/json-schema-org.github.io/Priority:%20Low.svg)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Priority%3A%20Low) Labels are assigned based on [Sensible Github Labels](https://github.com/Relequestual/sensible-github-labels). +## Compile and run locally + +This site runs via github pages, with automatically building PR previews via netlify. +If you wish to compile and run this site locally, you will need to have ruby installed. + +If you're not familiar with ruby, consider using `rvm` (https://rvm.io/). +Once you have Ruby installed, follow these instructions while in the project directory + +> Instructions +> +> 1. Install the jekyll and bundler gems. +> +> `gem install jekyll bundler` +> +> 2. Create a new Jekyll site at ./myblog. +> +> ... +> +> 3. Build the site and make it available on a local server. +> +> `bundle exec jekyll serve` +> +> 4. Browse to http://localhost:4000 + +Adapted from https://jekyllrb.com/docs/ + ## License -The source material in this repository is licensed under the AFL or BSD license. +The source material in this repository is licensed under the AFL or BSD license. diff --git a/hyper-schema.md b/hyper-schema.md deleted file mode 100644 index d57e3c3f..00000000 --- a/hyper-schema.md +++ /dev/null @@ -1,3 +0,0 @@ ---- -redirect_to: /draft/2019-09/hyper-schema ---- diff --git a/index.md b/index.md index c7128a8b..0ad7c151 100644 --- a/index.md +++ b/index.md @@ -8,11 +8,9 @@ permalink: / **JSON Schema** is a vocabulary that allows you to **annotate** and **validate** JSON documents. -## Advantages +## Benefits -
    - -### JSON Schema +
    * Describes your existing data format(s). * Provides clear human- and machine- readable documentation. @@ -22,43 +20,56 @@ permalink: /
    -
    +## New to JSON Schema? -### JSON Hyper-Schema +Learning a new specification can be daunting. -* Make any JSON format a hypermedia format with no constraints on document structure -* Allows use of [URI Templates](https://tools.ietf.org/html/rfc6570) with instance data -* Describe client data for use with links using JSON Schema. -* Recognizes collections and collection items. +Luckily, we created this [getting started guide](/learn/getting-started-step-by-step)! -
    +After that, you could check out all our [learning resources](/learn). + +### Got questions? + +We're here to help! + +At any point, feel free to join our Slack server using the link in the menu. + +We also monitor the `jsonschema` tag on StackOverflow. ## Project Status -16 September 2019: Draft 2019-09 (formerly known as draft-08) has been published! +2021-02-01: Draft 2020-12 has been published! -The IETF document IDs are of the form `draft-handrews-*-02`. We are now using dates -for meta-schemas, which are what implementations should use to determine behavior, -so we will usually refer to `2019-09` (without the word "draft") on this web site. +The IETF document IDs are of the form `draft-bhutton-*-00`. + +We are using dates for meta-schemas, which are what implementations should use to determine behavior, +so we will usually refer to `2020-12` (without the word "draft") on this web site. See the [Specification page](specification.html) for details about naming and numbering. + ### The Path to Standardization -The JSON Schema project intends to shepherd all four draft series to RFC status. Currently, we are continuing to improve our self-published Internet-Drafts. The next step will be to get the drafts adopted by an IETF Working Group. We are actively investigating how to accomplish this. +The JSON Schema project intends to shepherd all three draft series to either: RFC status, the equivilent within another standards body, or join a foundation and establish self publication rules. -If you have experience with such things and would like to help, please contact us! +
    +Read more + +Currently, we are continuing to improve our self-published Internet-Drafts. We are not activly pursuing joining a standards organisation. + +We have a few contacts related to each potential path, but if you have experience with such things and would like to help, please still contact us! In the meantime, publication of Internet-Draft documents can be tracked through the IETF: -* [JSON Schema (core)](https://datatracker.ietf.org/doc/draft-handrews-json-schema/) -* [JSON Schema Validation](https://datatracker.ietf.org/doc/draft-handrews-json-schema-validation/) -* [JSON Hyper-Schema](https://datatracker.ietf.org/doc/draft-handrews-json-schema-hyperschema/) -* [Relative JSON Pointers](https://datatracker.ietf.org/doc/draft-handrews-relative-json-pointer/) +* [JSON Schema (core)](https://datatracker.ietf.org/doc/draft-bhutton-json-schema/) +* [JSON Schema Validation](https://datatracker.ietf.org/doc/draft-bhutton-json-schema-validation/) +* [Relative JSON Pointers](https://datatracker.ietf.org/doc/draft-bhutton-relative-json-pointer/) Internet-Drafts expire after six months, so our goal is to publish often enough to always have a set of unexpired drafts available. There may be brief gaps as we wrap up each draft and finalize the text. The intention, particularly for vocabularies such as validation which have been widely implemented, is to remain as compatible as possible from draft to draft. However, these are still drafts, and given a clear enough need validated with the user community, major changes can occur. +
    + ## Quickstart The JSON document being validated or described we call the *instance*, and the document containing the description is called the *schema*. @@ -77,6 +88,14 @@ You can apply constraints on an instance by adding validation keywords to the sc JSON Schema is hypermedia ready, and ideal for annotating your existing JSON-based HTTP API. JSON Schema documents are identified by URIs, which can be used in HTTP Link headers, and inside JSON Schema documents to allow recursive definitions. +## JSON Hyper-Schema + +JSON Hyper-Schema is on hiatus / not currently maintained as of 2021. + +This allows the team to focus the little time they do donate on JSON Schema core and validation. + +We may revisit JSON Hyper-Schema at a later date. + ## More Interested? Check out: @@ -86,7 +105,7 @@ Interested? Check out: * [Learning resources](./learn/index.md) * the growing list of [JSON (Hyper-)Schema software](./implementations.md) -We encourage updating to the latest specification, as described by the draft-07 meta-schemas. +We encourage updating to the latest specification where possible, which is 2020-12. Questions? Feeling helpful? Get involved on: diff --git a/latest/json-schema-core.md b/latest/json-schema-core.md index 600039c6..921902a6 100644 --- a/latest/json-schema-core.md +++ b/latest/json-schema-core.md @@ -1,5 +1,5 @@ --- -redirect_to: "/draft/2019-09/json-schema-core.html" +redirect_to: "/draft/2020-12/json-schema-core.html" title: "JSON Schema: A Media Type for Describing JSON Documents" --- diff --git a/latest/json-schema-hypermedia.md b/latest/json-schema-hypermedia.md deleted file mode 100644 index 7935b0df..00000000 --- a/latest/json-schema-hypermedia.md +++ /dev/null @@ -1,4 +0,0 @@ ---- -redirect_to: "/draft/2019-09/json-schema-hypermedia.html" -title: "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON" ---- diff --git a/latest/json-schema-validation.md b/latest/json-schema-validation.md index 16e6414a..c285f6df 100644 --- a/latest/json-schema-validation.md +++ b/latest/json-schema-validation.md @@ -1,4 +1,4 @@ --- -redirect_to: "/draft/2019-09/json-schema-validation.html" +redirect_to: "/draft/2020-12/json-schema-validation.html" title: "JSON Schema Validation: A Vocabulary for Structural Validation of JSON" --- diff --git a/latest/relative-json-pointer.md b/latest/relative-json-pointer.md index a49854a4..5b5de6c4 100644 --- a/latest/relative-json-pointer.md +++ b/latest/relative-json-pointer.md @@ -1,4 +1,4 @@ --- -redirect_to: "/draft/2019-09/relative-json-pointer.html" +redirect_to: "/draft/2020-12/relative-json-pointer.html" title: "Relative JSON Pointers" --- diff --git a/specification-links.md b/specification-links.md index 7f4253ed..6f3de025 100644 --- a/specification-links.md +++ b/specification-links.md @@ -225,11 +225,11 @@ For links to the somewhat more readably formatted versions on this web site, and draft‑handrews‑relative‑json‑pointer‑02
    - + 2019‑09 - - Draft 8 + + Draft 2019-09 Milestone: @@ -239,14 +239,28 @@ For links to the somewhat more readably formatted versions on this web site, and - (TBD, probably only a subset of the documents) + + draft‑bhutton‑json‑schema‑00 +
    + + draft‑bhutton‑json‑schema‑validation‑00 +
    + + draft‑bhutton‑relative‑json‑pointer‑00 +
    + + + 2020‑12 + + + Draft 2020-12 - bugfixes and/or clarifications, no functional changes -
    Milestone: draft-08-patch-1 +
    + Changes and fixes as a result of discussion with the OpenAPI community. (Includes breaking changes.)
    @@ -258,23 +272,47 @@ For links to the somewhat more readably formatted versions on this web site, and (TBD) - Draft 9 + Draft 2021-NN Milestone: - draft-09 + Draft 2021-NN - + ## Published Drafts +### 2020-12 + +- Specifications + - Core: [draft-bhutton-json-schema-00](https://tools.ietf.org/html/draft-bhutton-json-schema-00) ([changes](https://tools.ietf.org/html/draft-bhutton-json-schema-00#appendix-G)) + - Validation: [draft-bhutton-json-schema-validation-00](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-00) ([changes](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-00#appendix-C)) + - Relative JSON Pointer: [draft-bhutton-relative-json-pointer-00](https://tools.ietf.org/html/draft-bhutton-relative-json-pointer-00) ([changes](https://tools.ietf.org/html/draft-bhutton-relative-json-pointer-00#appendix-A)) +- General use meta-schemas + - [JSON Schema meta-schema](draft/2020-12/schema) +- Individual vocablary meta-schemas + - [Core Vocabulary meta-schema](draft/2020-12/meta/core) + - [Applicator Vocabulary meta-schema](draft/2020-12/meta/applicator) + - [Validation Vocabulary meta-schema](draft/2020-12/meta/validation) + - [Unevaluated Vocabulary meta-schema](draft/2020-12/meta/unevaluated) + - [Format Annotation Vocabulary meta-schema](draft/2020-12/meta/format-annotation) + - [Format Assertion Vocabulary meta-schema](draft/2020-12/meta/format-assertion) + - [Content Vocabulary meta-schema](draft/2020-12/meta/content) + - [Meta-Data Vocabulary meta-schema](draft/2020-12/meta/meta-data) +- Output schemas + - [JSON Schema recommended output schema](draft/2020-12/output/schema) +- Output examples + - [JSON Schema verbose output example](draft/2020-12/output/verbose-example) + ### 2019-09 (formerly known as Draft 8) _**NOTE:** All meta-schema URIs now use `https://`. While currently also available over plain HTTP due to the limitations of GitHub pages and the need to keep prior drafts available over HTTP, only the HTTPS URIs should be used._ +### Draft 2019-09 + - Specifications - Core: [draft-handrews-json-schema-02](https://tools.ietf.org/html/draft-handrews-json-schema-02) ([changes](https://tools.ietf.org/html/draft-handrews-json-schema-02#appendix-G)) - Validation: [draft-handrews-json-schema-validation-02](https://tools.ietf.org/html/draft-handrews-json-schema-validation-02) ([changes](https://tools.ietf.org/html/draft-handrews-json-schema-validation-02#appendix-C)) diff --git a/specification.md b/specification.md index 7edd5d0c..3516579e 100644 --- a/specification.md +++ b/specification.md @@ -5,60 +5,59 @@ permalink: /specification.html title: Specification --- -The current version is *2019-09*! +The current version is *2020-12*! +The previous version was 2019-09. Specification documents ----------------------- -See also the [release notes / change log](draft/2019-09/release-notes.html). +See also the release notes / change log (Work in progress). -The specification is split into three parts, Core, Validation, and Hyper-Schema, along with a related specification, Relative JSON Pointers: +The specification is split into two parts, Core and Validation, along with a related specification, Relative JSON Pointers: |--------------------------------------------------------------|-------------------------------------------------------| -| [JSON Schema Core](draft/2019-09/json-schema-core.html) | defines the basic foundation of JSON Schema | -| [JSON Schema Validation](draft/2019-09/json-schema-validation.html) | defines the validation keywords of JSON Schema | -| [JSON Hyper-Schema](draft/2019-09/json-schema-hypermedia.html) | defines the hyper-media keywords of JSON Schema | -| [Relative JSON Pointers](draft/2019-09/relative-json-pointer.html) | extends the JSON Pointer syntax for relative pointers | +| [JSON Schema Core](draft/2020-12/json-schema-core.html) | defines the basic foundation of JSON Schema | +| [JSON Schema Validation](draft/2020-12/json-schema-validation.html) | defines the validation keywords of JSON Schema | +| [Relative JSON Pointers](draft/2020-12/relative-json-pointer.html) | extends the JSON Pointer syntax for relative pointers | They are also available on the IETF main site: -* [draft-handrews-json-schema-02 (core)](https://tools.ietf.org/html/draft-handrews-json-schema-02) -* [draft-handrews-json-schema-validation-02](https://tools.ietf.org/html/draft-handrews-json-schema-validation-02) -* [draft-handrews-json-schema-hyperschema-02](https://tools.ietf.org/html/draft-handrews-json-schema-hyperschema-02) -* [draft-handrews-relative-json-pointer-02](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-02) +* [draft-bhutton-json-schema-00 (core)](https://tools.ietf.org/html/draft-bhutton-json-schema-00) +* [draft-bhutton-json-schema-validation-00](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-00) +* [draft-bhutton-relative-json-pointer-00](https://tools.ietf.org/html/draft-bhutton-relative-json-pointer-00) Meta-schemas ------------ -The meta-schemas are schemas against which other schemas can be validated. They are self-descriptive: the JSON Schema meta-schema validates itself, while the JSON Hyper-Schema meta-schema both validates itself and defines its own "self" link. +The meta-schemas are schemas against which other schemas can be validated.It is self-descriptive: the JSON Schema meta-schema validates itself. -The latest meta-schema is **2019-09**. For an explanation of the change to date-based identifiers, see the [Specification Links](specification-links.html) page. +The latest meta-schema is **2020-12**. For an explanation of the change to date-based identifiers, see the [Specification Links](specification-links.html) page. _If you are accessing these JSON document links **from a web browser**, you will need to **save the file** then open it as a JSON document. This is due to limitations with GitHub Pages._ -## General-purpose meta-schemas +## General-purpose meta-schema -These serve the same function as the analogous meta-schemas from past drafts, although note that the core and validation schema is no longer self-contained. +Please note, additional vocabulary specific schema files are needed to fully construct and use the Core/Validation Dialect meta-schema. |--------------------------------------------------------------|------------------------------------------------------------| -| [Core/Validation meta-schema](draft/2019-09/schema) | Used for schemas written for pure validation. | -| [Hyper meta-schema](draft/2019-09/hyper-schema) | Used for schemas written for validation and hyper-linking. | +| [Core/Validation Dialect meta-schema](draft/2020-12/schema) | Used for schemas written for pure validation. | +| [Recommended Output meta-schema](draft/2020-12/output/schema)| Recommended output structure of the application process. | ## Single-vocabulary meta-schemas These are relevant primarily to people who want to write their own meta-schemas that build on specific parts of the existing specification. -- [Core Vocabulary meta-schema](draft/2019-09/meta/core) -- [Applicator Vocabulary meta-schema](draft/2019-09/meta/applicator) -- [Validation Vocabulary meta-schema](draft/2019-09/meta/validation) -- [Format Vocabulary meta-schema](draft/2019-09/meta/format) -- [Content Vocabulary meta-schema](draft/2019-09/meta/content) -- [Meta-Data Vocabulary meta-schema](draft/2019-09/meta/meta-data) -- [Hyper-Schema Vocabulary meta-schema](draft/2019-09/meta/hyper-schema) +- [Core Vocabulary meta-schema](draft/2020-12/meta/core) +- [Applicator Vocabulary meta-schema](draft/2020-12/meta/applicator) +- [Validation Vocabulary meta-schema](draft/2020-12/meta/validation) +- [Unevaluated Vocabulary meta-schema](draft/2020-12/meta/unevaluated) +- [Format Annotation Vocabulary meta-schema](draft/2020-12/meta/format-annotation) +- [Format Assertion Vocabulary meta-schema](draft/2020-12/meta/format-assertion) +- [Content Vocabulary meta-schema](draft/2020-12/meta/content) +- [Meta-Data Vocabulary meta-schema](draft/2020-12/meta/meta-data) ## Output schemas and examples -- [JSON Schema recommended output schema](draft/2019-09/output/schema) -- [JSON Hyper-Schema recommended output schema](draft/2019-09/output/hyper-schema) -- [JSON Schema verbose output example](draft/2019-09/output/verbose-example) +- [JSON Schema recommended output schema](draft/2020-12/output/schema) +- [JSON Schema verbose output example](draft/2020-12/output/verbose-example) Migrating from older drafts ------------- @@ -66,10 +65,12 @@ Migrating from older drafts The release notes discuss the changes impacting users and implementers: - JSON Schema Core and Validation + - 2019-09 to 2020-12 (Work in progress - 2021-02-01) - [Draft-07 to 2019-09](draft/2019-09/release-notes.html) - [Draft-06 to Draft-07](draft-07/json-schema-release-notes.html) - [Draft-04 to Draft-06](draft-06/json-schema-release-notes.html) - JSON Hyper-Schema + - There was no JSON Hyper-Schema draft for 2020-12 releases. - [Draft-07 to 2019-09](draft/2019-09/release-notes.html#hyper-schema-vocabulary) - [Draft-04 to Draft-07](draft-07/json-hyper-schema-release-notes.html) - [Draft-04 to Draft-06](draft-06/json-hyper-schema-release-notes.html) From 6d87d4f80e5d43cc6da13606e5f80a75e3025139 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Fri, 10 Jul 2020 15:20:36 -0400 Subject: [PATCH 101/311] add a 'documentation generator' section --- implementations.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/implementations.md b/implementations.md index 971abd59..17a455d8 100644 --- a/implementations.md +++ b/implementations.md @@ -289,6 +289,14 @@ _None currently support draft-06 or later._ - [WebStorm](https://www.jetbrains.com/webstorm/), [IntelliJ IDEA](https://www.jetbrains.com/idea/), and other [JetBrains IDEs](https://www.jetbrains.com/products.html?fromMenu#type=ide) - *Code completion, documentation, and validation for JSON and YAML files using JSON Schema. Support for draft-4, draft-6, and draft-7.* - [Eclipse IDE](https://www.eclipse.org/downloads/eclipse-packages) - *Rich JSON edition supporting schema for instantaneous validation and error reporting, completion, documentation.* +#### Documentation generators + +- [jsonschematic](https://github.com/yanick/jsonschematic/) - Svelte-based schema viewer. Runs as a local web app. + +- [docson](https://github.com/lbovet/docson) - Javascript-based schema viewer. Runs as a local web app. + +- [json-schema-for-humans](https://pypi.org/project/json-schema-for-humans/) - Generate HTML representation of a schema. Python-based. + Schema Repositories ------------------- From b3857e88cef82ae5c2eb5f113e290112cbe99bea Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Tue, 14 Jul 2020 16:04:04 -0400 Subject: [PATCH 102/311] specify with draft versions are supported --- implementations.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/implementations.md b/implementations.md index 17a455d8..1f6bea6f 100644 --- a/implementations.md +++ b/implementations.md @@ -291,11 +291,11 @@ _None currently support draft-06 or later._ #### Documentation generators -- [jsonschematic](https://github.com/yanick/jsonschematic/) - Svelte-based schema viewer. Runs as a local web app. +- [jsonschematic](https://github.com/yanick/jsonschematic/) - Svelte-based schema viewer. Runs as a local web app. Supports draft-7. -- [docson](https://github.com/lbovet/docson) - Javascript-based schema viewer. Runs as a local web app. +- [docson](https://github.com/lbovet/docson) - Javascript-based schema viewer. Runs as a local web app. Supports draft-4. -- [json-schema-for-humans](https://pypi.org/project/json-schema-for-humans/) - Generate HTML representation of a schema. Python-based. +- [json-schema-for-humans](https://pypi.org/project/json-schema-for-humans/) - Generate HTML representation of a schema. Python-based. Supports draft-7. Schema Repositories ------------------- From 780896d7448ba1d4e3931ba1bba3b7aba8476bda Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 4 Feb 2021 22:00:30 +0000 Subject: [PATCH 103/311] Make spacing consistent --- implementations.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/implementations.md b/implementations.md index 1f6bea6f..8a3cdf62 100644 --- a/implementations.md +++ b/implementations.md @@ -292,9 +292,7 @@ _None currently support draft-06 or later._ #### Documentation generators - [jsonschematic](https://github.com/yanick/jsonschematic/) - Svelte-based schema viewer. Runs as a local web app. Supports draft-7. - - [docson](https://github.com/lbovet/docson) - Javascript-based schema viewer. Runs as a local web app. Supports draft-4. - - [json-schema-for-humans](https://pypi.org/project/json-schema-for-humans/) - Generate HTML representation of a schema. Python-based. Supports draft-7. Schema Repositories From 988a6fcf6e8f06e1d5cb80a21245e02bac4f525a Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 11 Feb 2021 11:37:47 +0000 Subject: [PATCH 104/311] Actually use symlinks for things (2020-12 files) that should be symlinked --- draft/2020-12/meta/applicator | 0 draft/2020-12/meta/content | 0 draft/2020-12/meta/core | 0 draft/2020-12/meta/format | 0 draft/2020-12/meta/format-annotation | 0 draft/2020-12/meta/format-assertion | 0 draft/2020-12/meta/meta-data | 0 draft/2020-12/meta/unevaluated | 0 draft/2020-12/meta/validation | 0 draft/2020-12/output/schema | 0 draft/2020-12/output/verbose-example | 0 draft/2020-12/schema | 0 12 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 120000 draft/2020-12/meta/applicator mode change 100644 => 120000 draft/2020-12/meta/content mode change 100644 => 120000 draft/2020-12/meta/core mode change 100644 => 120000 draft/2020-12/meta/format mode change 100644 => 120000 draft/2020-12/meta/format-annotation mode change 100644 => 120000 draft/2020-12/meta/format-assertion mode change 100644 => 120000 draft/2020-12/meta/meta-data mode change 100644 => 120000 draft/2020-12/meta/unevaluated mode change 100644 => 120000 draft/2020-12/meta/validation mode change 100644 => 120000 draft/2020-12/output/schema mode change 100644 => 120000 draft/2020-12/output/verbose-example mode change 100644 => 120000 draft/2020-12/schema diff --git a/draft/2020-12/meta/applicator b/draft/2020-12/meta/applicator deleted file mode 100644 index 8fd44f54..00000000 --- a/draft/2020-12/meta/applicator +++ /dev/null @@ -1 +0,0 @@ -../../../_includes/draft/2020-12/meta/applicator.json \ No newline at end of file diff --git a/draft/2020-12/meta/applicator b/draft/2020-12/meta/applicator new file mode 120000 index 00000000..8fd44f54 --- /dev/null +++ b/draft/2020-12/meta/applicator @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/applicator.json \ No newline at end of file diff --git a/draft/2020-12/meta/content b/draft/2020-12/meta/content deleted file mode 100644 index 784c2c5e..00000000 --- a/draft/2020-12/meta/content +++ /dev/null @@ -1 +0,0 @@ -../../../_includes/draft/2020-12/meta/content.json \ No newline at end of file diff --git a/draft/2020-12/meta/content b/draft/2020-12/meta/content new file mode 120000 index 00000000..784c2c5e --- /dev/null +++ b/draft/2020-12/meta/content @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/content.json \ No newline at end of file diff --git a/draft/2020-12/meta/core b/draft/2020-12/meta/core deleted file mode 100644 index acdf0634..00000000 --- a/draft/2020-12/meta/core +++ /dev/null @@ -1 +0,0 @@ -../../../_includes/draft/2020-12/meta/core.json \ No newline at end of file diff --git a/draft/2020-12/meta/core b/draft/2020-12/meta/core new file mode 120000 index 00000000..acdf0634 --- /dev/null +++ b/draft/2020-12/meta/core @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/core.json \ No newline at end of file diff --git a/draft/2020-12/meta/format b/draft/2020-12/meta/format deleted file mode 100644 index fa372ff7..00000000 --- a/draft/2020-12/meta/format +++ /dev/null @@ -1 +0,0 @@ -../../../_includes/draft/2020-12/meta/format.json \ No newline at end of file diff --git a/draft/2020-12/meta/format b/draft/2020-12/meta/format new file mode 120000 index 00000000..fa372ff7 --- /dev/null +++ b/draft/2020-12/meta/format @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/format.json \ No newline at end of file diff --git a/draft/2020-12/meta/format-annotation b/draft/2020-12/meta/format-annotation deleted file mode 100644 index 9470a37e..00000000 --- a/draft/2020-12/meta/format-annotation +++ /dev/null @@ -1 +0,0 @@ -../../../_includes/draft/2020-12/meta/format-annotaion.json \ No newline at end of file diff --git a/draft/2020-12/meta/format-annotation b/draft/2020-12/meta/format-annotation new file mode 120000 index 00000000..9470a37e --- /dev/null +++ b/draft/2020-12/meta/format-annotation @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/format-annotaion.json \ No newline at end of file diff --git a/draft/2020-12/meta/format-assertion b/draft/2020-12/meta/format-assertion deleted file mode 100644 index b31c612b..00000000 --- a/draft/2020-12/meta/format-assertion +++ /dev/null @@ -1 +0,0 @@ -../../../_includes/draft/2020-12/meta/format-assertion.json \ No newline at end of file diff --git a/draft/2020-12/meta/format-assertion b/draft/2020-12/meta/format-assertion new file mode 120000 index 00000000..b31c612b --- /dev/null +++ b/draft/2020-12/meta/format-assertion @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/format-assertion.json \ No newline at end of file diff --git a/draft/2020-12/meta/meta-data b/draft/2020-12/meta/meta-data deleted file mode 100644 index 49e5296e..00000000 --- a/draft/2020-12/meta/meta-data +++ /dev/null @@ -1 +0,0 @@ -../../../_includes/draft/2020-12/meta/meta-data.json \ No newline at end of file diff --git a/draft/2020-12/meta/meta-data b/draft/2020-12/meta/meta-data new file mode 120000 index 00000000..49e5296e --- /dev/null +++ b/draft/2020-12/meta/meta-data @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/meta-data.json \ No newline at end of file diff --git a/draft/2020-12/meta/unevaluated b/draft/2020-12/meta/unevaluated deleted file mode 100644 index fbd3c938..00000000 --- a/draft/2020-12/meta/unevaluated +++ /dev/null @@ -1 +0,0 @@ -../../../_includes/draft/2020-12/meta/unevaluated.json \ No newline at end of file diff --git a/draft/2020-12/meta/unevaluated b/draft/2020-12/meta/unevaluated new file mode 120000 index 00000000..fbd3c938 --- /dev/null +++ b/draft/2020-12/meta/unevaluated @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/unevaluated.json \ No newline at end of file diff --git a/draft/2020-12/meta/validation b/draft/2020-12/meta/validation deleted file mode 100644 index 90f062f1..00000000 --- a/draft/2020-12/meta/validation +++ /dev/null @@ -1 +0,0 @@ -../../../_includes/draft/2020-12/meta/validation.json \ No newline at end of file diff --git a/draft/2020-12/meta/validation b/draft/2020-12/meta/validation new file mode 120000 index 00000000..90f062f1 --- /dev/null +++ b/draft/2020-12/meta/validation @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/validation.json \ No newline at end of file diff --git a/draft/2020-12/output/schema b/draft/2020-12/output/schema deleted file mode 100644 index efe176a0..00000000 --- a/draft/2020-12/output/schema +++ /dev/null @@ -1 +0,0 @@ -../../../_includes/draft/2020-12/output/schema.json \ No newline at end of file diff --git a/draft/2020-12/output/schema b/draft/2020-12/output/schema new file mode 120000 index 00000000..efe176a0 --- /dev/null +++ b/draft/2020-12/output/schema @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/output/schema.json \ No newline at end of file diff --git a/draft/2020-12/output/verbose-example b/draft/2020-12/output/verbose-example deleted file mode 100644 index 38f31932..00000000 --- a/draft/2020-12/output/verbose-example +++ /dev/null @@ -1 +0,0 @@ -../../../_includes/draft/2020-12/output/verbose-example.json \ No newline at end of file diff --git a/draft/2020-12/output/verbose-example b/draft/2020-12/output/verbose-example new file mode 120000 index 00000000..38f31932 --- /dev/null +++ b/draft/2020-12/output/verbose-example @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/output/verbose-example.json \ No newline at end of file diff --git a/draft/2020-12/schema b/draft/2020-12/schema deleted file mode 100644 index 70e58e37..00000000 --- a/draft/2020-12/schema +++ /dev/null @@ -1 +0,0 @@ -../../_includes/draft/2020-12/schema.json \ No newline at end of file diff --git a/draft/2020-12/schema b/draft/2020-12/schema new file mode 120000 index 00000000..70e58e37 --- /dev/null +++ b/draft/2020-12/schema @@ -0,0 +1 @@ +../../_includes/draft/2020-12/schema.json \ No newline at end of file From cdc6d90cec3d5f2c6817e65f24bdbc74fa940536 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 11 Feb 2021 11:47:39 +0000 Subject: [PATCH 105/311] No format vocabulary for 2020-12, so remove dead symlink --- draft/2020-12/meta/format | 1 - 1 file changed, 1 deletion(-) delete mode 120000 draft/2020-12/meta/format diff --git a/draft/2020-12/meta/format b/draft/2020-12/meta/format deleted file mode 120000 index fa372ff7..00000000 --- a/draft/2020-12/meta/format +++ /dev/null @@ -1 +0,0 @@ -../../../_includes/draft/2020-12/meta/format.json \ No newline at end of file From 7126e0f5133b61518c16babaab2984a8255af238 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 11 Feb 2021 11:56:02 +0000 Subject: [PATCH 106/311] Fix typo in symlink --- draft/2020-12/meta/format-annotation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/draft/2020-12/meta/format-annotation b/draft/2020-12/meta/format-annotation index 9470a37e..1264ea08 120000 --- a/draft/2020-12/meta/format-annotation +++ b/draft/2020-12/meta/format-annotation @@ -1 +1 @@ -../../../_includes/draft/2020-12/meta/format-annotaion.json \ No newline at end of file +../../../_includes/draft/2020-12/meta/format-annotation.json \ No newline at end of file From a6b8c88e50f52e54e2c78db2959a9ed2df1087f9 Mon Sep 17 00:00:00 2001 From: Gertjan De Wilde Date: Fri, 12 Feb 2021 02:24:37 +0100 Subject: [PATCH 107/311] Add Open Collective link --- index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/index.md b/index.md index c7128a8b..99bc24ea 100644 --- a/index.md +++ b/index.md @@ -93,3 +93,4 @@ Questions? Feeling helpful? Get involved on: * [GitHub](http://github.com/json-schema-org/json-schema-spec) * [Google Groups](https://groups.google.com/forum/#!forum/json-schema) * [Slack](https://join.slack.com/t/json-schema/shared_invite/enQtNjc5NTk0MzkzODg5LTVlZGIxNmVhMGY2MWFlYTdiNDQ5NWFiZGUwOThhNmYxZDE0YzA5YjRiOTA5MGY4ZTZlZGZhZDFmYTY4NWM2N2Y) +* [Open Collective](https://opencollective.com/json-schema) From d7b93e657807189ef893851dadb26f2c7dee0289 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Tue, 16 Feb 2021 12:54:15 +0000 Subject: [PATCH 108/311] Move slack link use a nicer redirect link, so only needs to be updated once --- _includes/footer.html | 2 +- _includes/header.html | 2 +- index.md | 4 ++-- slack.md | 3 +++ 4 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 slack.md diff --git a/_includes/footer.html b/_includes/footer.html index beb53386..63643047 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -12,7 +12,7 @@ {% include icon-github.html username=site.github_username %} {% endif %} -
  • Discussion: Slack | Google Groups
  • +
  • Discussion: Slack | Google Groups
  • Site edits: GitHub repo for site
  • diff --git a/_includes/header.html b/_includes/header.html index a63449c6..a744b2a2 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -25,7 +25,7 @@ {{ my_page.title | escape }} {%- endif -%} {% endfor -%} - Join our Slack + Join our Slack {%- endif -%} diff --git a/index.md b/index.md index 0ad7c151..2f1db743 100644 --- a/index.md +++ b/index.md @@ -32,7 +32,7 @@ After that, you could check out all our [learning resources](/learn). We're here to help! -At any point, feel free to join our Slack server using the link in the menu. +At any point, feel free to join our [Slack server](/slack). We also monitor the `jsonschema` tag on StackOverflow. @@ -111,4 +111,4 @@ Questions? Feeling helpful? Get involved on: * [GitHub](http://github.com/json-schema-org/json-schema-spec) * [Google Groups](https://groups.google.com/forum/#!forum/json-schema) -* [Slack](https://join.slack.com/t/json-schema/shared_invite/enQtNjc5NTk0MzkzODg5LTVlZGIxNmVhMGY2MWFlYTdiNDQ5NWFiZGUwOThhNmYxZDE0YzA5YjRiOTA5MGY4ZTZlZGZhZDFmYTY4NWM2N2Y) +* [Slack](/slack) diff --git a/slack.md b/slack.md new file mode 100644 index 00000000..2dc08825 --- /dev/null +++ b/slack.md @@ -0,0 +1,3 @@ +--- +redirect_to: https://join.slack.com/t/json-schema/shared_invite/enQtNjc5NTk0MzkzODg5LTVlZGIxNmVhMGY2MWFlYTdiNDQ5NWFiZGUwOThhNmYxZDE0YzA5YjRiOTA5MGY4ZTZlZGZhZDFmYTY4NWM2N2Y +--- From b891eddea1a301f956578422086b0f708d831453 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Tue, 16 Feb 2021 13:05:31 +0000 Subject: [PATCH 109/311] Slightly update some of the phrasing on the home page --- index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.md b/index.md index 2f1db743..a240f0e8 100644 --- a/index.md +++ b/index.md @@ -24,13 +24,13 @@ permalink: / Learning a new specification can be daunting. -Luckily, we created this [getting started guide](/learn/getting-started-step-by-step)! +You should read our [getting started guide](/learn/getting-started-step-by-step)! -After that, you could check out all our [learning resources](/learn). +You can also see our other [learning resources](/learn). ### Got questions? -We're here to help! +The JSON Schema team and community are here to help! At any point, feel free to join our [Slack server](/slack). @@ -50,7 +50,7 @@ See the [Specification page](specification.html) for details about naming and nu ### The Path to Standardization -The JSON Schema project intends to shepherd all three draft series to either: RFC status, the equivilent within another standards body, or join a foundation and establish self publication rules. +The JSON Schema project intends to shepherd all three draft series to either: RFC status, the equivilent within another standards body, and/or join a foundation and establish self publication rules.
    Read more From 3bf38aad045439fc253452f02b374793f9507fab Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Wed, 17 Feb 2021 11:39:25 -0800 Subject: [PATCH 110/311] Add warning that Rel JSON Pointer is not used --- specification.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/specification.md b/specification.md index 3516579e..ef7b156f 100644 --- a/specification.md +++ b/specification.md @@ -13,7 +13,9 @@ Specification documents See also the release notes / change log (Work in progress). -The specification is split into two parts, Core and Validation, along with a related specification, Relative JSON Pointers: +The specification is split into two parts, Core and Validation. We also publish +the Relative JSON Pointers spec although it's not currently used by Core or +Validation in any significant way. |--------------------------------------------------------------|-------------------------------------------------------| | [JSON Schema Core](draft/2020-12/json-schema-core.html) | defines the basic foundation of JSON Schema | From 2f21a8374467515ca272fa2b4c8656fc7de27714 Mon Sep 17 00:00:00 2001 From: Relequestual Date: Sat, 20 Feb 2021 09:03:09 +0000 Subject: [PATCH 111/311] Move Hyper Schema listing on implementations page --- implementations.md | 82 +++++++++++++++++++++++----------------------- index.md | 2 +- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/implementations.md b/implementations.md index 8a3cdf62..f626c71c 100644 --- a/implementations.md +++ b/implementations.md @@ -78,47 +78,6 @@ Benchmarks that compare at least two implementations supporting draft-06+ may be - PHP - [php-json-schema-bench](https://github.com/swaggest/php-json-schema-bench) - comparative benchmark for JSON-schema PHP validators using JSON-Schema Test Suite and z-schema/JSCK (MIT) -Hyper-Schema ---------------------- - - - - - -
      - {% for language in hyper-schema-libraries %} -
    • - {{language.name}} -
        - {% for implementation in language.implementations %} -
      • - {{ implementation.name }} - - {% if implementation.draft %} - draft-0{{ implementation.draft | join: ", -0" }} - {% endif %} - - {{implementation.notes | markdownify | remove: '

        ' | remove: '

        '}} - - {% if implementation.license %} - ({{ implementation.license | join: ", " }}) - {% endif %} - -
      • - {% endfor %} -
      -
    • - {% endfor %} -
    - #### API documentation - JavaScript @@ -306,3 +265,44 @@ Schema Linter - [json-schema-linter](https://www.json-schema-linter.com/) - Lint/validate/parse json-schema itself, and find typos, missing properties, missing required keys, etc. Supports draft 4, 6, and 7. - [Stoplight Spectral](https://stoplight.io/open-source/spectral) - A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v2/v3 and JSON Schema. Supports draft 4, 6, and 7. + +Hyper-Schema +--------------------- + + + + + +
      + {% for language in hyper-schema-libraries %} +
    • + {{language.name}} +
        + {% for implementation in language.implementations %} +
      • + {{ implementation.name }} + + {% if implementation.draft %} + draft-0{{ implementation.draft | join: ", -0" }} + {% endif %} + + {{implementation.notes | markdownify | remove: '

        ' | remove: '

        '}} + + {% if implementation.license %} + ({{ implementation.license | join: ", " }}) + {% endif %} + +
      • + {% endfor %} +
      +
    • + {% endfor %} +
    \ No newline at end of file diff --git a/index.md b/index.md index 51d60b0e..4adc7d49 100644 --- a/index.md +++ b/index.md @@ -103,7 +103,7 @@ Interested? Check out: * [Understanding JSON Schema](/understanding-json-schema/) * The [specification](./specification.md) * [Learning resources](./learn/index.md) -* the growing list of [JSON (Hyper-)Schema software](./implementations.md) +* the growing list of [JSON Schema software](./implementations.md) We encourage updating to the latest specification where possible, which is 2020-12. From 56cc04254719024819722121889a4d67e02712d2 Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Mon, 22 Feb 2021 17:46:27 +1300 Subject: [PATCH 112/311] deprecate manatee.json; add 2020-12 support for json-everything --- _data/validator-libraries-modern.yml | 7 +------ _data/validator-libraries-obsolete.yml | 5 +++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index cac31e97..24e8619f 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -8,14 +8,9 @@ license: "AGPL-3.0-only" - name: JsonSchema.Net url: https://github.com/gregsdennis/json-everything - date-draft: [2019-09] + date-draft: [2019-09, 2012-12] draft: [7, 6] license: MIT - - name: Manatee.Json - url: https://github.com/gregsdennis/Manatee.Json - date-draft: [2019-09] - draft: [7, 6, 4] - license: MIT - name: C implementations: - name: WJElement diff --git a/_data/validator-libraries-obsolete.yml b/_data/validator-libraries-obsolete.yml index f0bece60..f1c3a4e6 100644 --- a/_data/validator-libraries-obsolete.yml +++ b/_data/validator-libraries-obsolete.yml @@ -6,6 +6,11 @@ notes: draft: [4] license: Ms-PL + - name: Manatee.Json + url: https://github.com/gregsdennis/Manatee.Json + date-draft: [2019-09] + draft: [7, 6, 4] + license: MIT - name: C++ anchor-name: cpp implementations: From cd3a77ff51bf5efbb40fecee23dda3a1a84a03fb Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Mon, 22 Feb 2021 17:48:51 +1300 Subject: [PATCH 113/311] save the file after a typo --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 24e8619f..d2cb3b78 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -8,7 +8,7 @@ license: "AGPL-3.0-only" - name: JsonSchema.Net url: https://github.com/gregsdennis/json-everything - date-draft: [2019-09, 2012-12] + date-draft: [2019-09, 2020-12] draft: [7, 6] license: MIT - name: C From 69c9f28c9c9bfcd3905105e215dd4a04649cd552 Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Mon, 22 Feb 2021 21:06:57 +1300 Subject: [PATCH 114/311] add note about 'no longer in development' --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index f626c71c..82c58acb 100644 --- a/implementations.md +++ b/implementations.md @@ -6,7 +6,7 @@ permalink: /implementations.html _**NOTE:** This page lists implementations with (or actively working towards) support for draft-06 or later._ -_For implementations supporting only draft-04 or older, see the [Obsolete Implementations](obsolete-implementations) page._ +_For implementations supporting only draft-04 or older, or that are no longer in development, see the [Obsolete Implementations](obsolete-implementations) page._ * TOC From 5e852f9ea9cd54e27514bbaee0f0ba510c2733a5 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Mon, 22 Feb 2021 09:56:25 +0000 Subject: [PATCH 115/311] Put most recent version first --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index d2cb3b78..c81c1e6d 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -8,7 +8,7 @@ license: "AGPL-3.0-only" - name: JsonSchema.Net url: https://github.com/gregsdennis/json-everything - date-draft: [2019-09, 2020-12] + date-draft: [2020-12, 2019-09] draft: [7, 6] license: MIT - name: C From ec240024fe360208f0224df3d37095b1029abee3 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Thu, 18 Feb 2021 10:11:22 -0800 Subject: [PATCH 116/311] Update all schemas in /learn to 2020-12 --- learn/examples/address.schema.json | 4 +- learn/examples/calendar.schema.json | 4 +- learn/examples/card.schema.json | 6 +- .../geographical-location.schema.json | 2 +- learn/file-system.md | 58 +++++++++---------- learn/getting-started-step-by-step.md | 30 +++++----- learn/miscellaneous-examples.md | 12 ++-- 7 files changed, 58 insertions(+), 58 deletions(-) diff --git a/learn/examples/address.schema.json b/learn/examples/address.schema.json index 77fadaf2..7b62083a 100644 --- a/learn/examples/address.schema.json +++ b/learn/examples/address.schema.json @@ -1,6 +1,6 @@ { "$id": "https://example.com/address.schema.json", - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "description": "An address similar to http://microformats.org/wiki/h-card", "type": "object", "properties": { @@ -27,7 +27,7 @@ } }, "required": [ "locality", "region", "country-name" ], - "dependencies": { + "dependentRequired": { "post-office-box": [ "street-address" ], "extended-address": [ "street-address" ] } diff --git a/learn/examples/calendar.schema.json b/learn/examples/calendar.schema.json index 7e235efc..afc40c51 100644 --- a/learn/examples/calendar.schema.json +++ b/learn/examples/calendar.schema.json @@ -1,6 +1,6 @@ { "$id": "https://example.com/calendar.schema.json", - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "description": "A representation of an event", "type": "object", "required": [ "dtstart", "summary" ], @@ -41,7 +41,7 @@ "type": "string" }, "geo": { - "$ref": "http://example.com/geographical-location.schema.json" + "$ref": "https://example.com/geographical-location.schema.json" } } } diff --git a/learn/examples/card.schema.json b/learn/examples/card.schema.json index a19439a6..acb33e2a 100644 --- a/learn/examples/card.schema.json +++ b/learn/examples/card.schema.json @@ -1,6 +1,6 @@ { "$id": "https://example.com/card.schema.json", - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "description": "A representation of a person, company, organization, or place", "type": "object", "required": [ "familyName", "givenName" ], @@ -61,8 +61,8 @@ } } }, - "adr": { "$ref": "http://example.com/address.schema.json" }, - "geo": { "$ref": "http://example.com/geographical-location.schema.json" }, + "adr": { "$ref": "https://example.com/address.schema.json" }, + "geo": { "$ref": "https://example.com/geographical-location.schema.json" }, "tz": { "type": "string" }, diff --git a/learn/examples/geographical-location.schema.json b/learn/examples/geographical-location.schema.json index 1e0fc9cf..758dca8f 100644 --- a/learn/examples/geographical-location.schema.json +++ b/learn/examples/geographical-location.schema.json @@ -1,6 +1,6 @@ { "$id": "https://example.com/geographical-location.schema.json", - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Longitude and Latitude Values", "description": "A geographical coordinate.", "required": [ "latitude", "longitude" ], diff --git a/learn/file-system.md b/learn/file-system.md index 65048d03..e7103b2b 100644 --- a/learn/file-system.md +++ b/learn/file-system.md @@ -82,8 +82,8 @@ Building out our JSON Schema from top to bottom: ```json { - "$id": "http://example.com/fstab", - "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://example.com/fstab", + "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "required": [ "/" ], "properties": { @@ -108,13 +108,13 @@ To this we add: * The [`oneOf`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.7.3) keyword. * The [`$ref`](http://json-schema.org/latest/json-schema-core.html#rfc.section.8.3) keyword. * In this case, all references used are local to the schema using a relative fragment URI (`#/...`). -* The [`definitions`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.9) keyword. +* The [`$defs`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.9) keyword. * Including several key names which we will define later. ```json { - "$id": "http://example.com/entry-schema", - "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://example.com/entry-schema", + "$schema": "https://json-schema.org/draft/2020-12/schema", "description": "JSON Schema for an fstab entry", "type": "object", "required": [ "storage" ], @@ -122,14 +122,14 @@ To this we add: "storage": { "type": "object", "oneOf": [ - { "$ref": "#/definitions/diskDevice" }, - { "$ref": "#/definitions/diskUUID" }, - { "$ref": "#/definitions/nfs" }, - { "$ref": "#/definitions/tmpfs" } + { "$ref": "#/$defs/diskDevice" }, + { "$ref": "#/$defs/diskUUID" }, + { "$ref": "#/$defs/nfs" }, + { "$ref": "#/$defs/tmpfs" } ] } }, - "definitions": { + "$defs": { "diskDevice": {}, "diskUUID": {}, "nfs": {}, @@ -155,8 +155,8 @@ With these added constraints, the schema now looks like this: ```json { - "$id": "http://example.com/entry-schema", - "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://example.com/entry-schema", + "$schema": "https://json-schema.org/draft/2020-12/schema", "description": "JSON Schema for an fstab entry", "type": "object", "required": [ "storage" ], @@ -164,10 +164,10 @@ With these added constraints, the schema now looks like this: "storage": { "type": "object", "oneOf": [ - { "$ref": "#/definitions/diskDevice" }, - { "$ref": "#/definitions/diskUUID" }, - { "$ref": "#/definitions/nfs" }, - { "$ref": "#/definitions/tmpfs" } + { "$ref": "#/$defs/diskDevice" }, + { "$ref": "#/$defs/diskUUID" }, + { "$ref": "#/$defs/nfs" }, + { "$ref": "#/$defs/tmpfs" } ] }, "fstype": { @@ -185,7 +185,7 @@ With these added constraints, the schema now looks like this: "type": "boolean" } }, - "definitions": { + "$defs": { "diskDevice": {}, "diskUUID": {}, "nfs": {}, @@ -303,8 +303,8 @@ The resulting schema is quite large: ```json { - "$id": "http://example.com/entry-schema", - "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://example.com/entry-schema", + "$schema": "https://json-schema.org/draft/2020-12/schema", "description": "JSON Schema for an fstab entry", "type": "object", "required": [ "storage" ], @@ -312,10 +312,10 @@ The resulting schema is quite large: "storage": { "type": "object", "oneOf": [ - { "$ref": "#/definitions/diskDevice" }, - { "$ref": "#/definitions/diskUUID" }, - { "$ref": "#/definitions/nfs" }, - { "$ref": "#/definitions/tmpfs" } + { "$ref": "#/$defs/diskDevice" }, + { "$ref": "#/$defs/diskUUID" }, + { "$ref": "#/$defs/nfs" }, + { "$ref": "#/$defs/tmpfs" } ] }, "fstype": { @@ -333,7 +333,7 @@ The resulting schema is quite large: "type": "boolean" } }, - "definitions": { + "$defs": { "diskDevice": { "properties": { "type": { @@ -404,16 +404,16 @@ Coming full circle we use the `$ref` keyword to add our entry schema into the ke ```json { - "$id": "http://example.com/fstab", - "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://example.com/fstab", + "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "required": [ "/" ], "properties": { - "/": { "$ref": "http://example.com/entry-schema" } + "/": { "$ref": "https://example.com/entry-schema" } }, "patternProperties": { - "^(/[^/]+)+$": { "$ref": "http://example.com/entry-schema" } + "^(/[^/]+)+$": { "$ref": "https://example.com/entry-schema" } }, - "additionalProperties": false, + "additionalProperties": false } ``` diff --git a/learn/getting-started-step-by-step.md b/learn/getting-started-step-by-step.md index 94b3a27a..aeebca0d 100644 --- a/learn/getting-started-step-by-step.md +++ b/learn/getting-started-step-by-step.md @@ -57,8 +57,8 @@ We start with four properties called **keywords** which are expressed as [JSON]( ```json { - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://example.com/product.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://example.com/product.schema.json", "title": "Product", "description": "A product in the catalog", "type": "object" @@ -85,8 +85,8 @@ In JSON Schema terms, we update our schema to add: ```json { - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://example.com/product.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://example.com/product.schema.json", "title": "Product", "description": "A product from Acme's catalog", "type": "object", @@ -106,8 +106,8 @@ In JSON Schema terms, we update our schema to add: ```json { - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://example.com/product.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://example.com/product.schema.json", "title": "Product", "description": "A product from Acme's catalog", "type": "object", @@ -135,8 +135,8 @@ According to the store owner there are no free products. ;) ```json { - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://example.com/product.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://example.com/product.schema.json", "title": "Product", "description": "A product from Acme's catalog", "type": "object", @@ -179,8 +179,8 @@ Therefore: ```json { - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://example.com/product.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://example.com/product.schema.json", "title": "Product", "description": "A product from Acme's catalog", "type": "object", @@ -222,8 +222,8 @@ Up until this point we've been dealing with a very flat schema -- only one level ```json { - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://example.com/product.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://example.com/product.schema.json", "title": "Product", "description": "A product from Acme's catalog", "type": "object", @@ -282,7 +282,7 @@ For this example we introduce a new JSON Schema resource and for both properties ```json { "$id": "https://example.com/geographical-location.schema.json", - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Longitude and Latitude", "description": "A geographical coordinate on a planet (most commonly Earth).", "required": [ "latitude", "longitude" ], @@ -306,8 +306,8 @@ Next we add a reference to this new schema so it can be incorporated. ```json { - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://example.com/product.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://example.com/product.schema.json", "title": "Product", "description": "A product from Acme's catalog", "type": "object", diff --git a/learn/miscellaneous-examples.md b/learn/miscellaneous-examples.md index 29bb7747..f73ef943 100644 --- a/learn/miscellaneous-examples.md +++ b/learn/miscellaneous-examples.md @@ -20,7 +20,7 @@ This example provides a typical minimum you are likely to see in JSON Schema. It ```json { "$id": "https://example.com/person.schema.json", - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Person", "type": "object", "properties": { @@ -62,7 +62,7 @@ This example introduces: ```json { "$id": "https://example.com/geographical-location.schema.json", - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Longitude and Latitude Values", "description": "A geographical coordinate.", "required": [ "latitude", "longitude" ], @@ -100,13 +100,13 @@ Arrays are fundamental structures in JSON -- here we demonstrate a couple of way We also introduce the following with this example: -* [`definitions`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.9) keyword +* [`$defs`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.9) keyword * [`$ref`](http://json-schema.org/latest/json-schema-core.html#rfc.section.8.3) keyword ```json { "$id": "https://example.com/arrays.schema.json", - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "description": "A representation of a person, company, organization, or place", "type": "object", "properties": { @@ -118,10 +118,10 @@ We also introduce the following with this example: }, "vegetables": { "type": "array", - "items": { "$ref": "#/definitions/veggie" } + "items": { "$ref": "#/$defs/veggie" } } }, - "definitions": { + "$defs": { "veggie": { "type": "object", "required": [ "veggieName", "veggieLike" ], From 5bcac3450df2763fa1d440a854d0895cd4a9fbe6 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Wed, 17 Feb 2021 12:08:14 -0800 Subject: [PATCH 117/311] Fix propertyNames example in draft-06 release notes --- draft-06/json-schema-release-notes.md | 34 +++++++++++++-------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/draft-06/json-schema-release-notes.md b/draft-06/json-schema-release-notes.md index 68984b5c..6716725b 100644 --- a/draft-06/json-schema-release-notes.md +++ b/draft-06/json-schema-release-notes.md @@ -70,19 +70,19 @@ The difficulty is that if you attempt to do this: { "type": "object", "allOf": [ - {"$ref": "#/definitions/foo"}, - {"$ref": "#/definitions/bar"} + { "$ref": "#/definitions/foo" }, + { "$ref": "#/definitions/bar" } ], "definitions": { "foo": { "properties": { - "foo": {"type": "string"} + "foo": { "type": "string" } }, "additionalProperties": false }, "bar": { "properties": { - "bar": {"type": "number"} + "bar": { "type": "number" } }, "additionalProperties": false } @@ -100,30 +100,28 @@ A workaround is available with the new `"propertyNames"` keyword: { "type": "object", "allOf": [ - {"$ref": "#/definitions/foo"}, - {"$ref": "#/definitions/bar"} - ], - "anyOf": [ - {"$ref": "#/definitions/fooNames"}, - {"$ref": "#/definitions/barNames"} + { "$ref": "#/definitions/foo" }, + { "$ref": "#/definitions/bar" } ], + "propertyNames": { + "anyOf": [ + { "$ref": "#/definitions/fooNames" }, + { "$ref": "#/definitions/barNames" } + ] + }, "definitions": { "foo": { "properties": { - "foo": {"type": "string"} + "foo": { "type": "string" } } }, - "fooNames": { - "propertyNames": {"enum": ["foo"]} - }, + "fooNames": { "enum": ["foo"] }, "bar": { "properties": { - "bar": {"type": "number"} + "bar": { "type": "number" } } }, - "barNames": { - "propertyNames": {"enum": ["bar"]} - } + "barNames": { "enum": ["bar"] } } } ``` From b298dc2aa4dd7da0013c694d14d04f07188edd91 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Tue, 8 Dec 2020 21:03:47 -0800 Subject: [PATCH 118/311] Update Hyperjump JSV for draft 2020-12 --- _data/validator-libraries-modern.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index c81c1e6d..34e9db7f 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -146,7 +146,7 @@ - name: Hyperjump JSV url: https://github.com/jdesrosiers/json-schema notes: "Built for Node.js and browsers. Includes support for custom vocabularies." - date-draft: [2019-09] + date-draft: [2019-09, 2020-12] draft: [7, 6, 4] license: MIT - name: vue-vuelidate-jsonschema @@ -243,7 +243,7 @@ implementations: - name: Hyperjump JSV url: https://json-schema.hyperjump.io - date-draft: [2019-09] + date-draft: [2019-09, 2020-12] draft: [7, 6, 4] notes: Supports multiple schemas and multiple instances - name: JSON Schema Validator From ef52582bca74be1030b2af3d1a663ecb53e165ac Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Thu, 18 Feb 2021 11:58:43 -0800 Subject: [PATCH 119/311] Update spec links in /learn to 2020-12 --- learn/file-system.md | 38 +++++++++++++-------------- learn/getting-started-step-by-step.md | 30 ++++++++++----------- learn/miscellaneous-examples.md | 24 ++++++++--------- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/learn/file-system.md b/learn/file-system.md index e7103b2b..72e32e3a 100644 --- a/learn/file-system.md +++ b/learn/file-system.md @@ -66,16 +66,16 @@ We will start with a base JSON Schema expressing the following constraints: Building out our JSON Schema from top to bottom: -* The [`$id`](http://json-schema.org/latest/json-schema-core.html#rfc.section.8.2) keyword. -* The [`$schema`](http://json-schema.org/latest/json-schema-core.html#rfc.section.7) keyword. -* The [`type`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.1) validation keyword. -* The [`required`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.3) validation keyword. -* The [`properties`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.4) validation keyword. +* The [`$id`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.1) keyword. +* The [`$schema`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1) keyword. +* The [`type`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1) validation keyword. +* The [`required`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.5.3) validation keyword. +* The [`properties`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.1) validation keyword. * The `/` key is empty now; We will fill it out later. -* The [`patternProperties`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.5) validation keyword. +* The [`patternProperties`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.2) validation keyword. * This matches other property names via a regular expression. Note: it does not match `/`. * The `^(/[^/]+)+$` key is empty now; We will fill it out later. -* The [`additionalProperties`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.6) validation keyword. +* The [`additionalProperties`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.3) validation keyword. * The value here is `false` to constrain object properties to be either `/` or to match the regular expression. > You will notice that the regular expression is explicitly anchored (with `^` and `$`): in JSON Schema, regular expressions (in `patternProperties` and in `pattern`) are not anchored by default. @@ -104,11 +104,11 @@ We saw these keywords in the prior exercise: `$id`, `$schema`, `type`, `required To this we add: -* The [`description`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.10.1) annotation keyword. -* The [`oneOf`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.7.3) keyword. -* The [`$ref`](http://json-schema.org/latest/json-schema-core.html#rfc.section.8.3) keyword. +* The [`description`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keyword. +* The [`oneOf`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.2.1.3) keyword. +* The [`$ref`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.3.1) keyword. * In this case, all references used are local to the schema using a relative fragment URI (`#/...`). -* The [`$defs`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.9) keyword. +* The [`$defs`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.4) keyword. * Including several key names which we will define later. ```json @@ -142,12 +142,12 @@ To this we add: Let's now extend this skeleton to add constraints to some of the properties. -* Our `fstype` key uses the [`enum`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.2) validation keyword. +* Our `fstype` key uses the [`enum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.2) validation keyword. * Our `options` key uses the following: * The `type` validation keyword (see above). - * The [`minItems`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.4.4) validation keyword. - * The [`items`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.4.1) validation keyword. - * The [`uniqueItems`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.4.5) validation keyword. + * The [`minItems`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.2) validation keyword. + * The [`items`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.1.2) validation keyword. + * The [`uniqueItems`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.3) validation keyword. * Together these say: `options` must be an array, and the items therein must be strings, there must be at least one item, and all items should be unique. * We have a `readonly` key. @@ -198,7 +198,7 @@ With these added constraints, the schema now looks like this: One new keyword is introduced here: -* The [`pattern`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.3.3) validation keyword notes the `device` key must be an absolute path starting with */dev*. +* The [`pattern`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.3.3) validation keyword notes the `device` key must be an absolute path starting with */dev*. ```json { @@ -246,7 +246,7 @@ We do have a new key: `label` and the `pattern` validation keyword states it mus We find another new keyword: -* The [`format`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.7) annotation and assertion keyword. +* The [`format`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.7) annotation and assertion keyword. ```json { @@ -276,8 +276,8 @@ We find another new keyword: Our last definition introduces two new keywords: -* The [`minimum`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.4) validation keyword. -* The [`maximum`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.2) validation keword. +* The [`minimum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword. +* The [`maximum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.2) validation keword. * Together these require the size be between 16 and 512, inclusive. ```json diff --git a/learn/getting-started-step-by-step.md b/learn/getting-started-step-by-step.md index aeebca0d..4a1eae90 100644 --- a/learn/getting-started-step-by-step.md +++ b/learn/getting-started-step-by-step.md @@ -50,10 +50,10 @@ We start with four properties called **keywords** which are expressed as [JSON]( > Yes. the standard uses a JSON data document to describe data documents, most often that are also JSON data documents but could be in any number of other content types like `text/xml`. -* The [`$schema`](http://json-schema.org/latest/json-schema-core.html#rfc.section.7) keyword states that this schema is written according to a specific draft of the standard and used for a variety of reasons, primarily version control. -* The [`$id`](http://json-schema.org/latest/json-schema-core.html#rfc.section.8.2) keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. -* The [`title`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.10.1) and [`description`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.10.1) annotation keywords are descriptive only. They do not add constraints to the data being validated. The intent of the schema is stated with these two keywords. -* The [`type`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.1) validation keyword defines the first constraint on our JSON data and in this case it has to be a JSON Object. +* The [`$schema`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1) keyword states that this schema is written according to a specific draft of the standard and used for a variety of reasons, primarily version control. +* The [`$id`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.1) keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. +* The [`title`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) and [`description`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keywords are descriptive only. They do not add constraints to the data being validated. The intent of the schema is stated with these two keywords. +* The [`type`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1) validation keyword defines the first constraint on our JSON data and in this case it has to be a JSON Object. ```json { @@ -67,9 +67,9 @@ We start with four properties called **keywords** which are expressed as [JSON]( We introduce the following pieces of terminology when we start the schema: -* [Schema Keyword](http://json-schema.org/latest/json-schema-core.html#rfc.section.4.3.1): `$schema` and `$id`. -* [Schema Annotations](http://json-schema.org/latest/json-schema-validation.html#rfc.section.10): `title` and `description`. -* [Validation Keyword](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6): `type`. +* [Schema Keyword](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1): `$schema` and `$id`. +* [Schema Annotations](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1): `title` and `description`. +* [Validation Keyword](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1): `type`. ## Defining the properties @@ -77,10 +77,10 @@ We introduce the following pieces of terminology when we start the schema: In JSON Schema terms, we update our schema to add: -* The [`properties`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.4) validation keyword. +* The [`properties`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.1) validation keyword. * The `productId` key. * `description` schema annotation and `type` validation keyword is noted -- we covered both of these in the previous section. -* The [`required`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.3) validation keyword listing `productId`. +* The [`required`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.5.3) validation keyword listing `productId`. ```json @@ -130,8 +130,8 @@ In JSON Schema terms, we update our schema to add: According to the store owner there are no free products. ;) * The `price` key is added with the usual `description` schema annotation and `type` validation keywords covered previously. It is also included in the array of keys defined by the `required` validation keyword. -* We specify the value of `price` must be something other than zero using the [`exclusiveMinimum`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.5) validation keyword. - * If we wanted to include zero as a valid price we would have specified the [`minimum`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.4) validation keyword. +* We specify the value of `price` must be something other than zero using the [`exclusiveMinimum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.5) validation keyword. + * If we wanted to include zero as a valid price we would have specified the [`minimum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword. ```json { @@ -172,9 +172,9 @@ Therefore: * The `tags` key is added with the usual annotations and keywords. * This time the `type` validation keyword is `array`. -* We introduce the [`items`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.4.1) validation keyword so we can define what appears in the array. In this case: `string` values via the `type` validation keyword. -* The [`minItems`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.4.4) validation keyword is used to make sure there is at least one item in the array. -* The [`uniqueItems`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.4.5) validation keyword notes all of the items in the array must be unique relative to one another. +* We introduce the [`items`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.1.2) validation keyword so we can define what appears in the array. In this case: `string` values via the `type` validation keyword. +* The [`minItems`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.2) validation keyword is used to make sure there is at least one item in the array. +* The [`uniqueItems`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.3) validation keyword notes all of the items in the array must be unique relative to one another. * We did not add this key to the `required` validation keyword array because it is optional. ```json @@ -276,7 +276,7 @@ So far our JSON schema has been wholly self contained. It is very common to shar For this example we introduce a new JSON Schema resource and for both properties therein: * We use the `minimum` validation keyword noted earlier. -* We add the [`maximum`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.2) validation keyword. +* We add the [`maximum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.2) validation keyword. * Combined, these give us a range to use in validation. ```json diff --git a/learn/miscellaneous-examples.md b/learn/miscellaneous-examples.md index f73ef943..754e6f4a 100644 --- a/learn/miscellaneous-examples.md +++ b/learn/miscellaneous-examples.md @@ -7,15 +7,15 @@ title: Miscellaneous Examples This example provides a typical minimum you are likely to see in JSON Schema. It contains: -* [`$id`](http://json-schema.org/latest/json-schema-core.html#rfc.section.8.2) keyword -* [`$schema`](http://json-schema.org/latest/json-schema-core.html#rfc.section.7) keyword -* [`title`](http://json-schema.org/latest/json-schema-hypermedia.html#rfc.section.6.5.1) annotation keyword -* [`type`](http://json-schema.org/latest/json-schema-core.html#rfc.section.4.2.1) instance data model -* [`properties`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.4) validation keyword +* [`$id`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.1) keyword +* [`$schema`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1) keyword +* [`title`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keyword +* [`type`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1) instance data model +* [`properties`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.1) validation keyword * Three keys: `firstName`, `lastName` and `age` each with their own: - * [`description`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.10.1) annotation keyword. + * [`description`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keyword. * `type` instance data model (see above). -* [`minimum`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.4) validation keyword on the `age` key. +* [`minimum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword on the `age` key. ```json { @@ -55,9 +55,9 @@ This example provides a typical minimum you are likely to see in JSON Schema. It This example introduces: -* [`required`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.3) validation keyword -* [`minimum`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.4) validation keyword -* [`maximum`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.2) validation keyword +* [`required`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.5.3) validation keyword +* [`minimum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword +* [`maximum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.2) validation keyword ```json { @@ -100,8 +100,8 @@ Arrays are fundamental structures in JSON -- here we demonstrate a couple of way We also introduce the following with this example: -* [`$defs`](http://json-schema.org/latest/json-schema-validation.html#rfc.section.9) keyword -* [`$ref`](http://json-schema.org/latest/json-schema-core.html#rfc.section.8.3) keyword +* [`$defs`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.4) keyword +* [`$ref`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.3.1) keyword ```json { From 1622768dd4b009fadf77771903ab85d3a876c77b Mon Sep 17 00:00:00 2001 From: GitHubPang <61439577+GitHubPang@users.noreply.github.com> Date: Wed, 24 Feb 2021 08:07:29 +0800 Subject: [PATCH 120/311] Fix typos in index.md --- index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.md b/index.md index 4adc7d49..b4a512cc 100644 --- a/index.md +++ b/index.md @@ -50,12 +50,12 @@ See the [Specification page](specification.html) for details about naming and nu ### The Path to Standardization -The JSON Schema project intends to shepherd all three draft series to either: RFC status, the equivilent within another standards body, and/or join a foundation and establish self publication rules. +The JSON Schema project intends to shepherd all three draft series to either: RFC status, the equivalent within another standards body, and/or join a foundation and establish self publication rules.
    Read more -Currently, we are continuing to improve our self-published Internet-Drafts. We are not activly pursuing joining a standards organisation. +Currently, we are continuing to improve our self-published Internet-Drafts. We are not actively pursuing joining a standards organisation. We have a few contacts related to each potential path, but if you have experience with such things and would like to help, please still contact us! From d7e4cf1ed9cb49689a570101069b08755aaf28da Mon Sep 17 00:00:00 2001 From: GitHubPang <61439577+GitHubPang@users.noreply.github.com> Date: Wed, 24 Feb 2021 08:08:53 +0800 Subject: [PATCH 121/311] Fix invalid link in CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6f0efcc2..77556cc1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,3 @@ Thank you for your interest in contributing to JSON Schema! Your participation is appreciated! -If your question/request/change concerns the [JSON Schema Website](json-schema.org) you are in the right place. If your question/request/change concerns the JSON Schema specification drafts or meta-schemas, please go to [the JSON Schema specification repository](https://github.com/json-schema-org/json-schema-spec). \ No newline at end of file +If your question/request/change concerns the [JSON Schema Website](http://json-schema.org/) you are in the right place. If your question/request/change concerns the JSON Schema specification drafts or meta-schemas, please go to [the JSON Schema specification repository](https://github.com/json-schema-org/json-schema-spec). From 833e1f2077e88c221400eb05e98a656732c262d4 Mon Sep 17 00:00:00 2001 From: GitHubPang <61439577+GitHubPang@users.noreply.github.com> Date: Wed, 24 Feb 2021 10:18:23 +0800 Subject: [PATCH 122/311] Change http link into https in CONTRIBUTING.md Co-authored-by: Jason Desrosiers --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 77556cc1..bd6dde57 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,3 @@ Thank you for your interest in contributing to JSON Schema! Your participation is appreciated! -If your question/request/change concerns the [JSON Schema Website](http://json-schema.org/) you are in the right place. If your question/request/change concerns the JSON Schema specification drafts or meta-schemas, please go to [the JSON Schema specification repository](https://github.com/json-schema-org/json-schema-spec). +If your question/request/change concerns the [JSON Schema Website](https://json-schema.org/) you are in the right place. If your question/request/change concerns the JSON Schema specification drafts or meta-schemas, please go to [the JSON Schema specification repository](https://github.com/json-schema-org/json-schema-spec). From 6891927e8673e8652e21b4c2c2818d87cc53a4f8 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Sat, 27 Feb 2021 12:14:30 +0000 Subject: [PATCH 123/311] Update schema.md --- schema.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema.md b/schema.md index e433ffa8..056a8079 100644 --- a/schema.md +++ b/schema.md @@ -1,3 +1,3 @@ --- -redirect_to: /draft/2019-09/schema +redirect_to: /draft/2020-12/schema --- From cf7a2f44eeb62ba6a6e35a3de7a6b84476a0b676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Machist=C3=A9=20N=2E=20Quintana?= Date: Sat, 13 Mar 2021 10:59:13 -0500 Subject: [PATCH 124/311] Fix jsonschema-rs Python bindings URL in validator list --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 34e9db7f..345cf4ec 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -202,7 +202,7 @@ draft: [7, 6, 4] license: BSD-3-Clause - name: jsonschema-rs - url: https://github.com/Stranger6667/jsonschema-rs/python + url: https://github.com/Stranger6667/jsonschema-rs/tree/master/bindings/python notes: Python bindings to Rust's jsonschema crate date-draft: draft: [7, 6, 4] From 36c74089e91e4e36d1b3950bdcbe922e7c94758f Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 18 Mar 2021 22:58:39 +0000 Subject: [PATCH 125/311] Update slack invite link --- slack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slack.md b/slack.md index 2dc08825..dd736185 100644 --- a/slack.md +++ b/slack.md @@ -1,3 +1,3 @@ --- -redirect_to: https://join.slack.com/t/json-schema/shared_invite/enQtNjc5NTk0MzkzODg5LTVlZGIxNmVhMGY2MWFlYTdiNDQ5NWFiZGUwOThhNmYxZDE0YzA5YjRiOTA5MGY4ZTZlZGZhZDFmYTY4NWM2N2Y +redirect_to: https://join.slack.com/t/json-schema/shared_invite/zt-nv0vbdfq-Ba_zz2cZBe_26ZoU7fEYGg --- From be41466e3c21397bdfe56ef5cd4fbc5c7ca310a2 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Sun, 28 Mar 2021 18:12:47 +0100 Subject: [PATCH 126/311] ajv draft-2020-12 support --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 34e9db7f..f0257fce 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -134,7 +134,7 @@ - name: ajv url: https://github.com/ajv-validator/ajv notes: "for Node.js and browsers - supports [user-defined keywords](https://github.com/ajv-validator/ajv/blob/master/docs/keywords.md) and [$data reference](https://github.com/json-schema-org/json-schema-spec/issues/51)" - date-draft: [2019-09] + date-draft: [2019-09, 2020-12] draft: [7, 6, 4] license: MIT - name: djv From 0940525245b2bff37de46948ce77bca96a547b76 Mon Sep 17 00:00:00 2001 From: Mark Jacobson <52427991+marksparkza@users.noreply.github.com> Date: Thu, 1 Apr 2021 13:02:38 +0200 Subject: [PATCH 127/311] Add jschon to list of Python validators --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 34e9db7f..fd9d4a86 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -207,6 +207,12 @@ date-draft: draft: [7, 6, 4] license: MIT + - name: jschon + url: https://github.com/marksparkza/jschon + notes: + date-draft: [2019-09, 2020-12] + draft: + license: MIT - name: Ruby implementations: - name: JSONSchemer From a5c39c1e562790bee580dce78fedf3799289d241 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 1 Apr 2021 12:17:53 +0100 Subject: [PATCH 128/311] Change ordering for python implementations New implementations with newer support should go at the top! --- _data/validator-libraries-modern.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index fd9d4a86..30c53620 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -189,6 +189,12 @@ license: "MIT" - name: Python implementations: + - name: jschon + url: https://github.com/marksparkza/jschon + notes: + date-draft: [2019-09, 2020-12] + draft: + license: MIT - name: jsonschema url: https://github.com/Julian/jsonschema notes: @@ -207,12 +213,6 @@ date-draft: draft: [7, 6, 4] license: MIT - - name: jschon - url: https://github.com/marksparkza/jschon - notes: - date-draft: [2019-09, 2020-12] - draft: - license: MIT - name: Ruby implementations: - name: JSONSchemer From 1d4ba3d21d4c44302d93aa1678e7fd3a967f7bfb Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 1 Apr 2021 12:02:44 -0700 Subject: [PATCH 129/311] move more recent draft implementation up top --- _data/validator-libraries-modern.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 30c53620..a9216511 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -162,17 +162,17 @@ license: MIT - name: Perl implementations: + - name: JSON::Schema::Draft201909 + url: https://github.com/karenetheridge/JSON-Schema-Draft201909 + notes: + date-draft: [2019-09] + license: "GNU General Public License, Version 1 + The Artistic License 1.0" - name: JSON::Validator url: https://github.com/mojolicious/json-validator notes: date-draft: draft: [7, 6, 4] license: "The Artistic License 2.0 (GPL Compatible)" - - name: JSON::Schema::Draft201909 - url: https://github.com/karenetheridge/JSON-Schema-Draft201909 - notes: - date-draft: [2019-09] - license: "GNU General Public License, Version 1 + The Artistic License 1.0" - name: PHP implementations: - name: Opis Json Schema From a68bee558698af31ec13dae31d2089ac74c28a7a Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 1 Apr 2021 12:03:25 -0700 Subject: [PATCH 130/311] add link to new perl implementation JSON::Schema::Tiny --- _data/validator-libraries-modern.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index a9216511..f142e1e8 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -167,6 +167,11 @@ notes: date-draft: [2019-09] license: "GNU General Public License, Version 1 + The Artistic License 1.0" + - name: JSON::Schema::Tiny + url: https://github.com/karenetheridge/JSON-Schema-Tiny + notes: + date-draft: [2019-09] + license: "GNU General Public License, Version 1 + The Artistic License 1.0" - name: JSON::Validator url: https://github.com/mojolicious/json-validator notes: From c1cce99edc276389fee1a8f41fb8b1ef1a753b6b Mon Sep 17 00:00:00 2001 From: Eric Moyer Date: Fri, 16 Apr 2021 14:02:36 -0400 Subject: [PATCH 131/311] Add jsonschema2pojo and jsonschematypes Add jsonschema2pojo and jsonschematypes as Java code generators (jsonschematypes was already under Typescript generators but is called "jsongenerator" there) --- implementations.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 5f9e7e52..3ffe3621 100644 --- a/implementations.md +++ b/implementations.md @@ -155,6 +155,8 @@ are the only keywords that changed. - [json-schema-to-elm](https://github.com/dragonwasrobot/json-schema-to-elm) - generates Elm types, JSON decoders+encoders, and fuzz tests from one or more JSON Schema files, using [dragonwasrobot/json_schema](https://github.com/dragonwasrobot/json_schema) *supports Draft 7* - Java - [jsonCodeGen](https://github.com/schlothauer-wauer/jsoncodegen) (MIT) - Groovy based generation tasks from JSON schema. Already includes templates/generators for Java Beans, Swagger specification files and PlantUML diagrams. + - [jsonschema2pojo](https://github.com/joelittlejohn/jsonschema2pojo) (Apache 2.0) - generates Java types from JSON Schema (or example JSON) and can annotate those types for data-binding with Jackson 2.x or Gson. *draft-07* + - [jsonschematypes](https://github.com/jimblackler/jsonschematypes) (Apache 2.0) - Java library to generate Java or TypeScript classes from standard JSON Schemas. *JSON Schema 2019-09, draft-07, -06, -04, -03* - [jsongenerator](https://github.com/jimblackler/jsonschematypes/tree/master/codegen) *JSON Schema 2019-09, draft-07, -06, -04, -03* (Apache-2.0) - Online (web tool) - [quicktype.io](https://app.quicktype.io/#l=schema) - infer JSON Schema from samples, and generate TypeScript, C++, go, Java, C#, Swift, etc. types from JSON Schema @@ -313,4 +315,4 @@ Hyper-Schema {% endfor %} - \ No newline at end of file + From 66969467feb494dcc02247a431a1905a6f283baf Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Tue, 4 May 2021 14:49:24 +0100 Subject: [PATCH 132/311] Add implementation disclaimer. Noted that the implementation listing does not signify endorsement --- implementations.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 5f9e7e52..05ffdbbf 100644 --- a/implementations.md +++ b/implementations.md @@ -19,6 +19,8 @@ Implementations are classified based on their functionality. When known, the lic If you have updates to this list, make a pull request on the [GitHub repo](https://github.com/json-schema-org/json-schema-org.github.io). +Listing does not signify a recommendation or endorsement of any kind. + Validators ---------- @@ -313,4 +315,4 @@ Hyper-Schema {% endfor %} - \ No newline at end of file + From 47d460a2630afb9f95637d8f419886e1e916548b Mon Sep 17 00:00:00 2001 From: Peter Wall Date: Tue, 18 May 2021 21:30:30 +1000 Subject: [PATCH 133/311] Removed 2019-09 from supported drafts, added to codegen generated types --- _data/validator-libraries-modern.yml | 2 +- implementations.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 6c37bd84..5150d4c1 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -130,7 +130,7 @@ - name: json-kotlin-schema url: https://github.com/pwall567/json-kotlin-schema notes: Kotlin implementation of JSON Schema - date-draft: [2019-09] + date-draft: draft: [7] license: MIT - name: JavaScript diff --git a/implementations.md b/implementations.md index 9e44db92..8e4ca800 100644 --- a/implementations.md +++ b/implementations.md @@ -197,7 +197,7 @@ are the only keywords that changed. - Java - [jsonCodeGen](https://github.com/schlothauer-wauer/jsoncodegen) (MIT) - Groovy based generation tasks from JSON schema. Already includes templates/generators for Java Beans, Swagger specification files and PlantUML diagrams. - Kotlin - - [json-kotlin-schema-codegen](https://github.com/pwall567/json-kotlin-schema-codegen) (MIT) - Generates Kotlin data classes from JSON Schema. + - [json-kotlin-schema-codegen](https://github.com/pwall567/json-kotlin-schema-codegen) (MIT) - Generates Kotlin data classes, Java classes or TypeScript interfaces from JSON Schema. - Online (web tool) - [quicktype.io](https://app.quicktype.io/#l=schema) - infer JSON Schema from samples, and generate TypeScript, C++, go, Java, C#, Swift, etc. types from JSON Schema - PHP From 5e72ef0e10b9d5c8021e9b9a8e41796262b9e2be Mon Sep 17 00:00:00 2001 From: Peter Wall Date: Fri, 21 May 2021 19:46:31 +1000 Subject: [PATCH 134/311] Added notes on coverage of specific drafts --- _data/validator-libraries-modern.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index fbdab964..5a78ee4a 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -137,7 +137,10 @@ license: Apache License 2.0 - name: json-kotlin-schema url: https://github.com/pwall567/json-kotlin-schema - notes: Kotlin implementation of JSON Schema + notes: | + Kotlin implementation of JSON Schema. + (Currently supports most of Draft 7; see the README for details. + Full compliance with Draft 7 and later drafts in progress.) date-draft: draft: [7] license: MIT From 96661020f66aedfde4b83ae04f0ccb8709a2aa76 Mon Sep 17 00:00:00 2001 From: AF <58430604+Liquid-Technologies@users.noreply.github.com> Date: Mon, 24 May 2021 08:42:38 +0100 Subject: [PATCH 135/311] Update implementations.md Added new links --- implementations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implementations.md b/implementations.md index 7f93d149..c5966913 100644 --- a/implementations.md +++ b/implementations.md @@ -132,6 +132,7 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - [luposlip/json-schema](https://github.com/luposlip/json-schema) (Apache 2.0) - infer JSON Schema from Clojure data - Online (web tool) - [jsonschema.net](https://www.jsonschema.net/) - generates schemas from example data + - [Liquid Online Tools](https://www.liquid-technologies.com/online-json-to-schema-converter) - infer JSON Schema from sample JSON data - [quicktype.io](https://app.quicktype.io/#l=schema) - infer JSON Schema from samples, and generate TypeScript, C++, go, Java, C#, Swift, etc. types from JSON Schema Generators from schemas @@ -256,6 +257,7 @@ _None currently support draft-06 or later._ - [Dashjoin JSON Schema editor](https://dashjoin.github.io/#/schema) - *Graphical online JSON Schema editor for draft-06 (minus oneOf, anyOf, allOf, not). The generated schema can be tested immediately via a form that is driven by it.* - [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator with context sensitive entry-helpers and sample data generation based on JSON schema. Support for draft-4, draft-6 and draft-7.* - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. +- [Liquid JSON Schema Editor](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON Schema editor for draft-04, draft-06, draft-07 and 2019-09, with split source code and grphical editing. Includes validation of JSON files based on JSON Schema, JSON Sample Generator and JSON Schema Documentation Generator.* - [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* - [Stoplight Studio](https://stoplight.io/) - *JSON Schema IDE (text-based and GUI) with support for JSON/YAML linting, which can also be based on JSON Schema rules via Spectral. Support for draft-4, draft-6 and draft-7.* - [Visual Studio Code](https://code.visualstudio.com/) - *Schema driven code completion, hovers and validation for editing JSON files (including schemas)* From efcf9db788e5e3c79e3e14c4245a727fecba2559 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Mon, 31 May 2021 19:51:15 -0700 Subject: [PATCH 136/311] Develop locally with docker --- .gitignore | 2 ++ README.md | 33 +++++++++++---------------------- docker-compose.yml | 11 +++++++++++ 3 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 6fe13fcd..778ea372 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ _site/ node_modules/ .vscode/ +.jekyll-metadata +vendor/ diff --git a/README.md b/README.md index 72766976..2a457cd9 100644 --- a/README.md +++ b/README.md @@ -19,28 +19,17 @@ Labels are assigned based on [Sensible Github Labels](https://github.com/Releque ## Compile and run locally This site runs via github pages, with automatically building PR previews via netlify. -If you wish to compile and run this site locally, you will need to have ruby installed. - -If you're not familiar with ruby, consider using `rvm` (https://rvm.io/). -Once you have Ruby installed, follow these instructions while in the project directory - -> Instructions -> -> 1. Install the jekyll and bundler gems. -> -> `gem install jekyll bundler` -> -> 2. Create a new Jekyll site at ./myblog. -> -> ... -> -> 3. Build the site and make it available on a local server. -> -> `bundle exec jekyll serve` -> -> 4. Browse to http://localhost:4000 - -Adapted from https://jekyllrb.com/docs/ + +This project uses git submodules, so you will need to run the following commands +to fully clone the repo. + +```bash +git submodule init +git submodule update +``` + +You can run the site locally using `docker-compose up` and browse to +http://localhost:4000 ## License diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..9b51565a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3.9" + +services: + web: + image: docker.io/jekyll/jekyll + volumes: + - .:/srv/jekyll:Z + - ./vendor/bundle:/usr/local/bundle:Z + ports: + - "4000:4000" + command: jekyll serve --incremental --watch From 8dd01ecd93a5689de22d9e58af36003d0ac7ca95 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Mon, 7 Jun 2021 11:09:33 -0700 Subject: [PATCH 137/311] Remove duplicates from obsolete-implemenetations page --- implementations.md | 2 -- obsolete-implementations.md | 15 --------------- 2 files changed, 17 deletions(-) diff --git a/implementations.md b/implementations.md index c5966913..df4c6b89 100644 --- a/implementations.md +++ b/implementations.md @@ -152,8 +152,6 @@ are the only keywords that changed. #### Code generation -- Delphi - - [DJsonSchema](https://github.com/schlothauer-wauer/DJsonSchema) (MIT) - JSON Schema reader and code generator for Delphi. - Elm - [json-schema-to-elm](https://github.com/dragonwasrobot/json-schema-to-elm) - generates Elm types, JSON decoders+encoders, and fuzz tests from one or more JSON Schema files, using [dragonwasrobot/json_schema](https://github.com/dragonwasrobot/json_schema) *supports Draft 7* - Java diff --git a/obsolete-implementations.md b/obsolete-implementations.md index 2950d504..86af9e19 100644 --- a/obsolete-implementations.md +++ b/obsolete-implementations.md @@ -77,12 +77,9 @@ Validators - JavaScript - - [json-schema-benchmark](https://github.com/ebdrup/json-schema-benchmark) - an independent benchmark for Node.js JSON-schema validators based on JSON-Schema Test Suite (MIT) - [z-schema validator benchmark](https://github.com/zaggino/z-schema#benchmarks) - compares performance in the individual tests from JSON-Schema Test Suite (MIT) - [JSCK validator benchmark](https://github.com/pandastrike/jsck#benchmarks) - shows performance for JSON-schemas of different complexity (MIT) -- PHP - - [php-json-schema-bench](https://github.com/swaggest/php-json-schema-bench) - comparative benchmark for JSON-schema PHP validators using JSON-Schema Test Suite and z-schema/JSCK (MIT) Hyper-Schema --------------------- @@ -149,8 +146,6 @@ Data Parsing and Code Generation - Delphi - [DJsonSchema](https://github.com/schlothauer-wauer/DJsonSchema) (MIT) - JSON Schema reader and code generator for Delphi. -- Groovy - - [jsonCodeGen](https://github.com/schlothauer-wauer/jsoncodegen) (MIT) - Groovy based generation tasks from JSON schema. Already includes generators for Java Beans, Swagger specification files and PlantUML diagrams. - Haskell - [aeson-schema](https://github.com/Fuuzetsu/aeson-schema) (MIT) - generates code for a parser - Ruby @@ -171,19 +166,11 @@ _TODO: Sort by draft support._ Various levels of support for UI generation primarily from the validation vocabulary or combined with UI specific definition. - JavaScript - - [Alpaca Forms](http://www.alpacajs.org/) (ASL 2.0) - - [Angular Schema Form](https://github.com/json-schema-form/angular-schema-form) (MIT) - - [Angular2 Schema Form](https://github.com/makinacorpus/angular2-schema-form) *unrelated to Angular Schema Form* (MIT) - [JSON Editor](https://github.com/jdorn/json-editor) (MIT) - - [JSON Form](https://github.com/joshfire/jsonform) (joshfire) (MIT) - - [Json Forms](https://github.com/brutusin/json-forms) (brutusin) (MIT) - [JSONForms](http://jsonforms.io) (EclipseSource) (MIT) - [Jsonary](http://jsonary.com/) (MIT) - - [Liform-react](https://github.com/Limenius/liform-react) (MIT) - [Metawidget](http://metawidget.org/) (LGPL) - [pure-form webcomponent](https://github.com/john-doherty/pure-form) (MIT) - - [React JSON Schema Form](https://github.com/mozilla-services/react-jsonschema-form) (Apache 2) - - [React Schema Form](https://github.com/networknt/react-schema-form) (MIT) Editors ------- @@ -216,5 +203,3 @@ Other - JavaScript - [Dojo](http://www.dojotoolkit.org/) (AFL or BSD) - supports some aspects of JSON Schema - [JSON Schema Random](https://github.com/andreineculau/json-schema-random) (Apache 2.0) - - [json-schema-merge-allof](https://github.com/mokkabonna/json-schema-merge-allof) (MIT) - - [json-schema-compare](https://github.com/mokkabonna/json-schema-compare) (MIT) From 9720b71e7584c9c91f04f5009579dfd6d16bba38 Mon Sep 17 00:00:00 2001 From: Mark Jacobson <52427991+marksparkza@users.noreply.github.com> Date: Thu, 10 Jun 2021 14:01:39 +0200 Subject: [PATCH 138/311] Add jschon.dev online validator --- _data/validator-libraries-modern.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index fc257fff..61b07912 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -278,6 +278,10 @@ date-draft: [2019-09, 2020-12] draft: [7, 6, 4] notes: Supports multiple schemas and multiple instances + - name: jschon.dev + url: https://jschon.dev/ + date-draft: [2019-09, 2020-12] + draft: - name: JSON Schema Validator url: https://www.jsonschemavalidator.net/ date-draft: [2019-09] From ec2cfe99c687380b43779b77ef221e2456c61876 Mon Sep 17 00:00:00 2001 From: Clemens Uhlenhut Date: Sat, 12 Jun 2021 15:02:08 +0200 Subject: [PATCH 139/311] Update implementations.md Added support for draft 2019-09 to JSONBuddy --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index c5966913..8af55d21 100644 --- a/implementations.md +++ b/implementations.md @@ -255,7 +255,7 @@ _None currently support draft-06 or later._ - [Altova XMLSpy 2019r3](https://www.altova.com/xmlspy-xml-editor#json_schema) - *Graphical JSON Schema editor for draft-06 and draft-7, as well as validation of JSON files based on JSON Schema* - [Dashjoin JSON Schema editor](https://dashjoin.github.io/#/schema) - *Graphical online JSON Schema editor for draft-06 (minus oneOf, anyOf, allOf, not). The generated schema can be tested immediately via a form that is driven by it.* -- [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator with context sensitive entry-helpers and sample data generation based on JSON schema. Support for draft-4, draft-6 and draft-7.* +- [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator with JSON schema analyzer, context sensitive entry-helpers and sample data generation based on JSON schema. Support for draft-4, draft-6, draft-7 and 2019-09.* - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Liquid JSON Schema Editor](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON Schema editor for draft-04, draft-06, draft-07 and 2019-09, with split source code and grphical editing. Includes validation of JSON files based on JSON Schema, JSON Sample Generator and JSON Schema Documentation Generator.* - [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* From f42dd18ed57a38c6dec099dc426a84878fca2f79 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Sat, 29 May 2021 13:01:59 -0700 Subject: [PATCH 140/311] Release Notes: Unlrelated fixes --- draft/2019-09/release-notes.md | 2 -- specification-links.md | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/draft/2019-09/release-notes.md b/draft/2019-09/release-notes.md index 0f5c933d..0583b94f 100644 --- a/draft/2019-09/release-notes.md +++ b/draft/2019-09/release-notes.md @@ -3,8 +3,6 @@ title: JSON Schema 2019-09 Release Notes layout: page --- -_NOTE: This page is still being written, and is currently a fairly minimal listing of changes._ - For the vast majority of schema authors, we hope that these changes are minimally disruptive. The most likely to be frustrating is that `format` is no longer treated as a validation assertion _by default_ (although it is still possible for an application or user to configure a validator to treat it as one). We decided this was acceptable because many schema authors are already extremely frustrated by its inconsistent behavior. diff --git a/specification-links.md b/specification-links.md index 6f3de025..c891aed5 100644 --- a/specification-links.md +++ b/specification-links.md @@ -307,12 +307,10 @@ For links to the somewhat more readably formatted versions on this web site, and - Output examples - [JSON Schema verbose output example](draft/2020-12/output/verbose-example) -### 2019-09 (formerly known as Draft 8) +### Draft 2019-09 (formerly known as Draft 8) _**NOTE:** All meta-schema URIs now use `https://`. While currently also available over plain HTTP due to the limitations of GitHub pages and the need to keep prior drafts available over HTTP, only the HTTPS URIs should be used._ -### Draft 2019-09 - - Specifications - Core: [draft-handrews-json-schema-02](https://tools.ietf.org/html/draft-handrews-json-schema-02) ([changes](https://tools.ietf.org/html/draft-handrews-json-schema-02#appendix-G)) - Validation: [draft-handrews-json-schema-validation-02](https://tools.ietf.org/html/draft-handrews-json-schema-validation-02) ([changes](https://tools.ietf.org/html/draft-handrews-json-schema-validation-02#appendix-C)) From bd73d0a3e088c8d370eb6983ef49832a3a0fb4a1 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Mon, 31 May 2021 19:08:15 -0700 Subject: [PATCH 141/311] Release Notes: Init 2020-12 release notes page --- draft/2020-12/release-notes.md | 4 ---- specification.md | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/draft/2020-12/release-notes.md b/draft/2020-12/release-notes.md index ed8cfc6e..372548d4 100644 --- a/draft/2020-12/release-notes.md +++ b/draft/2020-12/release-notes.md @@ -2,7 +2,3 @@ title: JSON Schema 2020-12 Release Notes layout: page --- - -_NOTE: This page is still being written._ - -You can find a minimal changelog at the end of the specification documents themselves. \ No newline at end of file diff --git a/specification.md b/specification.md index ef7b156f..63f9d73a 100644 --- a/specification.md +++ b/specification.md @@ -67,8 +67,8 @@ Migrating from older drafts The release notes discuss the changes impacting users and implementers: - JSON Schema Core and Validation - - 2019-09 to 2020-12 (Work in progress - 2021-02-01) - - [Draft-07 to 2019-09](draft/2019-09/release-notes.html) + - [Draft 2019-09 to Draft 2020-12](draft/2020-12/release-notes.html) + - [Draft-07 to Draft 2019-09](draft/2019-09/release-notes.html) - [Draft-06 to Draft-07](draft-07/json-schema-release-notes.html) - [Draft-04 to Draft-06](draft-06/json-schema-release-notes.html) - JSON Hyper-Schema From da05d901497487d628d2456f098ee9404a350c00 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Sat, 29 May 2021 13:10:32 -0700 Subject: [PATCH 142/311] Release Notes: tuple items changes --- draft/2020-12/release-notes.md | 100 +++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/draft/2020-12/release-notes.md b/draft/2020-12/release-notes.md index 372548d4..4fb7c5c2 100644 --- a/draft/2020-12/release-notes.md +++ b/draft/2020-12/release-notes.md @@ -2,3 +2,103 @@ title: JSON Schema 2020-12 Release Notes layout: page --- +## Changes to items and additionalItems +The keywords used for defining arrays and tuples have been redesigned to help +lower the learning curve for JSON Schema. Since the `items` keyword was used for +both types, we would often see people mistakenly defining a tuple when they +meant to define an array and not understand why only the first item in the array +was validating. + +The `items` and `additionalItems` keywords have been replaced with `prefixItems` +and `items` where `prefixItems` has the same functionality as the +array-of-schemas for of the old `items` and the new `items` keyword has the same +functionality as the old `additionalItems` keyword. + +Although the meaning of `items` has changed, the syntax for defining arrays +remains the same. Only the syntax for defining tuples has changed. The idea is +that an array has items (`items`) and optionally has some positionally defined +items that come before the normal items (`prefixItems`). + +Here are some examples to illustrate the changes. + +### Open tuple + + + + + + + + + +
    Draft 2019-09Draft 2020-12
    +
    {
    +  "items": [
    +    { "$ref": "#/$defs/foo" },
    +    { "$ref": "#/$defs/bar" }
    +  ]
    +}
    +
    +
    {
    +  "prefixItems": [
    +    { "$ref": "#/$defs/foo" },
    +    { "$ref": "#/$defs/bar" }
    +  ]
    +}
    +
    + +### Closed tuple + + + + + + + + + +
    Draft 2019-09Draft 2020-12
    +
    {
    +  "items": [
    +    { "$ref": "#/$defs/foo" },
    +    { "$ref": "#/$defs/bar" }
    +  ],
    +  "additionalItems": false
    +}
    +
    +
    {
    +  "prefixItems": [
    +    { "$ref": "#/$defs/foo" },
    +    { "$ref": "#/$defs/bar" }
    +  ],
    +  "items": false
    +}
    +
    + +### Tuple with constrained additional items + + + + + + + + + +
    Draft 2019-09Draft 2020-12
    +
    {
    +  "items": [
    +    { "$ref": "#/$defs/foo" },
    +    { "$ref": "#/$defs/bar" }
    +  ],
    +  "additionalItems": { "$ref": "#/$defs/baz" }
    +}
    +
    +
    {
    +  "prefixItems": [
    +    { "$ref": "#/$defs/foo" },
    +    { "$ref": "#/$defs/bar" }
    +  ],
    +  "items": { "$ref": "#/$defs/baz" }
    +}
    +
    From a151a916c6434468e68d5e9ea2f7b3f1ffa08357 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Mon, 31 May 2021 19:06:26 -0700 Subject: [PATCH 143/311] Release Notes: Dyanmic keywords --- draft/2020-12/release-notes.md | 82 ++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/draft/2020-12/release-notes.md b/draft/2020-12/release-notes.md index 4fb7c5c2..08311a30 100644 --- a/draft/2020-12/release-notes.md +++ b/draft/2020-12/release-notes.md @@ -102,3 +102,85 @@ Here are some examples to illustrate the changes. + +## $dynamicRef and $dynamicAnchor +The `$recursiveRef` and `$recursiveAnchor` keywords were replaced by the more +powerful `$dynamicRef` and `$dynamicAnchor` keywords. `$recursiveRef` and +`$recursiveAnchor` were introduced in the previous draft to solve the problem of +extending recursive schemas. As the "recursive" keywords got some use and we +understood them better, we discovered how we could generalize them to solve even +more types of problems. The name change reflects that these keywords are useful +for more than just extending recursive schemas. + +A `$dynamicAnchor` can be thought of like a normal `$anchor` except that it can +be referenced across schemas rather than just in the schema it was defined in. +You can think of the old `$recursiveAnchor` as working the same way except that +it only allowed you to create an anchor at the root of the schema and the anchor +name is always empty. + +`$dynamicRef` works the same as the old `$recursiveRef` except that fragments +are no longer empty (`"$dynamicRef": "#my-anchor"` instead of `"$recursiveRef": +"#"`) and non-fragment-only URIs are allowed. When a `$dynamicRef` contains a +non-fragment-only URI-Reference, the schema the URI-Reference resolves to is +used as the starting point for dynamic resolution. + +Here's how you would covert a schema using `$recursiveRef` to use `$dynamicRef`. + + + + + + + + + + +
    Draft 2019-09Draft 2020-12
    // tree schema, extensible
    +{
    +  "$schema": "https://json-schema.org/draft/2019-09/schema",
    +  "$id": "https://example.com/tree",
    +  "$recursiveAnchor": true,
    +
    +  "type": "object",
    +  "properties": {
    +    "data": true,
    +    "children": {
    +      "type": "array",
    +      "items": { "$recursiveRef": "#" }
    +    }
    +  }
    +}
    +
    +// strict-tree schema, guards against misspelled properties
    +{
    +  "$schema": "https://json-schema.org/draft/2019-09/schema",
    +  "$id": "https://example.com/strict-tree",
    +  "$recursiveAnchor": true,
    +
    +  "$ref": "tree",
    +  "unevaluatedProperties": false
    +}
    // tree schema, extensible
    +{
    +  "$schema": "https://json-schema.org/draft/2020-12/schema",
    +  "$id": "https://example.com/tree",
    +  "$dynamicAnchor": "node",
    +
    +  "type": "object",
    +  "properties": {
    +    "data": true,
    +    "children": {
    +      "type": "array",
    +      "items": { "$dynamicRef": "#node" }
    +    }
    +  }
    +}
    +
    +// strict-tree schema, guards against misspelled properties
    +{
    +  "$schema": "https://json-schema.org/draft/2020-12/schema",
    +  "$id": "https://example.com/strict-tree",
    +  "$dynamicAnchor": "node",
    +
    +  "$ref": "tree",
    +  "unevaluatedProperties": false
    +}
    From 974488384d0ee7cb83e6c77b2b1d6b665941742d Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Tue, 1 Jun 2021 10:36:45 -0700 Subject: [PATCH 144/311] Release Notes: Apply suggestions for dynamic changes Co-authored-by: Karen Etheridge --- draft/2020-12/release-notes.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/draft/2020-12/release-notes.md b/draft/2020-12/release-notes.md index 08311a30..5e21fc2c 100644 --- a/draft/2020-12/release-notes.md +++ b/draft/2020-12/release-notes.md @@ -113,10 +113,10 @@ more types of problems. The name change reflects that these keywords are useful for more than just extending recursive schemas. A `$dynamicAnchor` can be thought of like a normal `$anchor` except that it can -be referenced across schemas rather than just in the schema it was defined in. -You can think of the old `$recursiveAnchor` as working the same way except that -it only allowed you to create an anchor at the root of the schema and the anchor -name is always empty. +be referenced across schemas rather than just in the schema where it was +defined. You can think of the old `$recursiveAnchor` as working the same way +except that it only allowed you to create one anchor per schema, it had to be at +the root of the schema, and the anchor name is always empty. `$dynamicRef` works the same as the old `$recursiveRef` except that fragments are no longer empty (`"$dynamicRef": "#my-anchor"` instead of `"$recursiveRef": From e13116f85a8c8c4118d63b4895531d800454f1ba Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Mon, 31 May 2021 19:28:53 -0700 Subject: [PATCH 145/311] Release Notes: Vocabulary changes --- draft/2020-12/release-notes.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/draft/2020-12/release-notes.md b/draft/2020-12/release-notes.md index 5e21fc2c..745b2e27 100644 --- a/draft/2020-12/release-notes.md +++ b/draft/2020-12/release-notes.md @@ -184,3 +184,22 @@ Here's how you would covert a schema using `$recursiveRef` to use `$dynamicRef`. } + +## Vocabulary Changes +The `unevaluatedProperties` and `unevaluatedItems` keywords have been moved from +the applicator vocabulary to their own vocabulary designated which is required +in the default meta-schema. In Draft 2019-09, these keywords were expected to +throw an error if not implemented. This was a special-case behavior of the +applicator vocabulary. Moving the "unevaluated" keywords into their own +vocabulary allows us to remove that special-case and also allowing for dialects +to be constructed that don't require these keywords. + +The format vocabulary was broken into two separate vocabularies. The +"format-annotation" vocabulary treats the `format` keyword as an annotation and +the "format-assertion" vocabulary treats the `format` keyword as an assertion. +The "format-annotation" vocabulary is used in the default meta-schema and is +required. In Draft 2019-09, `format` should be evaluated as an annotation by +default and implementations could provide configuration to change the behavior +to evaluate `format` as an assertion. The separate vocabularies allow for +removing the special configuration requirements and just use the vocabulary +system to express which behavior should be used. From 782852c36f92b1aaac1a954d0fbd5b48760a322a Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Tue, 1 Jun 2021 16:09:47 -0700 Subject: [PATCH 146/311] Release Notes: Add section on contains and unevaluatedItems --- draft/2020-12/release-notes.md | 92 ++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/draft/2020-12/release-notes.md b/draft/2020-12/release-notes.md index 745b2e27..164be5e2 100644 --- a/draft/2020-12/release-notes.md +++ b/draft/2020-12/release-notes.md @@ -185,6 +185,98 @@ Here's how you would covert a schema using `$recursiveRef` to use `$dynamicRef`. +## contains and unevaluatedItems +In the previous draft, it wasn't specified how or if the `contains` keyword +affects the `unevaluatedItems` keyword. This draft specifies that any item in an +array that passes validation of the `contains` schema is considered "evaluated". + +This allows you to use `contains` to express some constraints more cleanly than +you could in previous drafts. This example show how you can express an array +that has some item matching one schema and everything else matching another +schema. + + + + + + + + + + +
    Draft 2019-09Draft 2020-12
    {
    +  "type": "array",
    +  "contains": { "type": "string" },
    +  "items": {
    +    "anyOf": [
    +      { "type": "string" },
    +      { "type": "number" }
    +    ]
    +  }
    +}
    {
    +  "type": "array",
    +  "contains": { "type": "string" },
    +  "unevaluatedItems": { "type": "number" }
    +}
    +
    +
    +
    +
    +
    +
    + +Unfortunately, this change means you may not be able to use `contains` in some +situations you did before. Consider this draft 2019-09 schema describing a tuple +of two strings where one of the two must be three or more characters long and +any additional items are not allowed. + +```json +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "type": "array", + "items": [{ "type": "string" }, { "type": "string" }], + "contains": { "type": "string", "minLength": 3 }, + "unevaluatedItems": false +} +``` + +Given this schema, the instance `["a", "b", "ccc"]` will fail because `"ccc"` is +considered unevaluated and fails the `unevaluatedItems` keyword. Now let's +naively convert that example to a draft 2020-12 schema. + +```json +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array", + "prefixItems": [{ "type": "string" }, { "type": "string" }], + "contains": { "type": "string", "minLength": 3 }, + "unevaluatedItems": false +} +``` + +Given this schema, the instance `["a", "b", "ccc"]` will pass because `"ccc"` is +considered evaluated and doesn't not apply to the `unevaluatedItems` keyword. To +fix this problem we can use the same boolean algebra transformation we used to +use before we had the `contains` keyword. + +```json +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array", + "prefixItems": [{ "type": "string" }, { "type": "string" }], + "not": { + "items": { + "not": { "type": "string", "minLength": 3 } + } + }, + "unevaluatedItems": false +} +``` + +Given this schema, the instance `["a", "b", "ccc"]` will fail because `"ccc"` is +considered unevaluated and fails the `unevaluatedItems` keyword like it did in +previous drafts. + ## Vocabulary Changes The `unevaluatedProperties` and `unevaluatedItems` keywords have been moved from the applicator vocabulary to their own vocabulary designated which is required From 136110d99c958a00568e420657fe054e99656923 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Thu, 3 Jun 2021 15:48:54 -0700 Subject: [PATCH 147/311] Release Notes: Add section on embedded schemas --- draft/2020-12/release-notes.md | 156 +++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) diff --git a/draft/2020-12/release-notes.md b/draft/2020-12/release-notes.md index 164be5e2..301d0f0b 100644 --- a/draft/2020-12/release-notes.md +++ b/draft/2020-12/release-notes.md @@ -277,6 +277,162 @@ Given this schema, the instance `["a", "b", "ccc"]` will fail because `"ccc"` is considered unevaluated and fails the `unevaluatedItems` keyword like it did in previous drafts. +## Embedded Schemas and Bundling +In Draft 2019-09, the meaning of `$id` in a sub-schema changed from indicating a +base URI change within the current schema to indicating an embedded schema +independent of the parent schema. A schema that contains one or more embedded +schemas is called a "Compound Schema Document". This draft introduces guidance +on how bundlers should embedded schemas to create Compound Schema Documents. + +If you reference an external schema, that schema can declare it's own `$schema` +and that may be different than the `$schema` of the referencing schema. +Implementations need to be prepared to switch processing modes or throw an +error if they don't support the `$schema` of the referenced schema. Embedded +schemas work exactly the same way. They may declare a `$schema` that is not the +same as the parent schema and implementations need to be prepared to handle the +`$schema` change appropriately. + +A notable consequence of embedded schemas having a different `$schema` than its +parent is that implementations can't validate Compound Schema Documents directly +against the meta-schema. The Compound Schema Document needs to be decomposed and +each Schema Resource needs to be validated individually against the appropriate +meta-schema for that schema. + +This draft introduces official guidance on how to use embedded schemas to +bundle schemas into a Compound Schema Document. The approach is designed to not +have to modify schemas (other than adding to `$defs`) so that output results +remain as similar as possible whether you are validating the bundled schema or +following external references. Here's an example of a customer schema with +external references that we want to bundle. + +```json +{ + "$schema": "https://json-schema.org/draft/2020-12", + "$id": "https://example.com/schema/customer", + + "type": "object", + "properties": { + "name": { "type": "string" }, + "phone": { "$ref": "/schema/common#/$defs/phone" }, + "address": { "$ref": "/schema/address" } + } +} +``` + +```json +{ + "$schema": "https://json-schema.org/draft/2020-12", + "$id": "https://example.com/schema/address", + + "type": "object", + "properties": { + "address": { "type": "string" }, + "city": { "type": "string" }, + "postalCode": { "type": "/schema/common#/$defs/usaPostalCode" }, + "state": { "type": "/$defs/states" } + }, + + "$defs": { + "states": { + "enum": [...] + } + } +} +``` + +```json +{ + "$schema": "https://json-schema.org/draft/2019-09", + "$id": "https://example.com/schema/common", + + "$defs": { + "phone": { + "type": "string", + "pattern": "^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$" + }, + "usaPostalCode": { + "type": "string", + "pattern": "^[0-9]{5}(?:-[0-9]{4})?$" + }, + "unsignedInt": { + "type": "integer", + "minimum": 0 + } + } +} +``` + +To bundle these schemas, we simply add each of the referenced schemas as +embedded schemas using `$defs`. Here's what the bundled schema would look like. + +```json +{ + "$schema": "https://json-schema.org/draft/2020-12", + "$id": "https://example.com/schema/customer", + + "type": "object", + "properties": { + "name": { "type": "string" }, + "phone": { "$ref": "/schema/common#/$defs/phone" }, + "address": { "$ref": "/schema/address" } + } + + "$defs": { + "https://example.com/schema/address": { + "$id": "https://example.com/schema/address", + + "type": "object", + "properties": { + "address": { "type": "string" }, + "city": { "type": "string" }, + "postalCode": { "type": "/schema/common#/$defs/usaPostalCode" }, + "state": { "type": "#/$defs/states" } + }, + + "$defs": { + "states": { + "enum": [...] + } + } + }, + "$id": "https://example.com/schema/common": { + "$schema": "https://json-schema.org/draft/2019-09", + "$id": "https://example.com/schema/common", + + "$defs": { + "phone": { + "type": "string", + "pattern": "^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$" + }, + "usaPostalCode": { + "type": "string", + "pattern": "^[0-9]{5}(?:-[0-9]{4})?$" + }, + "unsignedInt": { + "type": "integer", + "minimum": 0 + } + } + } + } +} +``` + +Here are a few things you might notice from this example. + +1. No `$ref`s were modified. Even local references are unchanged. +2. `https://example.com/schema/common#/$defs/unsignedInt` got pulled in with the +common schema even though it isn't used. It's allowed to trim out the extra +definitions, but not necessary. +3. `https://example.com/schema/address` doesn't declare a `$schema`. Because it +uses the same `$schema` as `https://example.com/schema/customer`, it can skip +that declaration and use the `$schema` from the schema it's embedded in. +4. `https://example.com/schema/common` uses a different `$schema` than the +document it's embedded in. That's allowed. +5. Definitions from `https://example.com/schema/common` are used in both of the +other schemas and only needs to be included once. It isn't necessary for +bundlers to embed a schema inside another embedded schema. + ## Vocabulary Changes The `unevaluatedProperties` and `unevaluatedItems` keywords have been moved from the applicator vocabulary to their own vocabulary designated which is required From e2a52d6f26e603d859493efd60514b8bc600101e Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Fri, 4 Jun 2021 10:49:41 -0700 Subject: [PATCH 148/311] Release Notes: Added an intro and a few smaller sections --- draft/2020-12/release-notes.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/draft/2020-12/release-notes.md b/draft/2020-12/release-notes.md index 301d0f0b..977eabfb 100644 --- a/draft/2020-12/release-notes.md +++ b/draft/2020-12/release-notes.md @@ -2,6 +2,16 @@ title: JSON Schema 2020-12 Release Notes layout: page --- +The previous draft (2019-09) introduced a lot of new concepts including +`$recursiveRef`/`$recursiveAnchor`, `unevaluatedProperties`/`unevaluatedItems`, +vocabularies, and more. Since then, these new features have seen multiple +implementations and usage in real schemas. This draft is mostly dedicated to +changes related to applying the lessons we've learned about implementing and +using these new features in the wild. + +This document attempts to put information most useful to schema authors toward +the top and information for implementation authors toward the bottom. + ## Changes to items and additionalItems The keywords used for defining arrays and tuples have been redesigned to help lower the learning curve for JSON Schema. Since the `items` keyword was used for @@ -277,6 +287,18 @@ Given this schema, the instance `["a", "b", "ccc"]` will fail because `"ccc"` is considered unevaluated and fails the `unevaluatedItems` keyword like it did in previous drafts. +## Regular Expressions +Regular expressions are now required to support unicode characters. Previously, +this was unspecified and implementations may or may not support this unicode in +regular expressions. + +## Media Type Changes +JSON Schema defines two media types, `application/schema+json` and +`application/schema-instance+json`. This draft drops support for the `schema` +media type parameter. It's caused a lot of confusion and disagreement. Since we +haven't seen any evidence of anyone actually using it, it was decided to remove +it for now. + ## Embedded Schemas and Bundling In Draft 2019-09, the meaning of `$id` in a sub-schema changed from indicating a base URI change within the current schema to indicating an embedded schema @@ -433,6 +455,11 @@ document it's embedded in. That's allowed. other schemas and only needs to be included once. It isn't necessary for bundlers to embed a schema inside another embedded schema. +## Annotations +Implementations that collect annotations should now include annotations for +unknown keywords in the "verbose" output format. The annotation value for an +unknown keyword is the keyword's value. + ## Vocabulary Changes The `unevaluatedProperties` and `unevaluatedItems` keywords have been moved from the applicator vocabulary to their own vocabulary designated which is required From 52f390e0b5e5d2cf4040a648cc6ae5f15a172884 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Thu, 1 Jul 2021 22:17:14 -0700 Subject: [PATCH 149/311] small typo fixes --- draft/2020-12/release-notes.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/draft/2020-12/release-notes.md b/draft/2020-12/release-notes.md index 977eabfb..742a5009 100644 --- a/draft/2020-12/release-notes.md +++ b/draft/2020-12/release-notes.md @@ -306,7 +306,7 @@ independent of the parent schema. A schema that contains one or more embedded schemas is called a "Compound Schema Document". This draft introduces guidance on how bundlers should embedded schemas to create Compound Schema Documents. -If you reference an external schema, that schema can declare it's own `$schema` +If you reference an external schema, that schema can declare its own `$schema` and that may be different than the `$schema` of the referencing schema. Implementations need to be prepared to switch processing modes or throw an error if they don't support the `$schema` of the referenced schema. Embedded @@ -417,7 +417,7 @@ embedded schemas using `$defs`. Here's what the bundled schema would look like. } } }, - "$id": "https://example.com/schema/common": { + "https://example.com/schema/common": { "$schema": "https://json-schema.org/draft/2019-09", "$id": "https://example.com/schema/common", @@ -462,7 +462,7 @@ unknown keyword is the keyword's value. ## Vocabulary Changes The `unevaluatedProperties` and `unevaluatedItems` keywords have been moved from -the applicator vocabulary to their own vocabulary designated which is required +the applicator vocabulary to their own designated vocabulary which is required in the default meta-schema. In Draft 2019-09, these keywords were expected to throw an error if not implemented. This was a special-case behavior of the applicator vocabulary. Moving the "unevaluated" keywords into their own From a7ae96b63025a36ccdfef524e36161d9233ff6f1 Mon Sep 17 00:00:00 2001 From: Iwan Aucamp Date: Sun, 4 Jul 2021 21:23:47 +0200 Subject: [PATCH 150/311] Clarify the meaning of the draft qualifier --- index.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/index.md b/index.md index b4a512cc..c85c7833 100644 --- a/index.md +++ b/index.md @@ -65,10 +65,19 @@ In the meantime, publication of Internet-Draft documents can be tracked through * [Relative JSON Pointers](https://datatracker.ietf.org/doc/draft-bhutton-relative-json-pointer/) Internet-Drafts expire after six months, so our goal is to publish often enough to always have a set of unexpired drafts available. There may be brief gaps as we wrap up each draft and finalize the text. +
    -The intention, particularly for vocabularies such as validation which have been widely implemented, is to remain as compatible as possible from draft to draft. However, these are still drafts, and given a clear enough need validated with the user community, major changes can occur. +### Use of the _draft_ qualifier -
    +Releases of the JSON schema specification and meta schemas are qualified as _draft_ primarily for historical reasons stemming from the relationship of this specification to IETF. + +The JSON schema project recognizes, condones and advocates for the use of the JSON schema standard in production. + +Each release of the JSON schema is treated as a production release by the JSON schema project. All changes in each new release are made judiciously, with great care and thorough review with careful consideration of how the changes will impact existing users and implementations of the JSON schema specification. + +Similarly to most specifications, the JSON schema specification will continue to evolve, and not all releases will be backwards compatible. The intention, particularly for vocabularies such as validation which have been widely implemented, is to remain as compatible as possible from release to release. However, major changes can still occur given a clear enough need validated with the user community. + +At some point, the draft qualifier will be dropped, and this may indicate that the frequency of releases and amount of changes in each release will decrease, but it won't indicate that no new releases will be made, or that all future releases will be backwards compatible. ## Quickstart From 298eb3d3728a81ca52c53bfb4b1f1ec6e3003755 Mon Sep 17 00:00:00 2001 From: Iwan Aucamp Date: Sat, 3 Jul 2021 21:03:44 +0200 Subject: [PATCH 151/311] Add links to GitHub Discussions --- _includes/footer.html | 1 + index.md | 1 + 2 files changed, 2 insertions(+) diff --git a/_includes/footer.html b/_includes/footer.html index 63643047..6f99d796 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -13,6 +13,7 @@ {% endif %}
  • Discussion: Slack | Google Groups
  • +
  • GitHub Discussions
  • Site edits: GitHub repo for site
  • diff --git a/index.md b/index.md index b4a512cc..cf00329c 100644 --- a/index.md +++ b/index.md @@ -110,6 +110,7 @@ We encourage updating to the latest specification where possible, which is 2020- Questions? Feeling helpful? Get involved on: * [GitHub](http://github.com/json-schema-org/json-schema-spec) +* [GitHub Discussions](https://github.com/json-schema-org/community/discussions) * [Google Groups](https://groups.google.com/forum/#!forum/json-schema) * [Slack](/slack) * [Open Collective](https://opencollective.com/json-schema) From 14e53de8139ab4bd13caba6b5d5e93796f429458 Mon Sep 17 00:00:00 2001 From: Iwan Aucamp Date: Mon, 5 Jul 2021 22:07:53 +0200 Subject: [PATCH 152/311] Update index.md Fix grammar Co-authored-by: Jason Desrosiers --- index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.md b/index.md index c85c7833..c449d2b9 100644 --- a/index.md +++ b/index.md @@ -73,7 +73,7 @@ Releases of the JSON schema specification and meta schemas are qualified as _dra The JSON schema project recognizes, condones and advocates for the use of the JSON schema standard in production. -Each release of the JSON schema is treated as a production release by the JSON schema project. All changes in each new release are made judiciously, with great care and thorough review with careful consideration of how the changes will impact existing users and implementations of the JSON schema specification. +Each release of the JSON schema specification is treated as a production release by the JSON schema project. All changes in each new release are made judiciously, with great care and thorough review with careful consideration of how the changes will impact existing users and implementations of the JSON schema specification. Similarly to most specifications, the JSON schema specification will continue to evolve, and not all releases will be backwards compatible. The intention, particularly for vocabularies such as validation which have been widely implemented, is to remain as compatible as possible from release to release. However, major changes can still occur given a clear enough need validated with the user community. From 24c9a1d930dc877849789c775213e478a6e6668b Mon Sep 17 00:00:00 2001 From: Iwan Aucamp Date: Tue, 6 Jul 2021 01:12:02 +0200 Subject: [PATCH 153/311] Add rationale for continued use of draft designation Also change "qualifier" to "designation", and fix grammar in third paragraph. --- index.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.md b/index.md index c449d2b9..b0a7dc0d 100644 --- a/index.md +++ b/index.md @@ -67,17 +67,18 @@ In the meantime, publication of Internet-Draft documents can be tracked through Internet-Drafts expire after six months, so our goal is to publish often enough to always have a set of unexpired drafts available. There may be brief gaps as we wrap up each draft and finalize the text. -### Use of the _draft_ qualifier +### Use of the _draft_ designation -Releases of the JSON schema specification and meta schemas are qualified as _draft_ primarily for historical reasons stemming from the relationship of this specification to IETF. +Releases of the JSON schema specification and meta schemas use the _draft_ designation primarily for historical reasons stemming from the relationship of this specification to IETF ([explained here](https://json-schema.org/specification-links.html#understanding-draft-names-and-numbers)). +The use of this designation is under review but will continue until this review process completes to avoid changing the designation style multiple times. The JSON schema project recognizes, condones and advocates for the use of the JSON schema standard in production. -Each release of the JSON schema specification is treated as a production release by the JSON schema project. All changes in each new release are made judiciously, with great care and thorough review with careful consideration of how the changes will impact existing users and implementations of the JSON schema specification. +Each release of the JSON schema specification is treated as a production release by the JSON schema project. All changes in each new release are made judiciously, with great care, thorough review and careful consideration of how the changes will impact existing users and implementations of the JSON schema specification. Similarly to most specifications, the JSON schema specification will continue to evolve, and not all releases will be backwards compatible. The intention, particularly for vocabularies such as validation which have been widely implemented, is to remain as compatible as possible from release to release. However, major changes can still occur given a clear enough need validated with the user community. -At some point, the draft qualifier will be dropped, and this may indicate that the frequency of releases and amount of changes in each release will decrease, but it won't indicate that no new releases will be made, or that all future releases will be backwards compatible. +When the _draft_ designation is dropped this may indicate that the frequency of releases and amount of changes in each release will decrease, but it won't indicate that no new releases will be made, or that all future releases will be backwards compatible. ## Quickstart From 11d2ab15dd250418be0f0a65054c8252104a689d Mon Sep 17 00:00:00 2001 From: Iwan Aucamp Date: Tue, 6 Jul 2021 18:44:10 +0200 Subject: [PATCH 154/311] Update index.md add oxford comma Co-authored-by: Ben Hutton --- index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.md b/index.md index b0a7dc0d..27d80190 100644 --- a/index.md +++ b/index.md @@ -72,7 +72,7 @@ Internet-Drafts expire after six months, so our goal is to publish often enough Releases of the JSON schema specification and meta schemas use the _draft_ designation primarily for historical reasons stemming from the relationship of this specification to IETF ([explained here](https://json-schema.org/specification-links.html#understanding-draft-names-and-numbers)). The use of this designation is under review but will continue until this review process completes to avoid changing the designation style multiple times. -The JSON schema project recognizes, condones and advocates for the use of the JSON schema standard in production. +The JSON schema project recognizes, condones, and advocates for the use of the JSON schema standard in production. Each release of the JSON schema specification is treated as a production release by the JSON schema project. All changes in each new release are made judiciously, with great care, thorough review and careful consideration of how the changes will impact existing users and implementations of the JSON schema specification. From 5d97d48efe61a4b6e672e7e97461ee9ad5242c5a Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Mon, 2 Aug 2021 22:33:38 -0700 Subject: [PATCH 155/311] update support info for JSON::Schema::Modern, JSON::Schema::Tiny JSON::Schema::Draft201909 has been renamed and now also supports drafts 7 and 2020-12 JSON::Schema::Tiny now also supports 7, 2019-09, 2020-12 --- _data/validator-libraries-modern.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 61b07912..ec275461 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -183,15 +183,15 @@ license: MIT - name: Perl implementations: - - name: JSON::Schema::Draft201909 - url: https://github.com/karenetheridge/JSON-Schema-Draft201909 + - name: JSON::Schema::Modern + url: https://github.com/karenetheridge/JSON-Schema-Modern notes: - date-draft: [2019-09] + date-draft: [7, 2019-09, 2020-12] license: "GNU General Public License, Version 1 + The Artistic License 1.0" - name: JSON::Schema::Tiny url: https://github.com/karenetheridge/JSON-Schema-Tiny notes: - date-draft: [2019-09] + date-draft: [7, 2019-09, 2020-12] license: "GNU General Public License, Version 1 + The Artistic License 1.0" - name: JSON::Validator url: https://github.com/mojolicious/json-validator From 64a4613255db30c1823e96e8579875e5bde90d3e Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Fri, 6 Aug 2021 15:05:25 +0100 Subject: [PATCH 156/311] Added blog --- _includes/header.html | 1 + 1 file changed, 1 insertion(+) diff --git a/_includes/header.html b/_includes/header.html index a744b2a2..3aa58e9b 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -25,6 +25,7 @@ {{ my_page.title | escape }} {%- endif -%} {% endfor -%} + Blog Join our Slack From fa6396562294496ddd6aa330d2921c9161bc9c07 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Thu, 12 Aug 2021 09:34:55 -0700 Subject: [PATCH 157/311] Release Notes: Unicode not required in RegExp While "SHOULD" is not a strict requirement, it does imply that it should be followed unless you have a really good reason not to. I tried to choose words that made it sound more important than just a recommendation while still making in clear that it's not strictly required. --- draft/2020-12/release-notes.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/draft/2020-12/release-notes.md b/draft/2020-12/release-notes.md index 742a5009..e4fb5c2b 100644 --- a/draft/2020-12/release-notes.md +++ b/draft/2020-12/release-notes.md @@ -288,9 +288,9 @@ considered unevaluated and fails the `unevaluatedItems` keyword like it did in previous drafts. ## Regular Expressions -Regular expressions are now required to support unicode characters. Previously, -this was unspecified and implementations may or may not support this unicode in -regular expressions. +Regular expressions are now expected (but not strictly required) to support +unicode characters. Previously, this was unspecified and implementations may or +may not support this unicode in regular expressions. ## Media Type Changes JSON Schema defines two media types, `application/schema+json` and From 2cacfcf9c098117b02c8bdea128380f147f3f2c8 Mon Sep 17 00:00:00 2001 From: Aleksey Stavrov Date: Mon, 16 Aug 2021 09:57:20 +0500 Subject: [PATCH 158/311] add perl validator JSONSchema::Validator --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index ec275461..03581a94 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -199,6 +199,12 @@ date-draft: draft: [7, 6, 4] license: "The Artistic License 2.0 (GPL Compatible)" + - name: JSONSchema::Validator + url: https://github.com/skbkontur/perl-jsonschema-validator + notes: + date-draft: + draft: [7, 6, 4] + license: MIT - name: PHP implementations: - name: Opis Json Schema From 8842f3b27f2f382fbff8c8ff7f1c8edb06574613 Mon Sep 17 00:00:00 2001 From: pinery-systems Date: Sun, 22 Aug 2021 23:27:22 -0400 Subject: [PATCH 159/311] JSON Essentials for COM/ActiveX added to the modern validator list --- _data/validator-libraries-modern.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index ec275461..d19c3ee6 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -55,6 +55,13 @@ date-draft: draft: [7] license: Apache License, Version 2.0 +- name: COM/ActiveX + implementations: + - name: JSON Essentials for COM/ActiveX + url: https://pinery.systems/json-essentials-com/index.html + draft: [7] + license: proprietary + notes: Language independent, includes JSON DOM parser, REST ready, 4 licensing options for free and business uses. For Windows platform only. - name: Common Lisp implementations: - name: json-schema From 6bdfb703e3df0422988deefc8a49c8aaaede471d Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Fri, 3 Sep 2021 00:25:24 +1200 Subject: [PATCH 160/311] add json-everything.net and jsonschema.dev to online validators --- _data/validator-libraries-modern.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index c81c1e6d..1dfb9b11 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -243,13 +243,24 @@ implementations: - name: Hyperjump JSV url: https://json-schema.hyperjump.io - date-draft: [2019-09] + date-draft: [2019-09, 2020-12] draft: [7, 6, 4] notes: Supports multiple schemas and multiple instances + - name: jsonschema.dev + url: https://jsonschema.dev + date-draft: [2019-09, 2020-12] + draft: [7, 6, 4] + notes: Powered by ajv; client-side validation + - name: json-everything + url: https://json-everything.net + date-draft: [2019-09, 2020-12] + draft: [7, 6] + notes: Powered by JsonSchema.Net; server-side validation - name: JSON Schema Validator url: https://www.jsonschemavalidator.net/ date-draft: [2019-09] draft: [7, 6, 4, 3] + notes: Powered by JSON.Net; server-side validation - name: JSON Schema Lint url: http://jsonschemalint.com/ date-draft: From 4823406bfd843a642413cf3edd65c371d4464274 Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Fri, 3 Sep 2021 00:42:07 +1200 Subject: [PATCH 161/311] updated with client-/server-side details where known --- _data/validator-libraries-modern.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 1dfb9b11..6127cbe5 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -243,19 +243,19 @@ implementations: - name: Hyperjump JSV url: https://json-schema.hyperjump.io - date-draft: [2019-09, 2020-12] - draft: [7, 6, 4] - notes: Supports multiple schemas and multiple instances - - name: jsonschema.dev - url: https://jsonschema.dev - date-draft: [2019-09, 2020-12] + date-draft: [2020-12, 2019-09] draft: [7, 6, 4] - notes: Powered by ajv; client-side validation + notes: Supports multiple schemas and multiple instances; client-side validation - name: json-everything url: https://json-everything.net - date-draft: [2019-09, 2020-12] + date-draft: [2020-12, 2019-09] draft: [7, 6] notes: Powered by JsonSchema.Net; server-side validation + - name: jsonschema.dev + url: https://jsonschema.dev + date-draft: [2019-09] + draft: [7, 6, 4] + notes: Powered by ajv; client-side validation - name: JSON Schema Validator url: https://www.jsonschemavalidator.net/ date-draft: [2019-09] From d47dfb11340c9cd0146d2222df6287a51e4fafba Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Tekuri Date: Thu, 2 Sep 2021 20:46:51 +0530 Subject: [PATCH 162/311] santhosh-tekuri/jsonschema: 2020-12, 2019-19 support --- _data/validator-libraries-modern.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index ec275461..172e70d1 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -84,10 +84,10 @@ license: "Apache 2.0" - name: santhosh-tekuri/jsonschema url: https://github.com/santhosh-tekuri/jsonschema - notes: - date-draft: + notes: includes custom keywords, output formats + date-draft: [2020-12, 2019-09] draft: [7, 6, 4] - license: BSD-3-Clause + license: Apache License 2.0 - name: qri-io/jsonschema url: https://github.com/qri-io/jsonschema date-draft: [2019-09] From 96a1e236e4e2ceeee4b27b0d496d6204c498d7df Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Fri, 3 Sep 2021 13:08:35 +1200 Subject: [PATCH 163/311] Update _data/validator-libraries-modern.yml Co-authored-by: Jason Desrosiers --- _data/validator-libraries-modern.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 9b24d2c0..d7096029 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -285,8 +285,7 @@ notes: Powered by JsonSchema.Net; server-side validation - name: jsonschema.dev url: https://jsonschema.dev - date-draft: [2019-09] - draft: [7, 6, 4] + draft: [7] notes: Powered by ajv; client-side validation - name: jschon.dev url: https://jschon.dev/ From ce287bae6d3ec63cae281258382872253bf3e965 Mon Sep 17 00:00:00 2001 From: IdrissaD <73114156+IdrissaD@users.noreply.github.com> Date: Fri, 10 Sep 2021 11:48:51 +0200 Subject: [PATCH 164/311] Update drafts jsonschema Python validator --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 32b1f8dd..6bb799d7 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -224,7 +224,7 @@ - name: jsonschema url: https://github.com/Julian/jsonschema notes: - date-draft: + date-draft: [2019-09, 2020-12] draft: [7, 6, 4, 3] license: "MIT" - name: fastjsonschema From f5ee27e26faafa83ee99408e5503e66b6283a85e Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Fri, 24 Sep 2021 11:31:52 -0400 Subject: [PATCH 165/311] Add wetzel to documentation generators Proposed in https://github.com/CesiumGS/wetzel/issues/13#issuecomment-926447549 --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index 36f55bf3..61252d21 100644 --- a/implementations.md +++ b/implementations.md @@ -267,6 +267,7 @@ _None currently support draft-06 or later._ - [jsonschematic](https://github.com/yanick/jsonschematic/) - Svelte-based schema viewer. Runs as a local web app. Supports draft-7. - [docson](https://github.com/lbovet/docson) - Javascript-based schema viewer. Runs as a local web app. Supports draft-4. - [json-schema-for-humans](https://pypi.org/project/json-schema-for-humans/) - Generate HTML representation of a schema. Python-based. Supports draft-7. +- [wetzel](https://github.com/CesiumGS/wetzel) - Generates Markdown and AsciiDoc. With some limitations, supports draft-3, draft-4, draft-7, and 2020-12. Schema Repositories ------------------- From 0e7e8eaad51775f56324975b33e08333cefb0fd0 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Wed, 6 Oct 2021 18:34:57 +0500 Subject: [PATCH 166/311] Fix typo: vocablary => vocabulary --- specification-links.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification-links.md b/specification-links.md index c891aed5..c20aa358 100644 --- a/specification-links.md +++ b/specification-links.md @@ -293,7 +293,7 @@ For links to the somewhat more readably formatted versions on this web site, and - Relative JSON Pointer: [draft-bhutton-relative-json-pointer-00](https://tools.ietf.org/html/draft-bhutton-relative-json-pointer-00) ([changes](https://tools.ietf.org/html/draft-bhutton-relative-json-pointer-00#appendix-A)) - General use meta-schemas - [JSON Schema meta-schema](draft/2020-12/schema) -- Individual vocablary meta-schemas +- Individual vocabulary meta-schemas - [Core Vocabulary meta-schema](draft/2020-12/meta/core) - [Applicator Vocabulary meta-schema](draft/2020-12/meta/applicator) - [Validation Vocabulary meta-schema](draft/2020-12/meta/validation) @@ -320,7 +320,7 @@ _**NOTE:** All meta-schema URIs now use `https://`. While currently also availa - [JSON Schema meta-schema](https://json-schema.org/draft/2019-09/schema) - [JSON Hyper-Schema meta-schema](https://json-schema.org/draft/2019-09/hyper-schema) - [JSON Hyper-Schema Link Description Object meta-schema](https://json-schema.org/draft/2019-09/links) -- Individual vocablary meta-schemas +- Individual vocabulary meta-schemas - [Core Vocabulary meta-schema](https://json-schema.org/draft/2019-09/meta/core) - [Applicator Vocabulary meta-schema](https://json-schema.org/draft/2019-09/meta/applicator) - [Validation Vocabulary meta-schema](https://json-schema.org/draft/2019-09/meta/validation) From 231ad3b2201e1b95f7e216021e8fa3417bd4d596 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Thu, 21 Oct 2021 09:30:09 -0700 Subject: [PATCH 167/311] Updates to make hyper-schema fixes/additions available --- .gitmodules | 1 + _includes/draft/2019-09 | 2 +- _includes/draft/2020-12 | 2 +- specification-links.md | 1 + specification.md | 1 + 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 3ac879c1..ec9c71cd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,6 +26,7 @@ [submodule "_includes/draft/2019-09"] path = _includes/draft/2019-09 url = https://github.com/json-schema-org/json-schema-spec.git + branch = 2019-09 [submodule "_includes/draft/2020-12"] path = _includes/draft/2020-12 url = https://github.com/json-schema-org/json-schema-spec.git diff --git a/_includes/draft/2019-09 b/_includes/draft/2019-09 index 03fe369b..f25113a1 160000 --- a/_includes/draft/2019-09 +++ b/_includes/draft/2019-09 @@ -1 +1 @@ -Subproject commit 03fe369b6192bcd6052e96bac8a5b0cfd15d5c07 +Subproject commit f25113a1300b11938541c5c31ff9f908a06861f4 diff --git a/_includes/draft/2020-12 b/_includes/draft/2020-12 index 0e08f035..117c05e5 160000 --- a/_includes/draft/2020-12 +++ b/_includes/draft/2020-12 @@ -1 +1 @@ -Subproject commit 0e08f03573753bebe2841023dd6fcc822490ea07 +Subproject commit 117c05e55ae0a798a10907f61348c81318971f9d diff --git a/specification-links.md b/specification-links.md index c20aa358..c77c896c 100644 --- a/specification-links.md +++ b/specification-links.md @@ -293,6 +293,7 @@ For links to the somewhat more readably formatted versions on this web site, and - Relative JSON Pointer: [draft-bhutton-relative-json-pointer-00](https://tools.ietf.org/html/draft-bhutton-relative-json-pointer-00) ([changes](https://tools.ietf.org/html/draft-bhutton-relative-json-pointer-00#appendix-A)) - General use meta-schemas - [JSON Schema meta-schema](draft/2020-12/schema) + - [JSON Hyper-Schema meta-schema](draft/2020-12/hyper-schema) (2019-09 Hyper-Schema with 2020-12 Validation) - Individual vocabulary meta-schemas - [Core Vocabulary meta-schema](draft/2020-12/meta/core) - [Applicator Vocabulary meta-schema](draft/2020-12/meta/applicator) diff --git a/specification.md b/specification.md index 63f9d73a..ab8e91c2 100644 --- a/specification.md +++ b/specification.md @@ -42,6 +42,7 @@ Please note, additional vocabulary specific schema files are needed to fully con |--------------------------------------------------------------|------------------------------------------------------------| | [Core/Validation Dialect meta-schema](draft/2020-12/schema) | Used for schemas written for pure validation. | +| [Hyper-Schema Dialect meta-schema](draft/2020-12/hyper-schema) | Used for schemas written for validation (2020-12) and hyper-linking (2019-09).| | [Recommended Output meta-schema](draft/2020-12/output/schema)| Recommended output structure of the application process. | ## Single-vocabulary meta-schemas From 5222a67a2ee2f4e9cd763fdae24aeb4b1b4c1525 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 4 Nov 2021 11:03:59 +0000 Subject: [PATCH 168/311] Migrated content about draft notation inside an expandable details element --- index.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.md b/index.md index 97269dce..ea8d289f 100644 --- a/index.md +++ b/index.md @@ -68,9 +68,10 @@ Internet-Drafts expire after six months, so our goal is to publish often enough ### Use of the _draft_ designation - Releases of the JSON schema specification and meta schemas use the _draft_ designation primarily for historical reasons stemming from the relationship of this specification to IETF ([explained here](https://json-schema.org/specification-links.html#understanding-draft-names-and-numbers)). The use of this designation is under review but will continue until this review process completes to avoid changing the designation style multiple times. +
    +Read more The JSON schema project recognizes, condones, and advocates for the use of the JSON schema standard in production. @@ -79,7 +80,7 @@ Each release of the JSON schema specification is treated as a production release Similarly to most specifications, the JSON schema specification will continue to evolve, and not all releases will be backwards compatible. The intention, particularly for vocabularies such as validation which have been widely implemented, is to remain as compatible as possible from release to release. However, major changes can still occur given a clear enough need validated with the user community. When the _draft_ designation is dropped this may indicate that the frequency of releases and amount of changes in each release will decrease, but it won't indicate that no new releases will be made, or that all future releases will be backwards compatible. - +
    ## Quickstart The JSON document being validated or described we call the *instance*, and the document containing the description is called the *schema*. From ea2ace2f18fee8d1f6401a9990e29381189cbc45 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 4 Nov 2021 13:42:41 +0000 Subject: [PATCH 169/311] Highlight and link to community discussions, regular calls, and our slack server. Resolves #98 Resolves #99 Resolves #100 --- assets/logo-slack.svg | 1 + assets/main.scss | 53 +++++++++++++++++++++++++++++++++++++++++++ index.md | 44 +++++++++++++++++++++++++++-------- 3 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 assets/logo-slack.svg diff --git a/assets/logo-slack.svg b/assets/logo-slack.svg new file mode 100644 index 00000000..69a4eb6a --- /dev/null +++ b/assets/logo-slack.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/main.scss b/assets/main.scss index 39e9a030..9e965232 100644 --- a/assets/main.scss +++ b/assets/main.scss @@ -124,3 +124,56 @@ $content-width: 960px !default; font-size: 14px; } } + +// Minimal buttons https://github.com/vladocar/Simple-Button +.button { + font-size: 1em; + display: block; + border: 0; + margin: 0 6px; + padding: 0.7em; + cursor: pointer; + text-align: center; + transition-duration: 0.1s; + transition-timing-function: linear; +} +.button:hover, +.button:focus { + opacity: 0.8; +} +.btcolor { + background-color: red; + color: #fff; +} +.btcolor:hover, +.btcolor:focus { + background: #ff6666; + color: #f0f0f0; +} +.round { + border-radius: 0.6em; +} +.pill { + border-radius: 1.1em / 50%; +} +.border { + border: 1px solid #1577ca; +} + +// Other custom CSS + +.button-center { + display: inline-block; +} +.text-center { + text-align: center; +} + +.small-svg-logo { + height: 1.3em; + width: 1.3em; +} + +.wrapper.buttons { + margin-bottom: 10px; +} \ No newline at end of file diff --git a/index.md b/index.md index ea8d289f..5392fa11 100644 --- a/index.md +++ b/index.md @@ -20,21 +20,48 @@ permalink: / -## New to JSON Schema? +## What now? -Learning a new specification can be daunting. +Learn, Get help, Shape the Community, Chat, with the JSON Schema team and Community! -You should read our [getting started guide](/learn/getting-started-step-by-step)! + + +## Regular Activities + +We hold weekly Office Hours and twice monthly Open Community Working Meetings. + + + +Office Hours are every Tuesday at 15:00 UTC. -You can also see our other [learning resources](/learn). +Open Community Working Meetings follow two patterns: +- First Friday of the month at 20:00 UTC. +- Third Friday of the month at 15:00 UTC. -### Got questions? +## Need more? + +We have our other [learning resources](/learn), including the [Understanding JSON Schema documentation](/understanding-json-schema). + +## About Our Community + +We have an active and growing community. All are welcome to be part of our community, help shape it, or simply observe. + +We want keep our community welcoming and inclusive, so please read our [JSON Schema Organizational Code of Conduct](https://github.com/json-schema-org/.github/blob/main/CODE_OF_CONDUCT.md). (This is a combination of the Contributor Covenant and IETF BCP 54.) The JSON Schema team and community are here to help! -At any point, feel free to join our [Slack server](/slack). +At any point, feel free to join our Slack server. [Slack server](/slack). + +Our Slack server has limited history, so we also use [GitHub Discussions](https://github.com/json-schema-org/community/discussions). -We also monitor the `jsonschema` tag on StackOverflow. +We monitor the `jsonschema` tag on StackOverflow. ## Project Status @@ -47,7 +74,6 @@ so we will usually refer to `2020-12` (without the word "draft") on this web sit See the [Specification page](specification.html) for details about naming and numbering. - ### The Path to Standardization The JSON Schema project intends to shepherd all three draft series to either: RFC status, the equivalent within another standards body, and/or join a foundation and establish self publication rules. @@ -107,7 +133,7 @@ This allows the team to focus the little time they do donate on JSON Schema core We may revisit JSON Hyper-Schema at a later date. -## More +## More Links Interested? Check out: From ca9837fdf963a54aff8ab1c887eb8fa83954f852 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Mon, 8 Nov 2021 10:49:38 -0800 Subject: [PATCH 170/311] Add missing symbolic links for serving hyper-schema --- draft/2020-12/hyper-schema | 1 + draft/2020-12/links | 1 + specification-links.md | 1 + 3 files changed, 3 insertions(+) create mode 120000 draft/2020-12/hyper-schema create mode 120000 draft/2020-12/links diff --git a/draft/2020-12/hyper-schema b/draft/2020-12/hyper-schema new file mode 120000 index 00000000..efe89864 --- /dev/null +++ b/draft/2020-12/hyper-schema @@ -0,0 +1 @@ +../../_includes/draft/2020-12/hyper-schema.json \ No newline at end of file diff --git a/draft/2020-12/links b/draft/2020-12/links new file mode 120000 index 00000000..f36c1c0d --- /dev/null +++ b/draft/2020-12/links @@ -0,0 +1 @@ +../../_includes/draft/2020-12/links.json \ No newline at end of file diff --git a/specification-links.md b/specification-links.md index c77c896c..2bf9b018 100644 --- a/specification-links.md +++ b/specification-links.md @@ -294,6 +294,7 @@ For links to the somewhat more readably formatted versions on this web site, and - General use meta-schemas - [JSON Schema meta-schema](draft/2020-12/schema) - [JSON Hyper-Schema meta-schema](draft/2020-12/hyper-schema) (2019-09 Hyper-Schema with 2020-12 Validation) + - [JSON Hyper-Schema Link Description Object meta-schema](draft/2020-12/links) - Individual vocabulary meta-schemas - [Core Vocabulary meta-schema](draft/2020-12/meta/core) - [Applicator Vocabulary meta-schema](draft/2020-12/meta/applicator) From b8146af7a811e1f54c70caeaef1a645f1efa3c01 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Tue, 9 Nov 2021 09:11:21 +0000 Subject: [PATCH 171/311] Undo accidental repetition Co-authored-by: Jason Desrosiers --- index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.md b/index.md index 5392fa11..e065360f 100644 --- a/index.md +++ b/index.md @@ -57,7 +57,7 @@ We want keep our community welcoming and inclusive, so please read our [JSON Sch The JSON Schema team and community are here to help! -At any point, feel free to join our Slack server. [Slack server](/slack). +At any point, feel free to join our [Slack server](/slack). Our Slack server has limited history, so we also use [GitHub Discussions](https://github.com/json-schema-org/community/discussions). From 46e2c5c14ec3b805548e9e701ce89b70ff215187 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Tue, 9 Nov 2021 09:12:22 +0000 Subject: [PATCH 172/311] Correct grammar Co-authored-by: Jason Desrosiers --- index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.md b/index.md index e065360f..7e4087dd 100644 --- a/index.md +++ b/index.md @@ -53,7 +53,7 @@ We have our other [learning resources](/learn), including the [Understanding JSO We have an active and growing community. All are welcome to be part of our community, help shape it, or simply observe. -We want keep our community welcoming and inclusive, so please read our [JSON Schema Organizational Code of Conduct](https://github.com/json-schema-org/.github/blob/main/CODE_OF_CONDUCT.md). (This is a combination of the Contributor Covenant and IETF BCP 54.) +We want to keep our community welcoming and inclusive, so please read our [JSON Schema Organizational Code of Conduct](https://github.com/json-schema-org/.github/blob/main/CODE_OF_CONDUCT.md). (This is a combination of the Contributor Covenant and IETF BCP 54.) The JSON Schema team and community are here to help! From 149ae3c6a2cc11d214035f2d7a43adf17632cf26 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Tue, 9 Nov 2021 11:26:37 -0800 Subject: [PATCH 173/311] Update 2019-09 includes --- _includes/draft/2019-09 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/draft/2019-09 b/_includes/draft/2019-09 index f25113a1..41014ea7 160000 --- a/_includes/draft/2019-09 +++ b/_includes/draft/2019-09 @@ -1 +1 @@ -Subproject commit f25113a1300b11938541c5c31ff9f908a06861f4 +Subproject commit 41014ea723120ce70b314d72f863c6929d9f3cfd From 44dcd53056fb6e5e376ff5bee876fe6eb8571ce4 Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Thu, 18 Nov 2021 14:45:20 -0500 Subject: [PATCH 174/311] Add networknt/json-schema-validator to validator-libraries-modern.yml --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 7412aa37..03c43399 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -103,6 +103,12 @@ notes: includes custom validator support, rich error returns - name: Java implementations: + - name: networknt/json-schema-validator + url: https://github.com/networknt/json-schema-validator + notes: Uses the Jackson to parse the JSON. Claims to be the fastest JSON Schema Validator. + date-draft: [2019-09] + draft: [4, 6, 7] + license: Apache License, Version 2.0 - name: Snow url: https://github.com/ssilverman/snowy-json notes: Uses Maven for the project and Gson under the hood. From b389a48146c6a5f56637aa4e62d0424fd702b9a8 Mon Sep 17 00:00:00 2001 From: "ben.rubin" Date: Mon, 13 Dec 2021 20:33:07 -0800 Subject: [PATCH 175/311] Change http links to https for links to json-schema.org in documentation --- README.md | 2 +- draft-07/json-hyper-schema-release-notes.md | 2 +- implementations.md | 2 +- index.md | 2 +- learn/file-system.md | 38 ++++++++++----------- learn/getting-started-step-by-step.md | 32 ++++++++--------- learn/miscellaneous-examples.md | 24 ++++++------- obsolete-implementations.md | 10 +++--- 8 files changed, 56 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 2a457cd9..6e874b59 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # JSON Schema Website -This is the repository for the [JSON Schema website](http://json-schema.org). +This is the repository for the [JSON Schema website](https://json-schema.org). For issues, discussion, and changes to the JSON Schema specification, please use the [json-schema-spec](https://github.com/json-schema-org/json-schema-spec) repository. diff --git a/draft-07/json-hyper-schema-release-notes.md b/draft-07/json-hyper-schema-release-notes.md index 2b6ae1ca..8484ca38 100644 --- a/draft-07/json-hyper-schema-release-notes.md +++ b/draft-07/json-hyper-schema-release-notes.md @@ -50,7 +50,7 @@ for information related to draft-05. ### Migrating from draft-04 In the ideal draft-07 world, links and -[operations](http://json-schema.org/draft-07/json-schema-hypermedia.html#rfc.section.3.1) +[operations](https://json-schema.org/draft-07/json-schema-hypermedia.html#rfc.section.3.1) are not the same concept. Using terminology borrowed from [OpenAPI's Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#operationObject), HTTP methods are operations, and each link (as described by a single LDO) can support multiple operations. diff --git a/implementations.md b/implementations.md index 61252d21..23211827 100644 --- a/implementations.md +++ b/implementations.md @@ -272,7 +272,7 @@ _None currently support draft-06 or later._ Schema Repositories ------------------- -- [SchemaStore.org](http://schemastore.org/json/) - validate against common JSON Schemas +- [SchemaStore.org](https://schemastore.org/json/) - validate against common JSON Schemas Schema Linter diff --git a/index.md b/index.md index 7e4087dd..fc42c924 100644 --- a/index.md +++ b/index.md @@ -146,7 +146,7 @@ We encourage updating to the latest specification where possible, which is 2020- Questions? Feeling helpful? Get involved on: -* [GitHub](http://github.com/json-schema-org/json-schema-spec) +* [GitHub](https://github.com/json-schema-org/json-schema-spec) * [GitHub Discussions](https://github.com/json-schema-org/community/discussions) * [Google Groups](https://groups.google.com/forum/#!forum/json-schema) * [Slack](/slack) diff --git a/learn/file-system.md b/learn/file-system.md index 72e32e3a..da7630b9 100644 --- a/learn/file-system.md +++ b/learn/file-system.md @@ -66,16 +66,16 @@ We will start with a base JSON Schema expressing the following constraints: Building out our JSON Schema from top to bottom: -* The [`$id`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.1) keyword. -* The [`$schema`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1) keyword. -* The [`type`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1) validation keyword. -* The [`required`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.5.3) validation keyword. -* The [`properties`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.1) validation keyword. +* The [`$id`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.1) keyword. +* The [`$schema`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1) keyword. +* The [`type`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1) validation keyword. +* The [`required`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.5.3) validation keyword. +* The [`properties`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.1) validation keyword. * The `/` key is empty now; We will fill it out later. -* The [`patternProperties`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.2) validation keyword. +* The [`patternProperties`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.2) validation keyword. * This matches other property names via a regular expression. Note: it does not match `/`. * The `^(/[^/]+)+$` key is empty now; We will fill it out later. -* The [`additionalProperties`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.3) validation keyword. +* The [`additionalProperties`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.3) validation keyword. * The value here is `false` to constrain object properties to be either `/` or to match the regular expression. > You will notice that the regular expression is explicitly anchored (with `^` and `$`): in JSON Schema, regular expressions (in `patternProperties` and in `pattern`) are not anchored by default. @@ -104,11 +104,11 @@ We saw these keywords in the prior exercise: `$id`, `$schema`, `type`, `required To this we add: -* The [`description`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keyword. -* The [`oneOf`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.2.1.3) keyword. -* The [`$ref`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.3.1) keyword. +* The [`description`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keyword. +* The [`oneOf`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.2.1.3) keyword. +* The [`$ref`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.3.1) keyword. * In this case, all references used are local to the schema using a relative fragment URI (`#/...`). -* The [`$defs`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.4) keyword. +* The [`$defs`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.4) keyword. * Including several key names which we will define later. ```json @@ -142,12 +142,12 @@ To this we add: Let's now extend this skeleton to add constraints to some of the properties. -* Our `fstype` key uses the [`enum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.2) validation keyword. +* Our `fstype` key uses the [`enum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.2) validation keyword. * Our `options` key uses the following: * The `type` validation keyword (see above). - * The [`minItems`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.2) validation keyword. - * The [`items`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.1.2) validation keyword. - * The [`uniqueItems`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.3) validation keyword. + * The [`minItems`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.2) validation keyword. + * The [`items`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.1.2) validation keyword. + * The [`uniqueItems`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.3) validation keyword. * Together these say: `options` must be an array, and the items therein must be strings, there must be at least one item, and all items should be unique. * We have a `readonly` key. @@ -198,7 +198,7 @@ With these added constraints, the schema now looks like this: One new keyword is introduced here: -* The [`pattern`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.3.3) validation keyword notes the `device` key must be an absolute path starting with */dev*. +* The [`pattern`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.3.3) validation keyword notes the `device` key must be an absolute path starting with */dev*. ```json { @@ -246,7 +246,7 @@ We do have a new key: `label` and the `pattern` validation keyword states it mus We find another new keyword: -* The [`format`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.7) annotation and assertion keyword. +* The [`format`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.7) annotation and assertion keyword. ```json { @@ -276,8 +276,8 @@ We find another new keyword: Our last definition introduces two new keywords: -* The [`minimum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword. -* The [`maximum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.2) validation keword. +* The [`minimum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword. +* The [`maximum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.2) validation keyword. * Together these require the size be between 16 and 512, inclusive. ```json diff --git a/learn/getting-started-step-by-step.md b/learn/getting-started-step-by-step.md index 4a1eae90..5c2e51d5 100644 --- a/learn/getting-started-step-by-step.md +++ b/learn/getting-started-step-by-step.md @@ -13,7 +13,7 @@ title: Getting Started Step-By-Step ## Introduction -The following example is by no means definitive of all the value JSON Schema can provide. For this you will need to go deep into the specification itself -- learn more at [http://json-schema.org/specification.html](http://json-schema.org/specification.html). +The following example is by no means definitive of all the value JSON Schema can provide. For this you will need to go deep into the specification itself -- learn more at [https://json-schema.org/specification.html](https://json-schema.org/specification.html). Let's pretend we're interacting with a JSON based product catalog. This catalog has a product which has: @@ -50,10 +50,10 @@ We start with four properties called **keywords** which are expressed as [JSON]( > Yes. the standard uses a JSON data document to describe data documents, most often that are also JSON data documents but could be in any number of other content types like `text/xml`. -* The [`$schema`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1) keyword states that this schema is written according to a specific draft of the standard and used for a variety of reasons, primarily version control. -* The [`$id`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.1) keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. -* The [`title`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) and [`description`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keywords are descriptive only. They do not add constraints to the data being validated. The intent of the schema is stated with these two keywords. -* The [`type`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1) validation keyword defines the first constraint on our JSON data and in this case it has to be a JSON Object. +* The [`$schema`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1) keyword states that this schema is written according to a specific draft of the standard and used for a variety of reasons, primarily version control. +* The [`$id`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.1) keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. +* The [`title`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) and [`description`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keywords are descriptive only. They do not add constraints to the data being validated. The intent of the schema is stated with these two keywords. +* The [`type`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1) validation keyword defines the first constraint on our JSON data and in this case it has to be a JSON Object. ```json { @@ -67,9 +67,9 @@ We start with four properties called **keywords** which are expressed as [JSON]( We introduce the following pieces of terminology when we start the schema: -* [Schema Keyword](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1): `$schema` and `$id`. -* [Schema Annotations](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1): `title` and `description`. -* [Validation Keyword](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1): `type`. +* [Schema Keyword](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1): `$schema` and `$id`. +* [Schema Annotations](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1): `title` and `description`. +* [Validation Keyword](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1): `type`. ## Defining the properties @@ -77,10 +77,10 @@ We introduce the following pieces of terminology when we start the schema: In JSON Schema terms, we update our schema to add: -* The [`properties`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.1) validation keyword. +* The [`properties`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.1) validation keyword. * The `productId` key. * `description` schema annotation and `type` validation keyword is noted -- we covered both of these in the previous section. -* The [`required`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.5.3) validation keyword listing `productId`. +* The [`required`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.5.3) validation keyword listing `productId`. ```json @@ -130,8 +130,8 @@ In JSON Schema terms, we update our schema to add: According to the store owner there are no free products. ;) * The `price` key is added with the usual `description` schema annotation and `type` validation keywords covered previously. It is also included in the array of keys defined by the `required` validation keyword. -* We specify the value of `price` must be something other than zero using the [`exclusiveMinimum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.5) validation keyword. - * If we wanted to include zero as a valid price we would have specified the [`minimum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword. +* We specify the value of `price` must be something other than zero using the [`exclusiveMinimum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.5) validation keyword. + * If we wanted to include zero as a valid price we would have specified the [`minimum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword. ```json { @@ -172,9 +172,9 @@ Therefore: * The `tags` key is added with the usual annotations and keywords. * This time the `type` validation keyword is `array`. -* We introduce the [`items`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.1.2) validation keyword so we can define what appears in the array. In this case: `string` values via the `type` validation keyword. -* The [`minItems`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.2) validation keyword is used to make sure there is at least one item in the array. -* The [`uniqueItems`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.3) validation keyword notes all of the items in the array must be unique relative to one another. +* We introduce the [`items`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.1.2) validation keyword so we can define what appears in the array. In this case: `string` values via the `type` validation keyword. +* The [`minItems`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.2) validation keyword is used to make sure there is at least one item in the array. +* The [`uniqueItems`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.3) validation keyword notes all of the items in the array must be unique relative to one another. * We did not add this key to the `required` validation keyword array because it is optional. ```json @@ -276,7 +276,7 @@ So far our JSON schema has been wholly self contained. It is very common to shar For this example we introduce a new JSON Schema resource and for both properties therein: * We use the `minimum` validation keyword noted earlier. -* We add the [`maximum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.2) validation keyword. +* We add the [`maximum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.2) validation keyword. * Combined, these give us a range to use in validation. ```json diff --git a/learn/miscellaneous-examples.md b/learn/miscellaneous-examples.md index 754e6f4a..946274fd 100644 --- a/learn/miscellaneous-examples.md +++ b/learn/miscellaneous-examples.md @@ -7,15 +7,15 @@ title: Miscellaneous Examples This example provides a typical minimum you are likely to see in JSON Schema. It contains: -* [`$id`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.1) keyword -* [`$schema`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1) keyword -* [`title`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keyword -* [`type`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1) instance data model -* [`properties`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.1) validation keyword +* [`$id`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.1) keyword +* [`$schema`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1) keyword +* [`title`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keyword +* [`type`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1) instance data model +* [`properties`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.1) validation keyword * Three keys: `firstName`, `lastName` and `age` each with their own: - * [`description`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keyword. + * [`description`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keyword. * `type` instance data model (see above). -* [`minimum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword on the `age` key. +* [`minimum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword on the `age` key. ```json { @@ -55,9 +55,9 @@ This example provides a typical minimum you are likely to see in JSON Schema. It This example introduces: -* [`required`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.5.3) validation keyword -* [`minimum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword -* [`maximum`](http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.2) validation keyword +* [`required`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.5.3) validation keyword +* [`minimum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword +* [`maximum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.2) validation keyword ```json { @@ -100,8 +100,8 @@ Arrays are fundamental structures in JSON -- here we demonstrate a couple of way We also introduce the following with this example: -* [`$defs`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.4) keyword -* [`$ref`](http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.3.1) keyword +* [`$defs`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.4) keyword +* [`$ref`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.3.1) keyword ```json { diff --git a/obsolete-implementations.md b/obsolete-implementations.md index 86af9e19..e8de25fb 100644 --- a/obsolete-implementations.md +++ b/obsolete-implementations.md @@ -129,7 +129,7 @@ Schema Generators - TypeScript - [Typson](https://github.com/lbovet/typson) (Apache 2.0) - Visual Studio - - [JSON Schema Generator](http://visualstudiogallery.msdn.microsoft.com/b4515ef8-a518-41ca-b48c-bb1fd4e6faf7) - free extension + - [JSON Schema Generator](https://visualstudiogallery.msdn.microsoft.com/b4515ef8-a518-41ca-b48c-bb1fd4e6faf7) - free extension - Sparx Enterprise Architect - [API-Add-In](https://github.com/bayeslife/api-add-in) - Sparx EA extension for exporting JSON Schema from UML models @@ -167,9 +167,9 @@ Various levels of support for UI generation primarily from the validation vocabu - JavaScript - [JSON Editor](https://github.com/jdorn/json-editor) (MIT) - - [JSONForms](http://jsonforms.io) (EclipseSource) (MIT) - - [Jsonary](http://jsonary.com/) (MIT) - - [Metawidget](http://metawidget.org/) (LGPL) + - [JSONForms](https://jsonforms.io) (EclipseSource) (MIT) + - [Jsonary](https://jsonary.com/) (MIT) + - [Metawidget](https://metawidget.org/) (LGPL) - [pure-form webcomponent](https://github.com/john-doherty/pure-form) (MIT) Editors @@ -201,5 +201,5 @@ Other ----- - JavaScript - - [Dojo](http://www.dojotoolkit.org/) (AFL or BSD) - supports some aspects of JSON Schema + - [Dojo](https://www.dojotoolkit.org/) (AFL or BSD) - supports some aspects of JSON Schema - [JSON Schema Random](https://github.com/andreineculau/json-schema-random) (Apache 2.0) From 49bdef94d7c56c8bb9391c5cef2f136f3d761544 Mon Sep 17 00:00:00 2001 From: Jamie Tanna Date: Thu, 16 Dec 2021 08:42:43 +0000 Subject: [PATCH 176/311] Clarify license for the wework library As it's present in the `package.json`. --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 23211827..0a803e94 100644 --- a/implementations.md +++ b/implementations.md @@ -235,7 +235,7 @@ _None currently support draft-06 or later._ #### Format converters - OpenAPI - - [JSON Schema to OpenAPI Schema](https://github.com/wework/json-schema-to-openapi-schema) _draft-04_ Draft-06 and -07 planned per README (_license not stated_) + - [JSON Schema to OpenAPI Schema](https://github.com/wework/json-schema-to-openapi-schema) _draft-04_ Draft-06 and -07 planned per README (MIT) - Orderly - [Orderly](https://github.com/lloyd/orderly) (BSD-3-Clause) - RAML From 22c6137f23bb17a24209aaf738dae5f092ab8a21 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 16 Dec 2021 11:27:07 +0000 Subject: [PATCH 177/311] Updated draft support for existing listing of networknt lib --- _data/validator-libraries-modern.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 03c43399..f5ef02a0 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -103,12 +103,6 @@ notes: includes custom validator support, rich error returns - name: Java implementations: - - name: networknt/json-schema-validator - url: https://github.com/networknt/json-schema-validator - notes: Uses the Jackson to parse the JSON. Claims to be the fastest JSON Schema Validator. - date-draft: [2019-09] - draft: [4, 6, 7] - license: Apache License, Version 2.0 - name: Snow url: https://github.com/ssilverman/snowy-json notes: Uses Maven for the project and Gson under the hood. @@ -137,7 +131,7 @@ - name: networknt/json-schema-validator url: https://github.com/networknt/json-schema-validator notes: Support OpenAPI 3.0 with Jackson parser - date-draft: + date-draft: [2019-09] draft: [7, 6, 4] license: Apache License 2.0 - name: jsonschemafriend From d6408d5bad9e9deb89bbfb2a6d20e0186b8b2e7d Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Mon, 20 Dec 2021 21:32:36 +0000 Subject: [PATCH 178/311] Added org badges --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6e874b59..b1992750 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # JSON Schema Website +[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://github.com/json-schema-org/.github/blob/main/CODE_OF_CONDUCT.md) +[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) +[![Financial Contributors on Open Collective](https://opencollective.com/json-schema/all/badge.svg?label=financial+contributors)](https://opencollective.com/json-schema) + This is the repository for the [JSON Schema website](https://json-schema.org). For issues, discussion, and changes to the JSON Schema specification, please use the [json-schema-spec](https://github.com/json-schema-org/json-schema-spec) repository. From 5573078007d084310a4e1ad1777dc550b44e46db Mon Sep 17 00:00:00 2001 From: Pascal Desmarets Date: Tue, 21 Dec 2021 15:00:18 +0100 Subject: [PATCH 179/311] Added Hackolade Studio JSON Schema editor Added Hackolade Studio to the list of Editors, since it supports all recent specifications of JSON Schema. See https://hackolade.com/help/JSONSchemaEditor.html for more information --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index 0a803e94..a3a2acf5 100644 --- a/implementations.md +++ b/implementations.md @@ -253,6 +253,7 @@ _None currently support draft-06 or later._ - [Altova XMLSpy 2019r3](https://www.altova.com/xmlspy-xml-editor#json_schema) - *Graphical JSON Schema editor for draft-06 and draft-7, as well as validation of JSON files based on JSON Schema* - [Dashjoin JSON Schema editor](https://dashjoin.github.io/#/schema) - *Graphical online JSON Schema editor for draft-06 (minus oneOf, anyOf, allOf, not). The generated schema can be tested immediately via a form that is driven by it.* +- [Hackolade Studio](https://hackolade.com/help/JSONSchemaEditor.html) - *Visual JSON Schema editor for draft-04, draft-06, draft-07, 2019-09, 2020-12, as well as data modeling tool for NoSQL databases, storage formats, REST APIs, and JSON in RDBMS. Also converts to and from: different draft specifications, DDL, XSD, Swagger, OpenAPI, YAML, Avro, Parquet, Protobuf, and most of the NoSQL script syntaxes. Includes a GUI for Entity-Relationship Diagrams and a Command-Line Interface.* - [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator with JSON schema analyzer, context sensitive entry-helpers and sample data generation based on JSON schema. Support for draft-4, draft-6, draft-7 and 2019-09.* - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Liquid JSON Schema Editor](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON Schema editor for draft-04, draft-06, draft-07 and 2019-09, with split source code and grphical editing. Includes validation of JSON files based on JSON Schema, JSON Sample Generator and JSON Schema Documentation Generator.* From ab5ef9d233dc8ba6d531fa43e53e015d38eb0506 Mon Sep 17 00:00:00 2001 From: Ethan Date: Thu, 27 Jan 2022 15:18:31 -0800 Subject: [PATCH 180/311] add validation library JSI for ruby --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index f5ef02a0..d3e8bbaa 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -260,6 +260,12 @@ date-draft: draft: [7, 6, 4] license: MIT + - name: JSI + url: https://rubydoc.info/gems/jsi + notes: + date-draft: + draft: [7, 6, 4] + license: AGPL-3.0 - name: Rust implementations: - name: jsonschema-rs From 9e8bb227e518f7864bf59bd894d2f33f78728320 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Fri, 18 Feb 2022 10:57:03 +0000 Subject: [PATCH 181/311] Update OCWM call times Both calls each month are now 12:00 PT --- index.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/index.md b/index.md index fc42c924..e41723d8 100644 --- a/index.md +++ b/index.md @@ -41,9 +41,8 @@ We hold weekly Office Hours and twice monthly Open Community Working Meetings. Office Hours are every Tuesday at 15:00 UTC. -Open Community Working Meetings follow two patterns: -- First Friday of the month at 20:00 UTC. -- Third Friday of the month at 15:00 UTC. +Open Community Working Meetings are every First and Third Friday of the month at 12:00 PT. + ## Need more? From a3a1442bd60aa8d44db0420da1a447e791ba2aae Mon Sep 17 00:00:00 2001 From: Norbert Schultz Date: Fri, 11 Mar 2022 10:31:24 +0100 Subject: [PATCH 182/311] Add rc-circe-json-validator --- _data/validator-libraries-modern.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index d3e8bbaa..17f9a7e8 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -274,6 +274,14 @@ date-draft: draft: [7, 6, 4] license: MIT +- name: Scala + implementations: + - name: Reactive Core Circe JSON Validator + url: https://github.com/reactivecore/rc-circe-json-schema + notes: Based on Circe-Library + date-draft: [2020-12] + draft: + license: Apache License, Version 2.0 - name: Objective-C implementations: - name: DSJSONSchemaValidation From 56f770e0a3b7598093e86f83d23c3e01cb9085f4 Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Tue, 15 Mar 2022 23:09:50 +0000 Subject: [PATCH 183/311] Add Go invopop/jsonschema schema generator link --- implementations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implementations.md b/implementations.md index a3a2acf5..87078a6f 100644 --- a/implementations.md +++ b/implementations.md @@ -111,6 +111,8 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - .NET - [Json.NET](https://www.newtonsoft.com/jsonschema) (AGPL-3.0) - generates schemas from .NET types - [NJsonSchema](https://github.com/RSuter/NJsonSchema/) - (Ms-PL) - generates schemas from .NET types, see issue [574](https://github.com/RSuter/NJsonSchema/issues/574) for draft-06+ support progress +- Go + - [jsonschema](https://github.com/invopop/jsonschema) - (MIT) - generate schemas from Go structs. Supports Draft 2020-12. - PHP - [Liform](https://github.com/Limenius/liform) (MIT) - generates schemas from Symfony forms - TypeScript From 965844604741c0d3b0309c38d3039687b9ee82df Mon Sep 17 00:00:00 2001 From: Norbert Schultz Date: Fri, 18 Mar 2022 10:08:16 +0100 Subject: [PATCH 184/311] Add 2019-09 --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 17f9a7e8..ccf6cdce 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -279,7 +279,7 @@ - name: Reactive Core Circe JSON Validator url: https://github.com/reactivecore/rc-circe-json-schema notes: Based on Circe-Library - date-draft: [2020-12] + date-draft: [2020-12, 2019-09] draft: license: Apache License, Version 2.0 - name: Objective-C From 4217fee03315cbfcf59eb900fe4e6ff55fe64aa4 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Fri, 25 Mar 2022 10:40:09 +0000 Subject: [PATCH 185/311] Update slack invite link --- slack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slack.md b/slack.md index dd736185..18113d47 100644 --- a/slack.md +++ b/slack.md @@ -1,3 +1,3 @@ --- -redirect_to: https://join.slack.com/t/json-schema/shared_invite/zt-nv0vbdfq-Ba_zz2cZBe_26ZoU7fEYGg +redirect_to: https://join.slack.com/t/json-schema/shared_invite/zt-15ylccbuu-3T2bRia8uzhE157TSW6nXg --- From 82ab1cd0ea690c1c592e06cf61dc2720b805cc69 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 21 Apr 2022 11:10:33 +0100 Subject: [PATCH 186/311] Clarify implementation state --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index ccf6cdce..dd24f022 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -278,7 +278,7 @@ implementations: - name: Reactive Core Circe JSON Validator url: https://github.com/reactivecore/rc-circe-json-schema - notes: Based on Circe-Library + notes: Based on Circe-Library -Early state and API may not be stable. Not yet produciton ready. date-draft: [2020-12, 2019-09] draft: license: Apache License, Version 2.0 From 62045b05ce3831496c0075b0bbb368a408988676 Mon Sep 17 00:00:00 2001 From: Sascha Goldhofer Date: Sat, 23 Apr 2022 20:17:26 +0200 Subject: [PATCH 187/311] add: json-schema-library to list of utilities --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index 87078a6f..4f6d3316 100644 --- a/implementations.md +++ b/implementations.md @@ -216,6 +216,7 @@ the utility, and decided on a case-by-case basis. - JavaScript - [json-schema-ref-parser](https://github.com/BigstickCarpet/json-schema-ref-parser) (MIT) Tools for dereferencing non-cyclic schemas, bundling referenced schemas into a single file, and other `$ref` processing. + - [json-schema-library](https://github.com/sagold/json-schema-library) (MIT) - Exposes tools to work with json-schema, including: data creation from json-schema, `$ref` processing, walk through schemas, etc. - [@cloudflare/json-schema-walker](https://github.com/cloudflare/json-schema-tools/tree/master/workspaces/json-schema-walker) ([JSON Schema Tools](https://github.com/cloudflare/json-schema-tools)), _draft-07, -06, -04, and Cloudflare's Doca extensions_ Walks schemas and runs pre- and post-walk callbacks. Can modify schemas in place. (BSD-3-Clause) - [@hyperjump/json-schema-core](https://github.com/jdesrosiers/json-schema-core) (MIT) Tools for working with schemas that handle identifiers and From 1ad3d13c0cd361104879ae9a7067acc1092e8998 Mon Sep 17 00:00:00 2001 From: Sascha Goldhofer Date: Sat, 23 Apr 2022 20:17:53 +0200 Subject: [PATCH 188/311] add: json-schema-library to list of validators --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index dd24f022..75b7ce46 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -177,6 +177,12 @@ date-draft: [2019-09, 2020-12] draft: [7, 6, 4] license: MIT + - name: JSON Schema Library + url: https://github.com/sagold/json-schema-library + notes: "Built for Node.js and browsers. Customizable json-validator and json-schema utilities for traversal, data generation and validation" + date-draft: + draft: [7, 6, 4] + license: MIT - name: vue-vuelidate-jsonschema url: https://github.com/mokkabonna/vue-vuelidate-jsonschema date-draft: From 3c826ed40561ddf689ffd4163cd4f5190f7fdd2d Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Wed, 27 Apr 2022 18:35:31 +1200 Subject: [PATCH 189/311] add json-everything as a generator --- implementations.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/implementations.md b/implementations.md index 87078a6f..5ff600c7 100644 --- a/implementations.md +++ b/implementations.md @@ -111,6 +111,7 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - .NET - [Json.NET](https://www.newtonsoft.com/jsonschema) (AGPL-3.0) - generates schemas from .NET types - [NJsonSchema](https://github.com/RSuter/NJsonSchema/) - (Ms-PL) - generates schemas from .NET types, see issue [574](https://github.com/RSuter/NJsonSchema/issues/574) for draft-06+ support progress + - [JsonSchema.Net.Generation](https://github.com/gregsdennis/json-everything) (MIT) - generates schemas from .NET types - Go - [jsonschema](https://github.com/invopop/jsonschema) - (MIT) - generate schemas from Go structs. Supports Draft 2020-12. - PHP @@ -201,6 +202,8 @@ Various levels of support for UI generation primarily from the validation vocabu #### Data from schemas +- .Net + - [JsonSchema.Net.DataGeneration](https://github.com/gregsdennis/json-everything) (MIT) Data generation from JSON schemas, powered by the Bogus testing data generation library. - Python - [hypothesis-jsonschema](https://github.com/Zac-HD/hypothesis-jsonschema) (MPL) *draft-07, -06, -04*; takes any schema, even with complex and interacting constraints, and returns a [Hypothesis](https://hypothesis.works/) strategy which can generate valid documents for testing. - Java From aeb9df3124b69ad77358a95dcfd39f6f4a06bd89 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Fri, 29 Apr 2022 09:19:49 +0100 Subject: [PATCH 190/311] Add 2020-12 patch release RC-0 preview Update work in progress page to reflect current state --- draft/preview/jsonschema-core.html | 5802 ++++++++++++++++++++++ draft/preview/jsonschema-validation.html | 3173 ++++++++++++ work-in-progress/index.md | 40 +- 3 files changed, 9014 insertions(+), 1 deletion(-) create mode 100644 draft/preview/jsonschema-core.html create mode 100644 draft/preview/jsonschema-validation.html diff --git a/draft/preview/jsonschema-core.html b/draft/preview/jsonschema-core.html new file mode 100644 index 00000000..b8a7b2e9 --- /dev/null +++ b/draft/preview/jsonschema-core.html @@ -0,0 +1,5802 @@ + + + + + + +JSON Schema: A Media Type for Describing JSON Documents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Internet-DraftJSON SchemaApril 2022
    Wright, et al.Expires 30 October 2022[Page]
    +
    +
    +
    +
    Workgroup:
    +
    Internet Engineering Task Force
    +
    Internet-Draft:
    +
    draft-bhutton-json-schema-01
    +
    Published:
    +
    + +
    +
    Intended Status:
    +
    Informational
    +
    Expires:
    +
    +
    Authors:
    +
    +
    +
    A. Wright, Ed. +
    +
    +
    +
    H. Andrews, Ed. +
    +
    +
    +
    B. Hutton, Ed. +
    +
    +
    +
    G. Dennis
    +
    +
    +
    +
    +

    JSON Schema: A Media Type for Describing JSON Documents

    +
    +

    Abstract

    +

    + JSON Schema defines the media type "application/schema+json", a JSON-based format + for describing the structure of JSON data. + JSON Schema asserts what a JSON document must look like, + ways to extract information from it, + and how to interact with it. + The "application/schema-instance+json" media type provides additional + feature-rich integration with "application/schema+json" beyond what can be offered + for "application/json" documents.

    +
    +
    +

    +Note to Readers +

    +

    + The issues list for this draft can be found at + https://github.com/json-schema-org/json-schema-spec/issues.

    +

    + For additional information, see https://json-schema.org/.

    +

    + To provide feedback, use this issue tracker, the communication methods listed on the + homepage, or email the document editors.

    +
    +
    +
    +

    +Status of This Memo +

    +

    + This Internet-Draft is submitted in full conformance with the + provisions of BCP 78 and BCP 79.

    +

    + Internet-Drafts are working documents of the Internet Engineering Task + Force (IETF). Note that other groups may also distribute working + documents as Internet-Drafts. The list of current Internet-Drafts is + at https://datatracker.ietf.org/drafts/current/.

    +

    + Internet-Drafts are draft documents valid for a maximum of six months + and may be updated, replaced, or obsoleted by other documents at any + time. It is inappropriate to use Internet-Drafts as reference + material or to cite them other than as "work in progress."

    +

    + This Internet-Draft will expire on 30 October 2022.

    +
    +
    + +
    +
    +

    +Table of Contents +

    + +
    +
    +
    +

    +1. Introduction +

    +

    + JSON Schema is a JSON media type for defining the structure of JSON data. JSON Schema + is intended to define validation, documentation, hyperlink navigation, and interaction + control of JSON data.

    +

    + This specification defines JSON Schema core terminology and mechanisms, including + pointing to another JSON Schema by reference, + dereferencing a JSON Schema reference, + specifying the dialect being used, + specifying a dialect's vocabulary requirements, + and defining the expected output.

    +

    + Other specifications define the vocabularies that perform assertions about validation, + linking, annotation, navigation, and interaction.

    +
    +
    +

    +2. Conventions and Terminology +

    +

    + + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", + "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be + interpreted as described in RFC 2119 [RFC2119].

    +

    + The terms "JSON", "JSON text", "JSON value", "member", "element", "object", "array", + "number", "string", "boolean", "true", "false", and "null" in this document are to + be interpreted as defined in RFC 8259 [RFC8259].

    +
    +
    +

    +3. Overview +

    +

    + This document proposes a new media type "application/schema+json" to identify a JSON + Schema for describing JSON data. + It also proposes a further optional media type, "application/schema-instance+json", + to provide additional integration features. + JSON Schemas are themselves JSON documents. + This, and related specifications, define keywords allowing authors to describe JSON + data in several ways.

    +

    + JSON Schema uses keywords to assert constraints on JSON instances or annotate those + instances with additional information. Additional keywords are used to apply + assertions and annotations to more complex JSON data structures, or based on + some sort of condition.

    +

    + To facilitate re-use, keywords can be organized into vocabularies. A vocabulary + consists of a list of keywords, together with their syntax and semantics. + A dialect is defined as a set of vocabularies and their required support + identified in a meta-schema.

    +

    + JSON Schema can be extended either by defining additional vocabularies, + or less formally by defining additional keywords outside of any vocabulary. + Unrecognized individual keywords simply have their values collected as annotations, + while the behavior with respect to an unrecognized vocabulary can be controlled + when declaring which vocabularies are in use.

    +

    + This document defines a core vocabulary that MUST be supported by any + implementation, and cannot be disabled. Its keywords are each prefixed + with a "$" character to emphasize their required nature. This vocabulary + is essential to the functioning of the "application/schema+json" media + type, and is used to bootstrap the loading of other vocabularies.

    +

    + Additionally, this document defines a RECOMMENDED vocabulary of keywords + for applying subschemas conditionally, and for applying subschemas to + the contents of objects and arrays. Either this vocabulary or one very + much like it is required to write schemas for non-trivial JSON instances, + whether those schemas are intended for assertion validation, annotation, + or both. While not part of the required core vocabulary, for maximum + interoperability this additional vocabulary is included in this document + and its use is strongly encouraged.

    +

    + Further vocabularies for purposes such as structural validation or + hypermedia annotation are defined in other documents. These other + documents each define a dialect collecting the standard sets of + vocabularies needed to write schemas for that document's purpose.

    +
    +
    +

    +4. Definitions +

    +
    +

    +4.1. JSON Document +

    +

    + A JSON document is an information resource (series of octets) described by the + application/json media type.

    +

    + In JSON Schema, the terms "JSON document", "JSON text", and "JSON value" are + interchangeable because of the data model it defines.

    +

    + JSON Schema is only defined over JSON documents. However, any document or memory + structure that can be parsed into or processed according to the JSON Schema data + model can be interpreted against a JSON Schema, including media types like + CBOR [RFC7049].

    +
    +
    +

    +4.2. Instance +

    +

    + A JSON document to which a schema is applied is known as an "instance".

    +

    + JSON Schema is defined over "application/json" or compatible documents, + including media types with the "+json" structured syntax suffix.

    +

    + Among these, this specification defines the "application/schema-instance+json" + media type which defines handling for fragments in the URI.

    +
    +

    +4.2.1. Instance Data Model +

    +

    + JSON Schema interprets documents according to a data model. A JSON value + interpreted according to this data model is called an "instance".

    +

    + An instance has one of six primitive types, and a range of possible values + depending on the type:

    +
    +
    null:
    +
    A JSON "null" value +
    +
    +
    boolean:
    +
    A "true" or "false" value, from the JSON "true" or "false" value +
    +
    +
    object:
    +
    An unordered set of properties mapping a string to an instance, from the JSON "object" value +
    +
    +
    array:
    +
    An ordered list of instances, from the JSON "array" value +
    +
    +
    number:
    +
    An arbitrary-precision, base-10 decimal number value, from the JSON "number" value +
    +
    +
    string:
    +
    A string of Unicode code points, from the JSON "string" value +
    +
    +
    +

    + Whitespace and formatting concerns, including different lexical + representations of numbers that are equal within the data model, are thus + outside the scope of JSON Schema. JSON Schema + vocabularies (Section 8.1) that wish + to work with such differences in lexical representations SHOULD define + keywords to precisely interpret formatted strings within the data model + rather than relying on having the original JSON representation Unicode + characters available.

    +

    + Since an object cannot have two properties with the same key, behavior for a + JSON document that tries to define two properties with + the same key in a single object is undefined.

    +

    + Note that JSON Schema vocabularies are free to define their own extended + type system. This should not be confused with the core data model types + defined here. As an example, "integer" is a reasonable type for a + vocabulary to define as a value for a keyword, but the data model + makes no distinction between integers and other numbers.

    +
    +
    +

    +4.2.2. Instance Equality +

    +

    + Two JSON instances are said to be equal if and only if they are of the same type + and have the same value according to the data model. Specifically, this means:

    +
      +
    • both are null; or +
    • +
    • both are true; or +
    • +
    • both are false; or +
    • +
    • both are strings, and are the same codepoint-for-codepoint; or +
    • +
    • both are numbers, and have the same mathematical value; or +
    • +
    • both are arrays, and have an equal value item-for-item; or +
    • +
    • both are objects, and each property in one has exactly one property with + a key equal to the other's, and that other property has an equal + value. +
    • +
    +

    + Implied in this definition is that arrays must be the same length, + objects must have the same number of members, + properties in objects are unordered, + there is no way to define multiple properties with the same key, + and mere formatting differences (indentation, placement of commas, trailing + zeros) are insignificant.

    +
    +
    +

    +4.2.3. Non-JSON Instances +

    +

    + It is possible to use JSON Schema with a superset of the JSON Schema data model, + where an instance may be outside any of the six JSON data types.

    +

    + In this case, annotations still apply; but most validation keywords will not be useful, + as they will always pass or always fail.

    +

    + A custom vocabulary may define support for a superset of the core data model. + The schema itself may only be expressible in this superset; + for example, to make use of the "const" keyword.

    +
    +
    +
    +
    +

    +4.3. JSON Schema Documents +

    +

    + A JSON Schema document, or simply a schema, is a JSON document used to describe + an instance. + A schema can itself be interpreted as an instance, but SHOULD always be given + the media type "application/schema+json" rather than + "application/schema-instance+json". The "application/schema+json" media + type is defined to offer a superset of the + fragment identifier syntax and semantics provided by + "application/schema-instance+json".

    +

    + A JSON Schema MUST be an object or a boolean.

    +
    +

    +4.3.1. JSON Schema Objects and Keywords +

    +

    + Object properties that are applied to the instance are called keywords, + or schema keywords. Broadly speaking, keywords fall into one + of five categories:

    +
    +
    identifiers:
    +
    + control schema identification through setting a URI + for the schema and/or changing how the base URI is determined +
    +
    +
    assertions:
    +
    + produce a boolean result when applied to an instance +
    +
    +
    annotations:
    +
    + attach information to an instance for application use +
    +
    +
    applicators:
    +
    + apply one or more subschemas to a particular location + in the instance, and combine or modify their results +
    +
    +
    reserved locations:
    +
    + do not directly affect results, but reserve a place + for a specific purpose to ensure interoperability +
    +
    +
    +

    + Keywords may fall into multiple categories, although applicators + SHOULD only produce assertion results based on their subschemas' + results. They should not define additional constraints independent + of their subschemas.

    +

    + Keywords which are properties within the same schema object are referred to as adjacent keywords.

    +

    + Extension keywords, meaning those defined outside of this document + and its companions, are free to define other behaviors as well.

    +

    + A JSON Schema MAY contain properties which are not schema keywords. + Unknown keywords SHOULD be treated as annotations, where the value + of the keyword is the value of the annotation.

    +

    + An empty schema is a JSON Schema with no properties, or only unknown + properties.

    +
    +
    +

    +4.3.2. Boolean JSON Schemas +

    +

    + The boolean schema values "true" and "false" are trivial schemas that + always produce themselves as assertion results, regardless of the + instance value. They never produce annotation results.

    +

    + These boolean schemas exist to clarify schema author intent and + facilitate schema processing optimizations. They behave identically + to the following schema objects (where "not" is part of the + subschema application vocabulary defined in this document).

    +
    +
    true:
    +
    + Always passes validation, as if the empty schema {} +
    +
    +
    false:
    +
    + Always fails validation, as if the schema { "not": {} } +
    +
    +
    +

    + While the empty schema object is unambiguous, there are many + possible equivalents to the "false" schema. Using the boolean + values ensures that the intent is clear to both human readers + and implementations.

    +
    +
    +

    +4.3.3. Schema Vocabularies +

    +

    + A schema vocabulary, or simply a vocabulary, is a set of keywords, + their syntax, and their semantics. A vocabulary is generally organized + around a particular purpose. Different uses of JSON Schema, such + as validation, hypermedia, or user interface generation, will + involve different sets of vocabularies.

    +

    + Vocabularies are the primary unit of re-use in JSON Schema, as schema + authors can indicate what vocabularies are required or optional in + order to process the schema. Since vocabularies are identified by URIs + in the meta-schema, generic implementations can load extensions to support + previously unknown vocabularies. While keywords can be supported outside + of any vocabulary, there is no analogous mechanism to indicate individual + keyword usage.

    +

    + A schema vocabulary can be defined by anything from an informal description + to a standards proposal, depending on the audience and interoperability + expectations. In particular, in order to facilitate vocabulary use within + non-public organizations, a vocabulary specification need not be published + outside of its scope of use.

    +
    +
    +

    +4.3.4. Meta-Schemas +

    +

    + A schema that itself describes a schema is called a meta-schema. + Meta-schemas are used to validate JSON Schemas and specify which vocabularies + they are using.

    +

    + Typically, a meta-schema will specify a set of vocabularies, and validate + schemas that conform to the syntax of those vocabularies. However, meta-schemas + and vocabularies are separate in order to allow meta-schemas to validate + schema conformance more strictly or more loosely than the vocabularies' + specifications call for. Meta-schemas may also describe and validate + additional keywords that are not part of a formal vocabulary.

    +
    +
    +
    +

    +4.3.5. Root Schema and Subschemas and Resources +

    +

    + A JSON Schema resource is a schema which is + canonically [RFC6596] identified by an + absolute URI [RFC3986]. Schema resources MAY + also be identified by URIs, including URIs with fragments, + if the resulting secondary resource (as defined by + section 3.5 of RFC 3986 [RFC3986]) is identical + to the primary resource. This can occur with the empty fragment, + or when one schema resource is embedded in another. Any such URIs + with fragments are considered to be non-canonical.

    +

    + The root schema is the schema that comprises the entire JSON document + in question. The root schema is always a schema resource, where the + URI is determined as described in section + 9.1.1. + + Note that documents that embed schemas in another format will not + have a root schema resource in this sense. Exactly how such usages + fit with the JSON Schema document and resource concepts will be + clarified in a future draft. +

    +

    + Some keywords take schemas themselves, allowing JSON Schemas to be nested:

    +
    +
    +
    +{
    +    "title": "root",
    +    "items": {
    +        "title": "array item"
    +    }
    +}
    +
    +
    +
    +

    + In this example document, the schema titled "array item" is a subschema, + and the schema titled "root" is the root schema.

    +

    + As with the root schema, a subschema is either an object or a boolean.

    +

    + As discussed in section + 8.2.1, a JSON Schema document + can contain multiple JSON Schema resources. When used without qualification, + the term "root schema" refers to the document's root schema. In some + cases, resource root schemas are discussed. A resource's root schema + is its top-level schema object, which would also be a document root schema + if the resource were to be extracted to a standalone JSON Schema document.

    +

    + Whether multiple schema resources are embedded or linked with a reference, + they are processed in the same way, with the same available behaviors.

    +
    +
    +
    +
    +
    +
    +
    +

    +5. Fragment Identifiers +

    +

    + In accordance with section 3.1 of RFC 6839 [RFC6839], + the syntax and semantics of fragment identifiers specified for + any +json media type SHOULD be as specified for "application/json". + (At publication of this document, there is no fragment identification + syntax defined for "application/json".)

    +

    + Additionally, the "application/schema+json" media type supports two + fragment identifier structures: plain names and JSON Pointers. + The "application/schema-instance+json" media type supports one + fragment identifier structure: JSON Pointers.

    +

    + The use of JSON Pointers as URI fragment identifiers is described in + RFC 6901 [RFC6901]. + For "application/schema+json", which supports two fragment identifier syntaxes, + fragment identifiers matching the JSON Pointer syntax, including the empty string, + MUST be interpreted as JSON Pointer fragment identifiers.

    +

    + Per the W3C's + best practices for fragment identifiers [W3C.WD-fragid-best-practices-20121025], + plain name fragment identifiers in "application/schema+json" are reserved for referencing + locally named schemas. All fragment identifiers that do + not match the JSON Pointer syntax MUST be interpreted as + plain name fragment identifiers.

    +

    + Defining and referencing a plain name fragment identifier within an + "application/schema+json" document are specified + in the "$anchor" keyword (Section 8.2.2) section.

    +

    +
    +
    +
    +

    +6. General Considerations +

    +
    +

    +6.1. Range of JSON Values +

    +

    + An instance may be any valid JSON value as defined by JSON [RFC8259]. + JSON Schema imposes no restrictions on type: JSON Schema can describe any JSON + value, including, for example, null.

    +
    +
    +
    +

    +6.2. Programming Language Independence +

    +

    + JSON Schema is programming language agnostic, and supports the full range of + values described in the data model. + Be aware, however, that some languages and JSON parsers may not be able to + represent in memory the full range of values describable by JSON.

    +
    +
    +
    +
    +

    +6.3. Mathematical Integers +

    +

    + Some programming languages and parsers use different internal representations + for floating point numbers than they do for integers.

    +

    + For consistency, integer JSON numbers SHOULD NOT be encoded with a fractional + part.

    +
    +
    +
    +
    +

    +6.4. Regular Expressions +

    +

    + Keywords MAY use regular expressions to express constraints, or constrain + the instance value to be a regular expression. + These regular expressions SHOULD be valid according to the regular expression + dialect described in ECMA-262, section 21.2.1 [ecma262].

    +

    + Regular expressions SHOULD be built with the "u" flag (or equivalent) to provide + Unicode support, or processed in such a way which provides Unicode support as + defined by ECMA-262.

    +

    + Furthermore, given the high disparity in regular expression constructs support, + schema authors SHOULD limit themselves to the following regular expression + tokens:

    +
      +
    • individual Unicode characters, as defined by the JSON specification [RFC8259]; +
    • +
    • simple character classes ([abc]), range character classes ([a-z]); +
    • +
    • complemented character classes ([^abc], [^a-z]); +
    • +
    • simple quantifiers: "+" (one or more), "*" (zero or more), "?" (zero or + one), and their lazy versions ("+?", "*?", "??"); +
    • +
    • range quantifiers: "{x}" (exactly x occurrences), "{x,y}" (at least x, at + most y, occurrences), {x,} (x occurrences or more), and their lazy + versions; +
    • +
    • the beginning-of-input ("^") and end-of-input ("$") anchors; +
    • +
    • simple grouping ("(...)") and alternation ("|"). +
    • +
    +

    + Finally, implementations MUST NOT take regular expressions to be + anchored, neither at the beginning nor at the end. This means, for instance, + the pattern "es" matches "expression".

    +
    +
    +
    +
    +

    +6.5. Extending JSON Schema +

    +

    + Additional schema keywords and schema vocabularies MAY be defined + by any entity. Save for explicit agreement, schema authors SHALL NOT + expect these additional keywords and vocabularies to be supported by + implementations that do not explicitly document such support. + Implementations SHOULD treat keywords they do not support as annotations, + where the value of the keyword is the value of the annotation.

    +

    + Implementations MAY provide the ability to register or load handlers + for vocabularies that they do not support directly. The exact mechanism + for registering and implementing such handlers is implementation-dependent.

    +
    +
    +
    +
    +

    +7. Keyword Behaviors +

    +

    + JSON Schema keywords fall into several general behavior categories. + Assertions validate that an instance satisfies constraints, producing + a boolean result. Annotations attach information that applications + may use in any way they see fit. + Applicators apply subschemas to parts of the instance and combine + their results.

    +

    + Extension keywords SHOULD stay within these categories, keeping in mind + that annotations in particular are extremely flexible. Complex behavior + is usually better delegated to applications on the basis of annotation + data than implemented directly as schema keywords. However, extension + keywords MAY define other behaviors for specialized purposes.

    +

    + Evaluating an instance against a schema involves processing all of the + keywords in the schema against the appropriate locations within the instance. + Typically, applicator keywords are processed until a schema object with no + applicators (and therefore no subschemas) is reached. The appropriate + location in the instance is evaluated against the assertion and + annotation keywords in the schema object, and their results are gathered + into the parent schema according to the rules of the applicator.

    +

    + Evaluation of a parent schema object can complete once all of its + subschemas have been evaluated, although in some circumstances evaluation + may be short-circuited due to assertion results. When annotations are + being collected, some assertion result short-circuiting is not possible + due to the need to examine all subschemas for annotation collection, including + those that cannot further change the assertion result.

    +
    +
    +

    +7.1. Lexical Scope and Dynamic Scope +

    +

    + While most JSON Schema keywords can be evaluated on their own, + or at most need to take into account the values or results of + adjacent keywords in the same schema object, a few have more + complex behavior.

    +

    + The lexical scope of a keyword is determined by the nested JSON + data structure of objects and arrays. The largest such scope + is an entire schema document. The smallest scope is a single + schema object with no subschemas.

    +

    + Keywords MAY be defined with a partial value, such as a URI-reference, + which must be resolved against another value, such as another + URI-reference or a full URI, which is found through the lexical + structure of the JSON document. The "$id", "$ref", and + "$dynamicRef" core keywords, and the "base" JSON Hyper-Schema + keyword, are examples of this sort of behavior.

    +

    + Note that some keywords, such as "$schema", apply to the lexical + scope of the entire schema resource, and therefore MUST only + appear in a schema resource's root schema.

    +

    + Other keywords may take into account the dynamic scope that + exists during the evaluation of a schema, typically together + with an instance document. + The outermost dynamic scope is the schema object at + which processing begins, even if it is not a schema resource root. + The path from this root schema to any particular keyword (that + includes any "$ref" and "$dynamicRef" keywords that may have + been resolved) is considered the keyword's "validation path."

    +

    + Lexical and dynamic scopes align until a reference keyword + is encountered. While following the reference keyword moves processing + from one lexical scope into a different one, from the perspective + of dynamic scope, following a reference is no different from descending + into a subschema present as a value. A keyword on the far side of + that reference that resolves information through the dynamic scope + will consider the originating side of the reference to be their + dynamic parent, rather than examining the local lexically enclosing parent.

    +

    + The concept of dynamic scope is primarily used with "$dynamicRef" and + "$dynamicAnchor", and should be considered an advanced feature + and used with caution when defining additional keywords. It also appears + when reporting errors and collected annotations, as it may be possible + to revisit the same lexical scope repeatedly with different dynamic + scopes. In such cases, it is important to inform the user of the + dynamic path that produced the error or annotation.

    +
    +
    +
    +

    +7.2. Keyword Interactions +

    +

    + Keyword behavior MAY be defined in terms of the annotation results + of subschemas (Section 4.3.5) and/or adjacent keywords + (keywords within the same schema object) and their subschemas. + Such keywords MUST NOT result in a circular dependency. + Keywords MAY modify their behavior based on the presence or absence + of another keyword in the same + schema object (Section 4.3).

    +
    +
    +

    +7.3. Default Behaviors +

    +

    + A missing keyword MUST NOT produce a false assertion result, MUST + NOT produce annotation results, and MUST NOT cause any other schema + to be evaluated as part of its own behavioral definition. + However, given that missing keywords do not contribute annotations, + the lack of annotation results may indirectly change the behavior + of other keywords.

    +

    + In some cases, the missing keyword assertion behavior of a keyword is + identical to that produced by a certain value, and keyword definitions + SHOULD note such values where known. However, even if the value which + produces the default behavior would produce annotation results if + present, the default behavior still MUST NOT result in annotations.

    +

    + Because annotation collection can add significant cost in terms of both + computation and memory, implementations MAY opt out of this feature. + Keywords that are specified in terms of collected annotations SHOULD + describe reasonable alternate approaches when appropriate. + This approach is demonstrated by the + "items" and + "additionalProperties" keywords in this + document.

    +

    + Note that when no such alternate approach is possible for a keyword, + implementations that do not support annotation collections will not + be able to support those keywords or vocabularies that contain them.

    +
    +
    +

    +7.4. Identifiers +

    +

    + Identifiers define URIs for a schema, or affect how such URIs are + resolved in references (Section 8.2.3), or both. + The Core vocabulary defined in this document defines several + identifying keywords, most notably "$id".

    +

    + Canonical schema URIs MUST NOT change while processing an instance, but + keywords that affect URI-reference resolution MAY have behavior that + is only fully determined at runtime.

    +

    + While custom identifier keywords are possible, vocabulary designers should + take care not to disrupt the functioning of core keywords. For example, + the "$dynamicAnchor" keyword in this specification limits its URI resolution + effects to the matching "$dynamicRef" keyword, leaving the behavior + of "$ref" undisturbed.

    +
    +
    +
    +

    +7.5. Applicators +

    +

    + Applicators allow for building more complex schemas than can be accomplished + with a single schema object. Evaluation of an instance against a + schema document (Section 4.3) begins by applying + the root schema (Section 4.3.5) to the complete instance + document. From there, keywords known as applicators are used to determine + which additional schemas are applied. Such schemas may be applied in-place + to the current location, or to a child location.

    +

    + The schemas to be applied may be present as subschemas comprising all or + part of the keyword's value. Alternatively, an applicator may refer to + a schema elsewhere in the same schema document, or in a different one. + The mechanism for identifying such referenced schemas is defined by the + keyword.

    +

    + Applicator keywords also define how subschema or referenced schema + boolean assertion (Section 7.6) + results are modified and/or combined to produce the boolean result + of the applicator. Applicators may apply any boolean logic operation + to the assertion results of subschemas, but MUST NOT introduce new + assertion conditions of their own.

    +

    + Annotation (Section 7.7) results are + preserved along with the instance location and the location of + the schema keyword, so that applications can decide how to + interpret multiple values.

    +
    +
    +

    +7.5.1. Referenced and Referencing Schemas +

    +

    + As noted in Section 7.5, an applicator keyword may + refer to a schema to be applied, rather than including it as a + subschema in the applicator's value. In such situations, the + schema being applied is known as the referenced schema, while + the schema containing the applicator keyword is the referencing schema.

    +

    + While root schemas and subschemas are static concepts based on a + schema's position within a schema document, referenced and referencing + schemas are dynamic. Different pairs of schemas may find themselves + in various referenced and referencing arrangements during the evaluation + of an instance against a schema.

    +

    + For some by-reference applicators, such as + "$ref" (Section 8.2.3.1), the referenced schema can be determined + by static analysis of the schema document's lexical scope. Others, + such as "$dynamicRef" (with "$dynamicAnchor"), may make use of dynamic + scoping, and therefore only be resolvable in the process of evaluating + the schema with an instance.

    +
    +
    +
    +
    +
    +
    +

    +7.6. Assertions +

    +

    + JSON Schema can be used to assert constraints on a JSON document, which + either passes or fails the assertions. This approach can be used to validate + conformance with the constraints, or document what is needed to satisfy them.

    +

    + JSON Schema implementations produce a single boolean result when evaluating + an instance against schema assertions.

    +

    + An instance can only fail an assertion that is present in the schema.

    +
    +

    +7.6.1. Assertions and Instance Primitive Types +

    +

    + Most assertions only constrain values within a certain + primitive type. When the type of the instance is not of the type + targeted by the keyword, the instance is considered to conform + to the assertion.

    +

    + For example, the "maxLength" keyword from the companion + validation vocabulary [json-schema-validation]: + will only restrict certain strings + (that are too long) from being valid. If the instance is a number, + boolean, null, array, or object, then it is valid against this assertion.

    +

    + This behavior allows keywords to be used more easily with instances + that can be of multiple primitive types. The companion validation + vocabulary also includes a "type" keyword which can independently + restrict the instance to one or more primitive types. This allows + for a concise expression of use cases such as a function that might + return either a string of a certain length or a null value:

    +
    +
    +
    +{
    +    "type": ["string", "null"],
    +    "maxLength": 255
    +}
    +
    +
    +
    +

    + If "maxLength" also restricted the instance type to be a string, + then this would be substantially more cumbersome to express because + the example as written would not actually allow null values. + Each keyword is evaluated separately unless explicitly specified + otherwise, so if "maxLength" restricted the instance to strings, + then including "null" in "type" would not have any useful effect.

    +
    +
    +
    +
    +
    +

    +7.7. Annotations +

    +

    + JSON Schema can annotate an instance with information, whenever the instance + validates against the schema object containing the annotation, and all of its + parent schema objects. The information can be a simple value, or can be + calculated based on the instance contents.

    +

    + Annotations are attached to specific locations in an instance. + Since many subschemas can be applied to any single + location, applications may need to decide how to handle differing + annotation values being attached to the same instance location by + the same schema keyword in different schema objects.

    +

    + Unlike assertion results, annotation data can take a wide variety of forms, + which are provided to applications to use as they see fit. JSON Schema + implementations are not expected to make use of the collected information + on behalf of applications.

    +

    + Unless otherwise specified, the value of an annotation keyword + is the keyword's value. However, other behaviors are possible. + For example, JSON Hyper-Schema's [json-hyper-schema] + "links" keyword is a complex annotation that produces a value based + in part on the instance data.

    +

    + While "short-circuit" evaluation is possible for assertions, collecting + annotations requires examining all schemas that apply to an instance + location, even if they cannot change the overall assertion result. + The only exception is that subschemas of a schema object that has + failed validation MAY be skipped, as annotations are not retained + for failing schemas.

    +
    +

    +7.7.1. Collecting Annotations +

    +

    + Annotations are collected by keywords that explicitly define + annotation-collecting behavior. Note that boolean schemas cannot + produce annotations as they do not make use of keywords.

    +

    + A collected annotation MUST include the following information:

    +
      +
    • + The name of the keyword that produces the annotation +
    • +
    • + The instance location to which it is attached, as a JSON Pointer +
    • +
    • + The schema location path, indicating how reference keywords + such as "$ref" were followed to reach the absolute schema location. +
    • +
    • + The absolute schema location of the attaching keyword, as a URI. + This MAY be omitted if it is the same as the schema location path + from above. +
    • +
    • + The attached value(s) +
    • +
    +
    +
    +7.7.1.1. Distinguishing Among Multiple Values +
    +

    + Applications MAY make decisions on which of multiple annotation values + to use based on the schema location that contributed the value. + This is intended to allow flexible usage. Collecting the schema location + facilitates such usage.

    +

    + For example, consider this schema, which uses annotations and assertions from + the Validation specification [json-schema-validation]:

    +

    + Note that some lines are wrapped for clarity.

    +
    +
    +
    +{
    +    "title": "Feature list",
    +    "type": "array",
    +    "prefixItems": [
    +        {
    +            "title": "Feature A",
    +            "properties": {
    +                "enabled": {
    +                    "$ref": "#/$defs/enabledToggle",
    +                    "default": true
    +                }
    +            }
    +        },
    +        {
    +            "title": "Feature B",
    +            "properties": {
    +                "enabled": {
    +                    "description": "If set to null, Feature B
    +                                    inherits the enabled
    +                                    value from Feature A",
    +                    "$ref": "#/$defs/enabledToggle"
    +                }
    +            }
    +        }
    +    ],
    +    "$defs": {
    +        "enabledToggle": {
    +            "title": "Enabled",
    +            "description": "Whether the feature is enabled (true),
    +                            disabled (false), or under
    +                            automatic control (null)",
    +            "type": ["boolean", "null"],
    +            "default": null
    +        }
    +    }
    +}
    +
    +
    +
    +

    + In this example, both Feature A and Feature B make use of the re-usable + "enabledToggle" schema. That schema uses the "title", "description", + and "default" annotations. Therefore the application has to decide how + to handle the additional "default" value for Feature A, and the additional + "description" value for Feature B.

    +

    + The application programmer and the schema author need to agree on the + usage. For this example, let's assume that they agree that the most + specific "default" value will be used, and any additional, more generic + "default" values will be silently ignored. Let's also assume that they + agree that all "description" text is to be used, starting with the most + generic, and ending with the most specific. This requires the schema + author to write descriptions that work when combined in this way.

    +

    + The application can use the schema location path to determine which + values are which. The values in the feature's immediate "enabled" + property schema are more specific, while the values under the re-usable + schema that is referenced to with "$ref" are more generic. The schema + location path will show whether each value was found by crossing a + "$ref" or not.

    +

    + Feature A will therefore use a default value of true, while Feature B + will use the generic default value of null. Feature A will only + have the generic description from the "enabledToggle" schema, while + Feature B will use that description, and also append its locally + defined description that explains how to interpret a null value.

    +

    + Note that there are other reasonable approaches that a different application + might take. For example, an application may consider the presence of + two different values for "default" to be an error, regardless of their + schema locations.

    +
    +
    +
    +7.7.1.2. Annotations and Assertions +
    +

    + Schema objects that produce a false assertion result MUST NOT + produce any annotation results, whether from their own keywords + or from keywords in subschemas.

    +

    + Note that the overall schema results may still include annotations + collected from other schema locations. Given this schema:

    +
    +
    +
    +{
    +    "oneOf": [
    +        {
    +            "title": "Integer Value",
    +            "type": "integer"
    +        },
    +        {
    +            "title": "String Value",
    +            "type": "string"
    +        }
    +    ]
    +}
    +
    +
    +
    +

    + Against the instance "This is a string", the + title annotation "Integer Value" is discarded because the type assertion + in that schema object fails. The title annotation "String Value" + is kept, as the instance passes the string type assertions.

    +
    +
    +
    +7.7.1.3. Annotations and Applicators +
    +

    + In addition to possibly defining annotation results of their own, + applicator keywords aggregate the annotations collected in their + subschema(s) or referenced schema(s).

    +
    +
    +
    +
    +
    +

    +7.8. Reserved Locations +

    +

    + A fourth category of keywords simply reserve a location to hold re-usable + components or data of interest to schema authors that is not suitable + for re-use. These keywords do not affect validation or annotation results. + Their purpose in the core vocabulary is to ensure that locations are + available for certain purposes and will not be redefined by extension + keywords.

    +

    + While these keywords do not directly affect results, as explained in section + 9.4.2 unrecognized + extension keywords that reserve locations for re-usable schemas may have + undesirable interactions with references in certain circumstances.

    +
    +
    +

    +7.9. Loading Instance Data +

    +

    + While none of the vocabularies defined as part of this or the associated documents + define a keyword which may target and/or load instance data, it is possible that + other vocabularies may wish to do so.

    +

    + Keywords MAY be defined to use JSON Pointers or Relative JSON Pointers to examine + parts of an instance outside the current evaluation location.

    +

    + Keywords that allow adjusting the location using a Relative JSON Pointer SHOULD + default to using the current location if a default is desireable.

    +
    +
    +
    +

    +8. The JSON Schema Core Vocabulary +

    +

    + Keywords declared in this section, which all begin with "$", make up + the JSON Schema Core vocabulary. These keywords are either required in + order to process any schema or meta-schema, including those split across + multiple documents, or exist to reserve keywords for purposes that + require guaranteed interoperability.

    +

    + The Core vocabulary MUST be considered mandatory at all times, in order + to bootstrap the processing of further vocabularies. Meta-schemas + that use the "$vocabulary" (Section 8.1) keyword + to declare the vocabularies in use MUST explicitly list the Core vocabulary, + which MUST have a value of true indicating that it is required.

    +

    + The behavior of a false value for this vocabulary (and only this + vocabulary) is undefined, as is the behavior when "$vocabulary" + is present but the Core vocabulary is not included. However, it + is RECOMMENDED that implementations detect these cases and raise + an error when they occur. It is not meaningful to declare that + a meta-schema optionally uses Core.

    +

    + Meta-schemas that do not use "$vocabulary" MUST be considered to + require the Core vocabulary as if its URI were present with a value of true.

    +

    + The current URI for the Core vocabulary is: + <https://json-schema.org/draft/2020-12/vocab/core>.

    +

    + The current URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/core.

    +

    + While the "$" prefix is not formally reserved for the Core vocabulary, + it is RECOMMENDED that extension keywords (in vocabularies or otherwise) + begin with a character other than "$" to avoid possible future collisions.

    +
    +
    +

    +8.1. Meta-Schemas and Vocabularies +

    +

    + Two concepts, meta-schemas and vocabularies, are used to inform an implementation + how to interpret a schema. Every schema has a meta-schema, which can be declared + using the "$schema" keyword.

    +

    + The meta-schema serves two purposes:

    +
    +
    Declaring the vocabularies in use
    +
    + The "$vocabulary" keyword, when it appears in a meta-schema, declares + which vocabularies are available to be used in schemas that refer + to that meta-schema. Vocabularies define keyword semantics, + as well as their general syntax. +
    +
    +
    Describing valid schema syntax
    +
    + A schema MUST successfully validate against its meta-schema, which + constrains the syntax of the available keywords. The syntax described + is expected to be compatible with the vocabularies declared; while + it is possible to describe an incompatible syntax, such a meta-schema + would be unlikely to be useful. +
    +
    +
    +

    + Meta-schemas are separate from vocabularies to allow for + vocabularies to be combined in different ways, and for meta-schema authors + to impose additional constraints such as forbidding certain keywords, or + performing unusually strict syntactical validation, as might be done + during a development and testing cycle. Each vocabulary typically identifies + a meta-schema consisting only of the vocabulary's keywords.

    +

    + Meta-schema authoring is an advanced usage of JSON Schema, so the design of + meta-schema features emphasizes flexibility over simplicity.

    +
    +
    +

    +8.1.1. The "$schema" Keyword +

    +

    + The "$schema" keyword is both used as a JSON Schema dialect identifier and + as the identifier of a resource which is itself a JSON Schema, which describes the + set of valid schemas written for this particular dialect.

    +

    + The value of this keyword MUST be a URI [RFC3986] + (containing a scheme) and this URI MUST be normalized. + The current schema MUST be valid against the meta-schema identified by this URI.

    +

    + If this URI identifies a retrievable resource, that resource SHOULD be of + media type "application/schema+json".

    +

    + The "$schema" keyword SHOULD be used in the document root schema object, + and MAY be used in the root schema objects of embedded schema resources. + It MUST NOT appear in non-resource root schema objects. If absent from + the document root schema, the resulting behavior is implementation-defined.

    +

    + Values for this property are defined elsewhere in this and other documents, + and by other parties.

    +
    +
    +
    +

    +8.1.2. The "$vocabulary" Keyword +

    +

    + The "$vocabulary" keyword is used in meta-schemas to identify the + vocabularies available for use in schemas described by that meta-schema. + It is also used to indicate whether each vocabulary is required or optional, + in the sense that an implementation MUST understand the required vocabularies + in order to successfully process the schema. Together, this information forms + a dialect. Any vocabulary that is understood by the implementation MUST be + processed in a manner consistent with the semantic definitions contained + within the vocabulary.

    +

    + The value of this keyword MUST be an object. The property names in the + object MUST be URIs (containing a scheme) and this URI MUST be normalized. + Each URI that appears as a property name identifies a specific set of + keywords and their semantics.

    +

    + The URI MAY be a URL, but the nature of the retrievable resource is + currently undefined, and reserved for future use. Vocabulary authors + MAY use the URL of the vocabulary specification, in a human-readable + media type such as text/html or text/plain, as the vocabulary URI. + + Vocabulary documents may be added in forthcoming drafts. + For now, identifying the keyword set is deemed sufficient as that, + along with meta-schema validation, is how the current "vocabularies" + work today. Any future vocabulary document format will be specified + as a JSON document, so using text/html or other non-JSON formats + in the meantime will not produce any future ambiguity. +

    +

    + The values of the object properties MUST be booleans. + If the value is true, then implementations that do not recognize + the vocabulary MUST refuse to process any schemas that declare + this meta-schema with "$schema". If the value is false, implementations + that do not recognize the vocabulary SHOULD proceed with processing + such schemas. The value has no impact if the implementation + understands the vocabulary.

    +

    + Per 6.5, unrecognized + keywords SHOULD be treated as annotations. + This remains the case for keywords defined + by unrecognized vocabularies. It is not currently possible to distinguish + between unrecognized keywords that are defined in vocabularies from + those that are not part of any vocabulary.

    +

    + The "$vocabulary" keyword SHOULD be used in the root schema of any schema + document intended for use as a meta-schema. It MUST NOT appear in subschemas.

    +

    + The "$vocabulary" keyword MUST be ignored in schema documents that + are not being processed as a meta-schema. This allows validating + a meta-schema M against its own meta-schema M' without requiring + the validator to understand the vocabularies declared by M.

    +
    +
    +8.1.2.1. Default vocabularies +
    +

    + If "$vocabulary" is absent, an implementation MAY determine + behavior based on the meta-schema if it is recognized from the + URI value of the referring schema's "$schema" keyword. + This is how behavior (such as Hyper-Schema usage) has been + recognized prior to the existence of vocabularies.

    +

    + If the meta-schema, as referenced by the schema, is not recognized, + or is missing, then the behavior is implementation-defined. + If the implementation + proceeds with processing the schema, it MUST assume the use of the + core vocabulary. If the implementation is built for a specific purpose, + then it SHOULD assume the use of all of the most relevant vocabularies + for that purpose.

    +

    + For example, an implementation that is a validator + SHOULD assume the use of all vocabularies in this + specification and the companion Validation specification.

    +
    +
    +
    +8.1.2.2. Non-inheritability of vocabularies +
    +

    + Note that the processing restrictions on "$vocabulary" mean that + meta-schemas that reference other meta-schemas using "$ref" or + similar keywords do not automatically inherit the vocabulary + declarations of those other meta-schemas. All such declarations + must be repeated in the root of each schema document intended + for use as a meta-schema. This is demonstrated in + the example meta-schema (Appendix D.2). + + This requirement allows implementations to find all vocabulary + requirement information in a single place for each meta-schema. + As schema extensibility means that there are endless potential + ways to combine more fine-grained meta-schemas by reference, + requiring implementations to anticipate all possibilities and + search for vocabularies in referenced meta-schemas would + be overly burdensome. +

    +
    +
    +
    +

    +8.1.3. Updates to Meta-Schema and Vocabulary URIs +

    +

    + Updated vocabulary and meta-schema URIs MAY be published between + specification drafts in order to correct errors. Implementations + SHOULD consider URIs dated after this specification draft and + before the next to indicate the same syntax and semantics + as those listed here.

    +
    +
    +
    +
    +

    +8.2. Base URI, Anchors, and Dereferencing +

    +

    + To differentiate between schemas in a vast ecosystem, schemas are + identified by URI [RFC3986], and can embed references + to other schemas by specifying their URI.

    +

    + Several keywords can accept a relative URI-reference [RFC3986], + or a value used to construct a relative URI-reference. For these keywords, + it is necessary to establish a base URI in order to resolve the reference.

    +
    +
    +

    +8.2.1. The "$id" Keyword +

    +

    + The "$id" keyword identifies a schema resource with its + canonical [RFC6596] URI.

    +

    + Note that this URI is an identifier and not necessarily a network locator. + In the case of a network-addressable URL, a schema need not be downloadable + from its canonical URI.

    +

    + If present, the value for this keyword MUST be a string, and MUST represent a + valid URI-reference [RFC3986]. This URI-reference + SHOULD be normalized, and MUST resolve to an + absolute-URI [RFC3986] (without a fragment), + or to a URI with an empty fragment.

    +

    + The empty fragment form is NOT RECOMMENDED and is retained only + for backwards compatibility, and because the + application/schema+json media type defines that a URI with an + empty fragment identifies the same resource as the same URI + with the fragment removed. However, since this equivalence is not + part of the RFC 3986 normalization process [RFC3986], + implementers and schema authors cannot rely on generic URI libraries + understanding it.

    +

    + Therefore, "$id" MUST NOT contain a non-empty fragment, and SHOULD NOT + contain an empty fragment. The absolute-URI form MUST be considered + the canonical URI, regardless of the presence or absence of an empty fragment. + + An empty fragment is currently allowed because older meta-schemas have + an empty fragment in their $id (or previously, id). + A future draft may outright forbid even empty fragments in "$id". +

    +

    + The absolute-URI also serves as the base URI for relative URI-references + in keywords within the schema resource, in accordance with + RFC 3986 section 5.1.1 [RFC3986] regarding base URIs + embedded in content.

    +

    + The presence of "$id" in a subschema indicates that the subschema constitutes + a distinct schema resource within a single schema document. Furthermore, + in accordance with RFC 3986 section 5.1.2 [RFC3986] + regarding encapsulating entities, if an "$id" in a subschema is a relative + URI-reference, the base URI for resolving that reference is the URI of + the parent schema resource.

    +

    + If no parent schema object explicitly identifies itself as a resource + with "$id", the base URI is that of the entire document, as established + by the steps given in the previous section. (Section 9.1.1)

    +
    +
    +8.2.1.1. Identifying the root schema +
    +

    + The root schema of a JSON Schema document SHOULD contain an "$id" keyword + with an absolute-URI [RFC3986] (containing a scheme, + but no fragment).

    +
    +
    +
    +
    +
    +

    +8.2.2. Defining location-independent identifiers +

    +

    + Using JSON Pointer fragments requires knowledge of the structure of the schema. + When writing schema documents with the intention to provide re-usable + schemas, it may be preferable to use a plain name fragment that is not tied to + any particular structural location. This allows a subschema to be relocated + without requiring JSON Pointer references to be updated.

    +

    + The "$anchor" and "$dynamicAnchor" keywords are used to specify such + fragments. They are identifier keywords that can only be used to create + plain name fragments, rather than absolute URIs as seen with "$id".

    +

    + The base URI to which the resulting fragment is appended is the canonical + URI of the schema resource containing the "$anchor" or "$dynamicAnchor" + in question. As discussed in the previous section, this is either the + nearest "$id" in the same or parent schema object, or the base URI + for the document as determined according to RFC 3986.

    +

    + Separately from the usual usage of URIs, "$dynamicAnchor" + indicates that the fragment is an extension point when used with + the "$dynamicRef" keyword. This low-level, advanced feature + makes it easier to extend recursive schemas such as the meta-schemas, + without imposing any particular semantics on that extension. + See the section on "$dynamicRef" (Section 8.2.3.2) + for details.

    +

    + In most cases, the normal fragment behavior both suffices and + is more intuitive. Therefore it is RECOMMENDED that "$anchor" + be used to create plain name fragments unless there is a clear + need for "$dynamicAnchor".

    +

    + If present, the value of this keyword MUST be a string and MUST start with + a letter ([A-Za-z]) or underscore ("_"), followed by any number of letters, + digits ([0-9]), hyphens ("-"), underscores ("_"), and periods ("."). + This matches the US-ASCII part of XML's + NCName production [xml-names]. + + Note that the anchor string does not include the "#" character, + as it is not a URI-reference. An "$anchor": "foo" becomes the + fragment "#foo" when used in a URI. See below for full examples. +

    +

    + The effect of specifying the same fragment name multiple times within + the same resource, using any combination of "$anchor" and/or + "$dynamicAnchor", is undefined. Implementations MAY + raise an error if such usage is detected.

    +
    +
    +
    +
    +

    +8.2.3. Schema References +

    +

    + Several keywords can be used to reference a schema which is to be applied to the + current instance location. "$ref" and "$dynamicRef" are applicator + keywords, applying the referenced schema to the instance.

    +

    + As the values of "$ref" and "$dynamicRef" are URI References, this allows + the possibility to externalise or divide a schema across multiple files, + and provides the ability to validate recursive structures through + self-reference.

    +

    + The resolved URI produced by these keywords is not necessarily a network + locator, only an identifier. A schema need not be downloadable from the + address if it is a network-addressable URL, and implementations SHOULD NOT + assume they should perform a network operation when they encounter + a network-addressable URI.

    +
    +
    +
    +8.2.3.1. Direct References with "$ref" +
    +

    + The "$ref" keyword is an applicator that is used to reference a statically + identified schema. Its results are the results of the referenced schema. + + Note that this definition of how the results are determined means that + other keywords can appear alongside of "$ref" in the same schema object. +

    +

    + The value of the "$ref" keyword MUST be a string which is a URI-Reference. + Resolved against the current URI base, it produces the URI of the schema + to apply. This resolution is safe to perform on schema load, as the + process of evaluating an instance cannot change how the reference resolves.

    +
    +
    +
    +
    +
    +8.2.3.2. Dynamic References with "$dynamicRef" +
    +

    + The "$dynamicRef" keyword is an applicator that allows for deferring the + full resolution until runtime, at which point it is resolved each time it is + encountered while evaluating an instance.

    +

    + Together with "$dynamicAnchor", "$dynamicRef" implements a cooperative + extension mechanism that is primarily useful with recursive schemas + (schemas that reference themselves). Both the extension point and the + runtime-determined extension target are defined with "$dynamicAnchor", + and only exhibit runtime dynamic behavior when referenced with + "$dynamicRef".

    +

    + The value of the "$dynamicRef" property MUST be a string which is + a URI-Reference. Resolved against the current URI base, it produces + the URI used as the starting point for runtime resolution. This initial + resolution is safe to perform on schema load.

    +

    + If the initially resolved starting point URI includes a fragment that + was created by the "$dynamicAnchor" keyword, the initial URI MUST be + replaced by the URI (including the fragment) for the outermost schema + resource in the dynamic scope (Section 7.1) that defines + an identically named fragment with "$dynamicAnchor".

    +

    + Otherwise, its behavior is identical to "$ref", and no runtime + resolution is needed.

    +

    + For a full example using these keyword, see appendix + C. + + The difference between the hyper-schema meta-schema in pre-2019 + drafts and an this draft dramatically demonstrates the utility + of these keywords. +

    +
    +
    +
    +
    +
    +
    +

    +8.2.4. Schema Re-Use With "$defs" +

    +

    + The "$defs" keyword reserves a location for schema + authors to inline re-usable JSON Schemas into a more general schema. + The keyword does not directly affect the validation result.

    +

    + This keyword's value MUST be an object. + Each member value of this object MUST be a valid JSON Schema.

    +

    + As an example, here is a schema describing an array of positive + integers, where the positive integer constraint is a subschema in + "$defs":

    +
    +
    +
    +{
    +    "type": "array",
    +    "items": { "$ref": "#/$defs/positiveInteger" },
    +    "$defs": {
    +        "positiveInteger": {
    +            "type": "integer",
    +            "exclusiveMinimum": 0
    +        }
    +    }
    +}
    +
    +
    +
    +
    +
    +
    +
    +

    +8.3. Comments With "$comment" +

    +

    + This keyword reserves a location for comments from schema authors + to readers or maintainers of the schema.

    +

    + The value of this keyword MUST be a string. Implementations MUST NOT present this + string to end users. Tools for editing schemas SHOULD support displaying and + editing this keyword. The value of this keyword MAY be used in debug or error + output which is intended for developers making use of schemas.

    +

    + Schema vocabularies SHOULD allow "$comment" within any object containing + vocabulary keywords. Implementations MAY assume "$comment" is allowed + unless the vocabulary specifically forbids it. Vocabularies MUST NOT + specify any effect of "$comment" beyond what is described in this + specification.

    +

    + Tools that translate other media types or programming languages + to and from application/schema+json MAY choose to convert that media type or + programming language's native comments to or from "$comment" values. + The behavior of such translation when both native comments and "$comment" + properties are present is implementation-dependent.

    +

    + Implementations MAY strip "$comment" values at any point during processing. + In particular, this allows for shortening schemas when the size of deployed + schemas is a concern.

    +

    + Implementations MUST NOT take any other action based on the presence, absence, + or contents of "$comment" properties. In particular, the value of "$comment" + MUST NOT be collected as an annotation result.

    +
    +
    +
    +

    +9. Loading and Processing Schemas +

    +

    +
    +

    +9.1. Loading a Schema +

    +
    +
    +

    +9.1.1. Initial Base URI +

    +

    + RFC3986 Section 5.1 [RFC3986] defines how to determine the + default base URI of a document.

    +

    + Informatively, the initial base URI of a schema is the URI at which it was + found, whether that was a network location, a local filesystem, or any other + situation identifiable by a URI of any known scheme.

    +

    + If a schema document defines no explicit base URI with "$id" + (embedded in content), the base URI is that determined per + RFC 3986 section 5 [RFC3986].

    +

    + If no source is known, or no URI scheme is known for the source, a suitable + implementation-specific default URI MAY be used as described in + RFC 3986 Section 5.1.4 [RFC3986]. It is RECOMMENDED + that implementations document any default base URI that they assume.

    +

    + If a schema object is embedded in a document of another media type, then + the initial base URI is determined according to the rules of that + media type.

    +

    + Unless the "$id" keyword described in an earlier section is present in the + root schema, this base URI SHOULD be considered the canonical URI of the + schema document's root schema resource.

    +
    +
    +
    +

    +9.1.2. Loading a referenced schema +

    +

    + The use of URIs to identify remote schemas does not necessarily mean anything is downloaded, + but instead JSON Schema implementations SHOULD understand ahead of time which schemas they will be using, + and the URIs that identify them.

    +

    + When schemas are downloaded, + for example by a generic user-agent that does not know until runtime which schemas to download, + see Usage for Hypermedia (Section 9.5.1).

    +

    + Implementations SHOULD be able to associate arbitrary URIs with an arbitrary + schema and/or automatically associate a schema's "$id"-given URI, depending + on the trust that the validator has in the schema. Such URIs and schemas + can be supplied to an implementation prior to processing instances, or may + be noted within a schema document as it is processed, producing associations + as shown in appendix A.

    +

    + A schema MAY (and likely will) have multiple URIs, but there is no way for a + URI to identify more than one schema. When multiple schemas try to identify + as the same URI, validators SHOULD raise an error condition.

    +
    +
    +

    +9.1.3. Detecting a Meta-Schema +

    +

    + Implementations MUST recognize a schema as a meta-schema if it + is being examined because it was identified as such by another + schema's "$schema" keyword. This means that a single schema + document might sometimes be considered a regular schema, and + other times be considered a meta-schema.

    +

    + In the case of examining a schema which is its own meta-schema, + when an implementation begins processing it as a regular schema, + it is processed under those rules. However, when loaded a second + time as a result of checking its own "$schema" value, it is treated + as a meta-schema. So the same document is processed both ways in + the course of one session.

    +

    + Implementations MAY allow a schema to be explicitly passed as a meta-schema, + for implementation-specific purposes, such as pre-loading a commonly + used meta-schema and checking its vocabulary support requirements + up front. Meta-schema authors MUST NOT expect such features to be + interoperable across implementations.

    +
    +
    +
    +

    +9.2. Dereferencing +

    +

    + Schemas can be identified by any URI that has been given to them, including + a JSON Pointer or their URI given directly by "$id". In all cases, + dereferencing a "$ref" reference involves first resolving its value as a + URI reference against the current base URI per + RFC 3986 [RFC3986].

    +

    + If the resulting URI identifies a schema within the current document, or + within another schema document that has been made available to the implementation, + then that schema SHOULD be used automatically.

    +

    + For example, consider this schema:

    +
    +
    +
    +{
    +    "$id": "https://example.net/root.json",
    +    "items": {
    +        "type": "array",
    +        "items": { "$ref": "#item" }
    +    },
    +    "$defs": {
    +        "single": {
    +            "$anchor": "item",
    +            "type": "object",
    +            "additionalProperties": { "$ref": "other.json" }
    +        }
    +    }
    +}
    +
    +
    +
    +

    + When an implementation encounters the <#/$defs/single> schema, + it resolves the "$anchor" value as a fragment name against the current + base URI to form <https://example.net/root.json#item>.

    +

    + When an implementation then looks inside the <#/items> schema, it + encounters the <#item> reference, and resolves this to + <https://example.net/root.json#item>, which it has seen defined in + this same document and can therefore use automatically.

    +

    + When an implementation encounters the reference to "other.json", it resolves + this to <https://example.net/other.json>, which is not defined in this + document. If a schema with that identifier has otherwise been supplied to + the implementation, it can also be used automatically. + + What should implementations do when the referenced schema is not known? + Are there circumstances in which automatic network dereferencing is + allowed? A same origin policy? A user-configurable option? In the + case of an evolving API described by Hyper-Schema, it is expected that + new schemas will be added to the system dynamically, so placing an + absolute requirement of pre-loading schema documents is not feasible. +

    +
    +
    +

    +9.2.1. JSON Pointer fragments and embedded schema resources +

    +

    + Since JSON Pointer URI fragments are constructed based on the structure + of the schema document, an embedded schema resource and its subschemas + can be identified by JSON Pointer fragments relative to either its own + canonical URI, or relative to any containing resource's URI.

    +

    + Conceptually, a set of linked schema resources should behave + identically whether each resource is a separate document connected with + schema references (Section 8.2.3), or is structured as + a single document with one or more schema resources embedded as + subschemas.

    +

    + Since URIs involving JSON Pointer fragments relative to the parent + schema resource's URI cease to be valid when the embedded schema + is moved to a separate document and referenced, applications and schemas + SHOULD NOT use such URIs to identify embedded schema resources or + locations within them.

    +

    + Consider the following schema document that contains another + schema resource embedded within it:

    +
    +
    +
    +{
    +    "$id": "https://example.com/foo",
    +    "items": {
    +        "$id": "https://example.com/bar",
    +        "additionalProperties": { }
    +    }
    +}
    +
    +
    +
    +

    + The URI "https://example.com/foo#/items" points to the "items" schema, + which is an embedded resource. The canonical URI of that schema + resource, however, is "https://example.com/bar".

    +

    + For the "additionalProperties" schema within that embedded resource, + the URI "https://example.com/foo#/items/additionalProperties" points + to the correct object, but that object's URI relative to its resource's + canonical URI is "https://example.com/bar#/additionalProperties".

    +

    + Now consider the following two schema resources linked by reference + using a URI value for "$ref":

    +
    +
    +
    +{
    +    "$id": "https://example.com/foo",
    +    "items": {
    +        "$ref": "bar"
    +    }
    +}
    +
    +{
    +    "$id": "https://example.com/bar",
    +    "additionalProperties": { }
    +}
    +
    +
    +
    +

    + Here we see that "https://example.com/bar#/additionalProperties", + using a JSON Pointer fragment appended to the canonical URI of + the "bar" schema resource, is still valid, while + "https://example.com/foo#/items/additionalProperties", which relied + on a JSON Pointer fragment appended to the canonical URI of the + "foo" schema resource, no longer resolves to anything.

    +

    + Note also that "https://example.com/foo#/items" is valid in both + arrangements, but resolves to a different value. This URI ends up + functioning similarly to a retrieval URI for a resource. While this URI + is valid, it is more robust to use the "$id" of the embedded or referenced + resource unless it is specifically desired to identify the object containing + the "$ref" in the second (non-embedded) arrangement.

    +

    + An implementation MAY choose not to support addressing schema resource + contents by URIs using a base other than the resource's canonical URI, + plus a JSON Pointer fragment relative to that base. Therefore, schema + authors SHOULD NOT rely on such URIs, as using them may reduce interoperability. + + This is to avoid requiring implementations to keep track of a whole + stack of possible base URIs and JSON Pointer fragments for each, + given that all but one will be fragile if the schema resources + are reorganized. Some + have argued that this is easy so there is + no point in forbidding it, while others have argued that it complicates + schema identification and should be forbidden. Feedback on this + topic is encouraged. + After some discussion, we feel that we need to remove the use of + "canonical" in favour of talking about JSON Pointers which reference + across schema resource boundaries as undefined or even forbidden behavior + (https://github.com/json-schema-org/json-schema-spec/issues/937, + https://github.com/json-schema-org/json-schema-spec/issues/1183) +

    +

    + Further examples of such non-canonical URI construction, as well as + the appropriate canonical URI-based fragments to use instead, + are provided in appendix A.

    +
    +
    +
    +
    +

    +9.3. Compound Documents +

    +

    + A Compound Schema Document is defined as a JSON document (sometimes called a "bundled" schema) + which has multiple embedded JSON Schema Resources bundled into the same document to + ease transportation.

    +

    + Each embedded Schema Resource MUST be treated as an individual Schema Resource, following standard + schema loading and processing requirements, including determining vocabulary support.

    +
    +

    +9.3.1. Bundling +

    +

    + The bundling process for creating a Compound Schema Document is defined as taking + references (such as "$ref") to an external Schema Resource and embedding the referenced + Schema Resources within the referring document. Bundling SHOULD be done in such a way that + all URIs (used for referencing) in the base document and any referenced/embedded + documents do not require altering.

    +

    + Each embedded JSON Schema Resource MUST identify itself with a URI using the "$id" keyword, + and SHOULD make use of the "$schema" keyword to identify the dialect it is using, in the root of the + schema resource. It is RECOMMENDED that the URI identifier value of "$id" be an Absolute URI.

    +

    + When the Schema Resource referenced by a by-reference applicator is bundled, it is RECOMMENDED that + the Schema Resource be located as a value of a "$defs" object at the containing schema's root. + The key of the "$defs" for the now embedded Schema Resource MAY be the "$id" of the bundled schema + or some other form of application defined unique identifer (such as a UUID). This key is not + intended to be referenced in JSON Schema, but may be used by an application to aid the + bundling process.

    +

    + A Schema Resource MAY be embedded in a location other than "$defs" where the location is defined + as a schema value.

    +

    + A Bundled Schema Resource MUST NOT be bundled by replacing the schema object from which it was + referenced, or by wrapping the Schema Resource in other applicator keywords.

    +

    + In order to produce identical output, references in the containing schema document to the + previously external Schema Resources MUST NOT be changed, and now resolve to a schema using the + "$id" of an embedded Schema Resource. Such identical output includes validation evaluation and URIs + or paths used in resulting annotations or errors.

    +

    + While the bundling process will often be the main method for creating a Compound Schema Document, + it is also possible and expected that some will be created by hand, potentially without individual + Schema Resources existing on their own previously.

    +
    +
    +

    +9.3.2. Differing and Default Dialects +

    +

    + When multiple schema resources are present in a single document, + schema resources which do not define with which dialect they should be processed + MUST be processed with the same dialect as the enclosing resource.

    +

    + Since any schema that can be referenced can also be embedded, embedded schema resources MAY + specify different processing dialects using the "$schema" values from their enclosing resource.

    +
    +
    +

    +9.3.3. Validating +

    +

    + Given that a Compound Schema Document may have embedded resources which identify as using different + dialects, these documents SHOULD NOT be validated by applying a meta-schema + to the Compound Schema Document as an instance. It is RECOMMENDED that an alternate + validation process be provided in order to validate Schema Documents. Each Schema Resource + SHOULD be separately validated against its associated meta-schema. + + If you know a schema is what's being validated, you can identify if the schemas + is a Compound Schema Document or not, by way of use of "$id", which identifies an + embedded resource when used not at the document's root. +

    +

    + A Compound Schema Document in which all embedded resources identify as using the same + dialect, or in which "$schema" is omitted and therefore defaults to that of the enclosing resource, + MAY be validated by applying the appropriate meta-schema.

    +
    +
    +
    +

    +9.4. Caveats +

    +
    +

    +9.4.1. Guarding Against Infinite Recursion +

    +

    + A schema MUST NOT be run into an infinite loop against an instance. For + example, if two schemas "#alice" and "#bob" both have an "allOf" property + that refers to the other, a naive validator might get stuck in an infinite + recursive loop trying to validate the instance. Schemas SHOULD NOT make + use of infinite recursive nesting like this; the behavior is undefined.

    +
    +
    +
    +

    +9.4.2. References to Possible Non-Schemas +

    +

    + Subschema objects (or booleans) are recognized by their use with known + applicator keywords or with location-reserving keywords such as + "$defs" (Section 8.2.4) that take one or more subschemas + as a value. These keywords may be "$defs" and the standard applicators + from this document, or extension keywords from a known vocabulary, or + implementation-specific custom keywords.

    +

    + Multi-level structures of unknown keywords are capable of introducing + nested subschemas, which would be subject to the processing rules for + "$id". Therefore, having a reference target in such an unrecognized + structure cannot be reliably implemented, and the resulting behavior + is undefined. Similarly, a reference target under a known keyword, + for which the value is known not to be a schema, results in undefined + behavior in order to avoid burdening implementations with the need + to detect such targets. + + These scenarios are analogous to fetching a schema over HTTP + but receiving a response with a Content-Type other than + application/schema+json. An implementation can certainly + try to interpret it as a schema, but the origin server + offered no guarantee that it actually is any such thing. + Therefore, interpreting it as such has security implications + and may produce unpredictable results. +

    +

    + Note that single-level custom keywords with identical syntax and + semantics to "$defs" do not allow for any intervening "$id" keywords, + and therefore will behave correctly under implementations that attempt + to use any reference target as a schema. However, this behavior is + implementation-specific and MUST NOT be relied upon for interoperability.

    +
    +
    +
    +
    +

    +9.5. Associating Instances and Schemas +

    +
    +
    +

    +9.5.1. Usage for Hypermedia +

    +

    + JSON has been adopted widely by HTTP servers for automated APIs and robots. This + section describes how to enhance processing of JSON documents in a more RESTful + manner when used with protocols that support media types and + Web linking [RFC8288].

    +
    +
    +9.5.1.1. Linking to a Schema +
    +

    + It is RECOMMENDED that instances described by a schema provide a link to + a downloadable JSON Schema using the link relation "describedby", as defined by + Linked Data Protocol 1.0, section 8.1 [W3C.REC-ldp-20150226].

    +

    + In HTTP, such links can be attached to any response using the + Link header [RFC8288]. An example of such a header would be:

    +
    +
    +
    +        Link: <https://example.com/my-hyper-schema>; rel="describedby"
    +
    +
    +
    +
    +
    +
    +9.5.1.2. Usage Over HTTP +
    +

    + When used for hypermedia systems over a network, + HTTP [RFC7231] is frequently the protocol of choice for + distributing schemas. Misbehaving clients can pose problems for server + maintainers if they pull a schema over the network more frequently than + necessary, when it's instead possible to cache a schema for a long period of + time.

    +

    + HTTP servers SHOULD set long-lived caching headers on JSON Schemas. + HTTP clients SHOULD observe caching headers and not re-request documents within + their freshness period. + Distributed systems SHOULD make use of a shared cache and/or caching proxy.

    +

    + Clients SHOULD set or prepend a User-Agent header specific to the JSON Schema + implementation or software product. Since symbols are listed in decreasing order + of significance, the JSON Schema library name/version should precede the more + generic HTTP library name (if any). For example:

    +
    +
    +
    +        User-Agent: product-name/5.4.1 so-cool-json-schema/1.0.2 curl/7.43.0
    +
    +
    +
    +

    + Clients SHOULD be able to make requests with a "From" header so that server + operators can contact the owner of a potentially misbehaving script.

    +
    +
    +
    +
    +
    +
    +

    +10. A Vocabulary for Applying Subschemas +

    +

    + This section defines a vocabulary of applicator keywords that + are RECOMMENDED for use as the basis of other vocabularies.

    +

    + Meta-schemas that do not use "$vocabulary" SHOULD be considered to + require this vocabulary as if its URI were present with a value of true.

    +

    + The current URI for this vocabulary, known as the Applicator vocabulary, is: + <https://json-schema.org/draft/2020-12/vocab/applicator>.

    +

    + The current URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/applicator.

    +
    +

    +10.1. Keyword Independence +

    +

    + Schema keywords typically operate independently, without + affecting each other's outcomes.

    +

    + For schema author convenience, there are some exceptions among the + keywords in this vocabulary:

    +
      +
    • + "additionalProperties", whose behavior is defined in terms of + "properties" and "patternProperties" +
    • +
    • + "items", whose behavior is defined in terms of "prefixItems" +
    • +
    • + "contains", whose behavior is affected by the presence and value of + "minContains", in the Validation vocabulary +
    • +
    +
    +
    +
    +

    +10.2. Keywords for Applying Subschemas in Place +

    +

    + These keywords apply subschemas to the same location in the instance + as the parent schema is being applied. They allow combining + or modifying the subschema results in various ways.

    +

    + Subschemas of these keywords evaluate the instance completely independently + such that the results of one such subschema MUST NOT impact the results of sibling + subschemas. Therefore subschemas may be applied in + any order.

    +
    +
    +

    +10.2.1. Keywords for Applying Subschemas With Logic +

    +

    + These keywords correspond to logical operators for combining or modifying + the boolean assertion results of the subschemas. They have no direct + impact on annotation collection, although they enable the same annotation + keyword to be applied to an instance location with different values. + Annotation keywords define their own rules for combining such values.

    +
    +
    +
    +10.2.1.1. allOf +
    +

    + This keyword's value MUST be a non-empty array. + Each item of the array MUST be a valid JSON Schema.

    +

    + An instance validates successfully against this keyword if it validates + successfully against all schemas defined by this keyword's value.

    +
    +
    +
    +
    +10.2.1.2. anyOf +
    +

    + This keyword's value MUST be a non-empty array. + Each item of the array MUST be a valid JSON Schema.

    +

    + An instance validates successfully against this keyword if it validates + successfully against at least one schema defined by this keyword's value. + Note that when annotations are being collected, all subschemas MUST + be examined so that annotations are collected from each subschema + that validates successfully.

    +
    +
    +
    +10.2.1.3. oneOf +
    +

    + This keyword's value MUST be a non-empty array. + Each item of the array MUST be a valid JSON Schema.

    +

    + An instance validates successfully against this keyword if it validates + successfully against exactly one schema defined by this keyword's value.

    +
    +
    +
    +
    +10.2.1.4. not +
    +

    + This keyword's value MUST be a valid JSON Schema.

    +

    + An instance is valid against this keyword if it fails to validate + successfully against the schema defined by this keyword.

    +
    +
    +
    +
    +
    +
    +

    +10.2.2. Keywords for Applying Subschemas Conditionally +

    +

    + Three of these keywords work together to implement conditional + application of a subschema based on the outcome of another subschema. + The fourth is a shortcut for a specific conditional case.

    +

    + "if", "then", and "else" MUST NOT interact with each other across + subschema boundaries. In other words, an "if" in one + branch of an "allOf" MUST NOT have an impact on a "then" + or "else" in another branch.

    +

    + There is no default behavior for "if", "then", or "else" + when they are not present. In particular, they MUST NOT + be treated as if present with an empty schema, and when + "if" is not present, both "then" and "else" MUST be + entirely ignored.

    +
    +
    +10.2.2.1. if +
    +

    + This keyword's value MUST be a valid JSON Schema.

    +

    + This validation outcome of this keyword's subschema + has no direct effect on the overall validation + result. Rather, it controls which of the "then" + or "else" keywords are evaluated.

    +

    + Instances that successfully validate against this + keyword's subschema MUST also be valid against + the subschema value of the "then" keyword, if + present.

    +

    + Instances that fail to validate against this + keyword's subschema MUST also be valid against + the subschema value of the "else" keyword, if + present.

    +

    + If annotations (Section 7.7) + are being collected, they are collected from this + keyword's subschema in the usual way, including when + the keyword is present without either "then" or "else".

    +
    +
    +
    +10.2.2.2. then +
    +

    + This keyword's value MUST be a valid JSON Schema.

    +

    + When "if" is present, and the instance successfully + validates against its subschema, then validation + succeeds against this keyword if the instance also + successfully validates against this keyword's subschema.

    +

    + This keyword has no effect when "if" is absent, or + when the instance fails to validate against its + subschema. Implementations MUST NOT evaluate + the instance against this keyword, for either validation + or annotation collection purposes, in such cases.

    +
    +
    +
    +10.2.2.3. else +
    +

    + This keyword's value MUST be a valid JSON Schema.

    +

    + When "if" is present, and the instance fails to + validate against its subschema, then validation + succeeds against this keyword if the instance + successfully validates against this keyword's subschema.

    +

    + This keyword has no effect when "if" is absent, or + when the instance successfully validates against its + subschema. Implementations MUST NOT evaluate + the instance against this keyword, for either validation + or annotation collection purposes, in such cases.

    +
    +
    +
    +10.2.2.4. dependentSchemas +
    +

    + This keyword specifies subschemas that are evaluated if the instance + is an object and contains a certain property.

    +

    + This keyword's value MUST be an object. + Each value in the object MUST be a valid JSON Schema.

    +

    + If the object key is a property in the instance, the entire + instance must validate against the subschema. Its use is + dependent on the presence of the property.

    +

    + Omitting this keyword has the same behavior as an empty object.

    +
    +
    +
    +
    +
    +
    +

    +10.3. Keywords for Applying Subschemas to Child Instances +

    +

    + Each of these keywords defines a rule for applying its + subschema(s) to child instances, specifically object + properties and array items, and combining their results.

    +
    +

    +10.3.1. Keywords for Applying Subschemas to Arrays +

    +
    +
    +10.3.1.1. prefixItems +
    +

    + The value of "prefixItems" MUST be a non-empty array of valid JSON Schemas.

    +

    + Validation succeeds if each element of the instance validates + against the schema at the same position, if any. This keyword + does not constrain the length of the array. If the array is longer + than this keyword's value, this keyword validates only the + prefix of matching length.

    +

    + This keyword produces an annotation value which is the largest + index to which this keyword applied a subschema. The value + MAY be a boolean true if a subschema was applied to every + index of the instance, such as is produced by the "items" keyword. + This annotation affects the behavior of "items" and "unevaluatedItems".

    +

    + Omitting this keyword has the same assertion behavior as + an empty array.

    +
    +
    +
    +
    +10.3.1.2. items +
    +

    + The value of "items" MUST be a valid JSON Schema.

    +

    + This keyword applies its subschema to all instance elements + at indexes greater than the length of the "prefixItems" array + in the same schema object, as reported by the annotation result + of that "prefixItems" keyword. If no such annotation + result exists, "items" applies its subschema to all instance + array elements. + + Note that the behavior of "items" without "prefixItems" is + identical to that of the schema form of "items" in prior drafts. + When "prefixItems" is present, the behavior of "items" is + identical to the former "additionalItems" keyword. +

    +

    + If the "items" subschema is applied to any + positions within the instance array, it produces an + annotation result of boolean true, indicating that all remaining array + elements have been evaluated against this keyword's subschema. + This annotation affects the behavior of "unevaluatedItems" in the + Unevaluated vocabulary.

    +

    + Omitting this keyword has the same assertion behavior as + an empty schema.

    +

    + Implementations MAY choose to implement or optimize this keyword + in another way that produces the same effect, such as by directly + checking for the presence and size of a "prefixItems" array. + Implementations that do not support annotation collection MUST do so.

    +
    +
    +
    +
    +10.3.1.3. contains +
    +

    + The value of this keyword MUST be a valid JSON Schema.

    +

    + An array instance is valid against "contains" if at least one of + its elements is valid against the given schema, + except when "minContains" is present and has a value of 0, in which + case an array instance MUST be considered valid against the "contains" keyword, + even if none of its elements is valid against the given schema.

    +

    + This keyword produces an annotation value which is an array of + the indexes to which this keyword validates successfully when applying + its subschema, in ascending order. The value MAY be a boolean "true" if + the subschema validates successfully when applied to every index of the + instance. The annotation MUST be present if the instance array to which + this keyword's schema applies is empty.

    +

    + This annotation affects the behavior of "unevaluatedItems" in the + Unevaluated vocabulary, and MAY also be used to implement the + "minContains" and "maxContains" keywords in the Validation vocabulary.

    +

    + The subschema MUST be applied to every array element even after the first + match has been found, in order to collect annotations for use by other + keywords. This is to ensure that all possible annotations are collected.

    +
    +
    +
    +

    +10.3.2. Keywords for Applying Subschemas to Objects +

    +
    +
    +10.3.2.1. properties +
    +

    + The value of "properties" MUST be an object. + Each value of this object MUST be a valid JSON Schema.

    +

    + Validation succeeds if, for each name that appears in both + the instance and as a name within this keyword's value, the child + instance for that name successfully validates against the + corresponding schema.

    +

    + The annotation result of this keyword is the set of instance + property names matched by this keyword. + This annotation affects the behavior of "additionalProperties" (in + this vocabulary) and "unevaluatedProperties" in the Unevaluated vocabulary.

    +

    + Omitting this keyword has the same assertion behavior as + an empty object.

    +
    +
    +
    +10.3.2.2. patternProperties +
    +

    + The value of "patternProperties" MUST be an object. Each property name + of this object SHOULD be a valid regular expression, according to the + ECMA-262 regular expression dialect. Each property value of this object + MUST be a valid JSON Schema.

    +

    + Validation succeeds if, for each instance name that matches any + regular expressions that appear as a property name in this keyword's value, + the child instance for that name successfully validates against each + schema that corresponds to a matching regular expression.

    +

    + The annotation result of this keyword is the set of instance + property names matched by this keyword. + This annotation affects the behavior of "additionalProperties" (in this + vocabulary) and "unevaluatedProperties" (in the Unevaluated vocabulary).

    +

    + Omitting this keyword has the same assertion behavior as + an empty object.

    +
    +
    +
    +
    +10.3.2.3. additionalProperties +
    +

    + The value of "additionalProperties" MUST be a valid JSON Schema.

    +

    + The behavior of this keyword depends on the presence and + annotation results of "properties" and "patternProperties" + within the same schema object. + Validation with "additionalProperties" applies only to the child + values of instance names that do not appear in the annotation + results of either "properties" or "patternProperties".

    +

    + For all such properties, validation succeeds if the child instance + validates against the "additionalProperties" schema.

    +

    + The annotation result of this keyword is the set of instance + property names validated by this keyword's subschema. + This annotation affects the behavior of "unevaluatedProperties" + in the Unevaluated vocabulary.

    +

    + Omitting this keyword has the same assertion behavior as + an empty schema.

    +

    + Implementations MAY choose to implement or optimize this keyword + in another way that produces the same effect, such as by directly + checking the names in "properties" and the patterns in + "patternProperties" against the instance property set. + Implementations that do not support annotation collection MUST do so. + + In defining this option, it seems there is the potential for + ambiguity in the output format. The ambiguity does not affect validation results, + but it does affect the resulting output format. + The ambiguity allows for multiple valid output results depending on whether annotations + are used or a solution that "produces the same effect" as draft-07. It is understood + that annotations from failing schemas are dropped. + See our + [Decision Record](https://github.com/json-schema-org/json-schema-spec/tree/HEAD/adr/2022-04-08-cref-for-ambiguity-and-fix-later-gh-spec-issue-1172.md) + for further details. +

    +
    +
    +
    +
    +10.3.2.4. propertyNames +
    +

    + The value of "propertyNames" MUST be a valid JSON Schema.

    +

    + If the instance is an object, this keyword validates if every property name in + the instance validates against the provided schema. + Note the property name that the schema is testing will always be a string.

    +

    + Omitting this keyword has the same behavior as an empty schema.

    +
    +
    +
    +
    +
    +

    +11. A Vocabulary for Unevaluated Locations +

    +

    + The purpose of these keywords is to enable schema authors to apply + subschemas to array items or object properties that have not been + successfully evaluated against any dynamic-scope subschema of any + adjacent keywords.

    +

    + These instance items or properties may have been unsuccessfully evaluated + against one or more adjacent keyword subschemas, such as when an assertion + in a branch of an "anyOf" fails. Such failed evaluations are not considered + to contribute to whether or not the item or property has been evaluated. + Only successful evaluations are considered.

    +

    + If an item in an array or an object property is "successfully evaluated", it + is logically considered to be valid in terms of the representation of the + object or array that's expected. For example if a subschema represents a car, + which requires between 2-4 wheels, and the value of "wheels" is 6, the instance + object is not "evaluated" to be a car, and the "wheels" property is considered + "unevaluated (successfully as a known thing)", and does not retain any annotations.

    +

    + Recall that adjacent keywords are keywords within the same schema object, + and that the dynamic-scope subschemas include reference targets as well as + lexical subschemas.

    +

    + The behavior of these keywords depend on the annotation results of + adjacent keywords that apply to the instance location being validated.

    +

    + Meta-schemas that do not use "$vocabulary" SHOULD be considered to + require this vocabulary as if its URI were present with a value of true.

    +

    + The current URI for this vocabulary, known as the Unevaluated Applicator + vocabulary, is: + <https://json-schema.org/draft/2020-12/vocab/unevaluated>.

    +

    + The current URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/unevaluated.

    +
    +

    +11.1. Keyword Independence +

    +

    + Schema keywords typically operate independently, without + affecting each other's outcomes. However, the keywords in this + vocabulary are notable exceptions:

    +
      +
    • + "unevaluatedItems", whose behavior is defined in terms of annotations + from "prefixItems", "items", "contains", and itself +
    • +
    • + "unevaluatedProperties", whose behavior is defined in terms of + annotations from "properties", "patternProperties", + "additionalProperties" and itself +
    • +
    +
    +
    +
    +

    +11.2. unevaluatedItems +

    +

    + The value of "unevaluatedItems" MUST be a valid JSON Schema.

    +

    + The behavior of this keyword depends on the annotation results of + adjacent keywords that apply to the instance location being validated. + Specifically, the annotations from "prefixItems", "items", and "contains", + which can come from those keywords when they are adjacent to the + "unevaluatedItems" keyword. Those three annotations, as well as + "unevaluatedItems", can also result from any and all adjacent + in-place applicator (Section 10.2) keywords. + This includes but is not limited to the in-place applicators + defined in this document.

    +

    + If no relevant annotations are present, the "unevaluatedItems" + subschema MUST be applied to all locations in the array. + If a boolean true value is present from any of the relevant annotations, + "unevaluatedItems" MUST be ignored. Otherwise, the subschema + MUST be applied to any index greater than the largest annotation + value for "prefixItems", which does not appear in any annotation + value for "contains".

    +

    + This means that "prefixItems", "items", "contains", and all in-place + applicators MUST be evaluated before this keyword can be evaluated. + Authors of extension keywords MUST NOT define an in-place applicator + that would need to be evaluated after this keyword.

    +

    + If the "unevaluatedItems" subschema is applied to any + positions within the instance array, it produces an + annotation result of boolean true, analogous to the + behavior of "items". + This annotation affects the behavior of "unevaluatedItems" in parent schemas.

    +

    + Omitting this keyword has the same assertion behavior as + an empty schema.

    +
    +
    +
    +
    +

    +11.3. unevaluatedProperties +

    +

    + The value of "unevaluatedProperties" MUST be a valid JSON Schema.

    +

    + The behavior of this keyword depends on the annotation results of + adjacent keywords that apply to the instance location being validated. + Specifically, the annotations from "properties", "patternProperties", + and "additionalProperties", which can come from those keywords when + they are adjacent to the "unevaluatedProperties" keyword. Those + three annotations, as well as "unevaluatedProperties", can also + result from any and all adjacent + in-place applicator (Section 10.2) keywords. + This includes but is not limited to the in-place applicators + defined in this document.

    +

    + Validation with "unevaluatedProperties" applies only to the child + values of instance names that do not appear in the "properties", + "patternProperties", "additionalProperties", or + "unevaluatedProperties" annotation results that apply to the + instance location being validated.

    +

    + For all such properties, validation succeeds if the child instance + validates against the "unevaluatedProperties" schema.

    +

    + This means that "properties", "patternProperties", "additionalProperties", + and all in-place applicators MUST be evaluated before this keyword can + be evaluated. Authors of extension keywords MUST NOT define an in-place + applicator that would need to be evaluated after this keyword.

    +

    + The annotation result of this keyword is the set of instance + property names validated by this keyword's subschema. + This annotation affects the behavior of "unevaluatedProperties" in parent schemas.

    +

    + Omitting this keyword has the same assertion behavior as + an empty schema.

    +
    +
    +
    +
    +
    +

    +12. Output Formatting +

    +

    + JSON Schema is defined to be platform-independent. As such, to increase compatibility + across platforms, implementations SHOULD conform to a standard validation output + format. This section describes the minimum requirements that consumers will need to + properly interpret validation results.

    +
    +

    +12.1. Format +

    +

    + JSON Schema output is defined using the JSON Schema data instance model as described + in section 4.2.1. Implementations MAY deviate from this as supported by their + specific languages and platforms, however it is RECOMMENDED that the output be + convertible to the JSON format defined herein via serialization or other means.

    +
    +
    +

    +12.2. Output Formats +

    +

    + This specification defines four output formats. See the "Output Structure" + section for the requirements of each format.

    +
      +
    • + Flag - A boolean which simply indicates the overall validation result + with no further details. +
    • +
    • + Basic - Provides validation information in a flat list structure. +
    • +
    • + Detailed - Provides validation information in a condensed hierarchical + structure based on the structure of the schema. +
    • +
    • + Verbose - Provides validation information in an uncondensed hierarchical + structure that matches the exact structure of the schema. +
    • +
    +

    + An implementation SHOULD provide at least one of the "flag", "basic", or "detailed" + format and MAY provide the "verbose" format. If it provides one or more of the + "detailed" or "verbose" formats, it MUST also provide the "flag" format. + Implementations SHOULD specify in their documentation which formats they support.

    +
    +
    +

    +12.3. Minimum Information +

    +

    + Beyond the simplistic "flag" output, additional information is useful to aid in + debugging a schema or instance. Each sub-result SHOULD contain the information + contained within this section at a minimum.

    +

    + A single object that contains all of these components is considered an + output unit.

    +

    + Implementations MAY elect to provide additional information.

    +
    +

    +12.3.1. Keyword Relative Location +

    +

    + The relative location of the validating keyword that follows the validation + path. The value MUST be expressed as a JSON Pointer, and it MUST include + any by-reference applicators such as "$ref" or "$dynamicRef".

    +
    +
    +
    +/properties/width/$ref/minimum
    +
    +
    +
    +

    + Note that this pointer may not be resolvable by the normal JSON Pointer process + due to the inclusion of these by-reference applicator keywords.

    +

    + The JSON key for this information is "keywordLocation".

    +
    +
    +

    +12.3.2. Keyword Absolute Location +

    +

    + The absolute, dereferenced location of the validating keyword. The value MUST + be expressed as a full URI using the canonical URI of the relevant schema resource + with a JSON Pointer fragment, and it MUST NOT include by-reference applicators + such as "$ref" or "$dynamicRef" as non-terminal path components. + It MAY end in such keywords if the error or annotation is for that + keyword, such as an unresolvable reference. + + Note that "absolute" here is in the sense of "absolute filesystem path" + (meaning the complete location) rather than the "absolute-URI" + terminology from RFC 3986 (meaning with scheme but without fragment). + Keyword absolute locations will have a fragment in order to + identify the keyword. +

    +
    +
    +
    +https://example.com/schemas/common#/$defs/count/minimum
    +
    +
    +
    +

    + This information MAY be omitted only if either the dynamic scope did not pass + over a reference or if the schema does not declare an absolute URI as its "$id".

    +

    + The JSON key for this information is "absoluteKeywordLocation".

    +
    +
    +

    +12.3.3. Instance Location +

    +

    + The location of the JSON value within the instance being validated. The + value MUST be expressed as a JSON Pointer.

    +

    + The JSON key for this information is "instanceLocation".

    +
    +
    +

    +12.3.4. Error or Annotation +

    +

    + The error or annotation that is produced by the validation.

    +

    + For errors, the specific wording for the message is not defined by this + specification. Implementations will need to provide this.

    +

    + For annotations, each keyword that produces an annotation specifies its + format. By default, it is the keyword's value.

    +

    + The JSON key for failed validations is "error"; for successful validations + it is "annotation".

    +
    +
    +

    +12.3.5. Nested Results +

    +

    + For the two hierarchical structures, this property will hold nested errors + and annotations.

    +

    + The JSON key for nested results in failed validations is "errors"; for + successful validations it is "annotations". Note the plural forms, as + a keyword with nested results can also have a local error or annotation.

    +
    +
    +
    +

    +12.4. Output Structure +

    +

    + The output MUST be an object containing a boolean property named "valid". When + additional information about the result is required, the output MUST also contain + "errors" or "annotations" as described below.

    +
      +
    • + "valid" - a boolean value indicating the overall validation success or + failure +
    • +
    • + "errors" - the collection of errors or annotations produced by a failed + validation +
    • +
    • + "annotations" - the collection of errors or annotations produced by a + successful validation +
    • +
    +

    + For these examples, the following schema and instance will be used.

    +
    +
    +
    +{
    +  "$id": "https://example.com/polygon",
    +  "$schema": "https://json-schema.org/draft/2020-12/schema",
    +  "$defs": {
    +    "point": {
    +      "type": "object",
    +      "properties": {
    +        "x": { "type": "number" },
    +        "y": { "type": "number" }
    +      },
    +      "additionalProperties": false,
    +      "required": [ "x", "y" ]
    +    }
    +  },
    +  "type": "array",
    +  "items": { "$ref": "#/$defs/point" },
    +  "minItems": 3
    +}
    +
    +[
    +  {
    +    "x": 2.5,
    +    "y": 1.3
    +  },
    +  {
    +    "x": 1,
    +    "z": 6.7
    +  }
    +]
    +
    +
    +
    +

    + This instance will fail validation and produce errors, but it's trivial to deduce + examples for passing schemas that produce annotations.

    +

    + Specifically, the errors it will produce are:

    +
      +
    • + The second object is missing a "y" property. +
    • +
    • + The second object has a disallowed "z" property. +
    • +
    • + There are only two objects, but three are required. +
    • +
    +

    + Note that the error message wording as depicted in these examples is not a + requirement of this specification. Implementations SHOULD craft error messages + tailored for their audience or provide a templating mechanism that allows their + users to craft their own messages.

    +
    +

    +12.4.1. Flag +

    +

    + In the simplest case, merely the boolean result for the "valid" valid property + needs to be fulfilled.

    +
    +
    +
    +{
    +  "valid": false
    +}
    +
    +
    +
    +

    + Because no errors or annotations are returned with this format, it is + RECOMMENDED that implementations use short-circuiting logic to return + failure or success as soon as the outcome can be determined. For example, + if an "anyOf" keyword contains five sub-schemas, and the second one + passes, there is no need to check the other three. The logic can simply + return with success.

    +
    +
    +

    +12.4.2. Basic +

    +

    + The "Basic" structure is a flat list of output units.

    +
    +
    +
    +{
    +  "valid": false,
    +  "errors": [
    +    {
    +      "keywordLocation": "",
    +      "instanceLocation": "",
    +      "error": "A subschema had errors."
    +    },
    +    {
    +      "keywordLocation": "/items/$ref",
    +      "absoluteKeywordLocation":
    +        "https://example.com/polygon#/$defs/point",
    +      "instanceLocation": "/1",
    +      "error": "A subschema had errors."
    +    },
    +    {
    +      "keywordLocation": "/items/$ref/required",
    +      "absoluteKeywordLocation":
    +        "https://example.com/polygon#/$defs/point/required",
    +      "instanceLocation": "/1",
    +      "error": "Required property 'y' not found."
    +    },
    +    {
    +      "keywordLocation": "/items/$ref/additionalProperties",
    +      "absoluteKeywordLocation":
    +        "https://example.com/polygon#/$defs/point/additionalProperties",
    +      "instanceLocation": "/1/z",
    +      "error": "Additional property 'z' found but was invalid."
    +    },
    +    {
    +      "keywordLocation": "/minItems",
    +      "instanceLocation": "",
    +      "error": "Expected at least 3 items but found 2"
    +    }
    +  ]
    +}
    +
    +
    +
    +
    +
    +

    +12.4.3. Detailed +

    +

    + The "Detailed" structure is based on the schema and can be more readable + for both humans and machines. Having the structure organized this way makes + associations between the errors more apparent. For example, the fact that + the missing "y" property and the extra "z" property both stem from the same + location in the instance is not immediately obvious in the "Basic" structure. + In a hierarchy, the correlation is more easily identified.

    +

    + The following rules govern the construction of the results object:

    +
      +
    • + All applicator keywords ("*Of", "$ref", "if"/"then"/"else", etc.) require + a node. +
    • +
    • + Nodes that have no children are removed. +
    • +
    • + Nodes that have a single child are replaced by the child. +
    • +
    +

    + Branch nodes do not require an error message or an annotation.

    +
    +
    +
    +{
    +  "valid": false,
    +  "keywordLocation": "",
    +  "instanceLocation": "",
    +  "errors": [
    +    {
    +      "valid": false,
    +      "keywordLocation": "/items/$ref",
    +      "absoluteKeywordLocation":
    +        "https://example.com/polygon#/$defs/point",
    +      "instanceLocation": "/1",
    +      "errors": [
    +        {
    +          "valid": false,
    +          "keywordLocation": "/items/$ref/required",
    +          "absoluteKeywordLocation":
    +            "https://example.com/polygon#/$defs/point/required",
    +          "instanceLocation": "/1",
    +          "error": "Required property 'y' not found."
    +        },
    +        {
    +          "valid": false,
    +          "keywordLocation": "/items/$ref/additionalProperties",
    +          "absoluteKeywordLocation":
    +            "https://example.com/polygon#/$defs/point/additionalProperties",
    +          "instanceLocation": "/1/z",
    +          "error": "Additional property 'z' found but was invalid."
    +        }
    +      ]
    +    },
    +    {
    +      "valid": false,
    +      "keywordLocation": "/minItems",
    +      "instanceLocation": "",
    +      "error": "Expected at least 3 items but found 2"
    +    }
    +  ]
    +}
    +
    +
    +
    +
    +
    +

    +12.4.4. Verbose +

    +

    + The "Verbose" structure is a fully realized hierarchy that exactly matches + that of the schema. This structure has applications in form generation and + validation where the error's location is important.

    +

    + The primary difference between this and the "Detailed" structure is that + all results are returned. This includes sub-schema validation results that + would otherwise be removed (e.g. annotations for failed validations, + successful validations inside a `not` keyword, etc.). Because of this, it + is RECOMMENDED that each node also carry a `valid` property to indicate the + validation result for that node.

    +

    + Because this output structure can be quite large, a smaller example is given + here for brevity. The URI of the full output structure of the example above is: + https://json-schema.org/draft/2020-12/output/verbose-example.

    +
    +
    +
    +// schema
    +{
    +  "$id": "https://example.com/polygon",
    +  "$schema": "https://json-schema.org/draft/2020-12/schema",
    +  "type": "object",
    +  "properties": {
    +    "validProp": true,
    +  },
    +  "additionalProperties": false
    +}
    +
    +// instance
    +{
    +  "validProp": 5,
    +  "disallowedProp": "value"
    +}
    +
    +// result
    +{
    +  "valid": false,
    +  "keywordLocation": "",
    +  "instanceLocation": "",
    +  "errors": [
    +    {
    +      "valid": true,
    +      "keywordLocation": "/type",
    +      "instanceLocation": ""
    +    },
    +    {
    +      "valid": true,
    +      "keywordLocation": "/properties",
    +      "instanceLocation": ""
    +    },
    +    {
    +      "valid": false,
    +      "keywordLocation": "/additionalProperties",
    +      "instanceLocation": "",
    +      "errors": [
    +        {
    +          "valid": false,
    +          "keywordLocation": "/additionalProperties",
    +          "instanceLocation": "/disallowedProp",
    +          "error": "Additional property 'disallowedProp' found but was invalid."
    +        }
    +      ]
    +    }
    +  ]
    +}
    +
    +
    +
    +
    +
    +

    +12.4.5. Output validation schemas +

    +

    + For convenience, JSON Schema has been provided to validate output generated + by implementations. Its URI is: + https://json-schema.org/draft/2020-12/output/schema.

    +
    +
    +
    +
    +
    +
    +

    +13. Security Considerations +

    +

    + Both schemas and instances are JSON values. As such, all security considerations + defined in RFC 8259 [RFC8259] apply.

    +

    + Instances and schemas are both frequently written by untrusted third parties, to be + deployed on public Internet servers. + Validators should take care that the parsing and validating against schemas does not consume excessive + system resources. + Validators MUST NOT fall into an infinite loop.

    +

    + A malicious party could cause an implementation to repeatedly collect a copy + of a very large value as an annotation. Implementations SHOULD guard against + excessive consumption of system resources in such a scenario.

    +

    + Servers MUST ensure that malicious parties cannot change the functionality of + existing schemas by uploading a schema with a pre-existing or very similar "$id".

    +

    + Individual JSON Schema vocabularies are liable to also have their own security + considerations. Consult the respective specifications for more information.

    +

    + Schema authors should take care with "$comment" contents, as a malicious + implementation can display them to end-users in violation of a spec, or + fail to strip them if such behavior is expected.

    +

    + A malicious schema author could place executable code or other dangerous + material within a "$comment". Implementations MUST NOT parse or otherwise + take action based on "$comment" contents.

    +
    +
    +
    +

    +14. IANA Considerations +

    +
    +

    +14.1. application/schema+json +

    +

    + The proposed MIME media type for JSON Schema is defined as follows:

    +
      +
    • Type name: application +
    • +
    • Subtype name: schema+json +
    • +
    • Required parameters: N/A +
    • +
    • + Encoding considerations: Encoding considerations are + identical to those specified for the "application/json" + media type. See JSON [RFC8259]. +
    • +
    • + Security considerations: See Section + 13 above. +
    • +
    • + Interoperability considerations: See Sections + 6.2, + 6.3, and + 6.4 above. +
    • +
    • + Fragment identifier considerations: See Section + 5 +
    • +
    +
    +
    +

    +14.2. application/schema-instance+json +

    +

    + The proposed MIME media type for JSON Schema Instances that require + a JSON Schema-specific media type is defined as follows:

    +
      +
    • Type name: application +
    • +
    • Subtype name: schema-instance+json +
    • +
    • Required parameters: N/A +
    • +
    • + Encoding considerations: Encoding considerations are + identical to those specified for the "application/json" + media type. See JSON [RFC8259]. +
    • +
    • + Security considerations: See Section + 13 above. +
    • +
    • + Interoperability considerations: See Sections + 6.2, + 6.3, and + 6.4 above. +
    • +
    • + Fragment identifier considerations: See Section + 5 +
    • +
    +
    +
    +
    +

    +15. References +

    +
    +

    +15.1. Normative References +

    +
    +
    [RFC2119]
    +
    +Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://www.rfc-editor.org/info/rfc2119>.
    +
    +
    [RFC3986]
    +
    +Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, , <https://www.rfc-editor.org/info/rfc3986>.
    +
    +
    [RFC6839]
    +
    +Hansen, T. and A. Melnikov, "Additional Media Type Structured Syntax Suffixes", RFC 6839, DOI 10.17487/RFC6839, , <https://www.rfc-editor.org/info/rfc6839>.
    +
    +
    [RFC6901]
    +
    +Bryan, P., Ed., Zyp, K., and M. Nottingham, Ed., "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, , <https://www.rfc-editor.org/info/rfc6901>.
    +
    +
    [RFC8259]
    +
    +Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, , <https://www.rfc-editor.org/info/rfc8259>.
    +
    +
    [W3C.REC-ldp-20150226]
    +
    +Speicher, S., Arwe, J., and A. Malhotra, "Linked Data Platform 1.0", World Wide Web Consortium Recommendation REC-ldp-20150226, , <https://www.w3.org/TR/2015/REC-ldp-20150226>.
    +
    +
    [ecma262]
    +
    +"ECMA-262, 11th edition specification", , <https://www.ecma-international.org/ecma-262/11.0/index.html>.
    +
    +
    +
    +
    +

    +15.2. Informative References +

    +
    +
    [RFC6596]
    +
    +Ohye, M. and J. Kupke, "The Canonical Link Relation", RFC 6596, DOI 10.17487/RFC6596, , <https://www.rfc-editor.org/info/rfc6596>.
    +
    +
    [RFC7049]
    +
    +Bormann, C. and P. Hoffman, "Concise Binary Object Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, , <https://www.rfc-editor.org/info/rfc7049>.
    +
    +
    [RFC7231]
    +
    +Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content", RFC 7231, DOI 10.17487/RFC7231, , <https://www.rfc-editor.org/info/rfc7231>.
    +
    +
    [RFC8288]
    +
    +Nottingham, M., "Web Linking", RFC 8288, DOI 10.17487/RFC8288, , <https://www.rfc-editor.org/info/rfc8288>.
    +
    +
    [W3C.WD-fragid-best-practices-20121025]
    +
    +Tennison, J., "Best Practices for Fragment Identifiers and Media Type Definitions", World Wide Web Consortium WD WD-fragid-best-practices-20121025, , <https://www.w3.org/TR/2012/WD-fragid-best-practices-20121025>.
    +
    +
    [json-schema-validation]
    +
    +Wright, A., Andrews, H., and B. Hutton, "JSON Schema Validation: A Vocabulary for Structural Validation of JSON", Work in Progress, Internet-Draft, draft-bhutton-json-schema-validation-01, , <https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-01>.
    +
    +
    [json-hyper-schema]
    +
    +Andrews, H. and A. Wright, "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON", Work in Progress, Internet-Draft, draft-handrews-json-schema-hyperschema-02, , <https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-02>.
    +
    +
    [xml-names]
    +
    +Bray, T., Ed., Hollander, D., Ed., Layman, A., Ed., and R. Tobin, Ed., "Namespaces in XML 1.1 (Second Edition)", , <http://www.w3.org/TR/2006/REC-xml-names11-20060816>.
    +
    +
    +
    +
    +
    +
    +

    +Appendix A. Schema identification examples +

    +

    + Consider the following schema, which shows "$id" being used to identify + both the root schema and various subschemas, and "$anchor" being used + to define plain name fragment identifiers.

    +
    +
    +
    +{
    +    "$id": "https://example.com/root.json",
    +    "$defs": {
    +        "A": { "$anchor": "foo" },
    +        "B": {
    +            "$id": "other.json",
    +            "$defs": {
    +                "X": { "$anchor": "bar" },
    +                "Y": {
    +                    "$id": "t/inner.json",
    +                    "$anchor": "bar"
    +                }
    +            }
    +        },
    +        "C": {
    +            "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f"
    +        }
    +    }
    +}
    +
    +
    +
    +

    + The schemas at the following URI-encoded JSON + Pointers [RFC6901] (relative to the root schema) have the following + base URIs, and are identifiable by any listed URI in accordance with + sections 5 and + 9.2.1 above.

    +
    +
    # (document root)
    +
    +
    +
    canonical (and base) URI
    +
    + https://example.com/root.json +
    +
    +
    canonical resource URI plus pointer fragment
    +
    + https://example.com/root.json# +
    +
    +
    +
    +
    +
    #/$defs/A
    +
    +
    +
    base URI
    +
    https://example.com/root.json +
    +
    +
    canonical resource URI plus plain fragment
    +
    + https://example.com/root.json#foo +
    +
    +
    canonical resource URI plus pointer fragment
    +
    + https://example.com/root.json#/$defs/A +
    +
    +
    +
    +
    +
    #/$defs/B
    +
    +
    +
    canonical (and base) URI
    +
    https://example.com/other.json +
    +
    +
    canonical resource URI plus pointer fragment
    +
    + https://example.com/other.json# +
    +
    +
    base URI of enclosing (root.json) resource plus fragment
    +
    + https://example.com/root.json#/$defs/B +
    +
    +
    +
    +
    +
    #/$defs/B/$defs/X
    +
    +
    +
    base URI
    +
    https://example.com/other.json +
    +
    +
    canonical resource URI plus plain fragment
    +
    + https://example.com/other.json#bar +
    +
    +
    canonical resource URI plus pointer fragment
    +
    + https://example.com/other.json#/$defs/X +
    +
    +
    base URI of enclosing (root.json) resource plus fragment
    +
    + https://example.com/root.json#/$defs/B/$defs/X +
    +
    +
    +
    +
    +
    #/$defs/B/$defs/Y
    +
    +
    +
    canonical (and base) URI
    +
    https://example.com/t/inner.json +
    +
    +
    canonical URI plus plain fragment
    +
    + https://example.com/t/inner.json#bar +
    +
    +
    canonical URI plus pointer fragment
    +
    + https://example.com/t/inner.json# +
    +
    +
    base URI of enclosing (other.json) resource plus fragment
    +
    + https://example.com/other.json#/$defs/Y +
    +
    +
    base URI of enclosing (root.json) resource plus fragment
    +
    + https://example.com/root.json#/$defs/B/$defs/Y +
    +
    +
    +
    +
    +
    #/$defs/C
    +
    +
    +
    canonical (and base) URI
    +
    + urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f +
    +
    +
    canonical URI plus pointer fragment
    +
    + urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f# +
    +
    +
    base URI of enclosing (root.json) resource plus fragment
    +
    + https://example.com/root.json#/$defs/C +
    +
    +
    +
    +
    +
    +

    + Note: The fragment part of the URI does not make it canonical or non-canonical, + rather, the base URI used (as part of the full URI with any fragment) is what + determines the canonical nature of the resulting full URI. + + Multiple "canonical" URIs? We Acknowledge this is potentially confusing, and + direct you to read the CREF located in the + JSON Pointer fragments and embedded schema resources (Section 9.2.1) + section for futher comments. +

    +
    +
    +
    +

    +Appendix B. Manipulating schema documents and references +

    +

    + Various tools have been created to rearrange schema documents + based on how and where references ("$ref") appear. This appendix discusses + which use cases and actions are compliant with this specification.

    +
    +

    +B.1. Bundling schema resources into a single document +

    +

    + A set of schema resources intended for use together can be organized + with each in its own schema document, all in the same schema document, + or any granularity of document grouping in between.

    +

    + Numerous tools exist to perform various sorts of reference removal. + A common case of this is producing a single file where all references + can be resolved within that file. This is typically done to simplify + distribution, or to simplify coding so that various invocations + of JSON Schema libraries do not have to keep track of and load + a large number of resources.

    +

    + This transformation can be safely and reversibly done as long as + all static references (e.g. "$ref") use URI-references that resolve + to URIs using the canonical resource URI as the base, and all schema + resources have an absolute-URI as the "$id" in their root schema.

    +

    + With these conditions met, each external resource can be copied + under "$defs", without breaking any references among the resources' + schema objects, and without changing any aspect of validation or + annotation results. The names of the schemas under "$defs" do + not affect behavior, assuming they are each unique, as they + do not appear in the canonical URIs for the embedded resources.

    +
    +
    +

    +B.2. Reference removal is not always safe +

    +

    + Attempting to remove all references and produce a single schema document does not, + in all cases, produce a schema with identical behavior to the original form.

    +

    + Since "$ref" is now treated like any other keyword, with other keywords allowed + in the same schema objects, fully supporting non-recursive "$ref" removal in + all cases can require relatively complex schema manipulations. It is beyond + the scope of this specification to determine or provide a set of safe "$ref" + removal transformations, as they depend not only on the schema structure + but also on the intended usage.

    +
    +
    +
    +
    +

    +Appendix C. Example of recursive schema extension +

    +

    + Consider the following two schemas describing a simple + recursive tree structure, where each node in the tree + can have a "data" field of any type. The first schema + allows and ignores other instance properties. The second is + more strict and only allows the "data" and "children" properties. + An example instance with "data" misspelled as "daat" is also shown.

    +
    +
    +
    +// tree schema, extensible
    +{
    +    "$schema": "https://json-schema.org/draft/2020-12/schema",
    +    "$id": "https://example.com/tree",
    +    "$dynamicAnchor": "node",
    +
    +    "type": "object",
    +    "properties": {
    +        "data": true,
    +        "children": {
    +            "type": "array",
    +            "items": {
    +                "$dynamicRef": "#node"
    +            }
    +        }
    +    }
    +}
    +
    +// strict-tree schema, guards against misspelled properties
    +{
    +    "$schema": "https://json-schema.org/draft/2020-12/schema",
    +    "$id": "https://example.com/strict-tree",
    +    "$dynamicAnchor": "node",
    +
    +    "$ref": "tree",
    +    "unevaluatedProperties": false
    +}
    +
    +// instance with misspelled field
    +{
    +    "children": [ { "daat": 1 } ]
    +}
    +
    +
    +
    +

    + When we load these two schemas, we will notice the "$dynamicAnchor" + named "node" (note the lack of "#" as this is just the name) + present in each, resulting in the following full schema URIs:

    +
      +
    • "https://example.com/tree#node" +
    • +
    • "https://example.com/strict-tree#node" +
    • +
    +

    + In addition, JSON Schema implementations keep track of the fact + that these fragments were created with "$dynamicAnchor".

    +

    + If we apply the "strict-tree" schema to the instance, we will follow + the "$ref" to the "tree" schema, examine its "children" subschema, + and find the "$dynamicRef": to "#node" (note the "#" for URI fragment syntax) + in its "items" subschema. That reference resolves to + "https://example.com/tree#node", which is a URI with a fragment + created by "$dynamicAnchor". Therefore we must examine the dynamic + scope before following the reference.

    +

    + At this point, the dynamic path is + "#/$ref/properties/children/items/$dynamicRef", with a dynamic scope + containing (from the outermost scope to the innermost):

    +
      +
    1. "https://example.com/strict-tree#" +
    2. +
    3. "https://example.com/tree#" +
    4. +
    5. "https://example.com/tree#/properties/children" +
    6. +
    7. "https://example.com/tree#/properties/children/items" +
    8. +
    +

    + Since we are looking for a plain name fragment, which can be + defined anywhere within a schema resource, the JSON Pointer fragments + are irrelevant to this check. That means that we can remove those + fragments and eliminate consecutive duplicates, producing:

    +
      +
    1. "https://example.com/strict-tree" +
    2. +
    3. "https://example.com/tree" +
    4. +
    +

    + In this case, the outermost resource also has a "node" fragment + defined by "$dynamicAnchor". Therefore instead of resolving the + "$dynamicRef" to "https://example.com/tree#node", we resolve it to + "https://example.com/strict-tree#node".

    +

    + This way, the recursion in the "tree" schema recurses to the root + of "strict-tree", instead of only applying "strict-tree" to the + instance root, but applying "tree" to instance children.

    +

    + This example shows both "$dynamicAnchor"s in the same place + in each schema, specifically the resource root schema. + Since plain-name fragments are independent of the JSON structure, + this would work just as well if one or both of the node schema objects + were moved under "$defs". It is the matching "$dynamicAnchor" values + which tell us how to resolve the dynamic reference, not any sort of + correlation in JSON structure.

    +
    +
    +
    +

    +Appendix D. Working with vocabularies +

    +
    +

    +D.1. Best practices for vocabulary and meta-schema authors +

    +

    + Vocabulary authors should + take care to avoid keyword name collisions if the vocabulary is intended + for broad use, and potentially combined with other vocabularies. JSON + Schema does not provide any formal namespacing system, but also does + not constrain keyword names, allowing for any number of namespacing + approaches.

    +

    + Vocabularies may build on each other, such as by defining the behavior + of their keywords with respect to the behavior of keywords from another + vocabulary, or by using a keyword from another vocabulary with + a restricted or expanded set of acceptable values. Not all such + vocabulary re-use will result in a new vocabulary that is compatible + with the vocabulary on which it is built. Vocabulary authors should + clearly document what level of compatibility, if any, is expected.

    +

    + Meta-schema authors should not use "$vocabulary" to combine multiple + vocabularies that define conflicting syntax or semantics for the same + keyword. As semantic conflicts are not generally detectable through + schema validation, implementations are not expected to detect such + conflicts. If conflicting vocabularies are declared, the resulting + behavior is undefined.

    +

    + Vocabulary authors SHOULD provide a meta-schema that validates the + expected usage of the vocabulary's keywords on their own. Such meta-schemas + SHOULD not forbid additional keywords, and MUST not forbid any + keywords from the Core vocabulary.

    +

    + It is recommended that meta-schema authors reference each vocabulary's + meta-schema using the "allOf" (Section 10.2.1.1) keyword, + although other mechanisms for constructing the meta-schema may be + appropriate for certain use cases.

    +

    + The recursive nature of meta-schemas makes the "$dynamicAnchor" + and "$dynamicRef" keywords particularly useful for extending + existing meta-schemas, as can be seen in the JSON Hyper-Schema meta-schema + which extends the Validation meta-schema.

    +

    + Meta-schemas may impose additional constraints, including describing + keywords not present in any vocabulary, beyond what the meta-schemas + associated with the declared vocabularies describe. This allows for + restricting usage to a subset of a vocabulary, and for validating + locally defined keywords not intended for re-use.

    +

    + However, meta-schemas should not contradict any vocabularies that + they declare, such as by requiring a different JSON type than + the vocabulary expects. The resulting behavior is undefined.

    +

    + Meta-schemas intended for local use, with no need to test for + vocabulary support in arbitrary implementations, can safely omit + "$vocabulary" entirely.

    +
    +
    +
    +

    +D.2. Example meta-schema with vocabulary declarations +

    +

    + This meta-schema explicitly declares both the Core and Applicator vocabularies, + together with an extension vocabulary, and combines their meta-schemas with + an "allOf". The extension vocabulary's meta-schema, which describes only the + keywords in that vocabulary, is shown after the main example meta-schema.

    +

    + The main example meta-schema also restricts the usage of the Unevaluated + vocabulary by forbidding the keywords prefixed with "unevaluated", which + are particularly complex to implement. This does not change the semantics + or set of keywords defined by the other vocabularies. It just ensures + that schemas using this meta-schema that attempt to use the keywords + prefixed with "unevaluated" will fail validation against this meta-schema.

    +

    + Finally, this meta-schema describes the syntax of a keyword, "localKeyword", + that is not part of any vocabulary. Presumably, the implementors and users + of this meta-schema will understand the semantics of "localKeyword". + JSON Schema does not define any mechanism for expressing keyword semantics + outside of vocabularies, making them unsuitable for use except in a + specific environment in which they are understood.

    +

    + This meta-schema combines several vocabularies for general use.

    +
    +
    +
    +{
    +  "$schema": "https://json-schema.org/draft/2020-12/schema",
    +  "$id": "https://example.com/meta/general-use-example",
    +  "$dynamicAnchor": "meta",
    +  "$vocabulary": {
    +    "https://json-schema.org/draft/2020-12/vocab/core": true,
    +    "https://json-schema.org/draft/2020-12/vocab/applicator": true,
    +    "https://json-schema.org/draft/2020-12/vocab/validation": true,
    +    "https://example.com/vocab/example-vocab": true
    +  },
    +  "allOf": [
    +    {"$ref": "https://json-schema.org/draft/2020-12/meta/core"},
    +    {"$ref": "https://json-schema.org/draft/2020-12/meta/applicator"},
    +    {"$ref": "https://json-schema.org/draft/2020-12/meta/validation"},
    +    {"$ref": "https://example.com/meta/example-vocab"}
    +  ],
    +  "patternProperties": {
    +    "^unevaluated": false
    +  },
    +  "properties": {
    +    "localKeyword": {
    +      "$comment": "Not in vocabulary, but validated if used",
    +      "type": "string"
    +    }
    +  }
    +}
    +
    +
    +
    +

    + This meta-schema describes only a single extension vocabulary.

    +
    +
    +
    +{
    +  "$schema": "https://json-schema.org/draft/2020-12/schema",
    +  "$id": "https://example.com/meta/example-vocab",
    +  "$dynamicAnchor": "meta",
    +  "$vocabulary": {
    +    "https://example.com/vocab/example-vocab": true,
    +  },
    +  "type": ["object", "boolean"],
    +  "properties": {
    +    "minDate": {
    +      "type": "string",
    +      "pattern": "\d\d\d\d-\d\d-\d\d",
    +      "format": "date",
    +    }
    +  }
    +}
    +
    +
    +
    +

    + As shown above, even though each of the single-vocabulary meta-schemas + referenced in the general-use meta-schema's "allOf" declares its + corresponding vocabulary, this new meta-schema must re-declare them.

    +

    + The standard meta-schemas that combine all vocabularies defined by + the Core and Validation specification, and that combine all vocabularies + defined by those specifications as well as the Hyper-Schema specification, + demonstrate additional complex combinations. These URIs for these + meta-schemas may be found in the Validation and Hyper-Schema specifications, + respectively.

    +

    + While the general-use meta-schema can validate the syntax of "minDate", + it is the vocabulary that defines the logic behind the semantic meaning + of "minDate". Without an understanding of the semantics (in this example, + that the instance value must be a date equal to or after the date + provided as the keyword's value in the schema), an implementation can + only validate the syntactic usage. In this case, that means validating + that it is a date-formatted string (using "pattern" to ensure that it is + validated even when "format" functions purely as an annotation, as explained + in the Validation specification [json-schema-validation].

    +
    +
    +
    +
    +

    +Appendix E. References and generative use cases +

    +

    + While the presence of references is expected to be transparent + to validation results, generative use cases such as code generators + and UI renderers often consider references to be semantically significant.

    +

    + To make such use case-specific semantics explicit, the best practice + is to create an annotation keyword for use in the same + schema object alongside of a reference keyword such as "$ref".

    +

    + For example, here is a hypothetical keyword for determining + whether a code generator should consider the reference + target to be a distinct class, and how those classes are related. + Note that this example is solely for illustrative purposes, and is + not intended to propose a functional code generation keyword.

    +
    +
    +
    +{
    +    "allOf": [
    +        {
    +            "classRelation": "is-a",
    +            "$ref": "classes/base.json"
    +        },
    +        {
    +            "$ref": "fields/common.json"
    +        }
    +    ],
    +    "properties": {
    +        "foo": {
    +            "classRelation": "has-a",
    +            "$ref": "classes/foo.json"
    +        },
    +        "date": {
    +            "$ref": "types/dateStruct.json",
    +        }
    +    }
    +}
    +
    +
    +
    +

    + Here, this schema represents some sort of object-oriented class. + The first reference in the "allOf" is noted as the base class. + The second is not assigned a class relationship, meaning that the + code generator should combine the target's definition with this + one as if no reference were involved.

    +

    + Looking at the properties, "foo" is flagged as object composition, + while the "date" property is not. It is simply a field with + sub-fields, rather than an instance of a distinct class.

    +

    + This style of usage requires the annotation to be in the same object + as the reference, which must be recognizable as a reference.

    +
    +
    +

    +Appendix F. Acknowledgments +

    +

    + Thanks to + Gary Court, + Francis Galiegue, + Kris Zyp, + and Geraint Luff + for their work on the initial drafts of JSON Schema.

    +

    + Thanks to + Jason Desrosiers, + Daniel Perrett, + Erik Wilde, + Evgeny Poberezkin, + Brad Bowman, + Gowry Sankar, + Donald Pipowitch, + Dave Finlay, + Denis Laxalde, + Phil Sturgeon, + Shawn Silverman, + and Karen Etheridge + for their submissions and patches to the document.

    +
    +
    +

    +Appendix G. ChangeLog +

    +

    + This section to be removed before leaving Internet-Draft status.

    +
    +
    draft-bhutton-json-schema-00
    +
    +
      +
    • "$schema" MAY change for embedded resources +
    • +
    • Array-value "items" functionality is now "prefixItems" +
    • +
    • "items" subsumes the old function of "additionalItems" +
    • +
    • "contains" annotation behavior, and "contains" and "unevaluatedItems" interactions now specified +
    • +
    • Rename $recursive* to $dynamic*, with behavior modification +
    • +
    • $dynamicAnchor defines a fragment like $anchor +
    • +
    • $dynamic* (previously $recursive) no longer use runtime base URI determination +
    • +
    • Define Compound Schema Documents (bundle) and processing +
    • +
    • Reference ECMA-262, 11th edition for regular expression support +
    • +
    • Regular expression should support unicode +
    • +
    • Remove media type parameters +
    • +
    • Specify Unknown keywords are collected as annotations +
    • +
    • Moved "unevaluatedItems" and "unevaluatedProperties" from core into their own vocabulary +
    • +
    +
    +
    +
    draft-handrews-json-schema-02
    +
    +
      +
    • Update to RFC 8259 for JSON specification +
    • +
    • Moved "definitions" from the Validation specification here as "$defs" +
    • +
    • Moved applicator keywords from the Validation specification as their own vocabulary +
    • +
    • Moved the schema form of "dependencies" from the Validation specification as "dependentSchemas" +
    • +
    • Formalized annotation collection +
    • +
    • Specified recommended output formats +
    • +
    • Defined keyword interactions in terms of annotation and assertion results +
    • +
    • Added "unevaluatedProperties" and "unevaluatedItems" +
    • +
    • Define "$ref" behavior in terms of the assertion, applicator, and annotation model +
    • +
    • Allow keywords adjacent to "$ref" +
    • +
    • Note undefined behavior for "$ref" targets involving unknown keywords +
    • +
    • Add recursive referencing, primarily for meta-schema extension +
    • +
    • Add the concept of formal vocabularies, and how they can be recognized through meta-schemas +
    • +
    • Additional guidance on initial base URIs beyond network retrieval +
    • +
    • Allow "schema" media type parameter for "application/schema+json" +
    • +
    • Better explanation of media type parameters and the HTTP Accept header +
    • +
    • Use "$id" to establish canonical and base absolute-URIs only, no fragments +
    • +
    • Replace plain-name-fragment-only form of "$id" with "$anchor" +
    • +
    • Clarified that the behavior of JSON Pointers across "$id" boundary is unreliable +
    • +
    +
    +
    +
    draft-handrews-json-schema-01
    +
    +
      +
    • This draft is purely a clarification with no functional changes +
    • +
    • Emphasized annotations as a primary usage of JSON Schema +
    • +
    • Clarified $id by use cases +
    • +
    • Exhaustive schema identification examples +
    • +
    • Replaced "external referencing" with how and when an implementation might know of a schema from another document +
    • +
    • Replaced "internal referencing" with how an implementation should recognized schema identifiers during parsing +
    • +
    • Dereferencing the former "internal" or "external" references is always the same process +
    • +
    • Minor formatting improvements +
    • +
    +
    +
    +
    draft-handrews-json-schema-00
    +
    +
      +
    • Make the concept of a schema keyword vocabulary more clear +
    • +
    • Note that the concept of "integer" is from a vocabulary, not the data model +
    • +
    • Classify keywords as assertions or annotations and describe their general behavior +
    • +
    • Explain the boolean schemas in terms of generalized assertions +
    • +
    • Reserve "$comment" for non-user-visible notes about the schema +
    • +
    • Wording improvements around "$id" and fragments +
    • +
    • Note the challenges of extending meta-schemas with recursive references +
    • +
    • Add "application/schema-instance+json" media type +
    • +
    • Recommend a "schema" link relation / parameter instead of "profile" +
    • +
    +
    +
    +
    draft-wright-json-schema-01
    +
    +
      +
    • Updated intro +
    • +
    • Allowed for any schema to be a boolean +
    • +
    • "$schema" SHOULD NOT appear in subschemas, although that may change +
    • +
    • Changed "id" to "$id"; all core keywords prefixed with "$" +
    • +
    • Clarify and formalize fragments for application/schema+json +
    • +
    • Note applicability to formats such as CBOR that can be represented in the JSON data model +
    • +
    +
    +
    +
    draft-wright-json-schema-00
    +
    +
      +
    • Updated references to JSON +
    • +
    • Updated references to HTTP +
    • +
    • Updated references to JSON Pointer +
    • +
    • Behavior for "id" is now specified in terms of RFC3986 +
    • +
    • Aligned vocabulary usage for URIs with RFC3986 +
    • +
    • Removed reference to draft-pbryan-zyp-json-ref-03 +
    • +
    • Limited use of "$ref" to wherever a schema is expected +
    • +
    • Added definition of the "JSON Schema data model" +
    • +
    • Added additional security considerations +
    • +
    • Defined use of subschema identifiers for "id" +
    • +
    • Rewrote section on usage with HTTP +
    • +
    • Rewrote section on usage with rel="describedBy" and rel="profile" +
    • +
    • Fixed numerous invalid examples +
    • +
    +
    +
    +
    draft-zyp-json-schema-04
    +
    +
      +
    • Salvaged from draft v3. +
    • +
    • Split validation keywords into separate document. +
    • +
    • Split hypermedia keywords into separate document. +
    • +
    • Initial post-split draft. +
    • +
    • Mandate the use of JSON Reference, JSON Pointer. +
    • +
    • Define the role of "id". Define URI resolution scope. +
    • +
    • Add interoperability considerations. +
    • +
    +
    +
    +
    draft-zyp-json-schema-00
    +
    +
      +
    • Initial draft. +
    • +
    +
    +
    +
    +
    +
    +
    +

    +Authors' Addresses +

    +
    +
    Austin Wright (editor)
    + +
    +
    +
    Henry Andrews (editor)
    + +
    +
    +
    Ben Hutton (editor)
    + + +
    +
    +
    Greg Dennis
    + + +
    +
    +
    + + + diff --git a/draft/preview/jsonschema-validation.html b/draft/preview/jsonschema-validation.html new file mode 100644 index 00000000..758eeeb3 --- /dev/null +++ b/draft/preview/jsonschema-validation.html @@ -0,0 +1,3173 @@ + + + + + + +JSON Schema Validation: A Vocabulary for Structural Validation of JSON + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Internet-DraftJSON Schema ValidationApril 2022
    Wright, et al.Expires 30 October 2022[Page]
    +
    +
    +
    +
    Workgroup:
    +
    Internet Engineering Task Force
    +
    Internet-Draft:
    +
    draft-bhutton-json-schema-validation-01
    +
    Published:
    +
    + +
    +
    Intended Status:
    +
    Informational
    +
    Expires:
    +
    +
    Authors:
    +
    +
    +
    A. Wright, Ed. +
    +
    +
    +
    H. Andrews, Ed. +
    +
    +
    +
    B. Hutton, Ed. +
    +
    +
    +
    +
    +

    JSON Schema Validation: A Vocabulary for Structural Validation of JSON

    +
    +

    Abstract

    +

    + JSON Schema (application/schema+json) has several purposes, one of which is JSON + instance validation. + This document specifies a vocabulary for JSON Schema to describe the meaning of JSON + documents, provide hints for user interfaces working with JSON data, and to make + assertions about what a valid document must look like.

    +
    +
    +

    +Note to Readers +

    +

    + The issues list for this draft can be found at + https://github.com/json-schema-org/json-schema-spec/issues.

    +

    + For additional information, see https://json-schema.org/.

    +

    + To provide feedback, use this issue tracker, the communication methods listed on the + homepage, or email the document editors.

    +
    +
    +
    +

    +Status of This Memo +

    +

    + This Internet-Draft is submitted in full conformance with the + provisions of BCP 78 and BCP 79.

    +

    + Internet-Drafts are working documents of the Internet Engineering Task + Force (IETF). Note that other groups may also distribute working + documents as Internet-Drafts. The list of current Internet-Drafts is + at https://datatracker.ietf.org/drafts/current/.

    +

    + Internet-Drafts are draft documents valid for a maximum of six months + and may be updated, replaced, or obsoleted by other documents at any + time. It is inappropriate to use Internet-Drafts as reference + material or to cite them other than as "work in progress."

    +

    + This Internet-Draft will expire on 30 October 2022.

    +
    +
    + +
    +
    +

    +Table of Contents +

    + +
    +
    +
    +

    +1. Introduction +

    +

    + JSON Schema can be used to require that a given JSON document (an instance) + satisfies a certain number of criteria. These criteria are asserted by using + keywords described in this specification. In addition, a set of keywords + is also defined to assist in interactive user interface instance generation.

    +

    + This specification will use the concepts, syntax, and terminology defined + by the JSON Schema core [json-schema] specification.

    +
    +
    +

    +2. Conventions and Terminology +

    +

    + + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", + "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be + interpreted as described in RFC 2119 [RFC2119].

    +

    + This specification uses the term "container instance" to refer to both array and + object instances. It uses the term "children instances" to refer to array elements + or object member values.

    +

    + Elements in an array value are said to be unique if no two elements of this array + are equal [json-schema].

    +
    +
    +

    +3. Overview +

    +

    + JSON Schema validation asserts constraints on the structure of instance data. + An instance location that satisfies all asserted constraints is then + annotated with any keywords that contain non-assertion information, + such as descriptive metadata and usage hints. If all locations within + the instance satisfy all asserted constraints, then the instance is + said to be valid against the schema.

    +

    + Each schema object is independently evaluated against each instance location + to which it applies. This greatly simplifies the implementation requirements + for validators by ensuring that they do not need to maintain state across + the document-wide validation process.

    +

    + This specification defines a set of assertion keywords, as well as a small vocabulary + of metadata keywords that can be used to annotate the JSON instance with + useful information. The Section 7 keyword is intended primarily + as an annotation, but can optionally be used as an assertion. The + Section 8 keywords are annotations for working with documents + embedded as JSON strings.

    +
    +
    +

    +4. Interoperability Considerations +

    +
    +

    +4.1. Validation of String Instances +

    +

    + It should be noted that the nul character (\u0000) is valid in a JSON string. An + instance to validate may contain a string value with this character, regardless + of the ability of the underlying programming language to deal with such data.

    +
    +
    +

    +4.2. Validation of Numeric Instances +

    +

    + The JSON specification allows numbers with arbitrary precision, and JSON Schema + does not add any such bounds. + This means that numeric instances processed by JSON Schema can be arbitrarily large and/or + have an arbitrarily long decimal part, regardless of the ability of the + underlying programming language to deal with such data.

    +
    +
    +
    +

    +4.3. Regular Expressions +

    +

    + Keywords that use regular expressions, or constrain the instance value + to be a regular expression, are subject to the interoperability + considerations for regular expressions in the + JSON Schema Core [json-schema] specification.

    +
    +
    +
    +
    +
    +

    +5. Meta-Schema +

    +

    + The current URI for the default JSON Schema dialect meta-schema is + https://json-schema.org/draft/2020-12/schema. + For schema author convenience, this meta-schema describes a dialect + consisting of all vocabularies + defined in this specification and the JSON Schema Core specification, + as well as two former keywords which are reserved for a transitional period. + Individual vocabulary and vocabulary meta-schema URIs are given for + each section below. Certain vocabularies are optional to support, which + is explained in detail in the relevant sections.

    +

    + Updated vocabulary and meta-schema URIs MAY be published between + specification drafts in order to correct errors. Implementations + SHOULD consider URIs dated after this specification draft and + before the next to indicate the same syntax and semantics + as those listed here.

    +
    +
    +
    +

    +6. A Vocabulary for Structural Validation +

    +

    + Validation keywords in a schema impose requirements for successful validation of an + instance. These keywords are all assertions without any annotation behavior.

    +

    + Meta-schemas that do not use "$vocabulary" SHOULD be considered to + require this vocabulary as if its URI were present with a value of true.

    +

    + The current URI for this vocabulary, known as the Validation vocabulary, is: + <https://json-schema.org/draft/2020-12/vocab/validation>.

    +

    + The current URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/validation.

    +
    +
    +

    +6.1. Validation Keywords for Any Instance Type +

    +
    +

    +6.1.1. type +

    +

    + The value of this keyword MUST be either a string or an array. If it is + an array, elements of the array MUST be strings and MUST be unique.

    +

    + String values MUST be one of the six primitive types + ("null", "boolean", "object", "array", "number", or "string"), + or "integer" which matches any number with a zero fractional part.

    +

    + If the value of "type" is a string, then an instance validates successfully if + its type matches the type represented by the value of the string. + + If the value of "type" is an array, then an instance validates successfully if + its type matches any of the types indicated by the strings in the array.

    +
    +
    +
    +

    +6.1.2. enum +

    +

    + The value of this keyword MUST be an array. This array SHOULD have at + least one element. Elements in the array SHOULD be unique.

    +

    + An instance validates successfully against this keyword if its value is + equal to one of the elements in this keyword's array value.

    +

    + Elements in the array might be of any type, including null.

    +
    +
    +
    +

    +6.1.3. const +

    +

    + The value of this keyword MAY be of any type, including null.

    +

    + Use of this keyword is functionally equivalent to an + "enum" (Section 6.1.2) with a single value.

    +

    + An instance validates successfully against this keyword if its value is + equal to the value of the keyword.

    +
    +
    +
    +
    +
    +

    +6.2. Validation Keywords for Numeric Instances (number and integer) +

    +
    +

    +6.2.1. multipleOf +

    +

    + The value of "multipleOf" MUST be a number, strictly greater than 0.

    +

    + A numeric instance is valid only if division by this keyword's value results in + an integer.

    +
    +
    +

    +6.2.2. maximum +

    +

    + The value of "maximum" MUST be a number, representing an inclusive upper limit + for a numeric instance.

    +

    + If the instance is a number, then this keyword validates only if the instance is + less than or exactly equal to "maximum".

    +
    +
    +

    +6.2.3. exclusiveMaximum +

    +

    + The value of "exclusiveMaximum" MUST be a number, representing an exclusive upper + limit for a numeric instance.

    +

    + If the instance is a number, then the instance is valid only if it has a value + strictly less than (not equal to) "exclusiveMaximum".

    +
    +
    +

    +6.2.4. minimum +

    +

    + The value of "minimum" MUST be a number, representing an inclusive lower limit + for a numeric instance.

    +

    + If the instance is a number, then this keyword validates only if the instance is + greater than or exactly equal to "minimum".

    +
    +
    +

    +6.2.5. exclusiveMinimum +

    +

    + The value of "exclusiveMinimum" MUST be a number, representing an exclusive lower + limit for a numeric instance.

    +

    + If the instance is a number, then the instance is valid only if it has a value + strictly greater than (not equal to) "exclusiveMinimum".

    +
    +
    +
    +
    +
    +

    +6.3. Validation Keywords for Strings +

    +
    +

    +6.3.1. maxLength +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + A string instance is valid against this keyword if its + length is less than, or equal to, the value of this keyword.

    +

    + The length of a string instance is defined as the number of its + characters as defined by RFC 8259 [RFC8259].

    +
    +
    +

    +6.3.2. minLength +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + A string instance is valid against this keyword if its + length is greater than, or equal to, the value of this keyword.

    +

    + The length of a string instance is defined as the number of its + characters as defined by RFC 8259 [RFC8259].

    +

    + Omitting this keyword has the same behavior as a value of 0.

    +
    +
    +
    +

    +6.3.3. pattern +

    +

    + The value of this keyword MUST be a string. This string SHOULD be a + valid regular expression, according to the ECMA-262 regular expression + dialect.

    +

    + A string instance is considered valid if the regular + expression matches the instance successfully. Recall: regular + expressions are not implicitly anchored.

    +
    +
    +
    +
    +
    +

    +6.4. Validation Keywords for Arrays +

    +
    +

    +6.4.1. maxItems +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + An array instance is valid against "maxItems" if its size is + less than, or equal to, the value of this keyword.

    +
    +
    +

    +6.4.2. minItems +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + An array instance is valid against "minItems" if its size is + greater than, or equal to, the value of this keyword.

    +

    + Omitting this keyword has the same behavior as a value of 0.

    +
    +
    +

    +6.4.3. uniqueItems +

    +

    + The value of this keyword MUST be a boolean.

    +

    + If this keyword has boolean value false, the instance validates + successfully. If it has boolean value true, the instance validates + successfully if all of its elements are unique.

    +

    + Omitting this keyword has the same behavior as a value of false.

    +
    +
    +

    +6.4.4. maxContains +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + If "contains" is not present within the same schema object, + then this keyword has no effect.

    +

    + An instance array is valid against "maxContains" in two ways, depending on + the form of the annotation result of an adjacent + "contains" [json-schema] keyword. The first way is if + the annotation result is an array and the length of that array is less than + or equal to the "maxContains" value. The second way is if the annotation + result is a boolean "true" and the instance array length is less than or + equal to the "maxContains" value.

    +
    +
    +

    +6.4.5. minContains +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + If "contains" is not present within the same schema object, + then this keyword has no effect.

    +

    + An instance array is valid against "minContains" in two ways, depending on + the form of the annotation result of an adjacent + "contains" [json-schema] keyword. The first way is if + the annotation result is an array and the length of that array is greater + than or equal to the "minContains" value. The second way is if the + annotation result is a boolean "true" and the instance array length is + greater than or equal to the "minContains" value.

    +

    + A value of 0 is allowed, but is only useful for setting a range + of occurrences from 0 to the value of "maxContains". A value of + 0 causes "minContains" to always pass validation (but validation can + still fail against a "maxContains" keyword).

    +

    + Omitting this keyword has the same behavior as a value of 1.

    +
    +
    +
    +

    +6.5. Validation Keywords for Objects +

    +
    +

    +6.5.1. maxProperties +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + An object instance is valid against "maxProperties" if its + number of properties is less than, or equal to, the value of this + keyword.

    +
    +
    +

    +6.5.2. minProperties +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + An object instance is valid against "minProperties" if its + number of properties is greater than, or equal to, the value of this + keyword.

    +

    + Omitting this keyword has the same behavior as a value of 0.

    +
    +
    +

    +6.5.3. required +

    +

    + The value of this keyword MUST be an array. + Elements of this array, if any, MUST be strings, and MUST be unique.

    +

    + An object instance is valid against this keyword if every item in the array is + the name of a property in the instance.

    +

    + Omitting this keyword has the same behavior as an empty array.

    +
    +
    +

    +6.5.4. dependentRequired +

    +

    + The value of this keyword MUST be an object. Properties in + this object, if any, MUST be arrays. Elements in each array, + if any, MUST be strings, and MUST be unique.

    +

    + This keyword specifies properties that are required if a specific + other property is present. Their requirement is dependent on the + presence of the other property.

    +

    + Validation succeeds if, for each name that appears in both + the instance and as a name within this keyword's value, every + item in the corresponding array is also the name of a property + in the instance.

    +

    + Omitting this keyword has the same behavior as an empty object.

    +
    +
    +
    +
    +
    +

    +7. Vocabularies for Semantic Content With "format" +

    +
    +

    +7.1. Foreword +

    +

    + Structural validation alone may be insufficient to allow an application to correctly + utilize certain values. The "format" annotation keyword is defined to allow schema + authors to convey semantic information for a fixed subset of values which are + accurately described by authoritative resources, be they RFCs or other external + specifications.

    +

    + The value of this keyword is called a format attribute. It MUST be a string. A + format attribute can generally only validate a given set of instance types. If + the type of the instance to validate is not in this set, validation for this + format attribute and instance SHOULD succeed. All format attributes defined + in this section apply to strings, but a format attribute can be specified + to apply to any instance types defined in the data model defined in the + core JSON Schema. [json-schema] + + Note that the "type" keyword in this specification defines an "integer" type + which is not part of the data model. Therefore a format attribute can be + limited to numbers, but not specifically to integers. However, a numeric + format can be used alongside the "type" keyword with a value of "integer", + or could be explicitly defined to always pass if the number is not an integer, + which produces essentially the same behavior as only applying to integers. +

    +

    + The current URI for this vocabulary, known as the Format-Annotation vocabulary, is: + <https://json-schema.org/draft/2020-12/vocab/format-annotation>. The current + URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/format-annotation. + Implementing support for this vocabulary is REQUIRED.

    +

    + In addition to the Format-Annotation vocabulary, a secondary vocabulary is available + for custom meta-schemas that defines "format" as an assertion. The URI for the + Format-Assertion vocabulary, is: + <https://json-schema.org/draft/2020-12/vocab/format-assertion>. The current + URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/format-assertion. + Implementing support for the Format-Assertion vocabulary is OPTIONAL.

    +

    + Specifying both the Format-Annotation and the Format-Assertion vocabularies is functionally + equivalent to specifying only the Format-Assertion vocabulary since its requirements + are a superset of the Format-Annotation vocabulary.

    +
    +
    +

    +7.2. Implementation Requirements +

    +

    + The "format" keyword functions as defined by the vocabulary which is referenced.

    +
    +

    +7.2.1. Format-Annotation Vocabulary +

    +

    + The value of format MUST be collected as an annotation, if the implementation + supports annotation collection. This enables application-level validation when + schema validation is unavailable or inadequate.

    +

    + Implementations MAY still treat "format" as an assertion in addition to an + annotation and attempt to validate the value's conformance to the specified + semantics. The implementation MUST provide options to enable and disable such + evaluation and MUST be disabled by default. Implementations SHOULD document + their level of support for such validation. + + Specifying the Format-Annotation vocabulary and enabling validation in an + implementation should not be viewed as being equivalent to specifying + the Format-Assertion vocabulary since implementations are not required to + provide full validation support when the Format-Assertion vocabulary + is not specified. +

    +

    + When the implementation is configured for assertion behavior, it:

    +
      +
    • + SHOULD provide an implementation-specific best effort validation + for each format attribute defined below; +
    • +
    • + MAY choose to implement validation of any or all format attributes + as a no-op by always producing a validation result of true; +
    • +
    +

    + + This matches the current reality of implementations, which provide + widely varying levels of validation, including no validation at all, + for some or all format attributes. It is also designed to encourage + relying only on the annotation behavior and performing semantic + validation in the application, which is the recommended best practice. +

    +
    +
    +

    +7.2.2. Format-Assertion Vocabulary +

    +

    + When the Format-Assertion vocabulary is declared with a value of true, + implementations MUST provide full validation support for all of the formats + defined by this specificaion. Implementations that cannot provide full + validation support MUST refuse to process the schema.

    +

    + An implementation that supports the Format-Assertion vocabulary:

    +
      +
    • + MUST still collect "format" as an annotation if the implementation + supports annotation collection; +
    • +
    • + MUST evaluate "format" as an assertion; +
    • +
    • + MUST implement syntactic validation for all format attributes defined + in this specification, and for any additional format attributes that + it recognizes, such that there exist possible instance values + of the correct type that will fail validation. +
    • +
    +

    + The requirement for minimal validation of format attributes is intentionally + vague and permissive, due to the complexity involved in many of the attributes. + Note in particular that the requirement is limited to syntactic checking; it is + not to be expected that an implementation would send an email, attempt to connect + to a URL, or otherwise check the existence of an entity identified by a format + instance. + + The expectation is that for simple formats such as date-time, syntactic + validation will be thorough. For a complex format such as email addresses, + which are the amalgamation of various standards and numerous adjustments + over time, with obscure and/or obsolete rules that may or may not be + restricted by other applications making use of the value, a minimal validation + is sufficient. For example, an instance string that does not contain + an "@" is clearly not a valid email address, and an "email" or "hostname" + containing characters outside of 7-bit ASCII is likewise clearly invalid. +

    +

    + It is RECOMMENDED that implementations use a common parsing library for each format, + or a well-known regular expression. Implementations SHOULD clearly document + how and to what degree each format attribute is validated.

    +

    + The standard core and validation meta-schema (Section 5) + includes this vocabulary in its "$vocabulary" keyword with a value of false, + since by default implementations are not required to support this keyword + as an assertion. Supporting the format vocabulary with a value of true is + understood to greatly increase code size and in some cases execution time, + and will not be appropriate for all implementations.

    +
    +
    +

    +7.2.3. Custom format attributes +

    +

    + Implementations MAY support custom format attributes. Save for agreement between + parties, schema authors SHALL NOT expect a peer implementation to support such + custom format attributes. An implementation MUST NOT fail to collect unknown formats + as annotations. When the Format-Assertion vocabulary is specified, implementations + MUST fail upon encountering unknown formats.

    +

    + Vocabularies do not support specifically declaring different value sets for keywords. + Due to this limitation, and the historically uneven implementation of this keyword, + it is RECOMMENDED to define additional keywords in a custom vocabulary rather than + additional format attributes if interoperability is desired.

    +
    +
    +
    +

    +7.3. Defined Formats +

    +
    +

    +7.3.1. Dates, Times, and Duration +

    +

    + These attributes apply to string instances.

    +

    + Date and time format names are derived from + RFC 3339, section 5.6 [RFC3339]. + The duration format is from the ISO 8601 ABNF as given + in Appendix A of RFC 3339.

    +

    + Implementations supporting formats SHOULD implement support for + the following attributes:

    +
    +
    date-time:
    +
    + A string instance is valid against this attribute if it is + a valid representation according to the "date-time' ABNF rule + (referenced above) +
    +
    +
    date:
    +
    + A string instance is valid against this attribute if it is + a valid representation according to the "full-date" ABNF rule + (referenced above) +
    +
    +
    time:
    +
    + A string instance is valid against this attribute if it is + a valid representation according to the "full-time" ABNF rule + (referenced above) +
    +
    +
    duration:
    +
    + A string instance is valid against this attribute if it is + a valid representation according to the "duration" ABNF rule + (referenced above) +
    +
    +
    +

    + Implementations MAY support additional attributes using the other + format names defined anywhere in that RFC. If "full-date" or "full-time" + are implemented, the corresponding short form ("date" or "time" + respectively) MUST be implemented, and MUST behave identically. + Implementations SHOULD NOT define extension attributes + with any name matching an RFC 3339 format unless it validates + according to the rules of that format. + + There is not currently consensus on the need for supporting + all RFC 3339 formats, so this approach of reserving the + namespace will encourage experimentation without committing + to the entire set. Either the format implementation requirements + will become more flexible in general, or these will likely + either be promoted to fully specified attributes or dropped. +

    +
    +
    +

    +7.3.2. Email Addresses +

    +

    + These attributes apply to string instances.

    +

    + A string instance is valid against these attributes if it is a valid + Internet email address as follows:

    +
    +
    email:
    +
    + As defined by the "Mailbox" ABNF rule in + RFC 5321, section 4.1.2 [RFC5321]. +
    +
    +
    idn-email:
    +
    + As defined by the extended "Mailbox" ABNF rule in + RFC 6531, section 3.3 [RFC6531]. +
    +
    +
    +

    + Note that all strings valid against the "email" attribute are also + valid against the "idn-email" attribute.

    +
    +
    +

    +7.3.3. Hostnames +

    +

    + These attributes apply to string instances.

    +

    + A string instance is valid against these attributes if it is a valid + representation for an Internet hostname as follows:

    +
    +
    hostname:
    +
    + As defined by RFC 1123, section 2.1 [RFC1123], + including host names produced using the Punycode algorithm + specified in RFC 5891, section 4.4 [RFC5891]. +
    +
    +
    idn-hostname:
    +
    + As defined by either RFC 1123 as for hostname, or an + internationalized hostname as defined by + RFC 5890, section 2.3.2.3 [RFC5890]. +
    +
    +
    +

    + Note that all strings valid against the "hostname" attribute are also + valid against the "idn-hostname" attribute.

    +
    +
    +

    +7.3.4. IP Addresses +

    +

    + These attributes apply to string instances.

    +

    + A string instance is valid against these attributes if it is a valid + representation of an IP address as follows:

    +
    +
    ipv4:
    +
    + An IPv4 address according to the "dotted-quad" ABNF + syntax as defined in + RFC 2673, section 3.2 [RFC2673]. +
    +
    +
    ipv6:
    +
    + An IPv6 address as defined in + RFC 4291, section 2.2 [RFC4291]. +
    +
    +
    +
    +
    +

    +7.3.5. Resource Identifiers +

    +

    + These attributes apply to string instances.

    +
    +
    uri:
    +
    + A string instance is valid against this attribute if it is + a valid URI, according to [RFC3986]. +
    +
    +
    uri-reference:
    +
    + A string instance is valid against this attribute if it is a valid URI + Reference (either a URI or a relative-reference), + according to [RFC3986]. +
    +
    +
    iri:
    +
    + A string instance is valid against this attribute if it is + a valid IRI, according to [RFC3987]. +
    +
    +
    iri-reference:
    +
    + A string instance is valid against this attribute if it is a valid IRI + Reference (either an IRI or a relative-reference), + according to [RFC3987]. +
    +
    +
    uuid:
    +
    + A string instance is valid against this attribute if it is a valid + string representation of a UUID, according to [RFC4122]. +
    +
    +
    +

    + Note that all valid URIs are valid IRIs, and all valid URI References are + also valid IRI References.

    +

    + Note also that the "uuid" format is for plain UUIDs, not UUIDs in URNs. An example + is "f81d4fae-7dec-11d0-a765-00a0c91e6bf6". For UUIDs as URNs, use the "uri" format, + with a "pattern" regular expression of "^urn:uuid:" to indicate the URI scheme and + URN namespace.

    +
    +
    +

    +7.3.6. uri-template +

    +

    + This attribute applies to string instances.

    +

    + A string instance is valid against this attribute if it is a valid URI Template + (of any level), according to [RFC6570].

    +

    + Note that URI Templates may be used for IRIs; there is no separate + IRI Template specification.

    +
    +
    +

    +7.3.7. JSON Pointers +

    +

    + These attributes apply to string instances.

    +
    +
    json-pointer:
    +
    + A string instance is valid against this attribute if it + is a valid JSON string representation of a JSON Pointer, + according to RFC 6901, section 5 [RFC6901]. +
    +
    +
    relative-json-pointer:
    +
    + A string instance is valid against this attribute if it is a valid + Relative JSON Pointer [relative-json-pointer]. +
    +
    +
    +

    + To allow for both absolute and relative JSON Pointers, use "anyOf" or + "oneOf" to indicate support for either format.

    +
    +
    +

    +7.3.8. regex +

    +

    + This attribute applies to string instances.

    +

    + A regular expression, which SHOULD be valid according to the + ECMA-262 [ecma262] regular expression dialect.

    +

    + Implementations that validate formats MUST accept at least the subset of + ECMA-262 defined in the Regular Expressions (Section 4.3) + section of this specification, and SHOULD accept all valid ECMA-262 expressions.

    +
    +
    +
    +
    +
    +
    +

    +8. A Vocabulary for the Contents of String-Encoded Data +

    +
    +

    +8.1. Foreword +

    +

    + Annotations defined in this section indicate that an instance contains + non-JSON data encoded in a JSON string.

    +

    + These properties provide additional information required to interpret JSON data + as rich multimedia documents. They describe the type of content, how it is encoded, + and/or how it may be validated. They do not function as validation assertions; + a malformed string-encoded document MUST NOT cause the containing instance + to be considered invalid.

    +

    + Meta-schemas that do not use "$vocabulary" SHOULD be considered to + require this vocabulary as if its URI were present with a value of true.

    +

    + The current URI for this vocabulary, known as the Content vocabulary, is: + <https://json-schema.org/draft/2020-12/vocab/content>.

    +

    + The current URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/content.

    +
    +
    +

    +8.2. Implementation Requirements +

    +

    + Due to security and performance concerns, as well as the open-ended nature of + possible content types, implementations MUST NOT automatically decode, parse, + and/or validate the string contents by default. This additionally supports + the use case of embedded documents intended for processing by a different + consumer than that which processed the containing document.

    +

    + All keywords in this section apply only to strings, and have no + effect on other data types.

    +

    + Implementations MAY offer the ability to decode, parse, and/or validate + the string contents automatically. However, it MUST NOT perform these + operations by default, and MUST provide the validation result of each + string-encoded document separately from the enclosing document. This + process SHOULD be equivalent to fully evaluating the instance against + the original schema, followed by using the annotations to decode, parse, + and/or validate each string-encoded document. + + For now, the exact mechanism of performing and returning parsed + data and/or validation results from such an automatic decoding, parsing, + and validating feature is left unspecified. Should such a feature + prove popular, it may be specified more thoroughly in a future draft. +

    +

    + See also the Security Considerations (Section 10) + sections for possible vulnerabilities introduced by automatically + processing the instance string according to these keywords.

    +
    +
    +

    +8.3. contentEncoding +

    +

    + If the instance value is a string, this property defines that the string + SHOULD be interpreted as encoded binary data and decoded using the encoding + named by this property.

    +

    + Possible values indicating base 16, 32, and 64 encodings with several + variations are listed in RFC 4648 [RFC4648]. Additionally, + sections 6.7 and 6.8 of RFC 2045 [RFC2045] provide + encodings used in MIME. This keyword is derived from MIME's + Content-Transfer-Encoding header, which was designed to map binary data + into ASCII characters. It is not related to HTTP's Content-Encoding header, + which is used to encode (e.g. compress or encrypt) + the content of HTTP request and responses.

    +

    + As "base64" is defined in both RFCs, the definition + from RFC 4648 SHOULD be assumed unless the string is specifically intended + for use in a MIME context. Note that all of these encodings result in + strings consisting only of 7-bit ASCII characters. Therefore, this keyword + has no meaning for strings containing characters outside of that range.

    +

    + If this keyword is absent, but "contentMediaType" is present, this + indicates that the encoding is the identity encoding, meaning that + no transformation was needed in order to represent the content in + a UTF-8 string.

    +

    + The value of this property MUST be a string.

    +
    +
    +

    +8.4. contentMediaType +

    +

    + If the instance is a string, this property indicates the media type + of the contents of the string. If "contentEncoding" is present, + this property describes the decoded string.

    +

    + The value of this property MUST be a string, which MUST be a media type, + as defined by RFC 2046 [RFC2046].

    +
    +
    +

    +8.5. contentSchema +

    +

    + If the instance is a string, and if "contentMediaType" is present, this + property contains a schema which describes the structure of the string.

    +

    + This keyword MAY be used with any media type that can be mapped into + JSON Schema's data model.

    +

    + The value of this property MUST be a valid JSON schema. It SHOULD be ignored if + "contentMediaType" is not present.

    +
    +
    +

    +8.6. Example +

    +

    + Here is an example schema, illustrating the use of "contentEncoding" and + "contentMediaType":

    +
    +
    +
    +{
    +    "type": "string",
    +    "contentEncoding": "base64",
    +    "contentMediaType": "image/png"
    +}
    +
    +
    +
    +

    + Instances described by this schema are expected to be strings, + and their values should be interpretable as base64-encoded PNG images.

    +

    + Another example:

    +
    +
    +
    +{
    +    "type": "string",
    +    "contentMediaType": "text/html"
    +}
    +
    +
    +
    +

    + Instances described by this schema are expected to be strings containing HTML, + using whatever character set the JSON string was decoded into. + Per section 8.1 of + RFC 8259 [RFC8259], outside of an entirely closed + system, this MUST be UTF-8.

    +

    + This example describes a JWT that is MACed using the HMAC SHA-256 + algorithm, and requires the "iss" and "exp" fields in its claim set.

    +
    +
    +
    +{
    +    "type": "string",
    +    "contentMediaType": "application/jwt",
    +    "contentSchema": {
    +        "type": "array",
    +        "minItems": 2,
    +        "prefixItems": [
    +            {
    +                "const": {
    +                    "typ": "JWT",
    +                    "alg": "HS256"
    +                }
    +            },
    +            {
    +                "type": "object",
    +                "required": ["iss", "exp"],
    +                "properties": {
    +                    "iss": {"type": "string"},
    +                    "exp": {"type": "integer"}
    +                }
    +            }
    +        ]
    +    }
    +}
    +
    +
    +

    + Note that "contentEncoding" does not appear. While the "application/jwt" + media type makes use of base64url encoding, that is defined by the media + type, which determines how the JWT string is decoded into a list of two + JSON data structures: first the header, and then the payload. Since the + JWT media type ensures that the JWT can be represented in a JSON string, + there is no need for further encoding or decoding.

    +
    +
    +
    +
    +

    +9. A Vocabulary for Basic Meta-Data Annotations +

    +

    + These general-purpose annotation keywords provide commonly used information + for documentation and user interface display purposes. They are not intended + to form a comprehensive set of features. Rather, additional vocabularies + can be defined for more complex annotation-based applications.

    +

    + Meta-schemas that do not use "$vocabulary" SHOULD be considered to + require this vocabulary as if its URI were present with a value of true.

    +

    + The current URI for this vocabulary, known as the Meta-Data vocabulary, is: + <https://json-schema.org/draft/2020-12/vocab/meta-data>.

    +

    + The current URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/meta-data.

    +
    +

    +9.1. "title" and "description" +

    +

    + The value of both of these keywords MUST be a string.

    +

    + Both of these keywords can be used to decorate a user interface with + information about the data produced by this user interface. A title will + preferably be short, whereas a description will provide explanation about + the purpose of the instance described by this schema.

    +
    +
    +

    +9.2. "default" +

    +

    + There are no restrictions placed on the value of this keyword. When + multiple occurrences of this keyword are applicable to a single + sub-instance, implementations SHOULD remove duplicates.

    +

    + This keyword can be used to supply a default JSON value associated with a + particular schema. It is RECOMMENDED that a default value be valid against + the associated schema.

    +
    +
    +

    +9.3. "deprecated" +

    +

    + The value of this keyword MUST be a boolean. When multiple occurrences + of this keyword are applicable to a single sub-instance, applications + SHOULD consider the instance location to be deprecated if any occurrence + specifies a true value.

    +

    + If "deprecated" has a value of boolean true, it indicates that applications + SHOULD refrain from usage of the declared property. It MAY mean the property + is going to be removed in the future.

    +

    + A root schema containing "deprecated" with a value of true indicates that + the entire resource being described MAY be removed in the future.

    +

    + The "deprecated" keyword applies to each instance location to which the + schema object containing the keyword successfully applies. This can + result in scenarios where every array item or object property + is deprecated even though the containing array or object is not.

    +

    + Omitting this keyword has the same behavior as a value of false.

    +
    +
    +

    +9.4. "readOnly" and "writeOnly" +

    +

    + The value of these keywords MUST be a boolean. When multiple occurrences + of these keywords are applicable to a single sub-instance, the resulting + behavior SHOULD be as for a true value if any occurrence specifies a true value, + and SHOULD be as for a false value otherwise.

    +

    + If "readOnly" has a value of boolean true, it indicates that the value + of the instance is managed exclusively by the owning authority, and + attempts by an application to modify the value of this property are + expected to be ignored or rejected by that owning authority.

    +

    + An instance document that is marked as "readOnly" for the entire document + MAY be ignored if sent to the owning authority, or MAY result in an + error, at the authority's discretion.

    +

    + If "writeOnly" has a value of boolean true, it indicates that the value + is never present when the instance is retrieved from the owning authority. + It can be present when sent to the owning authority to update or create + the document (or the resource it represents), but it will not be included + in any updated or newly created version of the instance.

    +

    + An instance document that is marked as "writeOnly" for the entire document + MAY be returned as a blank document of some sort, or MAY produce an error + upon retrieval, or have the retrieval request ignored, at the authority's + discretion.

    +

    + For example, "readOnly" would be used to mark a database-generated serial + number as read-only, while "writeOnly" would be used to mark a password + input field.

    +

    + These keywords can be used to assist in user interface instance generation. + In particular, an application MAY choose to use a widget that hides + input values as they are typed for write-only fields.

    +

    + Omitting these keywords has the same behavior as values of false.

    +
    +
    +

    +9.5. "examples" +

    +

    + The value of this keyword MUST be an array. + There are no restrictions placed on the values within the array. + When multiple occurrences of this keyword are applicable to a single + sub-instance, implementations MUST provide a flat array of all + values rather than an array of arrays.

    +

    + This keyword can be used to provide sample JSON values associated with a + particular schema, for the purpose of illustrating usage. It is + RECOMMENDED that these values be valid against the associated schema.

    +

    + Implementations MAY use the value(s) of "default", if present, as + an additional example. If "examples" is absent, "default" + MAY still be used in this manner.

    +
    +
    +
    +
    +

    +10. Security Considerations +

    +

    + JSON Schema validation defines a vocabulary for JSON Schema core and concerns all + the security considerations listed there.

    +

    + JSON Schema validation allows the use of Regular Expressions, which have numerous + different (often incompatible) implementations. + Some implementations allow the embedding of arbitrary code, which is outside the + scope of JSON Schema and MUST NOT be permitted. + Regular expressions can often also be crafted to be extremely expensive to compute + (with so-called "catastrophic backtracking"), resulting in a denial-of-service + attack.

    +

    + Implementations that support validating or otherwise evaluating instance + string data based on "contentEncoding" and/or "contentMediaType" are at + risk of evaluating data in an unsafe way based on misleading information. + Applications can mitigate this risk by only performing such processing + when a relationship between the schema and instance is established + (e.g., they share the same authority).

    +

    + Processing a media type or encoding is subject to the security considerations + of that media type or encoding. For example, the security considerations + of RFC 4329 Scripting Media Types [RFC4329] apply when + processing JavaScript or ECMAScript encoded within a JSON string.

    +
    +
    +
    +

    +11. References +

    +
    +

    +11.1. Normative References +

    +
    +
    [RFC2119]
    +
    +Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://www.rfc-editor.org/info/rfc2119>.
    +
    +
    [RFC1123]
    +
    +Braden, R., Ed., "Requirements for Internet Hosts - Application and Support", STD 3, RFC 1123, DOI 10.17487/RFC1123, , <https://www.rfc-editor.org/info/rfc1123>.
    +
    +
    [RFC2045]
    +
    +Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", RFC 2045, DOI 10.17487/RFC2045, , <https://www.rfc-editor.org/info/rfc2045>.
    +
    +
    [RFC2046]
    +
    +Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types", RFC 2046, DOI 10.17487/RFC2046, , <https://www.rfc-editor.org/info/rfc2046>.
    +
    +
    [RFC2673]
    +
    +Crawford, M., "Binary Labels in the Domain Name System", RFC 2673, DOI 10.17487/RFC2673, , <https://www.rfc-editor.org/info/rfc2673>.
    +
    +
    [RFC3339]
    +
    +Klyne, G. and C. Newman, "Date and Time on the Internet: Timestamps", RFC 3339, DOI 10.17487/RFC3339, , <https://www.rfc-editor.org/info/rfc3339>.
    +
    +
    [RFC3986]
    +
    +Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, , <https://www.rfc-editor.org/info/rfc3986>.
    +
    +
    [RFC3987]
    +
    +Duerst, M. and M. Suignard, "Internationalized Resource Identifiers (IRIs)", RFC 3987, DOI 10.17487/RFC3987, , <https://www.rfc-editor.org/info/rfc3987>.
    +
    +
    [RFC4122]
    +
    +Leach, P., Mealling, M., and R. Salz, "A Universally Unique IDentifier (UUID) URN Namespace", RFC 4122, DOI 10.17487/RFC4122, , <https://www.rfc-editor.org/info/rfc4122>.
    +
    +
    [RFC4291]
    +
    +Hinden, R. and S. Deering, "IP Version 6 Addressing Architecture", RFC 4291, DOI 10.17487/RFC4291, , <https://www.rfc-editor.org/info/rfc4291>.
    +
    +
    [RFC4648]
    +
    +Josefsson, S., "The Base16, Base32, and Base64 Data Encodings", RFC 4648, DOI 10.17487/RFC4648, , <https://www.rfc-editor.org/info/rfc4648>.
    +
    +
    [RFC5321]
    +
    +Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, DOI 10.17487/RFC5321, , <https://www.rfc-editor.org/info/rfc5321>.
    +
    +
    [RFC5890]
    +
    +Klensin, J., "Internationalized Domain Names for Applications (IDNA): Definitions and Document Framework", RFC 5890, DOI 10.17487/RFC5890, , <https://www.rfc-editor.org/info/rfc5890>.
    +
    +
    [RFC5891]
    +
    +Klensin, J., "Internationalized Domain Names in Applications (IDNA): Protocol", RFC 5891, DOI 10.17487/RFC5891, , <https://www.rfc-editor.org/info/rfc5891>.
    +
    +
    [RFC6570]
    +
    +Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, "URI Template", RFC 6570, DOI 10.17487/RFC6570, , <https://www.rfc-editor.org/info/rfc6570>.
    +
    +
    [RFC6531]
    +
    +Yao, J. and W. Mao, "SMTP Extension for Internationalized Email", RFC 6531, DOI 10.17487/RFC6531, , <https://www.rfc-editor.org/info/rfc6531>.
    +
    +
    [RFC6901]
    +
    +Bryan, P., Ed., Zyp, K., and M. Nottingham, Ed., "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, , <https://www.rfc-editor.org/info/rfc6901>.
    +
    +
    [RFC8259]
    +
    +Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, , <https://www.rfc-editor.org/info/rfc8259>.
    +
    +
    [ecma262]
    +
    +"ECMA-262, 11th edition specification", , <https://www.ecma-international.org/ecma-262/11.0>.
    +
    +
    [relative-json-pointer]
    +
    +Luff, G., Andrews, H., and B. Hutton, Ed., "Relative JSON Pointers", Work in Progress, Internet-Draft, draft-handrews-relative-json-pointer-01, , <https://datatracker.ietf.org/doc/html/draft-handrews-relative-json-pointer-01>.
    +
    +
    [json-schema]
    +
    +Wright, A., Andrews, H., Hutton, B., and G. Dennis, "JSON Schema: A Media Type for Describing JSON Documents", Work in Progress, Internet-Draft, draft-bhutton-json-schema-01, , <https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-01>.
    +
    +
    +
    +
    +

    +11.2. Informative References +

    +
    +
    [RFC4329]
    +
    +Hoehrmann, B., "Scripting Media Types", RFC 4329, DOI 10.17487/RFC4329, , <https://www.rfc-editor.org/info/rfc4329>.
    +
    +
    +
    +
    +
    +

    +Appendix A. Keywords Moved from Validation to Core +

    +

    + Several keywords have been moved from this document into the + Core Specification [json-schema] as of this draft, in some + cases with re-naming or other changes. This affects the following former + validation keywords:

    +
    +
    "definitions"
    +
    + Renamed to "$defs" to match "$ref" and be shorter to type. + Schema vocabulary authors SHOULD NOT define a "definitions" keyword + with different behavior in order to avoid invalidating schemas that + still use the older name. While "definitions" is absent in the + single-vocabulary meta-schemas referenced by this document, it + remains present in the default meta-schema, and implementations + SHOULD assume that "$defs" and "definitions" have the same + behavior when that meta-schema is used. +
    +
    +
    "allOf", "anyOf", "oneOf", "not", "if", "then", "else", "items", "additionalItems", "contains", "propertyNames", "properties", "patternProperties", "additionalProperties"
    +
    + All of these keywords apply subschemas to the instance and combine + their results, without asserting any conditions of their own. + Without assertion keywords, these applicators can only cause assertion + failures by using the false boolean schema, or by inverting the result + of the true boolean schema (or equivalent schema objects). + For this reason, they are better defined as a generic mechanism on which + validation, hyper-schema, and extension vocabularies can all be based. +
    +
    +
    "dependencies"
    +
    + This keyword had two different modes of behavior, which made it + relatively challenging to implement and reason about. + The schema form has been moved to Core and renamed to + "dependentSchemas", as part of the applicator vocabulary. + It is analogous to "properties", except that instead of applying + its subschema to the property value, it applies it to the object + containing the property. + The property name array form is retained here and renamed to + "dependentRequired", as it is an assertion which is a shortcut + for the conditional use of the "required" assertion keyword. +
    +
    +
    +
    +
    +

    +Appendix B. Acknowledgments +

    +

    + Thanks to + Gary Court, + Francis Galiegue, + Kris Zyp, + and Geraint Luff + for their work on the initial drafts of JSON Schema.

    +

    + Thanks to + Jason Desrosiers, + Daniel Perrett, + Erik Wilde, + Evgeny Poberezkin, + Brad Bowman, + Gowry Sankar, + Donald Pipowitch, + Dave Finlay, + Denis Laxalde, + Phil Sturgeon, + Shawn Silverman, + and Karen Etheridge + for their submissions and patches to the document.

    +
    +
    +

    +Appendix C. ChangeLog +

    +

    + This section to be removed before leaving Internet-Draft status.

    +
    +
    draft-bhutton-json-schema-validation-00
    +
    +
      +
    • Correct email format RFC reference to 5321 instead of 5322 +
    • +
    • Clarified the set and meaning of "contentEncoding" values +
    • +
    • Reference ECMA-262, 11th edition for regular expression support +
    • +
    • Split "format" into an annotation only vocabulary and an assertion vocabulary +
    • +
    • Clarify "deprecated" when applicable to arrays +
    • +
    +
    +
    +
    draft-handrews-json-schema-validation-02
    +
    +
      +
    • Grouped keywords into formal vocabularies +
    • +
    • Update "format" implementation requirements in terms of vocabularies +
    • +
    • By default, "format" MUST NOT be validated, although validation can be enabled +
    • +
    • A vocabulary declaration can be used to require "format" validation +
    • +
    • Moved "definitions" to the core spec as "$defs" +
    • +
    • Moved applicator keywords to the core spec +
    • +
    • Renamed the array form of "dependencies" to "dependentRequired", moved the schema form to the core spec +
    • +
    • Specified all "content*" keywords as annotations, not assertions +
    • +
    • Added "contentSchema" to allow applying a schema to a string-encoded document +
    • +
    • Also allow RFC 4648 encodings in "contentEncoding" +
    • +
    • Added "minContains" and "maxContains" +
    • +
    • Update RFC reference for "hostname" and "idn-hostname" +
    • +
    • Add "uuid" and "duration" formats +
    • +
    +
    +
    +
    draft-handrews-json-schema-validation-01
    +
    +
      +
    • This draft is purely a clarification with no functional changes +
    • +
    • Provided the general principle behind ignoring annotations under "not" and similar cases +
    • +
    • Clarified "if"/"then"/"else" validation interactions +
    • +
    • Clarified "if"/"then"/"else" behavior for annotation +
    • +
    • Minor formatting and cross-referencing improvements +
    • +
    +
    +
    +
    draft-handrews-json-schema-validation-00
    +
    +
      +
    • Added "if"/"then"/"else" +
    • +
    • Classify keywords as assertions or annotations per the core spec +
    • +
    • Warn of possibly removing "dependencies" in the future +
    • +
    • Grouped validation keywords into sub-sections for readability +
    • +
    • Moved "readOnly" from hyper-schema to validation meta-data +
    • +
    • Added "writeOnly" +
    • +
    • Added string-encoded media section, with former hyper-schema "media" keywords +
    • +
    • Restored "regex" format (removal was unintentional) +
    • +
    • Added "date" and "time" formats, and reserved additional RFC 3339 format names +
    • +
    • I18N formats: "iri", "iri-reference", "idn-hostname", "idn-email" +
    • +
    • Clarify that "json-pointer" format means string encoding, not URI fragment +
    • +
    • Fixed typo that inverted the meaning of "minimum" and "exclusiveMinimum" +
    • +
    • Move format syntax references into Normative References +
    • +
    • JSON is a normative requirement +
    • +
    +
    +
    +
    draft-wright-json-schema-validation-01
    +
    +
      +
    • Standardized on hyphenated format names with full words ("uriref" becomes "uri-reference") +
    • +
    • Add the formats "uri-template" and "json-pointer" +
    • +
    • Changed "exclusiveMaximum"/"exclusiveMinimum" from boolean modifiers of "maximum"/"minimum" to independent numeric fields. +
    • +
    • Split the additionalItems/items into two sections +
    • +
    • Reworked properties/patternProperties/additionalProperties definition +
    • +
    • Added "examples" keyword +
    • +
    • Added "contains" keyword +
    • +
    • Allow empty "required" and "dependencies" arrays +
    • +
    • Fixed "type" reference to primitive types +
    • +
    • Added "const" keyword +
    • +
    • Added "propertyNames" keyword +
    • +
    +
    +
    +
    draft-wright-json-schema-validation-00
    +
    +
      +
    • Added additional security considerations +
    • +
    • Removed reference to "latest version" meta-schema, use numbered version instead +
    • +
    • Rephrased many keyword definitions for brevity +
    • +
    • Added "uriref" format that also allows relative URI references +
    • +
    +
    +
    +
    draft-fge-json-schema-validation-00
    +
    +
      +
    • Initial draft. +
    • +
    • Salvaged from draft v3. +
    • +
    • Redefine the "required" keyword. +
    • +
    • Remove "extends", "disallow" +
    • +
    • Add "anyOf", "allOf", "oneOf", "not", "definitions", "minProperties", + "maxProperties". +
    • +
    • "dependencies" member values can no longer be single strings; at + least one element is required in a property dependency array. +
    • +
    • Rename "divisibleBy" to "multipleOf". +
    • +
    • "type" arrays can no longer have schemas; remove "any" as a possible + value. +
    • +
    • Rework the "format" section; make support optional. +
    • +
    • "format": remove attributes "phone", "style", "color"; rename + "ip-address" to "ipv4"; add references for all attributes. +
    • +
    • Provide algorithms to calculate schema(s) for array/object + instances. +
    • +
    • Add interoperability considerations. +
    • +
    +
    +
    +
    +
    +
    +
    +

    +Authors' Addresses +

    +
    +
    Austin Wright (editor)
    + +
    +
    +
    Henry Andrews (editor)
    + +
    +
    +
    Ben Hutton (editor)
    + + +
    +
    +
    + + + diff --git a/work-in-progress/index.md b/work-in-progress/index.md index f2cf1e87..8e16de33 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -7,6 +7,44 @@ permalink: /work-in-progress * TOC {:toc} -We're working towards draft 2021-NN. +## Right now + +We're working towards JSON Schema 2022-NN. + +Additionally, we're working on draft 2020-12-patch-1 ([Associated GitHub milestone](https://github.com/json-schema-org/json-schema-spec/milestone/9)) + +## Release latest news + +On 2022-04-29, we published Release Candiate 0 for this release. + +These documents will be given the IETF identifiers `draft-bhutton-*-01`. + +## RC-0 preview + +You can find RC-0 preview of the following documents: +- [JSON Schema Core specificatoin](/draft/preview/jsonschema-core.html) +- [JSON Schema Validation specification](/draft/preview/jsonschema-validation.html) + +There are no changes to the Relative JSON Pointer specification. + +View the git diff on GitHub for: +- [draft 2020-12 release to 2020-12-patch-01-rc0](https://github.com/json-schema-org/json-schema-spec/compare/2020-12...draft-bhutton--01-rc0) (git tag `draft-bhutton--01-rc0) +- [draft 2020-12 release to master](https://github.com/json-schema-org/json-schema-spec/compare/2020-12...master) (This may include changes based on Release Candidate feedback) + +This "work in progress" page will be updated as the release progress for 2020-12-patch-1 progresses. + +## How to provide feedback for RC-0 +Note, feedback for RC-0 closes on 2022-05-14. + +Please make use of the two week feedback window for RC-0 by either: +- Filing issues on the [specification repository](https://github.com/json-schema-org/json-schema-spec/issues), making it clear the issue relates to 2020-12-patch-1-RC-0 +- Discuss in the [#specification channel on our Slack server](https://json-schema.slack.com/archives/CT7FF623C) - You will need to join if you haven't already + +**Please note, only feedback relating specifically to the changes found in the above diff are useful. This release is not making functional changes.** + +The previous `draft 2020-12` specification documents will become obsolete, as did draft-07 specification documents when they were patched. + +If you have suggestions for changes to the specification in general, we invite you to open a [Discussion on our GitHub organization](https://github.com/orgs/json-schema-org/discussions) and/or chat with us in the #general or #specificaiton channels on our [Slack server](/slack). + See the [GitHub repository](https://github.com/json-schema-org/json-schema-spec) for ongoing spec work. From d492f1f68e6cbf547ea7df48eb4aff58118fa98d Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Fri, 29 Apr 2022 09:30:35 +0100 Subject: [PATCH 191/311] Moved 2020-12-p1-rc-0 into specific folder in preview folder --- draft/preview/{ => 2020-12-p1-rc-0}/jsonschema-core.html | 0 .../preview/{ => 2020-12-p1-rc-0}/jsonschema-validation.html | 0 work-in-progress/index.md | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename draft/preview/{ => 2020-12-p1-rc-0}/jsonschema-core.html (100%) rename draft/preview/{ => 2020-12-p1-rc-0}/jsonschema-validation.html (100%) diff --git a/draft/preview/jsonschema-core.html b/draft/preview/2020-12-p1-rc-0/jsonschema-core.html similarity index 100% rename from draft/preview/jsonschema-core.html rename to draft/preview/2020-12-p1-rc-0/jsonschema-core.html diff --git a/draft/preview/jsonschema-validation.html b/draft/preview/2020-12-p1-rc-0/jsonschema-validation.html similarity index 100% rename from draft/preview/jsonschema-validation.html rename to draft/preview/2020-12-p1-rc-0/jsonschema-validation.html diff --git a/work-in-progress/index.md b/work-in-progress/index.md index 8e16de33..30aaea9c 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -22,8 +22,8 @@ These documents will be given the IETF identifiers `draft-bhutton-*-01`. ## RC-0 preview You can find RC-0 preview of the following documents: -- [JSON Schema Core specificatoin](/draft/preview/jsonschema-core.html) -- [JSON Schema Validation specification](/draft/preview/jsonschema-validation.html) +- [JSON Schema Core specificatoin](/draft/preview/2020-12-p1-rc-0/jsonschema-core.html) +- [JSON Schema Validation specification](/draft/preview/2020-12-p1-rc-0/jsonschema-validation.html) There are no changes to the Relative JSON Pointer specification. From 85dd6030e077a75ecf0edf36891542d3f302fa45 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Sat, 30 Apr 2022 10:27:51 -0700 Subject: [PATCH 192/311] spelling --- work-in-progress/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/work-in-progress/index.md b/work-in-progress/index.md index 30aaea9c..81f5f427 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -22,7 +22,7 @@ These documents will be given the IETF identifiers `draft-bhutton-*-01`. ## RC-0 preview You can find RC-0 preview of the following documents: -- [JSON Schema Core specificatoin](/draft/preview/2020-12-p1-rc-0/jsonschema-core.html) +- [JSON Schema Core specification](/draft/preview/2020-12-p1-rc-0/jsonschema-core.html) - [JSON Schema Validation specification](/draft/preview/2020-12-p1-rc-0/jsonschema-validation.html) There are no changes to the Relative JSON Pointer specification. From 228c76655ff3cf4ff90a1615ae9532f395bdc557 Mon Sep 17 00:00:00 2001 From: Clemens Uhlenhut Date: Mon, 2 May 2022 09:46:33 +0200 Subject: [PATCH 193/311] Update implementations.md Added information about the new JSON schema debugger in JSONBuddy. --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 5ff600c7..45f97ab3 100644 --- a/implementations.md +++ b/implementations.md @@ -259,7 +259,7 @@ _None currently support draft-06 or later._ - [Altova XMLSpy 2019r3](https://www.altova.com/xmlspy-xml-editor#json_schema) - *Graphical JSON Schema editor for draft-06 and draft-7, as well as validation of JSON files based on JSON Schema* - [Dashjoin JSON Schema editor](https://dashjoin.github.io/#/schema) - *Graphical online JSON Schema editor for draft-06 (minus oneOf, anyOf, allOf, not). The generated schema can be tested immediately via a form that is driven by it.* - [Hackolade Studio](https://hackolade.com/help/JSONSchemaEditor.html) - *Visual JSON Schema editor for draft-04, draft-06, draft-07, 2019-09, 2020-12, as well as data modeling tool for NoSQL databases, storage formats, REST APIs, and JSON in RDBMS. Also converts to and from: different draft specifications, DDL, XSD, Swagger, OpenAPI, YAML, Avro, Parquet, Protobuf, and most of the NoSQL script syntaxes. Includes a GUI for Entity-Relationship Diagrams and a Command-Line Interface.* -- [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator with JSON schema analyzer, context sensitive entry-helpers and sample data generation based on JSON schema. Support for draft-4, draft-6, draft-7 and 2019-09.* +- [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator with JSON schema analyzer, context sensitive entry-helpers and sample data generation based on JSON schema. Support for draft-4, draft-6, draft-7 and 2019-09. JSON Schema validation debugger: Step through the validation process and set breakpoints.* - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Liquid JSON Schema Editor](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON Schema editor for draft-04, draft-06, draft-07 and 2019-09, with split source code and grphical editing. Includes validation of JSON files based on JSON Schema, JSON Sample Generator and JSON Schema Documentation Generator.* - [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* From 63ebf52b5b48d30821eb82ddf95ad9f0ce9baa72 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 May 2022 22:02:06 +0000 Subject: [PATCH 194/311] Bump nokogiri from 1.10.5 to 1.13.6 Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.10.5 to 1.13.6. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.10.5...v1.13.6) --- updated-dependencies: - dependency-name: nokogiri dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3e8e182a..25dd3da2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -199,7 +199,7 @@ GEM rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) mercenary (0.3.6) - mini_portile2 (2.4.0) + mini_portile2 (2.8.0) minima (2.4.1) jekyll (~> 3.5) jekyll-feed (~> 0.9) @@ -207,13 +207,15 @@ GEM minitest (5.11.3) multipart-post (2.0.0) net-dns (0.8.0) - nokogiri (1.10.5) - mini_portile2 (~> 2.4.0) + nokogiri (1.13.6) + mini_portile2 (~> 2.8.0) + racc (~> 1.4) octokit (4.8.0) sawyer (~> 0.8.0, >= 0.5.3) pathutil (0.16.1) forwardable-extended (~> 2.6) public_suffix (2.0.5) + racc (1.6.0) rb-fsevent (0.10.3) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) From 0f6888b7d6160126f1fcab2bda6f931f519e6d4b Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Mon, 23 May 2022 11:45:02 +0100 Subject: [PATCH 195/311] Update office hours schedule Now only on the first Tuesday of the month, and by appointment --- index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.md b/index.md index e41723d8..57313053 100644 --- a/index.md +++ b/index.md @@ -39,7 +39,7 @@ We hold weekly Office Hours and twice monthly Open Community Working Meetings. 👷 Open Community Working Meetings -Office Hours are every Tuesday at 15:00 UTC. +Office Hours are every first Tuesday of the month at 15:00 UTC, and by appointment. Open Community Working Meetings are every First and Third Friday of the month at 12:00 PT. From 298ae8683bf4d065a6fa5507ec1f4cc134e2211c Mon Sep 17 00:00:00 2001 From: Kamil Giszczak Date: Tue, 31 May 2022 12:52:36 +0200 Subject: [PATCH 196/311] Add Shale, a Ruby schema and code generator --- implementations.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/implementations.md b/implementations.md index 785552b2..9ff96380 100644 --- a/implementations.md +++ b/implementations.md @@ -124,6 +124,8 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - [jsonschema-generator](https://github.com/victools/jsonschema-generator) (Apache 2.0) - generates schemas from Java types *supports Draft 7 and Draft 2019-09* - Scala - [scala-jsonschema](https://github.com/andyglow/scala-jsonschema) (Apache 2.0) - generates schemad out of Scala case classes +- Ruby + - [Shale](https://github.com/kgiszczak/shale) (MIT) - generates schema from Ruby models *supports Draft 2020-12* #### From data @@ -175,6 +177,8 @@ are the only keywords that changed. - [schemafy](https://github.com/Marwes/schemafy/) - generates Rust types and serialization code from a JSON schema. *supports Draft 4* - TypeScript - [jsongenerator](https://github.com/jimblackler/jsonschematypes/tree/master/codegen) *JSON Schema 2019-09, draft-07, -06, -04, -03* (Apache-2.0) +- Ruby + - [Shale](https://github.com/kgiszczak/shale) (MIT) - generates Ruby models from a JSON schema *supports Draft 2020-12* #### Web UI generation From 4991c4b9aeca623613c589acc3f52db67bc44805 Mon Sep 17 00:00:00 2001 From: Sam Weaver Date: Wed, 1 Jun 2022 15:12:18 -0400 Subject: [PATCH 197/311] Move JeSSE from obsolete to modern libraries on implementations page --- _data/validator-libraries-modern.yml | 6 ++++++ _data/validator-libraries-obsolete.yml | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 75b7ce46..ca0a2517 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -82,6 +82,12 @@ date-draft: draft: [7, 6, 4] license: MIT +- name: Erlang + implementations: + - name: JeSSE + url: https://github.com/for-GET/jesse + draft: [6, 4, 3] + license: "Apache 2.0" - name: Go implementations: - name: gojsonschema diff --git a/_data/validator-libraries-obsolete.yml b/_data/validator-libraries-obsolete.yml index f1c3a4e6..6cc5bd40 100644 --- a/_data/validator-libraries-obsolete.yml +++ b/_data/validator-libraries-obsolete.yml @@ -53,12 +53,6 @@ notes: draft: [4] license: BSL-1.0 -- name: Erlang - implementations: - - name: JeSSE - url: https://github.com/for-GET/jesse - draft: [4, 3] - license: "Apache 2.0" - name: Go implementations: - name: validate-json From a7be71bb5d0af223018b76093f0361e8816bd8d6 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Tue, 14 Jun 2022 09:29:01 +0100 Subject: [PATCH 198/311] Moved previous 2020-12 core and validation specification documents to obsolete folder, in line with previous obsolete structure from draft-07 --- draft/2020-12/{ => obsolete}/json-schema-core.html | 0 draft/2020-12/{ => obsolete}/json-schema-validation.html | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename draft/2020-12/{ => obsolete}/json-schema-core.html (100%) rename draft/2020-12/{ => obsolete}/json-schema-validation.html (100%) diff --git a/draft/2020-12/json-schema-core.html b/draft/2020-12/obsolete/json-schema-core.html similarity index 100% rename from draft/2020-12/json-schema-core.html rename to draft/2020-12/obsolete/json-schema-core.html diff --git a/draft/2020-12/json-schema-validation.html b/draft/2020-12/obsolete/json-schema-validation.html similarity index 100% rename from draft/2020-12/json-schema-validation.html rename to draft/2020-12/obsolete/json-schema-validation.html From a2530881fe5dfd7a5fe6fffde2c4be992c84ce70 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Tue, 14 Jun 2022 09:43:04 +0100 Subject: [PATCH 199/311] Remove 2020-12 patch preview Revert work in progress page to prior release ramp up --- .../2020-12-p1-rc-0/jsonschema-core.html | 5802 ----------------- .../jsonschema-validation.html | 3173 --------- work-in-progress/index.md | 40 +- 3 files changed, 1 insertion(+), 9014 deletions(-) delete mode 100644 draft/preview/2020-12-p1-rc-0/jsonschema-core.html delete mode 100644 draft/preview/2020-12-p1-rc-0/jsonschema-validation.html diff --git a/draft/preview/2020-12-p1-rc-0/jsonschema-core.html b/draft/preview/2020-12-p1-rc-0/jsonschema-core.html deleted file mode 100644 index b8a7b2e9..00000000 --- a/draft/preview/2020-12-p1-rc-0/jsonschema-core.html +++ /dev/null @@ -1,5802 +0,0 @@ - - - - - - -JSON Schema: A Media Type for Describing JSON Documents - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Internet-DraftJSON SchemaApril 2022
    Wright, et al.Expires 30 October 2022[Page]
    -
    -
    -
    -
    Workgroup:
    -
    Internet Engineering Task Force
    -
    Internet-Draft:
    -
    draft-bhutton-json-schema-01
    -
    Published:
    -
    - -
    -
    Intended Status:
    -
    Informational
    -
    Expires:
    -
    -
    Authors:
    -
    -
    -
    A. Wright, Ed. -
    -
    -
    -
    H. Andrews, Ed. -
    -
    -
    -
    B. Hutton, Ed. -
    -
    -
    -
    G. Dennis
    -
    -
    -
    -
    -

    JSON Schema: A Media Type for Describing JSON Documents

    -
    -

    Abstract

    -

    - JSON Schema defines the media type "application/schema+json", a JSON-based format - for describing the structure of JSON data. - JSON Schema asserts what a JSON document must look like, - ways to extract information from it, - and how to interact with it. - The "application/schema-instance+json" media type provides additional - feature-rich integration with "application/schema+json" beyond what can be offered - for "application/json" documents.

    -
    -
    -

    -Note to Readers -

    -

    - The issues list for this draft can be found at - https://github.com/json-schema-org/json-schema-spec/issues.

    -

    - For additional information, see https://json-schema.org/.

    -

    - To provide feedback, use this issue tracker, the communication methods listed on the - homepage, or email the document editors.

    -
    -
    -
    -

    -Status of This Memo -

    -

    - This Internet-Draft is submitted in full conformance with the - provisions of BCP 78 and BCP 79.

    -

    - Internet-Drafts are working documents of the Internet Engineering Task - Force (IETF). Note that other groups may also distribute working - documents as Internet-Drafts. The list of current Internet-Drafts is - at https://datatracker.ietf.org/drafts/current/.

    -

    - Internet-Drafts are draft documents valid for a maximum of six months - and may be updated, replaced, or obsoleted by other documents at any - time. It is inappropriate to use Internet-Drafts as reference - material or to cite them other than as "work in progress."

    -

    - This Internet-Draft will expire on 30 October 2022.

    -
    -
    - -
    -
    -

    -Table of Contents -

    - -
    -
    -
    -

    -1. Introduction -

    -

    - JSON Schema is a JSON media type for defining the structure of JSON data. JSON Schema - is intended to define validation, documentation, hyperlink navigation, and interaction - control of JSON data.

    -

    - This specification defines JSON Schema core terminology and mechanisms, including - pointing to another JSON Schema by reference, - dereferencing a JSON Schema reference, - specifying the dialect being used, - specifying a dialect's vocabulary requirements, - and defining the expected output.

    -

    - Other specifications define the vocabularies that perform assertions about validation, - linking, annotation, navigation, and interaction.

    -
    -
    -

    -2. Conventions and Terminology -

    -

    - - - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", - "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be - interpreted as described in RFC 2119 [RFC2119].

    -

    - The terms "JSON", "JSON text", "JSON value", "member", "element", "object", "array", - "number", "string", "boolean", "true", "false", and "null" in this document are to - be interpreted as defined in RFC 8259 [RFC8259].

    -
    -
    -

    -3. Overview -

    -

    - This document proposes a new media type "application/schema+json" to identify a JSON - Schema for describing JSON data. - It also proposes a further optional media type, "application/schema-instance+json", - to provide additional integration features. - JSON Schemas are themselves JSON documents. - This, and related specifications, define keywords allowing authors to describe JSON - data in several ways.

    -

    - JSON Schema uses keywords to assert constraints on JSON instances or annotate those - instances with additional information. Additional keywords are used to apply - assertions and annotations to more complex JSON data structures, or based on - some sort of condition.

    -

    - To facilitate re-use, keywords can be organized into vocabularies. A vocabulary - consists of a list of keywords, together with their syntax and semantics. - A dialect is defined as a set of vocabularies and their required support - identified in a meta-schema.

    -

    - JSON Schema can be extended either by defining additional vocabularies, - or less formally by defining additional keywords outside of any vocabulary. - Unrecognized individual keywords simply have their values collected as annotations, - while the behavior with respect to an unrecognized vocabulary can be controlled - when declaring which vocabularies are in use.

    -

    - This document defines a core vocabulary that MUST be supported by any - implementation, and cannot be disabled. Its keywords are each prefixed - with a "$" character to emphasize their required nature. This vocabulary - is essential to the functioning of the "application/schema+json" media - type, and is used to bootstrap the loading of other vocabularies.

    -

    - Additionally, this document defines a RECOMMENDED vocabulary of keywords - for applying subschemas conditionally, and for applying subschemas to - the contents of objects and arrays. Either this vocabulary or one very - much like it is required to write schemas for non-trivial JSON instances, - whether those schemas are intended for assertion validation, annotation, - or both. While not part of the required core vocabulary, for maximum - interoperability this additional vocabulary is included in this document - and its use is strongly encouraged.

    -

    - Further vocabularies for purposes such as structural validation or - hypermedia annotation are defined in other documents. These other - documents each define a dialect collecting the standard sets of - vocabularies needed to write schemas for that document's purpose.

    -
    -
    -

    -4. Definitions -

    -
    -

    -4.1. JSON Document -

    -

    - A JSON document is an information resource (series of octets) described by the - application/json media type.

    -

    - In JSON Schema, the terms "JSON document", "JSON text", and "JSON value" are - interchangeable because of the data model it defines.

    -

    - JSON Schema is only defined over JSON documents. However, any document or memory - structure that can be parsed into or processed according to the JSON Schema data - model can be interpreted against a JSON Schema, including media types like - CBOR [RFC7049].

    -
    -
    -

    -4.2. Instance -

    -

    - A JSON document to which a schema is applied is known as an "instance".

    -

    - JSON Schema is defined over "application/json" or compatible documents, - including media types with the "+json" structured syntax suffix.

    -

    - Among these, this specification defines the "application/schema-instance+json" - media type which defines handling for fragments in the URI.

    -
    -

    -4.2.1. Instance Data Model -

    -

    - JSON Schema interprets documents according to a data model. A JSON value - interpreted according to this data model is called an "instance".

    -

    - An instance has one of six primitive types, and a range of possible values - depending on the type:

    -
    -
    null:
    -
    A JSON "null" value -
    -
    -
    boolean:
    -
    A "true" or "false" value, from the JSON "true" or "false" value -
    -
    -
    object:
    -
    An unordered set of properties mapping a string to an instance, from the JSON "object" value -
    -
    -
    array:
    -
    An ordered list of instances, from the JSON "array" value -
    -
    -
    number:
    -
    An arbitrary-precision, base-10 decimal number value, from the JSON "number" value -
    -
    -
    string:
    -
    A string of Unicode code points, from the JSON "string" value -
    -
    -
    -

    - Whitespace and formatting concerns, including different lexical - representations of numbers that are equal within the data model, are thus - outside the scope of JSON Schema. JSON Schema - vocabularies (Section 8.1) that wish - to work with such differences in lexical representations SHOULD define - keywords to precisely interpret formatted strings within the data model - rather than relying on having the original JSON representation Unicode - characters available.

    -

    - Since an object cannot have two properties with the same key, behavior for a - JSON document that tries to define two properties with - the same key in a single object is undefined.

    -

    - Note that JSON Schema vocabularies are free to define their own extended - type system. This should not be confused with the core data model types - defined here. As an example, "integer" is a reasonable type for a - vocabulary to define as a value for a keyword, but the data model - makes no distinction between integers and other numbers.

    -
    -
    -

    -4.2.2. Instance Equality -

    -

    - Two JSON instances are said to be equal if and only if they are of the same type - and have the same value according to the data model. Specifically, this means:

    -
      -
    • both are null; or -
    • -
    • both are true; or -
    • -
    • both are false; or -
    • -
    • both are strings, and are the same codepoint-for-codepoint; or -
    • -
    • both are numbers, and have the same mathematical value; or -
    • -
    • both are arrays, and have an equal value item-for-item; or -
    • -
    • both are objects, and each property in one has exactly one property with - a key equal to the other's, and that other property has an equal - value. -
    • -
    -

    - Implied in this definition is that arrays must be the same length, - objects must have the same number of members, - properties in objects are unordered, - there is no way to define multiple properties with the same key, - and mere formatting differences (indentation, placement of commas, trailing - zeros) are insignificant.

    -
    -
    -

    -4.2.3. Non-JSON Instances -

    -

    - It is possible to use JSON Schema with a superset of the JSON Schema data model, - where an instance may be outside any of the six JSON data types.

    -

    - In this case, annotations still apply; but most validation keywords will not be useful, - as they will always pass or always fail.

    -

    - A custom vocabulary may define support for a superset of the core data model. - The schema itself may only be expressible in this superset; - for example, to make use of the "const" keyword.

    -
    -
    -
    -
    -

    -4.3. JSON Schema Documents -

    -

    - A JSON Schema document, or simply a schema, is a JSON document used to describe - an instance. - A schema can itself be interpreted as an instance, but SHOULD always be given - the media type "application/schema+json" rather than - "application/schema-instance+json". The "application/schema+json" media - type is defined to offer a superset of the - fragment identifier syntax and semantics provided by - "application/schema-instance+json".

    -

    - A JSON Schema MUST be an object or a boolean.

    -
    -

    -4.3.1. JSON Schema Objects and Keywords -

    -

    - Object properties that are applied to the instance are called keywords, - or schema keywords. Broadly speaking, keywords fall into one - of five categories:

    -
    -
    identifiers:
    -
    - control schema identification through setting a URI - for the schema and/or changing how the base URI is determined -
    -
    -
    assertions:
    -
    - produce a boolean result when applied to an instance -
    -
    -
    annotations:
    -
    - attach information to an instance for application use -
    -
    -
    applicators:
    -
    - apply one or more subschemas to a particular location - in the instance, and combine or modify their results -
    -
    -
    reserved locations:
    -
    - do not directly affect results, but reserve a place - for a specific purpose to ensure interoperability -
    -
    -
    -

    - Keywords may fall into multiple categories, although applicators - SHOULD only produce assertion results based on their subschemas' - results. They should not define additional constraints independent - of their subschemas.

    -

    - Keywords which are properties within the same schema object are referred to as adjacent keywords.

    -

    - Extension keywords, meaning those defined outside of this document - and its companions, are free to define other behaviors as well.

    -

    - A JSON Schema MAY contain properties which are not schema keywords. - Unknown keywords SHOULD be treated as annotations, where the value - of the keyword is the value of the annotation.

    -

    - An empty schema is a JSON Schema with no properties, or only unknown - properties.

    -
    -
    -

    -4.3.2. Boolean JSON Schemas -

    -

    - The boolean schema values "true" and "false" are trivial schemas that - always produce themselves as assertion results, regardless of the - instance value. They never produce annotation results.

    -

    - These boolean schemas exist to clarify schema author intent and - facilitate schema processing optimizations. They behave identically - to the following schema objects (where "not" is part of the - subschema application vocabulary defined in this document).

    -
    -
    true:
    -
    - Always passes validation, as if the empty schema {} -
    -
    -
    false:
    -
    - Always fails validation, as if the schema { "not": {} } -
    -
    -
    -

    - While the empty schema object is unambiguous, there are many - possible equivalents to the "false" schema. Using the boolean - values ensures that the intent is clear to both human readers - and implementations.

    -
    -
    -

    -4.3.3. Schema Vocabularies -

    -

    - A schema vocabulary, or simply a vocabulary, is a set of keywords, - their syntax, and their semantics. A vocabulary is generally organized - around a particular purpose. Different uses of JSON Schema, such - as validation, hypermedia, or user interface generation, will - involve different sets of vocabularies.

    -

    - Vocabularies are the primary unit of re-use in JSON Schema, as schema - authors can indicate what vocabularies are required or optional in - order to process the schema. Since vocabularies are identified by URIs - in the meta-schema, generic implementations can load extensions to support - previously unknown vocabularies. While keywords can be supported outside - of any vocabulary, there is no analogous mechanism to indicate individual - keyword usage.

    -

    - A schema vocabulary can be defined by anything from an informal description - to a standards proposal, depending on the audience and interoperability - expectations. In particular, in order to facilitate vocabulary use within - non-public organizations, a vocabulary specification need not be published - outside of its scope of use.

    -
    -
    -

    -4.3.4. Meta-Schemas -

    -

    - A schema that itself describes a schema is called a meta-schema. - Meta-schemas are used to validate JSON Schemas and specify which vocabularies - they are using.

    -

    - Typically, a meta-schema will specify a set of vocabularies, and validate - schemas that conform to the syntax of those vocabularies. However, meta-schemas - and vocabularies are separate in order to allow meta-schemas to validate - schema conformance more strictly or more loosely than the vocabularies' - specifications call for. Meta-schemas may also describe and validate - additional keywords that are not part of a formal vocabulary.

    -
    -
    -
    -

    -4.3.5. Root Schema and Subschemas and Resources -

    -

    - A JSON Schema resource is a schema which is - canonically [RFC6596] identified by an - absolute URI [RFC3986]. Schema resources MAY - also be identified by URIs, including URIs with fragments, - if the resulting secondary resource (as defined by - section 3.5 of RFC 3986 [RFC3986]) is identical - to the primary resource. This can occur with the empty fragment, - or when one schema resource is embedded in another. Any such URIs - with fragments are considered to be non-canonical.

    -

    - The root schema is the schema that comprises the entire JSON document - in question. The root schema is always a schema resource, where the - URI is determined as described in section - 9.1.1. - - Note that documents that embed schemas in another format will not - have a root schema resource in this sense. Exactly how such usages - fit with the JSON Schema document and resource concepts will be - clarified in a future draft. -

    -

    - Some keywords take schemas themselves, allowing JSON Schemas to be nested:

    -
    -
    -
    -{
    -    "title": "root",
    -    "items": {
    -        "title": "array item"
    -    }
    -}
    -
    -
    -
    -

    - In this example document, the schema titled "array item" is a subschema, - and the schema titled "root" is the root schema.

    -

    - As with the root schema, a subschema is either an object or a boolean.

    -

    - As discussed in section - 8.2.1, a JSON Schema document - can contain multiple JSON Schema resources. When used without qualification, - the term "root schema" refers to the document's root schema. In some - cases, resource root schemas are discussed. A resource's root schema - is its top-level schema object, which would also be a document root schema - if the resource were to be extracted to a standalone JSON Schema document.

    -

    - Whether multiple schema resources are embedded or linked with a reference, - they are processed in the same way, with the same available behaviors.

    -
    -
    -
    -
    -
    -
    -
    -

    -5. Fragment Identifiers -

    -

    - In accordance with section 3.1 of RFC 6839 [RFC6839], - the syntax and semantics of fragment identifiers specified for - any +json media type SHOULD be as specified for "application/json". - (At publication of this document, there is no fragment identification - syntax defined for "application/json".)

    -

    - Additionally, the "application/schema+json" media type supports two - fragment identifier structures: plain names and JSON Pointers. - The "application/schema-instance+json" media type supports one - fragment identifier structure: JSON Pointers.

    -

    - The use of JSON Pointers as URI fragment identifiers is described in - RFC 6901 [RFC6901]. - For "application/schema+json", which supports two fragment identifier syntaxes, - fragment identifiers matching the JSON Pointer syntax, including the empty string, - MUST be interpreted as JSON Pointer fragment identifiers.

    -

    - Per the W3C's - best practices for fragment identifiers [W3C.WD-fragid-best-practices-20121025], - plain name fragment identifiers in "application/schema+json" are reserved for referencing - locally named schemas. All fragment identifiers that do - not match the JSON Pointer syntax MUST be interpreted as - plain name fragment identifiers.

    -

    - Defining and referencing a plain name fragment identifier within an - "application/schema+json" document are specified - in the "$anchor" keyword (Section 8.2.2) section.

    -

    -
    -
    -
    -

    -6. General Considerations -

    -
    -

    -6.1. Range of JSON Values -

    -

    - An instance may be any valid JSON value as defined by JSON [RFC8259]. - JSON Schema imposes no restrictions on type: JSON Schema can describe any JSON - value, including, for example, null.

    -
    -
    -
    -

    -6.2. Programming Language Independence -

    -

    - JSON Schema is programming language agnostic, and supports the full range of - values described in the data model. - Be aware, however, that some languages and JSON parsers may not be able to - represent in memory the full range of values describable by JSON.

    -
    -
    -
    -
    -

    -6.3. Mathematical Integers -

    -

    - Some programming languages and parsers use different internal representations - for floating point numbers than they do for integers.

    -

    - For consistency, integer JSON numbers SHOULD NOT be encoded with a fractional - part.

    -
    -
    -
    -
    -

    -6.4. Regular Expressions -

    -

    - Keywords MAY use regular expressions to express constraints, or constrain - the instance value to be a regular expression. - These regular expressions SHOULD be valid according to the regular expression - dialect described in ECMA-262, section 21.2.1 [ecma262].

    -

    - Regular expressions SHOULD be built with the "u" flag (or equivalent) to provide - Unicode support, or processed in such a way which provides Unicode support as - defined by ECMA-262.

    -

    - Furthermore, given the high disparity in regular expression constructs support, - schema authors SHOULD limit themselves to the following regular expression - tokens:

    -
      -
    • individual Unicode characters, as defined by the JSON specification [RFC8259]; -
    • -
    • simple character classes ([abc]), range character classes ([a-z]); -
    • -
    • complemented character classes ([^abc], [^a-z]); -
    • -
    • simple quantifiers: "+" (one or more), "*" (zero or more), "?" (zero or - one), and their lazy versions ("+?", "*?", "??"); -
    • -
    • range quantifiers: "{x}" (exactly x occurrences), "{x,y}" (at least x, at - most y, occurrences), {x,} (x occurrences or more), and their lazy - versions; -
    • -
    • the beginning-of-input ("^") and end-of-input ("$") anchors; -
    • -
    • simple grouping ("(...)") and alternation ("|"). -
    • -
    -

    - Finally, implementations MUST NOT take regular expressions to be - anchored, neither at the beginning nor at the end. This means, for instance, - the pattern "es" matches "expression".

    -
    -
    -
    -
    -

    -6.5. Extending JSON Schema -

    -

    - Additional schema keywords and schema vocabularies MAY be defined - by any entity. Save for explicit agreement, schema authors SHALL NOT - expect these additional keywords and vocabularies to be supported by - implementations that do not explicitly document such support. - Implementations SHOULD treat keywords they do not support as annotations, - where the value of the keyword is the value of the annotation.

    -

    - Implementations MAY provide the ability to register or load handlers - for vocabularies that they do not support directly. The exact mechanism - for registering and implementing such handlers is implementation-dependent.

    -
    -
    -
    -
    -

    -7. Keyword Behaviors -

    -

    - JSON Schema keywords fall into several general behavior categories. - Assertions validate that an instance satisfies constraints, producing - a boolean result. Annotations attach information that applications - may use in any way they see fit. - Applicators apply subschemas to parts of the instance and combine - their results.

    -

    - Extension keywords SHOULD stay within these categories, keeping in mind - that annotations in particular are extremely flexible. Complex behavior - is usually better delegated to applications on the basis of annotation - data than implemented directly as schema keywords. However, extension - keywords MAY define other behaviors for specialized purposes.

    -

    - Evaluating an instance against a schema involves processing all of the - keywords in the schema against the appropriate locations within the instance. - Typically, applicator keywords are processed until a schema object with no - applicators (and therefore no subschemas) is reached. The appropriate - location in the instance is evaluated against the assertion and - annotation keywords in the schema object, and their results are gathered - into the parent schema according to the rules of the applicator.

    -

    - Evaluation of a parent schema object can complete once all of its - subschemas have been evaluated, although in some circumstances evaluation - may be short-circuited due to assertion results. When annotations are - being collected, some assertion result short-circuiting is not possible - due to the need to examine all subschemas for annotation collection, including - those that cannot further change the assertion result.

    -
    -
    -

    -7.1. Lexical Scope and Dynamic Scope -

    -

    - While most JSON Schema keywords can be evaluated on their own, - or at most need to take into account the values or results of - adjacent keywords in the same schema object, a few have more - complex behavior.

    -

    - The lexical scope of a keyword is determined by the nested JSON - data structure of objects and arrays. The largest such scope - is an entire schema document. The smallest scope is a single - schema object with no subschemas.

    -

    - Keywords MAY be defined with a partial value, such as a URI-reference, - which must be resolved against another value, such as another - URI-reference or a full URI, which is found through the lexical - structure of the JSON document. The "$id", "$ref", and - "$dynamicRef" core keywords, and the "base" JSON Hyper-Schema - keyword, are examples of this sort of behavior.

    -

    - Note that some keywords, such as "$schema", apply to the lexical - scope of the entire schema resource, and therefore MUST only - appear in a schema resource's root schema.

    -

    - Other keywords may take into account the dynamic scope that - exists during the evaluation of a schema, typically together - with an instance document. - The outermost dynamic scope is the schema object at - which processing begins, even if it is not a schema resource root. - The path from this root schema to any particular keyword (that - includes any "$ref" and "$dynamicRef" keywords that may have - been resolved) is considered the keyword's "validation path."

    -

    - Lexical and dynamic scopes align until a reference keyword - is encountered. While following the reference keyword moves processing - from one lexical scope into a different one, from the perspective - of dynamic scope, following a reference is no different from descending - into a subschema present as a value. A keyword on the far side of - that reference that resolves information through the dynamic scope - will consider the originating side of the reference to be their - dynamic parent, rather than examining the local lexically enclosing parent.

    -

    - The concept of dynamic scope is primarily used with "$dynamicRef" and - "$dynamicAnchor", and should be considered an advanced feature - and used with caution when defining additional keywords. It also appears - when reporting errors and collected annotations, as it may be possible - to revisit the same lexical scope repeatedly with different dynamic - scopes. In such cases, it is important to inform the user of the - dynamic path that produced the error or annotation.

    -
    -
    -
    -

    -7.2. Keyword Interactions -

    -

    - Keyword behavior MAY be defined in terms of the annotation results - of subschemas (Section 4.3.5) and/or adjacent keywords - (keywords within the same schema object) and their subschemas. - Such keywords MUST NOT result in a circular dependency. - Keywords MAY modify their behavior based on the presence or absence - of another keyword in the same - schema object (Section 4.3).

    -
    -
    -

    -7.3. Default Behaviors -

    -

    - A missing keyword MUST NOT produce a false assertion result, MUST - NOT produce annotation results, and MUST NOT cause any other schema - to be evaluated as part of its own behavioral definition. - However, given that missing keywords do not contribute annotations, - the lack of annotation results may indirectly change the behavior - of other keywords.

    -

    - In some cases, the missing keyword assertion behavior of a keyword is - identical to that produced by a certain value, and keyword definitions - SHOULD note such values where known. However, even if the value which - produces the default behavior would produce annotation results if - present, the default behavior still MUST NOT result in annotations.

    -

    - Because annotation collection can add significant cost in terms of both - computation and memory, implementations MAY opt out of this feature. - Keywords that are specified in terms of collected annotations SHOULD - describe reasonable alternate approaches when appropriate. - This approach is demonstrated by the - "items" and - "additionalProperties" keywords in this - document.

    -

    - Note that when no such alternate approach is possible for a keyword, - implementations that do not support annotation collections will not - be able to support those keywords or vocabularies that contain them.

    -
    -
    -

    -7.4. Identifiers -

    -

    - Identifiers define URIs for a schema, or affect how such URIs are - resolved in references (Section 8.2.3), or both. - The Core vocabulary defined in this document defines several - identifying keywords, most notably "$id".

    -

    - Canonical schema URIs MUST NOT change while processing an instance, but - keywords that affect URI-reference resolution MAY have behavior that - is only fully determined at runtime.

    -

    - While custom identifier keywords are possible, vocabulary designers should - take care not to disrupt the functioning of core keywords. For example, - the "$dynamicAnchor" keyword in this specification limits its URI resolution - effects to the matching "$dynamicRef" keyword, leaving the behavior - of "$ref" undisturbed.

    -
    -
    -
    -

    -7.5. Applicators -

    -

    - Applicators allow for building more complex schemas than can be accomplished - with a single schema object. Evaluation of an instance against a - schema document (Section 4.3) begins by applying - the root schema (Section 4.3.5) to the complete instance - document. From there, keywords known as applicators are used to determine - which additional schemas are applied. Such schemas may be applied in-place - to the current location, or to a child location.

    -

    - The schemas to be applied may be present as subschemas comprising all or - part of the keyword's value. Alternatively, an applicator may refer to - a schema elsewhere in the same schema document, or in a different one. - The mechanism for identifying such referenced schemas is defined by the - keyword.

    -

    - Applicator keywords also define how subschema or referenced schema - boolean assertion (Section 7.6) - results are modified and/or combined to produce the boolean result - of the applicator. Applicators may apply any boolean logic operation - to the assertion results of subschemas, but MUST NOT introduce new - assertion conditions of their own.

    -

    - Annotation (Section 7.7) results are - preserved along with the instance location and the location of - the schema keyword, so that applications can decide how to - interpret multiple values.

    -
    -
    -

    -7.5.1. Referenced and Referencing Schemas -

    -

    - As noted in Section 7.5, an applicator keyword may - refer to a schema to be applied, rather than including it as a - subschema in the applicator's value. In such situations, the - schema being applied is known as the referenced schema, while - the schema containing the applicator keyword is the referencing schema.

    -

    - While root schemas and subschemas are static concepts based on a - schema's position within a schema document, referenced and referencing - schemas are dynamic. Different pairs of schemas may find themselves - in various referenced and referencing arrangements during the evaluation - of an instance against a schema.

    -

    - For some by-reference applicators, such as - "$ref" (Section 8.2.3.1), the referenced schema can be determined - by static analysis of the schema document's lexical scope. Others, - such as "$dynamicRef" (with "$dynamicAnchor"), may make use of dynamic - scoping, and therefore only be resolvable in the process of evaluating - the schema with an instance.

    -
    -
    -
    -
    -
    -
    -

    -7.6. Assertions -

    -

    - JSON Schema can be used to assert constraints on a JSON document, which - either passes or fails the assertions. This approach can be used to validate - conformance with the constraints, or document what is needed to satisfy them.

    -

    - JSON Schema implementations produce a single boolean result when evaluating - an instance against schema assertions.

    -

    - An instance can only fail an assertion that is present in the schema.

    -
    -

    -7.6.1. Assertions and Instance Primitive Types -

    -

    - Most assertions only constrain values within a certain - primitive type. When the type of the instance is not of the type - targeted by the keyword, the instance is considered to conform - to the assertion.

    -

    - For example, the "maxLength" keyword from the companion - validation vocabulary [json-schema-validation]: - will only restrict certain strings - (that are too long) from being valid. If the instance is a number, - boolean, null, array, or object, then it is valid against this assertion.

    -

    - This behavior allows keywords to be used more easily with instances - that can be of multiple primitive types. The companion validation - vocabulary also includes a "type" keyword which can independently - restrict the instance to one or more primitive types. This allows - for a concise expression of use cases such as a function that might - return either a string of a certain length or a null value:

    -
    -
    -
    -{
    -    "type": ["string", "null"],
    -    "maxLength": 255
    -}
    -
    -
    -
    -

    - If "maxLength" also restricted the instance type to be a string, - then this would be substantially more cumbersome to express because - the example as written would not actually allow null values. - Each keyword is evaluated separately unless explicitly specified - otherwise, so if "maxLength" restricted the instance to strings, - then including "null" in "type" would not have any useful effect.

    -
    -
    -
    -
    -
    -

    -7.7. Annotations -

    -

    - JSON Schema can annotate an instance with information, whenever the instance - validates against the schema object containing the annotation, and all of its - parent schema objects. The information can be a simple value, or can be - calculated based on the instance contents.

    -

    - Annotations are attached to specific locations in an instance. - Since many subschemas can be applied to any single - location, applications may need to decide how to handle differing - annotation values being attached to the same instance location by - the same schema keyword in different schema objects.

    -

    - Unlike assertion results, annotation data can take a wide variety of forms, - which are provided to applications to use as they see fit. JSON Schema - implementations are not expected to make use of the collected information - on behalf of applications.

    -

    - Unless otherwise specified, the value of an annotation keyword - is the keyword's value. However, other behaviors are possible. - For example, JSON Hyper-Schema's [json-hyper-schema] - "links" keyword is a complex annotation that produces a value based - in part on the instance data.

    -

    - While "short-circuit" evaluation is possible for assertions, collecting - annotations requires examining all schemas that apply to an instance - location, even if they cannot change the overall assertion result. - The only exception is that subschemas of a schema object that has - failed validation MAY be skipped, as annotations are not retained - for failing schemas.

    -
    -

    -7.7.1. Collecting Annotations -

    -

    - Annotations are collected by keywords that explicitly define - annotation-collecting behavior. Note that boolean schemas cannot - produce annotations as they do not make use of keywords.

    -

    - A collected annotation MUST include the following information:

    -
      -
    • - The name of the keyword that produces the annotation -
    • -
    • - The instance location to which it is attached, as a JSON Pointer -
    • -
    • - The schema location path, indicating how reference keywords - such as "$ref" were followed to reach the absolute schema location. -
    • -
    • - The absolute schema location of the attaching keyword, as a URI. - This MAY be omitted if it is the same as the schema location path - from above. -
    • -
    • - The attached value(s) -
    • -
    -
    -
    -7.7.1.1. Distinguishing Among Multiple Values -
    -

    - Applications MAY make decisions on which of multiple annotation values - to use based on the schema location that contributed the value. - This is intended to allow flexible usage. Collecting the schema location - facilitates such usage.

    -

    - For example, consider this schema, which uses annotations and assertions from - the Validation specification [json-schema-validation]:

    -

    - Note that some lines are wrapped for clarity.

    -
    -
    -
    -{
    -    "title": "Feature list",
    -    "type": "array",
    -    "prefixItems": [
    -        {
    -            "title": "Feature A",
    -            "properties": {
    -                "enabled": {
    -                    "$ref": "#/$defs/enabledToggle",
    -                    "default": true
    -                }
    -            }
    -        },
    -        {
    -            "title": "Feature B",
    -            "properties": {
    -                "enabled": {
    -                    "description": "If set to null, Feature B
    -                                    inherits the enabled
    -                                    value from Feature A",
    -                    "$ref": "#/$defs/enabledToggle"
    -                }
    -            }
    -        }
    -    ],
    -    "$defs": {
    -        "enabledToggle": {
    -            "title": "Enabled",
    -            "description": "Whether the feature is enabled (true),
    -                            disabled (false), or under
    -                            automatic control (null)",
    -            "type": ["boolean", "null"],
    -            "default": null
    -        }
    -    }
    -}
    -
    -
    -
    -

    - In this example, both Feature A and Feature B make use of the re-usable - "enabledToggle" schema. That schema uses the "title", "description", - and "default" annotations. Therefore the application has to decide how - to handle the additional "default" value for Feature A, and the additional - "description" value for Feature B.

    -

    - The application programmer and the schema author need to agree on the - usage. For this example, let's assume that they agree that the most - specific "default" value will be used, and any additional, more generic - "default" values will be silently ignored. Let's also assume that they - agree that all "description" text is to be used, starting with the most - generic, and ending with the most specific. This requires the schema - author to write descriptions that work when combined in this way.

    -

    - The application can use the schema location path to determine which - values are which. The values in the feature's immediate "enabled" - property schema are more specific, while the values under the re-usable - schema that is referenced to with "$ref" are more generic. The schema - location path will show whether each value was found by crossing a - "$ref" or not.

    -

    - Feature A will therefore use a default value of true, while Feature B - will use the generic default value of null. Feature A will only - have the generic description from the "enabledToggle" schema, while - Feature B will use that description, and also append its locally - defined description that explains how to interpret a null value.

    -

    - Note that there are other reasonable approaches that a different application - might take. For example, an application may consider the presence of - two different values for "default" to be an error, regardless of their - schema locations.

    -
    -
    -
    -7.7.1.2. Annotations and Assertions -
    -

    - Schema objects that produce a false assertion result MUST NOT - produce any annotation results, whether from their own keywords - or from keywords in subschemas.

    -

    - Note that the overall schema results may still include annotations - collected from other schema locations. Given this schema:

    -
    -
    -
    -{
    -    "oneOf": [
    -        {
    -            "title": "Integer Value",
    -            "type": "integer"
    -        },
    -        {
    -            "title": "String Value",
    -            "type": "string"
    -        }
    -    ]
    -}
    -
    -
    -
    -

    - Against the instance "This is a string", the - title annotation "Integer Value" is discarded because the type assertion - in that schema object fails. The title annotation "String Value" - is kept, as the instance passes the string type assertions.

    -
    -
    -
    -7.7.1.3. Annotations and Applicators -
    -

    - In addition to possibly defining annotation results of their own, - applicator keywords aggregate the annotations collected in their - subschema(s) or referenced schema(s).

    -
    -
    -
    -
    -
    -

    -7.8. Reserved Locations -

    -

    - A fourth category of keywords simply reserve a location to hold re-usable - components or data of interest to schema authors that is not suitable - for re-use. These keywords do not affect validation or annotation results. - Their purpose in the core vocabulary is to ensure that locations are - available for certain purposes and will not be redefined by extension - keywords.

    -

    - While these keywords do not directly affect results, as explained in section - 9.4.2 unrecognized - extension keywords that reserve locations for re-usable schemas may have - undesirable interactions with references in certain circumstances.

    -
    -
    -

    -7.9. Loading Instance Data -

    -

    - While none of the vocabularies defined as part of this or the associated documents - define a keyword which may target and/or load instance data, it is possible that - other vocabularies may wish to do so.

    -

    - Keywords MAY be defined to use JSON Pointers or Relative JSON Pointers to examine - parts of an instance outside the current evaluation location.

    -

    - Keywords that allow adjusting the location using a Relative JSON Pointer SHOULD - default to using the current location if a default is desireable.

    -
    -
    -
    -

    -8. The JSON Schema Core Vocabulary -

    -

    - Keywords declared in this section, which all begin with "$", make up - the JSON Schema Core vocabulary. These keywords are either required in - order to process any schema or meta-schema, including those split across - multiple documents, or exist to reserve keywords for purposes that - require guaranteed interoperability.

    -

    - The Core vocabulary MUST be considered mandatory at all times, in order - to bootstrap the processing of further vocabularies. Meta-schemas - that use the "$vocabulary" (Section 8.1) keyword - to declare the vocabularies in use MUST explicitly list the Core vocabulary, - which MUST have a value of true indicating that it is required.

    -

    - The behavior of a false value for this vocabulary (and only this - vocabulary) is undefined, as is the behavior when "$vocabulary" - is present but the Core vocabulary is not included. However, it - is RECOMMENDED that implementations detect these cases and raise - an error when they occur. It is not meaningful to declare that - a meta-schema optionally uses Core.

    -

    - Meta-schemas that do not use "$vocabulary" MUST be considered to - require the Core vocabulary as if its URI were present with a value of true.

    -

    - The current URI for the Core vocabulary is: - <https://json-schema.org/draft/2020-12/vocab/core>.

    -

    - The current URI for the corresponding meta-schema is: - https://json-schema.org/draft/2020-12/meta/core.

    -

    - While the "$" prefix is not formally reserved for the Core vocabulary, - it is RECOMMENDED that extension keywords (in vocabularies or otherwise) - begin with a character other than "$" to avoid possible future collisions.

    -
    -
    -

    -8.1. Meta-Schemas and Vocabularies -

    -

    - Two concepts, meta-schemas and vocabularies, are used to inform an implementation - how to interpret a schema. Every schema has a meta-schema, which can be declared - using the "$schema" keyword.

    -

    - The meta-schema serves two purposes:

    -
    -
    Declaring the vocabularies in use
    -
    - The "$vocabulary" keyword, when it appears in a meta-schema, declares - which vocabularies are available to be used in schemas that refer - to that meta-schema. Vocabularies define keyword semantics, - as well as their general syntax. -
    -
    -
    Describing valid schema syntax
    -
    - A schema MUST successfully validate against its meta-schema, which - constrains the syntax of the available keywords. The syntax described - is expected to be compatible with the vocabularies declared; while - it is possible to describe an incompatible syntax, such a meta-schema - would be unlikely to be useful. -
    -
    -
    -

    - Meta-schemas are separate from vocabularies to allow for - vocabularies to be combined in different ways, and for meta-schema authors - to impose additional constraints such as forbidding certain keywords, or - performing unusually strict syntactical validation, as might be done - during a development and testing cycle. Each vocabulary typically identifies - a meta-schema consisting only of the vocabulary's keywords.

    -

    - Meta-schema authoring is an advanced usage of JSON Schema, so the design of - meta-schema features emphasizes flexibility over simplicity.

    -
    -
    -

    -8.1.1. The "$schema" Keyword -

    -

    - The "$schema" keyword is both used as a JSON Schema dialect identifier and - as the identifier of a resource which is itself a JSON Schema, which describes the - set of valid schemas written for this particular dialect.

    -

    - The value of this keyword MUST be a URI [RFC3986] - (containing a scheme) and this URI MUST be normalized. - The current schema MUST be valid against the meta-schema identified by this URI.

    -

    - If this URI identifies a retrievable resource, that resource SHOULD be of - media type "application/schema+json".

    -

    - The "$schema" keyword SHOULD be used in the document root schema object, - and MAY be used in the root schema objects of embedded schema resources. - It MUST NOT appear in non-resource root schema objects. If absent from - the document root schema, the resulting behavior is implementation-defined.

    -

    - Values for this property are defined elsewhere in this and other documents, - and by other parties.

    -
    -
    -
    -

    -8.1.2. The "$vocabulary" Keyword -

    -

    - The "$vocabulary" keyword is used in meta-schemas to identify the - vocabularies available for use in schemas described by that meta-schema. - It is also used to indicate whether each vocabulary is required or optional, - in the sense that an implementation MUST understand the required vocabularies - in order to successfully process the schema. Together, this information forms - a dialect. Any vocabulary that is understood by the implementation MUST be - processed in a manner consistent with the semantic definitions contained - within the vocabulary.

    -

    - The value of this keyword MUST be an object. The property names in the - object MUST be URIs (containing a scheme) and this URI MUST be normalized. - Each URI that appears as a property name identifies a specific set of - keywords and their semantics.

    -

    - The URI MAY be a URL, but the nature of the retrievable resource is - currently undefined, and reserved for future use. Vocabulary authors - MAY use the URL of the vocabulary specification, in a human-readable - media type such as text/html or text/plain, as the vocabulary URI. - - Vocabulary documents may be added in forthcoming drafts. - For now, identifying the keyword set is deemed sufficient as that, - along with meta-schema validation, is how the current "vocabularies" - work today. Any future vocabulary document format will be specified - as a JSON document, so using text/html or other non-JSON formats - in the meantime will not produce any future ambiguity. -

    -

    - The values of the object properties MUST be booleans. - If the value is true, then implementations that do not recognize - the vocabulary MUST refuse to process any schemas that declare - this meta-schema with "$schema". If the value is false, implementations - that do not recognize the vocabulary SHOULD proceed with processing - such schemas. The value has no impact if the implementation - understands the vocabulary.

    -

    - Per 6.5, unrecognized - keywords SHOULD be treated as annotations. - This remains the case for keywords defined - by unrecognized vocabularies. It is not currently possible to distinguish - between unrecognized keywords that are defined in vocabularies from - those that are not part of any vocabulary.

    -

    - The "$vocabulary" keyword SHOULD be used in the root schema of any schema - document intended for use as a meta-schema. It MUST NOT appear in subschemas.

    -

    - The "$vocabulary" keyword MUST be ignored in schema documents that - are not being processed as a meta-schema. This allows validating - a meta-schema M against its own meta-schema M' without requiring - the validator to understand the vocabularies declared by M.

    -
    -
    -8.1.2.1. Default vocabularies -
    -

    - If "$vocabulary" is absent, an implementation MAY determine - behavior based on the meta-schema if it is recognized from the - URI value of the referring schema's "$schema" keyword. - This is how behavior (such as Hyper-Schema usage) has been - recognized prior to the existence of vocabularies.

    -

    - If the meta-schema, as referenced by the schema, is not recognized, - or is missing, then the behavior is implementation-defined. - If the implementation - proceeds with processing the schema, it MUST assume the use of the - core vocabulary. If the implementation is built for a specific purpose, - then it SHOULD assume the use of all of the most relevant vocabularies - for that purpose.

    -

    - For example, an implementation that is a validator - SHOULD assume the use of all vocabularies in this - specification and the companion Validation specification.

    -
    -
    -
    -8.1.2.2. Non-inheritability of vocabularies -
    -

    - Note that the processing restrictions on "$vocabulary" mean that - meta-schemas that reference other meta-schemas using "$ref" or - similar keywords do not automatically inherit the vocabulary - declarations of those other meta-schemas. All such declarations - must be repeated in the root of each schema document intended - for use as a meta-schema. This is demonstrated in - the example meta-schema (Appendix D.2). - - This requirement allows implementations to find all vocabulary - requirement information in a single place for each meta-schema. - As schema extensibility means that there are endless potential - ways to combine more fine-grained meta-schemas by reference, - requiring implementations to anticipate all possibilities and - search for vocabularies in referenced meta-schemas would - be overly burdensome. -

    -
    -
    -
    -

    -8.1.3. Updates to Meta-Schema and Vocabulary URIs -

    -

    - Updated vocabulary and meta-schema URIs MAY be published between - specification drafts in order to correct errors. Implementations - SHOULD consider URIs dated after this specification draft and - before the next to indicate the same syntax and semantics - as those listed here.

    -
    -
    -
    -
    -

    -8.2. Base URI, Anchors, and Dereferencing -

    -

    - To differentiate between schemas in a vast ecosystem, schemas are - identified by URI [RFC3986], and can embed references - to other schemas by specifying their URI.

    -

    - Several keywords can accept a relative URI-reference [RFC3986], - or a value used to construct a relative URI-reference. For these keywords, - it is necessary to establish a base URI in order to resolve the reference.

    -
    -
    -

    -8.2.1. The "$id" Keyword -

    -

    - The "$id" keyword identifies a schema resource with its - canonical [RFC6596] URI.

    -

    - Note that this URI is an identifier and not necessarily a network locator. - In the case of a network-addressable URL, a schema need not be downloadable - from its canonical URI.

    -

    - If present, the value for this keyword MUST be a string, and MUST represent a - valid URI-reference [RFC3986]. This URI-reference - SHOULD be normalized, and MUST resolve to an - absolute-URI [RFC3986] (without a fragment), - or to a URI with an empty fragment.

    -

    - The empty fragment form is NOT RECOMMENDED and is retained only - for backwards compatibility, and because the - application/schema+json media type defines that a URI with an - empty fragment identifies the same resource as the same URI - with the fragment removed. However, since this equivalence is not - part of the RFC 3986 normalization process [RFC3986], - implementers and schema authors cannot rely on generic URI libraries - understanding it.

    -

    - Therefore, "$id" MUST NOT contain a non-empty fragment, and SHOULD NOT - contain an empty fragment. The absolute-URI form MUST be considered - the canonical URI, regardless of the presence or absence of an empty fragment. - - An empty fragment is currently allowed because older meta-schemas have - an empty fragment in their $id (or previously, id). - A future draft may outright forbid even empty fragments in "$id". -

    -

    - The absolute-URI also serves as the base URI for relative URI-references - in keywords within the schema resource, in accordance with - RFC 3986 section 5.1.1 [RFC3986] regarding base URIs - embedded in content.

    -

    - The presence of "$id" in a subschema indicates that the subschema constitutes - a distinct schema resource within a single schema document. Furthermore, - in accordance with RFC 3986 section 5.1.2 [RFC3986] - regarding encapsulating entities, if an "$id" in a subschema is a relative - URI-reference, the base URI for resolving that reference is the URI of - the parent schema resource.

    -

    - If no parent schema object explicitly identifies itself as a resource - with "$id", the base URI is that of the entire document, as established - by the steps given in the previous section. (Section 9.1.1)

    -
    -
    -8.2.1.1. Identifying the root schema -
    -

    - The root schema of a JSON Schema document SHOULD contain an "$id" keyword - with an absolute-URI [RFC3986] (containing a scheme, - but no fragment).

    -
    -
    -
    -
    -
    -

    -8.2.2. Defining location-independent identifiers -

    -

    - Using JSON Pointer fragments requires knowledge of the structure of the schema. - When writing schema documents with the intention to provide re-usable - schemas, it may be preferable to use a plain name fragment that is not tied to - any particular structural location. This allows a subschema to be relocated - without requiring JSON Pointer references to be updated.

    -

    - The "$anchor" and "$dynamicAnchor" keywords are used to specify such - fragments. They are identifier keywords that can only be used to create - plain name fragments, rather than absolute URIs as seen with "$id".

    -

    - The base URI to which the resulting fragment is appended is the canonical - URI of the schema resource containing the "$anchor" or "$dynamicAnchor" - in question. As discussed in the previous section, this is either the - nearest "$id" in the same or parent schema object, or the base URI - for the document as determined according to RFC 3986.

    -

    - Separately from the usual usage of URIs, "$dynamicAnchor" - indicates that the fragment is an extension point when used with - the "$dynamicRef" keyword. This low-level, advanced feature - makes it easier to extend recursive schemas such as the meta-schemas, - without imposing any particular semantics on that extension. - See the section on "$dynamicRef" (Section 8.2.3.2) - for details.

    -

    - In most cases, the normal fragment behavior both suffices and - is more intuitive. Therefore it is RECOMMENDED that "$anchor" - be used to create plain name fragments unless there is a clear - need for "$dynamicAnchor".

    -

    - If present, the value of this keyword MUST be a string and MUST start with - a letter ([A-Za-z]) or underscore ("_"), followed by any number of letters, - digits ([0-9]), hyphens ("-"), underscores ("_"), and periods ("."). - This matches the US-ASCII part of XML's - NCName production [xml-names]. - - Note that the anchor string does not include the "#" character, - as it is not a URI-reference. An "$anchor": "foo" becomes the - fragment "#foo" when used in a URI. See below for full examples. -

    -

    - The effect of specifying the same fragment name multiple times within - the same resource, using any combination of "$anchor" and/or - "$dynamicAnchor", is undefined. Implementations MAY - raise an error if such usage is detected.

    -
    -
    -
    -
    -

    -8.2.3. Schema References -

    -

    - Several keywords can be used to reference a schema which is to be applied to the - current instance location. "$ref" and "$dynamicRef" are applicator - keywords, applying the referenced schema to the instance.

    -

    - As the values of "$ref" and "$dynamicRef" are URI References, this allows - the possibility to externalise or divide a schema across multiple files, - and provides the ability to validate recursive structures through - self-reference.

    -

    - The resolved URI produced by these keywords is not necessarily a network - locator, only an identifier. A schema need not be downloadable from the - address if it is a network-addressable URL, and implementations SHOULD NOT - assume they should perform a network operation when they encounter - a network-addressable URI.

    -
    -
    -
    -8.2.3.1. Direct References with "$ref" -
    -

    - The "$ref" keyword is an applicator that is used to reference a statically - identified schema. Its results are the results of the referenced schema. - - Note that this definition of how the results are determined means that - other keywords can appear alongside of "$ref" in the same schema object. -

    -

    - The value of the "$ref" keyword MUST be a string which is a URI-Reference. - Resolved against the current URI base, it produces the URI of the schema - to apply. This resolution is safe to perform on schema load, as the - process of evaluating an instance cannot change how the reference resolves.

    -
    -
    -
    -
    -
    -8.2.3.2. Dynamic References with "$dynamicRef" -
    -

    - The "$dynamicRef" keyword is an applicator that allows for deferring the - full resolution until runtime, at which point it is resolved each time it is - encountered while evaluating an instance.

    -

    - Together with "$dynamicAnchor", "$dynamicRef" implements a cooperative - extension mechanism that is primarily useful with recursive schemas - (schemas that reference themselves). Both the extension point and the - runtime-determined extension target are defined with "$dynamicAnchor", - and only exhibit runtime dynamic behavior when referenced with - "$dynamicRef".

    -

    - The value of the "$dynamicRef" property MUST be a string which is - a URI-Reference. Resolved against the current URI base, it produces - the URI used as the starting point for runtime resolution. This initial - resolution is safe to perform on schema load.

    -

    - If the initially resolved starting point URI includes a fragment that - was created by the "$dynamicAnchor" keyword, the initial URI MUST be - replaced by the URI (including the fragment) for the outermost schema - resource in the dynamic scope (Section 7.1) that defines - an identically named fragment with "$dynamicAnchor".

    -

    - Otherwise, its behavior is identical to "$ref", and no runtime - resolution is needed.

    -

    - For a full example using these keyword, see appendix - C. - - The difference between the hyper-schema meta-schema in pre-2019 - drafts and an this draft dramatically demonstrates the utility - of these keywords. -

    -
    -
    -
    -
    -
    -
    -

    -8.2.4. Schema Re-Use With "$defs" -

    -

    - The "$defs" keyword reserves a location for schema - authors to inline re-usable JSON Schemas into a more general schema. - The keyword does not directly affect the validation result.

    -

    - This keyword's value MUST be an object. - Each member value of this object MUST be a valid JSON Schema.

    -

    - As an example, here is a schema describing an array of positive - integers, where the positive integer constraint is a subschema in - "$defs":

    -
    -
    -
    -{
    -    "type": "array",
    -    "items": { "$ref": "#/$defs/positiveInteger" },
    -    "$defs": {
    -        "positiveInteger": {
    -            "type": "integer",
    -            "exclusiveMinimum": 0
    -        }
    -    }
    -}
    -
    -
    -
    -
    -
    -
    -
    -

    -8.3. Comments With "$comment" -

    -

    - This keyword reserves a location for comments from schema authors - to readers or maintainers of the schema.

    -

    - The value of this keyword MUST be a string. Implementations MUST NOT present this - string to end users. Tools for editing schemas SHOULD support displaying and - editing this keyword. The value of this keyword MAY be used in debug or error - output which is intended for developers making use of schemas.

    -

    - Schema vocabularies SHOULD allow "$comment" within any object containing - vocabulary keywords. Implementations MAY assume "$comment" is allowed - unless the vocabulary specifically forbids it. Vocabularies MUST NOT - specify any effect of "$comment" beyond what is described in this - specification.

    -

    - Tools that translate other media types or programming languages - to and from application/schema+json MAY choose to convert that media type or - programming language's native comments to or from "$comment" values. - The behavior of such translation when both native comments and "$comment" - properties are present is implementation-dependent.

    -

    - Implementations MAY strip "$comment" values at any point during processing. - In particular, this allows for shortening schemas when the size of deployed - schemas is a concern.

    -

    - Implementations MUST NOT take any other action based on the presence, absence, - or contents of "$comment" properties. In particular, the value of "$comment" - MUST NOT be collected as an annotation result.

    -
    -
    -
    -

    -9. Loading and Processing Schemas -

    -

    -
    -

    -9.1. Loading a Schema -

    -
    -
    -

    -9.1.1. Initial Base URI -

    -

    - RFC3986 Section 5.1 [RFC3986] defines how to determine the - default base URI of a document.

    -

    - Informatively, the initial base URI of a schema is the URI at which it was - found, whether that was a network location, a local filesystem, or any other - situation identifiable by a URI of any known scheme.

    -

    - If a schema document defines no explicit base URI with "$id" - (embedded in content), the base URI is that determined per - RFC 3986 section 5 [RFC3986].

    -

    - If no source is known, or no URI scheme is known for the source, a suitable - implementation-specific default URI MAY be used as described in - RFC 3986 Section 5.1.4 [RFC3986]. It is RECOMMENDED - that implementations document any default base URI that they assume.

    -

    - If a schema object is embedded in a document of another media type, then - the initial base URI is determined according to the rules of that - media type.

    -

    - Unless the "$id" keyword described in an earlier section is present in the - root schema, this base URI SHOULD be considered the canonical URI of the - schema document's root schema resource.

    -
    -
    -
    -

    -9.1.2. Loading a referenced schema -

    -

    - The use of URIs to identify remote schemas does not necessarily mean anything is downloaded, - but instead JSON Schema implementations SHOULD understand ahead of time which schemas they will be using, - and the URIs that identify them.

    -

    - When schemas are downloaded, - for example by a generic user-agent that does not know until runtime which schemas to download, - see Usage for Hypermedia (Section 9.5.1).

    -

    - Implementations SHOULD be able to associate arbitrary URIs with an arbitrary - schema and/or automatically associate a schema's "$id"-given URI, depending - on the trust that the validator has in the schema. Such URIs and schemas - can be supplied to an implementation prior to processing instances, or may - be noted within a schema document as it is processed, producing associations - as shown in appendix A.

    -

    - A schema MAY (and likely will) have multiple URIs, but there is no way for a - URI to identify more than one schema. When multiple schemas try to identify - as the same URI, validators SHOULD raise an error condition.

    -
    -
    -

    -9.1.3. Detecting a Meta-Schema -

    -

    - Implementations MUST recognize a schema as a meta-schema if it - is being examined because it was identified as such by another - schema's "$schema" keyword. This means that a single schema - document might sometimes be considered a regular schema, and - other times be considered a meta-schema.

    -

    - In the case of examining a schema which is its own meta-schema, - when an implementation begins processing it as a regular schema, - it is processed under those rules. However, when loaded a second - time as a result of checking its own "$schema" value, it is treated - as a meta-schema. So the same document is processed both ways in - the course of one session.

    -

    - Implementations MAY allow a schema to be explicitly passed as a meta-schema, - for implementation-specific purposes, such as pre-loading a commonly - used meta-schema and checking its vocabulary support requirements - up front. Meta-schema authors MUST NOT expect such features to be - interoperable across implementations.

    -
    -
    -
    -

    -9.2. Dereferencing -

    -

    - Schemas can be identified by any URI that has been given to them, including - a JSON Pointer or their URI given directly by "$id". In all cases, - dereferencing a "$ref" reference involves first resolving its value as a - URI reference against the current base URI per - RFC 3986 [RFC3986].

    -

    - If the resulting URI identifies a schema within the current document, or - within another schema document that has been made available to the implementation, - then that schema SHOULD be used automatically.

    -

    - For example, consider this schema:

    -
    -
    -
    -{
    -    "$id": "https://example.net/root.json",
    -    "items": {
    -        "type": "array",
    -        "items": { "$ref": "#item" }
    -    },
    -    "$defs": {
    -        "single": {
    -            "$anchor": "item",
    -            "type": "object",
    -            "additionalProperties": { "$ref": "other.json" }
    -        }
    -    }
    -}
    -
    -
    -
    -

    - When an implementation encounters the <#/$defs/single> schema, - it resolves the "$anchor" value as a fragment name against the current - base URI to form <https://example.net/root.json#item>.

    -

    - When an implementation then looks inside the <#/items> schema, it - encounters the <#item> reference, and resolves this to - <https://example.net/root.json#item>, which it has seen defined in - this same document and can therefore use automatically.

    -

    - When an implementation encounters the reference to "other.json", it resolves - this to <https://example.net/other.json>, which is not defined in this - document. If a schema with that identifier has otherwise been supplied to - the implementation, it can also be used automatically. - - What should implementations do when the referenced schema is not known? - Are there circumstances in which automatic network dereferencing is - allowed? A same origin policy? A user-configurable option? In the - case of an evolving API described by Hyper-Schema, it is expected that - new schemas will be added to the system dynamically, so placing an - absolute requirement of pre-loading schema documents is not feasible. -

    -
    -
    -

    -9.2.1. JSON Pointer fragments and embedded schema resources -

    -

    - Since JSON Pointer URI fragments are constructed based on the structure - of the schema document, an embedded schema resource and its subschemas - can be identified by JSON Pointer fragments relative to either its own - canonical URI, or relative to any containing resource's URI.

    -

    - Conceptually, a set of linked schema resources should behave - identically whether each resource is a separate document connected with - schema references (Section 8.2.3), or is structured as - a single document with one or more schema resources embedded as - subschemas.

    -

    - Since URIs involving JSON Pointer fragments relative to the parent - schema resource's URI cease to be valid when the embedded schema - is moved to a separate document and referenced, applications and schemas - SHOULD NOT use such URIs to identify embedded schema resources or - locations within them.

    -

    - Consider the following schema document that contains another - schema resource embedded within it:

    -
    -
    -
    -{
    -    "$id": "https://example.com/foo",
    -    "items": {
    -        "$id": "https://example.com/bar",
    -        "additionalProperties": { }
    -    }
    -}
    -
    -
    -
    -

    - The URI "https://example.com/foo#/items" points to the "items" schema, - which is an embedded resource. The canonical URI of that schema - resource, however, is "https://example.com/bar".

    -

    - For the "additionalProperties" schema within that embedded resource, - the URI "https://example.com/foo#/items/additionalProperties" points - to the correct object, but that object's URI relative to its resource's - canonical URI is "https://example.com/bar#/additionalProperties".

    -

    - Now consider the following two schema resources linked by reference - using a URI value for "$ref":

    -
    -
    -
    -{
    -    "$id": "https://example.com/foo",
    -    "items": {
    -        "$ref": "bar"
    -    }
    -}
    -
    -{
    -    "$id": "https://example.com/bar",
    -    "additionalProperties": { }
    -}
    -
    -
    -
    -

    - Here we see that "https://example.com/bar#/additionalProperties", - using a JSON Pointer fragment appended to the canonical URI of - the "bar" schema resource, is still valid, while - "https://example.com/foo#/items/additionalProperties", which relied - on a JSON Pointer fragment appended to the canonical URI of the - "foo" schema resource, no longer resolves to anything.

    -

    - Note also that "https://example.com/foo#/items" is valid in both - arrangements, but resolves to a different value. This URI ends up - functioning similarly to a retrieval URI for a resource. While this URI - is valid, it is more robust to use the "$id" of the embedded or referenced - resource unless it is specifically desired to identify the object containing - the "$ref" in the second (non-embedded) arrangement.

    -

    - An implementation MAY choose not to support addressing schema resource - contents by URIs using a base other than the resource's canonical URI, - plus a JSON Pointer fragment relative to that base. Therefore, schema - authors SHOULD NOT rely on such URIs, as using them may reduce interoperability. - - This is to avoid requiring implementations to keep track of a whole - stack of possible base URIs and JSON Pointer fragments for each, - given that all but one will be fragile if the schema resources - are reorganized. Some - have argued that this is easy so there is - no point in forbidding it, while others have argued that it complicates - schema identification and should be forbidden. Feedback on this - topic is encouraged. - After some discussion, we feel that we need to remove the use of - "canonical" in favour of talking about JSON Pointers which reference - across schema resource boundaries as undefined or even forbidden behavior - (https://github.com/json-schema-org/json-schema-spec/issues/937, - https://github.com/json-schema-org/json-schema-spec/issues/1183) -

    -

    - Further examples of such non-canonical URI construction, as well as - the appropriate canonical URI-based fragments to use instead, - are provided in appendix A.

    -
    -
    -
    -
    -

    -9.3. Compound Documents -

    -

    - A Compound Schema Document is defined as a JSON document (sometimes called a "bundled" schema) - which has multiple embedded JSON Schema Resources bundled into the same document to - ease transportation.

    -

    - Each embedded Schema Resource MUST be treated as an individual Schema Resource, following standard - schema loading and processing requirements, including determining vocabulary support.

    -
    -

    -9.3.1. Bundling -

    -

    - The bundling process for creating a Compound Schema Document is defined as taking - references (such as "$ref") to an external Schema Resource and embedding the referenced - Schema Resources within the referring document. Bundling SHOULD be done in such a way that - all URIs (used for referencing) in the base document and any referenced/embedded - documents do not require altering.

    -

    - Each embedded JSON Schema Resource MUST identify itself with a URI using the "$id" keyword, - and SHOULD make use of the "$schema" keyword to identify the dialect it is using, in the root of the - schema resource. It is RECOMMENDED that the URI identifier value of "$id" be an Absolute URI.

    -

    - When the Schema Resource referenced by a by-reference applicator is bundled, it is RECOMMENDED that - the Schema Resource be located as a value of a "$defs" object at the containing schema's root. - The key of the "$defs" for the now embedded Schema Resource MAY be the "$id" of the bundled schema - or some other form of application defined unique identifer (such as a UUID). This key is not - intended to be referenced in JSON Schema, but may be used by an application to aid the - bundling process.

    -

    - A Schema Resource MAY be embedded in a location other than "$defs" where the location is defined - as a schema value.

    -

    - A Bundled Schema Resource MUST NOT be bundled by replacing the schema object from which it was - referenced, or by wrapping the Schema Resource in other applicator keywords.

    -

    - In order to produce identical output, references in the containing schema document to the - previously external Schema Resources MUST NOT be changed, and now resolve to a schema using the - "$id" of an embedded Schema Resource. Such identical output includes validation evaluation and URIs - or paths used in resulting annotations or errors.

    -

    - While the bundling process will often be the main method for creating a Compound Schema Document, - it is also possible and expected that some will be created by hand, potentially without individual - Schema Resources existing on their own previously.

    -
    -
    -

    -9.3.2. Differing and Default Dialects -

    -

    - When multiple schema resources are present in a single document, - schema resources which do not define with which dialect they should be processed - MUST be processed with the same dialect as the enclosing resource.

    -

    - Since any schema that can be referenced can also be embedded, embedded schema resources MAY - specify different processing dialects using the "$schema" values from their enclosing resource.

    -
    -
    -

    -9.3.3. Validating -

    -

    - Given that a Compound Schema Document may have embedded resources which identify as using different - dialects, these documents SHOULD NOT be validated by applying a meta-schema - to the Compound Schema Document as an instance. It is RECOMMENDED that an alternate - validation process be provided in order to validate Schema Documents. Each Schema Resource - SHOULD be separately validated against its associated meta-schema. - - If you know a schema is what's being validated, you can identify if the schemas - is a Compound Schema Document or not, by way of use of "$id", which identifies an - embedded resource when used not at the document's root. -

    -

    - A Compound Schema Document in which all embedded resources identify as using the same - dialect, or in which "$schema" is omitted and therefore defaults to that of the enclosing resource, - MAY be validated by applying the appropriate meta-schema.

    -
    -
    -
    -

    -9.4. Caveats -

    -
    -

    -9.4.1. Guarding Against Infinite Recursion -

    -

    - A schema MUST NOT be run into an infinite loop against an instance. For - example, if two schemas "#alice" and "#bob" both have an "allOf" property - that refers to the other, a naive validator might get stuck in an infinite - recursive loop trying to validate the instance. Schemas SHOULD NOT make - use of infinite recursive nesting like this; the behavior is undefined.

    -
    -
    -
    -

    -9.4.2. References to Possible Non-Schemas -

    -

    - Subschema objects (or booleans) are recognized by their use with known - applicator keywords or with location-reserving keywords such as - "$defs" (Section 8.2.4) that take one or more subschemas - as a value. These keywords may be "$defs" and the standard applicators - from this document, or extension keywords from a known vocabulary, or - implementation-specific custom keywords.

    -

    - Multi-level structures of unknown keywords are capable of introducing - nested subschemas, which would be subject to the processing rules for - "$id". Therefore, having a reference target in such an unrecognized - structure cannot be reliably implemented, and the resulting behavior - is undefined. Similarly, a reference target under a known keyword, - for which the value is known not to be a schema, results in undefined - behavior in order to avoid burdening implementations with the need - to detect such targets. - - These scenarios are analogous to fetching a schema over HTTP - but receiving a response with a Content-Type other than - application/schema+json. An implementation can certainly - try to interpret it as a schema, but the origin server - offered no guarantee that it actually is any such thing. - Therefore, interpreting it as such has security implications - and may produce unpredictable results. -

    -

    - Note that single-level custom keywords with identical syntax and - semantics to "$defs" do not allow for any intervening "$id" keywords, - and therefore will behave correctly under implementations that attempt - to use any reference target as a schema. However, this behavior is - implementation-specific and MUST NOT be relied upon for interoperability.

    -
    -
    -
    -
    -

    -9.5. Associating Instances and Schemas -

    -
    -
    -

    -9.5.1. Usage for Hypermedia -

    -

    - JSON has been adopted widely by HTTP servers for automated APIs and robots. This - section describes how to enhance processing of JSON documents in a more RESTful - manner when used with protocols that support media types and - Web linking [RFC8288].

    -
    -
    -9.5.1.1. Linking to a Schema -
    -

    - It is RECOMMENDED that instances described by a schema provide a link to - a downloadable JSON Schema using the link relation "describedby", as defined by - Linked Data Protocol 1.0, section 8.1 [W3C.REC-ldp-20150226].

    -

    - In HTTP, such links can be attached to any response using the - Link header [RFC8288]. An example of such a header would be:

    -
    -
    -
    -        Link: <https://example.com/my-hyper-schema>; rel="describedby"
    -
    -
    -
    -
    -
    -
    -9.5.1.2. Usage Over HTTP -
    -

    - When used for hypermedia systems over a network, - HTTP [RFC7231] is frequently the protocol of choice for - distributing schemas. Misbehaving clients can pose problems for server - maintainers if they pull a schema over the network more frequently than - necessary, when it's instead possible to cache a schema for a long period of - time.

    -

    - HTTP servers SHOULD set long-lived caching headers on JSON Schemas. - HTTP clients SHOULD observe caching headers and not re-request documents within - their freshness period. - Distributed systems SHOULD make use of a shared cache and/or caching proxy.

    -

    - Clients SHOULD set or prepend a User-Agent header specific to the JSON Schema - implementation or software product. Since symbols are listed in decreasing order - of significance, the JSON Schema library name/version should precede the more - generic HTTP library name (if any). For example:

    -
    -
    -
    -        User-Agent: product-name/5.4.1 so-cool-json-schema/1.0.2 curl/7.43.0
    -
    -
    -
    -

    - Clients SHOULD be able to make requests with a "From" header so that server - operators can contact the owner of a potentially misbehaving script.

    -
    -
    -
    -
    -
    -
    -

    -10. A Vocabulary for Applying Subschemas -

    -

    - This section defines a vocabulary of applicator keywords that - are RECOMMENDED for use as the basis of other vocabularies.

    -

    - Meta-schemas that do not use "$vocabulary" SHOULD be considered to - require this vocabulary as if its URI were present with a value of true.

    -

    - The current URI for this vocabulary, known as the Applicator vocabulary, is: - <https://json-schema.org/draft/2020-12/vocab/applicator>.

    -

    - The current URI for the corresponding meta-schema is: - https://json-schema.org/draft/2020-12/meta/applicator.

    -
    -

    -10.1. Keyword Independence -

    -

    - Schema keywords typically operate independently, without - affecting each other's outcomes.

    -

    - For schema author convenience, there are some exceptions among the - keywords in this vocabulary:

    -
      -
    • - "additionalProperties", whose behavior is defined in terms of - "properties" and "patternProperties" -
    • -
    • - "items", whose behavior is defined in terms of "prefixItems" -
    • -
    • - "contains", whose behavior is affected by the presence and value of - "minContains", in the Validation vocabulary -
    • -
    -
    -
    -
    -

    -10.2. Keywords for Applying Subschemas in Place -

    -

    - These keywords apply subschemas to the same location in the instance - as the parent schema is being applied. They allow combining - or modifying the subschema results in various ways.

    -

    - Subschemas of these keywords evaluate the instance completely independently - such that the results of one such subschema MUST NOT impact the results of sibling - subschemas. Therefore subschemas may be applied in - any order.

    -
    -
    -

    -10.2.1. Keywords for Applying Subschemas With Logic -

    -

    - These keywords correspond to logical operators for combining or modifying - the boolean assertion results of the subschemas. They have no direct - impact on annotation collection, although they enable the same annotation - keyword to be applied to an instance location with different values. - Annotation keywords define their own rules for combining such values.

    -
    -
    -
    -10.2.1.1. allOf -
    -

    - This keyword's value MUST be a non-empty array. - Each item of the array MUST be a valid JSON Schema.

    -

    - An instance validates successfully against this keyword if it validates - successfully against all schemas defined by this keyword's value.

    -
    -
    -
    -
    -10.2.1.2. anyOf -
    -

    - This keyword's value MUST be a non-empty array. - Each item of the array MUST be a valid JSON Schema.

    -

    - An instance validates successfully against this keyword if it validates - successfully against at least one schema defined by this keyword's value. - Note that when annotations are being collected, all subschemas MUST - be examined so that annotations are collected from each subschema - that validates successfully.

    -
    -
    -
    -10.2.1.3. oneOf -
    -

    - This keyword's value MUST be a non-empty array. - Each item of the array MUST be a valid JSON Schema.

    -

    - An instance validates successfully against this keyword if it validates - successfully against exactly one schema defined by this keyword's value.

    -
    -
    -
    -
    -10.2.1.4. not -
    -

    - This keyword's value MUST be a valid JSON Schema.

    -

    - An instance is valid against this keyword if it fails to validate - successfully against the schema defined by this keyword.

    -
    -
    -
    -
    -
    -
    -

    -10.2.2. Keywords for Applying Subschemas Conditionally -

    -

    - Three of these keywords work together to implement conditional - application of a subschema based on the outcome of another subschema. - The fourth is a shortcut for a specific conditional case.

    -

    - "if", "then", and "else" MUST NOT interact with each other across - subschema boundaries. In other words, an "if" in one - branch of an "allOf" MUST NOT have an impact on a "then" - or "else" in another branch.

    -

    - There is no default behavior for "if", "then", or "else" - when they are not present. In particular, they MUST NOT - be treated as if present with an empty schema, and when - "if" is not present, both "then" and "else" MUST be - entirely ignored.

    -
    -
    -10.2.2.1. if -
    -

    - This keyword's value MUST be a valid JSON Schema.

    -

    - This validation outcome of this keyword's subschema - has no direct effect on the overall validation - result. Rather, it controls which of the "then" - or "else" keywords are evaluated.

    -

    - Instances that successfully validate against this - keyword's subschema MUST also be valid against - the subschema value of the "then" keyword, if - present.

    -

    - Instances that fail to validate against this - keyword's subschema MUST also be valid against - the subschema value of the "else" keyword, if - present.

    -

    - If annotations (Section 7.7) - are being collected, they are collected from this - keyword's subschema in the usual way, including when - the keyword is present without either "then" or "else".

    -
    -
    -
    -10.2.2.2. then -
    -

    - This keyword's value MUST be a valid JSON Schema.

    -

    - When "if" is present, and the instance successfully - validates against its subschema, then validation - succeeds against this keyword if the instance also - successfully validates against this keyword's subschema.

    -

    - This keyword has no effect when "if" is absent, or - when the instance fails to validate against its - subschema. Implementations MUST NOT evaluate - the instance against this keyword, for either validation - or annotation collection purposes, in such cases.

    -
    -
    -
    -10.2.2.3. else -
    -

    - This keyword's value MUST be a valid JSON Schema.

    -

    - When "if" is present, and the instance fails to - validate against its subschema, then validation - succeeds against this keyword if the instance - successfully validates against this keyword's subschema.

    -

    - This keyword has no effect when "if" is absent, or - when the instance successfully validates against its - subschema. Implementations MUST NOT evaluate - the instance against this keyword, for either validation - or annotation collection purposes, in such cases.

    -
    -
    -
    -10.2.2.4. dependentSchemas -
    -

    - This keyword specifies subschemas that are evaluated if the instance - is an object and contains a certain property.

    -

    - This keyword's value MUST be an object. - Each value in the object MUST be a valid JSON Schema.

    -

    - If the object key is a property in the instance, the entire - instance must validate against the subschema. Its use is - dependent on the presence of the property.

    -

    - Omitting this keyword has the same behavior as an empty object.

    -
    -
    -
    -
    -
    -
    -

    -10.3. Keywords for Applying Subschemas to Child Instances -

    -

    - Each of these keywords defines a rule for applying its - subschema(s) to child instances, specifically object - properties and array items, and combining their results.

    -
    -

    -10.3.1. Keywords for Applying Subschemas to Arrays -

    -
    -
    -10.3.1.1. prefixItems -
    -

    - The value of "prefixItems" MUST be a non-empty array of valid JSON Schemas.

    -

    - Validation succeeds if each element of the instance validates - against the schema at the same position, if any. This keyword - does not constrain the length of the array. If the array is longer - than this keyword's value, this keyword validates only the - prefix of matching length.

    -

    - This keyword produces an annotation value which is the largest - index to which this keyword applied a subschema. The value - MAY be a boolean true if a subschema was applied to every - index of the instance, such as is produced by the "items" keyword. - This annotation affects the behavior of "items" and "unevaluatedItems".

    -

    - Omitting this keyword has the same assertion behavior as - an empty array.

    -
    -
    -
    -
    -10.3.1.2. items -
    -

    - The value of "items" MUST be a valid JSON Schema.

    -

    - This keyword applies its subschema to all instance elements - at indexes greater than the length of the "prefixItems" array - in the same schema object, as reported by the annotation result - of that "prefixItems" keyword. If no such annotation - result exists, "items" applies its subschema to all instance - array elements. - - Note that the behavior of "items" without "prefixItems" is - identical to that of the schema form of "items" in prior drafts. - When "prefixItems" is present, the behavior of "items" is - identical to the former "additionalItems" keyword. -

    -

    - If the "items" subschema is applied to any - positions within the instance array, it produces an - annotation result of boolean true, indicating that all remaining array - elements have been evaluated against this keyword's subschema. - This annotation affects the behavior of "unevaluatedItems" in the - Unevaluated vocabulary.

    -

    - Omitting this keyword has the same assertion behavior as - an empty schema.

    -

    - Implementations MAY choose to implement or optimize this keyword - in another way that produces the same effect, such as by directly - checking for the presence and size of a "prefixItems" array. - Implementations that do not support annotation collection MUST do so.

    -
    -
    -
    -
    -10.3.1.3. contains -
    -

    - The value of this keyword MUST be a valid JSON Schema.

    -

    - An array instance is valid against "contains" if at least one of - its elements is valid against the given schema, - except when "minContains" is present and has a value of 0, in which - case an array instance MUST be considered valid against the "contains" keyword, - even if none of its elements is valid against the given schema.

    -

    - This keyword produces an annotation value which is an array of - the indexes to which this keyword validates successfully when applying - its subschema, in ascending order. The value MAY be a boolean "true" if - the subschema validates successfully when applied to every index of the - instance. The annotation MUST be present if the instance array to which - this keyword's schema applies is empty.

    -

    - This annotation affects the behavior of "unevaluatedItems" in the - Unevaluated vocabulary, and MAY also be used to implement the - "minContains" and "maxContains" keywords in the Validation vocabulary.

    -

    - The subschema MUST be applied to every array element even after the first - match has been found, in order to collect annotations for use by other - keywords. This is to ensure that all possible annotations are collected.

    -
    -
    -
    -

    -10.3.2. Keywords for Applying Subschemas to Objects -

    -
    -
    -10.3.2.1. properties -
    -

    - The value of "properties" MUST be an object. - Each value of this object MUST be a valid JSON Schema.

    -

    - Validation succeeds if, for each name that appears in both - the instance and as a name within this keyword's value, the child - instance for that name successfully validates against the - corresponding schema.

    -

    - The annotation result of this keyword is the set of instance - property names matched by this keyword. - This annotation affects the behavior of "additionalProperties" (in - this vocabulary) and "unevaluatedProperties" in the Unevaluated vocabulary.

    -

    - Omitting this keyword has the same assertion behavior as - an empty object.

    -
    -
    -
    -10.3.2.2. patternProperties -
    -

    - The value of "patternProperties" MUST be an object. Each property name - of this object SHOULD be a valid regular expression, according to the - ECMA-262 regular expression dialect. Each property value of this object - MUST be a valid JSON Schema.

    -

    - Validation succeeds if, for each instance name that matches any - regular expressions that appear as a property name in this keyword's value, - the child instance for that name successfully validates against each - schema that corresponds to a matching regular expression.

    -

    - The annotation result of this keyword is the set of instance - property names matched by this keyword. - This annotation affects the behavior of "additionalProperties" (in this - vocabulary) and "unevaluatedProperties" (in the Unevaluated vocabulary).

    -

    - Omitting this keyword has the same assertion behavior as - an empty object.

    -
    -
    -
    -
    -10.3.2.3. additionalProperties -
    -

    - The value of "additionalProperties" MUST be a valid JSON Schema.

    -

    - The behavior of this keyword depends on the presence and - annotation results of "properties" and "patternProperties" - within the same schema object. - Validation with "additionalProperties" applies only to the child - values of instance names that do not appear in the annotation - results of either "properties" or "patternProperties".

    -

    - For all such properties, validation succeeds if the child instance - validates against the "additionalProperties" schema.

    -

    - The annotation result of this keyword is the set of instance - property names validated by this keyword's subschema. - This annotation affects the behavior of "unevaluatedProperties" - in the Unevaluated vocabulary.

    -

    - Omitting this keyword has the same assertion behavior as - an empty schema.

    -

    - Implementations MAY choose to implement or optimize this keyword - in another way that produces the same effect, such as by directly - checking the names in "properties" and the patterns in - "patternProperties" against the instance property set. - Implementations that do not support annotation collection MUST do so. - - In defining this option, it seems there is the potential for - ambiguity in the output format. The ambiguity does not affect validation results, - but it does affect the resulting output format. - The ambiguity allows for multiple valid output results depending on whether annotations - are used or a solution that "produces the same effect" as draft-07. It is understood - that annotations from failing schemas are dropped. - See our - [Decision Record](https://github.com/json-schema-org/json-schema-spec/tree/HEAD/adr/2022-04-08-cref-for-ambiguity-and-fix-later-gh-spec-issue-1172.md) - for further details. -

    -
    -
    -
    -
    -10.3.2.4. propertyNames -
    -

    - The value of "propertyNames" MUST be a valid JSON Schema.

    -

    - If the instance is an object, this keyword validates if every property name in - the instance validates against the provided schema. - Note the property name that the schema is testing will always be a string.

    -

    - Omitting this keyword has the same behavior as an empty schema.

    -
    -
    -
    -
    -
    -

    -11. A Vocabulary for Unevaluated Locations -

    -

    - The purpose of these keywords is to enable schema authors to apply - subschemas to array items or object properties that have not been - successfully evaluated against any dynamic-scope subschema of any - adjacent keywords.

    -

    - These instance items or properties may have been unsuccessfully evaluated - against one or more adjacent keyword subschemas, such as when an assertion - in a branch of an "anyOf" fails. Such failed evaluations are not considered - to contribute to whether or not the item or property has been evaluated. - Only successful evaluations are considered.

    -

    - If an item in an array or an object property is "successfully evaluated", it - is logically considered to be valid in terms of the representation of the - object or array that's expected. For example if a subschema represents a car, - which requires between 2-4 wheels, and the value of "wheels" is 6, the instance - object is not "evaluated" to be a car, and the "wheels" property is considered - "unevaluated (successfully as a known thing)", and does not retain any annotations.

    -

    - Recall that adjacent keywords are keywords within the same schema object, - and that the dynamic-scope subschemas include reference targets as well as - lexical subschemas.

    -

    - The behavior of these keywords depend on the annotation results of - adjacent keywords that apply to the instance location being validated.

    -

    - Meta-schemas that do not use "$vocabulary" SHOULD be considered to - require this vocabulary as if its URI were present with a value of true.

    -

    - The current URI for this vocabulary, known as the Unevaluated Applicator - vocabulary, is: - <https://json-schema.org/draft/2020-12/vocab/unevaluated>.

    -

    - The current URI for the corresponding meta-schema is: - https://json-schema.org/draft/2020-12/meta/unevaluated.

    -
    -

    -11.1. Keyword Independence -

    -

    - Schema keywords typically operate independently, without - affecting each other's outcomes. However, the keywords in this - vocabulary are notable exceptions:

    -
      -
    • - "unevaluatedItems", whose behavior is defined in terms of annotations - from "prefixItems", "items", "contains", and itself -
    • -
    • - "unevaluatedProperties", whose behavior is defined in terms of - annotations from "properties", "patternProperties", - "additionalProperties" and itself -
    • -
    -
    -
    -
    -

    -11.2. unevaluatedItems -

    -

    - The value of "unevaluatedItems" MUST be a valid JSON Schema.

    -

    - The behavior of this keyword depends on the annotation results of - adjacent keywords that apply to the instance location being validated. - Specifically, the annotations from "prefixItems", "items", and "contains", - which can come from those keywords when they are adjacent to the - "unevaluatedItems" keyword. Those three annotations, as well as - "unevaluatedItems", can also result from any and all adjacent - in-place applicator (Section 10.2) keywords. - This includes but is not limited to the in-place applicators - defined in this document.

    -

    - If no relevant annotations are present, the "unevaluatedItems" - subschema MUST be applied to all locations in the array. - If a boolean true value is present from any of the relevant annotations, - "unevaluatedItems" MUST be ignored. Otherwise, the subschema - MUST be applied to any index greater than the largest annotation - value for "prefixItems", which does not appear in any annotation - value for "contains".

    -

    - This means that "prefixItems", "items", "contains", and all in-place - applicators MUST be evaluated before this keyword can be evaluated. - Authors of extension keywords MUST NOT define an in-place applicator - that would need to be evaluated after this keyword.

    -

    - If the "unevaluatedItems" subschema is applied to any - positions within the instance array, it produces an - annotation result of boolean true, analogous to the - behavior of "items". - This annotation affects the behavior of "unevaluatedItems" in parent schemas.

    -

    - Omitting this keyword has the same assertion behavior as - an empty schema.

    -
    -
    -
    -
    -

    -11.3. unevaluatedProperties -

    -

    - The value of "unevaluatedProperties" MUST be a valid JSON Schema.

    -

    - The behavior of this keyword depends on the annotation results of - adjacent keywords that apply to the instance location being validated. - Specifically, the annotations from "properties", "patternProperties", - and "additionalProperties", which can come from those keywords when - they are adjacent to the "unevaluatedProperties" keyword. Those - three annotations, as well as "unevaluatedProperties", can also - result from any and all adjacent - in-place applicator (Section 10.2) keywords. - This includes but is not limited to the in-place applicators - defined in this document.

    -

    - Validation with "unevaluatedProperties" applies only to the child - values of instance names that do not appear in the "properties", - "patternProperties", "additionalProperties", or - "unevaluatedProperties" annotation results that apply to the - instance location being validated.

    -

    - For all such properties, validation succeeds if the child instance - validates against the "unevaluatedProperties" schema.

    -

    - This means that "properties", "patternProperties", "additionalProperties", - and all in-place applicators MUST be evaluated before this keyword can - be evaluated. Authors of extension keywords MUST NOT define an in-place - applicator that would need to be evaluated after this keyword.

    -

    - The annotation result of this keyword is the set of instance - property names validated by this keyword's subschema. - This annotation affects the behavior of "unevaluatedProperties" in parent schemas.

    -

    - Omitting this keyword has the same assertion behavior as - an empty schema.

    -
    -
    -
    -
    -
    -

    -12. Output Formatting -

    -

    - JSON Schema is defined to be platform-independent. As such, to increase compatibility - across platforms, implementations SHOULD conform to a standard validation output - format. This section describes the minimum requirements that consumers will need to - properly interpret validation results.

    -
    -

    -12.1. Format -

    -

    - JSON Schema output is defined using the JSON Schema data instance model as described - in section 4.2.1. Implementations MAY deviate from this as supported by their - specific languages and platforms, however it is RECOMMENDED that the output be - convertible to the JSON format defined herein via serialization or other means.

    -
    -
    -

    -12.2. Output Formats -

    -

    - This specification defines four output formats. See the "Output Structure" - section for the requirements of each format.

    -
      -
    • - Flag - A boolean which simply indicates the overall validation result - with no further details. -
    • -
    • - Basic - Provides validation information in a flat list structure. -
    • -
    • - Detailed - Provides validation information in a condensed hierarchical - structure based on the structure of the schema. -
    • -
    • - Verbose - Provides validation information in an uncondensed hierarchical - structure that matches the exact structure of the schema. -
    • -
    -

    - An implementation SHOULD provide at least one of the "flag", "basic", or "detailed" - format and MAY provide the "verbose" format. If it provides one or more of the - "detailed" or "verbose" formats, it MUST also provide the "flag" format. - Implementations SHOULD specify in their documentation which formats they support.

    -
    -
    -

    -12.3. Minimum Information -

    -

    - Beyond the simplistic "flag" output, additional information is useful to aid in - debugging a schema or instance. Each sub-result SHOULD contain the information - contained within this section at a minimum.

    -

    - A single object that contains all of these components is considered an - output unit.

    -

    - Implementations MAY elect to provide additional information.

    -
    -

    -12.3.1. Keyword Relative Location -

    -

    - The relative location of the validating keyword that follows the validation - path. The value MUST be expressed as a JSON Pointer, and it MUST include - any by-reference applicators such as "$ref" or "$dynamicRef".

    -
    -
    -
    -/properties/width/$ref/minimum
    -
    -
    -
    -

    - Note that this pointer may not be resolvable by the normal JSON Pointer process - due to the inclusion of these by-reference applicator keywords.

    -

    - The JSON key for this information is "keywordLocation".

    -
    -
    -

    -12.3.2. Keyword Absolute Location -

    -

    - The absolute, dereferenced location of the validating keyword. The value MUST - be expressed as a full URI using the canonical URI of the relevant schema resource - with a JSON Pointer fragment, and it MUST NOT include by-reference applicators - such as "$ref" or "$dynamicRef" as non-terminal path components. - It MAY end in such keywords if the error or annotation is for that - keyword, such as an unresolvable reference. - - Note that "absolute" here is in the sense of "absolute filesystem path" - (meaning the complete location) rather than the "absolute-URI" - terminology from RFC 3986 (meaning with scheme but without fragment). - Keyword absolute locations will have a fragment in order to - identify the keyword. -

    -
    -
    -
    -https://example.com/schemas/common#/$defs/count/minimum
    -
    -
    -
    -

    - This information MAY be omitted only if either the dynamic scope did not pass - over a reference or if the schema does not declare an absolute URI as its "$id".

    -

    - The JSON key for this information is "absoluteKeywordLocation".

    -
    -
    -

    -12.3.3. Instance Location -

    -

    - The location of the JSON value within the instance being validated. The - value MUST be expressed as a JSON Pointer.

    -

    - The JSON key for this information is "instanceLocation".

    -
    -
    -

    -12.3.4. Error or Annotation -

    -

    - The error or annotation that is produced by the validation.

    -

    - For errors, the specific wording for the message is not defined by this - specification. Implementations will need to provide this.

    -

    - For annotations, each keyword that produces an annotation specifies its - format. By default, it is the keyword's value.

    -

    - The JSON key for failed validations is "error"; for successful validations - it is "annotation".

    -
    -
    -

    -12.3.5. Nested Results -

    -

    - For the two hierarchical structures, this property will hold nested errors - and annotations.

    -

    - The JSON key for nested results in failed validations is "errors"; for - successful validations it is "annotations". Note the plural forms, as - a keyword with nested results can also have a local error or annotation.

    -
    -
    -
    -

    -12.4. Output Structure -

    -

    - The output MUST be an object containing a boolean property named "valid". When - additional information about the result is required, the output MUST also contain - "errors" or "annotations" as described below.

    -
      -
    • - "valid" - a boolean value indicating the overall validation success or - failure -
    • -
    • - "errors" - the collection of errors or annotations produced by a failed - validation -
    • -
    • - "annotations" - the collection of errors or annotations produced by a - successful validation -
    • -
    -

    - For these examples, the following schema and instance will be used.

    -
    -
    -
    -{
    -  "$id": "https://example.com/polygon",
    -  "$schema": "https://json-schema.org/draft/2020-12/schema",
    -  "$defs": {
    -    "point": {
    -      "type": "object",
    -      "properties": {
    -        "x": { "type": "number" },
    -        "y": { "type": "number" }
    -      },
    -      "additionalProperties": false,
    -      "required": [ "x", "y" ]
    -    }
    -  },
    -  "type": "array",
    -  "items": { "$ref": "#/$defs/point" },
    -  "minItems": 3
    -}
    -
    -[
    -  {
    -    "x": 2.5,
    -    "y": 1.3
    -  },
    -  {
    -    "x": 1,
    -    "z": 6.7
    -  }
    -]
    -
    -
    -
    -

    - This instance will fail validation and produce errors, but it's trivial to deduce - examples for passing schemas that produce annotations.

    -

    - Specifically, the errors it will produce are:

    -
      -
    • - The second object is missing a "y" property. -
    • -
    • - The second object has a disallowed "z" property. -
    • -
    • - There are only two objects, but three are required. -
    • -
    -

    - Note that the error message wording as depicted in these examples is not a - requirement of this specification. Implementations SHOULD craft error messages - tailored for their audience or provide a templating mechanism that allows their - users to craft their own messages.

    -
    -

    -12.4.1. Flag -

    -

    - In the simplest case, merely the boolean result for the "valid" valid property - needs to be fulfilled.

    -
    -
    -
    -{
    -  "valid": false
    -}
    -
    -
    -
    -

    - Because no errors or annotations are returned with this format, it is - RECOMMENDED that implementations use short-circuiting logic to return - failure or success as soon as the outcome can be determined. For example, - if an "anyOf" keyword contains five sub-schemas, and the second one - passes, there is no need to check the other three. The logic can simply - return with success.

    -
    -
    -

    -12.4.2. Basic -

    -

    - The "Basic" structure is a flat list of output units.

    -
    -
    -
    -{
    -  "valid": false,
    -  "errors": [
    -    {
    -      "keywordLocation": "",
    -      "instanceLocation": "",
    -      "error": "A subschema had errors."
    -    },
    -    {
    -      "keywordLocation": "/items/$ref",
    -      "absoluteKeywordLocation":
    -        "https://example.com/polygon#/$defs/point",
    -      "instanceLocation": "/1",
    -      "error": "A subschema had errors."
    -    },
    -    {
    -      "keywordLocation": "/items/$ref/required",
    -      "absoluteKeywordLocation":
    -        "https://example.com/polygon#/$defs/point/required",
    -      "instanceLocation": "/1",
    -      "error": "Required property 'y' not found."
    -    },
    -    {
    -      "keywordLocation": "/items/$ref/additionalProperties",
    -      "absoluteKeywordLocation":
    -        "https://example.com/polygon#/$defs/point/additionalProperties",
    -      "instanceLocation": "/1/z",
    -      "error": "Additional property 'z' found but was invalid."
    -    },
    -    {
    -      "keywordLocation": "/minItems",
    -      "instanceLocation": "",
    -      "error": "Expected at least 3 items but found 2"
    -    }
    -  ]
    -}
    -
    -
    -
    -
    -
    -

    -12.4.3. Detailed -

    -

    - The "Detailed" structure is based on the schema and can be more readable - for both humans and machines. Having the structure organized this way makes - associations between the errors more apparent. For example, the fact that - the missing "y" property and the extra "z" property both stem from the same - location in the instance is not immediately obvious in the "Basic" structure. - In a hierarchy, the correlation is more easily identified.

    -

    - The following rules govern the construction of the results object:

    -
      -
    • - All applicator keywords ("*Of", "$ref", "if"/"then"/"else", etc.) require - a node. -
    • -
    • - Nodes that have no children are removed. -
    • -
    • - Nodes that have a single child are replaced by the child. -
    • -
    -

    - Branch nodes do not require an error message or an annotation.

    -
    -
    -
    -{
    -  "valid": false,
    -  "keywordLocation": "",
    -  "instanceLocation": "",
    -  "errors": [
    -    {
    -      "valid": false,
    -      "keywordLocation": "/items/$ref",
    -      "absoluteKeywordLocation":
    -        "https://example.com/polygon#/$defs/point",
    -      "instanceLocation": "/1",
    -      "errors": [
    -        {
    -          "valid": false,
    -          "keywordLocation": "/items/$ref/required",
    -          "absoluteKeywordLocation":
    -            "https://example.com/polygon#/$defs/point/required",
    -          "instanceLocation": "/1",
    -          "error": "Required property 'y' not found."
    -        },
    -        {
    -          "valid": false,
    -          "keywordLocation": "/items/$ref/additionalProperties",
    -          "absoluteKeywordLocation":
    -            "https://example.com/polygon#/$defs/point/additionalProperties",
    -          "instanceLocation": "/1/z",
    -          "error": "Additional property 'z' found but was invalid."
    -        }
    -      ]
    -    },
    -    {
    -      "valid": false,
    -      "keywordLocation": "/minItems",
    -      "instanceLocation": "",
    -      "error": "Expected at least 3 items but found 2"
    -    }
    -  ]
    -}
    -
    -
    -
    -
    -
    -

    -12.4.4. Verbose -

    -

    - The "Verbose" structure is a fully realized hierarchy that exactly matches - that of the schema. This structure has applications in form generation and - validation where the error's location is important.

    -

    - The primary difference between this and the "Detailed" structure is that - all results are returned. This includes sub-schema validation results that - would otherwise be removed (e.g. annotations for failed validations, - successful validations inside a `not` keyword, etc.). Because of this, it - is RECOMMENDED that each node also carry a `valid` property to indicate the - validation result for that node.

    -

    - Because this output structure can be quite large, a smaller example is given - here for brevity. The URI of the full output structure of the example above is: - https://json-schema.org/draft/2020-12/output/verbose-example.

    -
    -
    -
    -// schema
    -{
    -  "$id": "https://example.com/polygon",
    -  "$schema": "https://json-schema.org/draft/2020-12/schema",
    -  "type": "object",
    -  "properties": {
    -    "validProp": true,
    -  },
    -  "additionalProperties": false
    -}
    -
    -// instance
    -{
    -  "validProp": 5,
    -  "disallowedProp": "value"
    -}
    -
    -// result
    -{
    -  "valid": false,
    -  "keywordLocation": "",
    -  "instanceLocation": "",
    -  "errors": [
    -    {
    -      "valid": true,
    -      "keywordLocation": "/type",
    -      "instanceLocation": ""
    -    },
    -    {
    -      "valid": true,
    -      "keywordLocation": "/properties",
    -      "instanceLocation": ""
    -    },
    -    {
    -      "valid": false,
    -      "keywordLocation": "/additionalProperties",
    -      "instanceLocation": "",
    -      "errors": [
    -        {
    -          "valid": false,
    -          "keywordLocation": "/additionalProperties",
    -          "instanceLocation": "/disallowedProp",
    -          "error": "Additional property 'disallowedProp' found but was invalid."
    -        }
    -      ]
    -    }
    -  ]
    -}
    -
    -
    -
    -
    -
    -

    -12.4.5. Output validation schemas -

    -

    - For convenience, JSON Schema has been provided to validate output generated - by implementations. Its URI is: - https://json-schema.org/draft/2020-12/output/schema.

    -
    -
    -
    -
    -
    -
    -

    -13. Security Considerations -

    -

    - Both schemas and instances are JSON values. As such, all security considerations - defined in RFC 8259 [RFC8259] apply.

    -

    - Instances and schemas are both frequently written by untrusted third parties, to be - deployed on public Internet servers. - Validators should take care that the parsing and validating against schemas does not consume excessive - system resources. - Validators MUST NOT fall into an infinite loop.

    -

    - A malicious party could cause an implementation to repeatedly collect a copy - of a very large value as an annotation. Implementations SHOULD guard against - excessive consumption of system resources in such a scenario.

    -

    - Servers MUST ensure that malicious parties cannot change the functionality of - existing schemas by uploading a schema with a pre-existing or very similar "$id".

    -

    - Individual JSON Schema vocabularies are liable to also have their own security - considerations. Consult the respective specifications for more information.

    -

    - Schema authors should take care with "$comment" contents, as a malicious - implementation can display them to end-users in violation of a spec, or - fail to strip them if such behavior is expected.

    -

    - A malicious schema author could place executable code or other dangerous - material within a "$comment". Implementations MUST NOT parse or otherwise - take action based on "$comment" contents.

    -
    -
    -
    -

    -14. IANA Considerations -

    -
    -

    -14.1. application/schema+json -

    -

    - The proposed MIME media type for JSON Schema is defined as follows:

    -
      -
    • Type name: application -
    • -
    • Subtype name: schema+json -
    • -
    • Required parameters: N/A -
    • -
    • - Encoding considerations: Encoding considerations are - identical to those specified for the "application/json" - media type. See JSON [RFC8259]. -
    • -
    • - Security considerations: See Section - 13 above. -
    • -
    • - Interoperability considerations: See Sections - 6.2, - 6.3, and - 6.4 above. -
    • -
    • - Fragment identifier considerations: See Section - 5 -
    • -
    -
    -
    -

    -14.2. application/schema-instance+json -

    -

    - The proposed MIME media type for JSON Schema Instances that require - a JSON Schema-specific media type is defined as follows:

    -
      -
    • Type name: application -
    • -
    • Subtype name: schema-instance+json -
    • -
    • Required parameters: N/A -
    • -
    • - Encoding considerations: Encoding considerations are - identical to those specified for the "application/json" - media type. See JSON [RFC8259]. -
    • -
    • - Security considerations: See Section - 13 above. -
    • -
    • - Interoperability considerations: See Sections - 6.2, - 6.3, and - 6.4 above. -
    • -
    • - Fragment identifier considerations: See Section - 5 -
    • -
    -
    -
    -
    -

    -15. References -

    -
    -

    -15.1. Normative References -

    -
    -
    [RFC2119]
    -
    -Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://www.rfc-editor.org/info/rfc2119>.
    -
    -
    [RFC3986]
    -
    -Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, , <https://www.rfc-editor.org/info/rfc3986>.
    -
    -
    [RFC6839]
    -
    -Hansen, T. and A. Melnikov, "Additional Media Type Structured Syntax Suffixes", RFC 6839, DOI 10.17487/RFC6839, , <https://www.rfc-editor.org/info/rfc6839>.
    -
    -
    [RFC6901]
    -
    -Bryan, P., Ed., Zyp, K., and M. Nottingham, Ed., "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, , <https://www.rfc-editor.org/info/rfc6901>.
    -
    -
    [RFC8259]
    -
    -Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, , <https://www.rfc-editor.org/info/rfc8259>.
    -
    -
    [W3C.REC-ldp-20150226]
    -
    -Speicher, S., Arwe, J., and A. Malhotra, "Linked Data Platform 1.0", World Wide Web Consortium Recommendation REC-ldp-20150226, , <https://www.w3.org/TR/2015/REC-ldp-20150226>.
    -
    -
    [ecma262]
    -
    -"ECMA-262, 11th edition specification", , <https://www.ecma-international.org/ecma-262/11.0/index.html>.
    -
    -
    -
    -
    -

    -15.2. Informative References -

    -
    -
    [RFC6596]
    -
    -Ohye, M. and J. Kupke, "The Canonical Link Relation", RFC 6596, DOI 10.17487/RFC6596, , <https://www.rfc-editor.org/info/rfc6596>.
    -
    -
    [RFC7049]
    -
    -Bormann, C. and P. Hoffman, "Concise Binary Object Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, , <https://www.rfc-editor.org/info/rfc7049>.
    -
    -
    [RFC7231]
    -
    -Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content", RFC 7231, DOI 10.17487/RFC7231, , <https://www.rfc-editor.org/info/rfc7231>.
    -
    -
    [RFC8288]
    -
    -Nottingham, M., "Web Linking", RFC 8288, DOI 10.17487/RFC8288, , <https://www.rfc-editor.org/info/rfc8288>.
    -
    -
    [W3C.WD-fragid-best-practices-20121025]
    -
    -Tennison, J., "Best Practices for Fragment Identifiers and Media Type Definitions", World Wide Web Consortium WD WD-fragid-best-practices-20121025, , <https://www.w3.org/TR/2012/WD-fragid-best-practices-20121025>.
    -
    -
    [json-schema-validation]
    -
    -Wright, A., Andrews, H., and B. Hutton, "JSON Schema Validation: A Vocabulary for Structural Validation of JSON", Work in Progress, Internet-Draft, draft-bhutton-json-schema-validation-01, , <https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-01>.
    -
    -
    [json-hyper-schema]
    -
    -Andrews, H. and A. Wright, "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON", Work in Progress, Internet-Draft, draft-handrews-json-schema-hyperschema-02, , <https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-02>.
    -
    -
    [xml-names]
    -
    -Bray, T., Ed., Hollander, D., Ed., Layman, A., Ed., and R. Tobin, Ed., "Namespaces in XML 1.1 (Second Edition)", , <http://www.w3.org/TR/2006/REC-xml-names11-20060816>.
    -
    -
    -
    -
    -
    -
    -

    -Appendix A. Schema identification examples -

    -

    - Consider the following schema, which shows "$id" being used to identify - both the root schema and various subschemas, and "$anchor" being used - to define plain name fragment identifiers.

    -
    -
    -
    -{
    -    "$id": "https://example.com/root.json",
    -    "$defs": {
    -        "A": { "$anchor": "foo" },
    -        "B": {
    -            "$id": "other.json",
    -            "$defs": {
    -                "X": { "$anchor": "bar" },
    -                "Y": {
    -                    "$id": "t/inner.json",
    -                    "$anchor": "bar"
    -                }
    -            }
    -        },
    -        "C": {
    -            "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f"
    -        }
    -    }
    -}
    -
    -
    -
    -

    - The schemas at the following URI-encoded JSON - Pointers [RFC6901] (relative to the root schema) have the following - base URIs, and are identifiable by any listed URI in accordance with - sections 5 and - 9.2.1 above.

    -
    -
    # (document root)
    -
    -
    -
    canonical (and base) URI
    -
    - https://example.com/root.json -
    -
    -
    canonical resource URI plus pointer fragment
    -
    - https://example.com/root.json# -
    -
    -
    -
    -
    -
    #/$defs/A
    -
    -
    -
    base URI
    -
    https://example.com/root.json -
    -
    -
    canonical resource URI plus plain fragment
    -
    - https://example.com/root.json#foo -
    -
    -
    canonical resource URI plus pointer fragment
    -
    - https://example.com/root.json#/$defs/A -
    -
    -
    -
    -
    -
    #/$defs/B
    -
    -
    -
    canonical (and base) URI
    -
    https://example.com/other.json -
    -
    -
    canonical resource URI plus pointer fragment
    -
    - https://example.com/other.json# -
    -
    -
    base URI of enclosing (root.json) resource plus fragment
    -
    - https://example.com/root.json#/$defs/B -
    -
    -
    -
    -
    -
    #/$defs/B/$defs/X
    -
    -
    -
    base URI
    -
    https://example.com/other.json -
    -
    -
    canonical resource URI plus plain fragment
    -
    - https://example.com/other.json#bar -
    -
    -
    canonical resource URI plus pointer fragment
    -
    - https://example.com/other.json#/$defs/X -
    -
    -
    base URI of enclosing (root.json) resource plus fragment
    -
    - https://example.com/root.json#/$defs/B/$defs/X -
    -
    -
    -
    -
    -
    #/$defs/B/$defs/Y
    -
    -
    -
    canonical (and base) URI
    -
    https://example.com/t/inner.json -
    -
    -
    canonical URI plus plain fragment
    -
    - https://example.com/t/inner.json#bar -
    -
    -
    canonical URI plus pointer fragment
    -
    - https://example.com/t/inner.json# -
    -
    -
    base URI of enclosing (other.json) resource plus fragment
    -
    - https://example.com/other.json#/$defs/Y -
    -
    -
    base URI of enclosing (root.json) resource plus fragment
    -
    - https://example.com/root.json#/$defs/B/$defs/Y -
    -
    -
    -
    -
    -
    #/$defs/C
    -
    -
    -
    canonical (and base) URI
    -
    - urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f -
    -
    -
    canonical URI plus pointer fragment
    -
    - urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f# -
    -
    -
    base URI of enclosing (root.json) resource plus fragment
    -
    - https://example.com/root.json#/$defs/C -
    -
    -
    -
    -
    -
    -

    - Note: The fragment part of the URI does not make it canonical or non-canonical, - rather, the base URI used (as part of the full URI with any fragment) is what - determines the canonical nature of the resulting full URI. - - Multiple "canonical" URIs? We Acknowledge this is potentially confusing, and - direct you to read the CREF located in the - JSON Pointer fragments and embedded schema resources (Section 9.2.1) - section for futher comments. -

    -
    -
    -
    -

    -Appendix B. Manipulating schema documents and references -

    -

    - Various tools have been created to rearrange schema documents - based on how and where references ("$ref") appear. This appendix discusses - which use cases and actions are compliant with this specification.

    -
    -

    -B.1. Bundling schema resources into a single document -

    -

    - A set of schema resources intended for use together can be organized - with each in its own schema document, all in the same schema document, - or any granularity of document grouping in between.

    -

    - Numerous tools exist to perform various sorts of reference removal. - A common case of this is producing a single file where all references - can be resolved within that file. This is typically done to simplify - distribution, or to simplify coding so that various invocations - of JSON Schema libraries do not have to keep track of and load - a large number of resources.

    -

    - This transformation can be safely and reversibly done as long as - all static references (e.g. "$ref") use URI-references that resolve - to URIs using the canonical resource URI as the base, and all schema - resources have an absolute-URI as the "$id" in their root schema.

    -

    - With these conditions met, each external resource can be copied - under "$defs", without breaking any references among the resources' - schema objects, and without changing any aspect of validation or - annotation results. The names of the schemas under "$defs" do - not affect behavior, assuming they are each unique, as they - do not appear in the canonical URIs for the embedded resources.

    -
    -
    -

    -B.2. Reference removal is not always safe -

    -

    - Attempting to remove all references and produce a single schema document does not, - in all cases, produce a schema with identical behavior to the original form.

    -

    - Since "$ref" is now treated like any other keyword, with other keywords allowed - in the same schema objects, fully supporting non-recursive "$ref" removal in - all cases can require relatively complex schema manipulations. It is beyond - the scope of this specification to determine or provide a set of safe "$ref" - removal transformations, as they depend not only on the schema structure - but also on the intended usage.

    -
    -
    -
    -
    -

    -Appendix C. Example of recursive schema extension -

    -

    - Consider the following two schemas describing a simple - recursive tree structure, where each node in the tree - can have a "data" field of any type. The first schema - allows and ignores other instance properties. The second is - more strict and only allows the "data" and "children" properties. - An example instance with "data" misspelled as "daat" is also shown.

    -
    -
    -
    -// tree schema, extensible
    -{
    -    "$schema": "https://json-schema.org/draft/2020-12/schema",
    -    "$id": "https://example.com/tree",
    -    "$dynamicAnchor": "node",
    -
    -    "type": "object",
    -    "properties": {
    -        "data": true,
    -        "children": {
    -            "type": "array",
    -            "items": {
    -                "$dynamicRef": "#node"
    -            }
    -        }
    -    }
    -}
    -
    -// strict-tree schema, guards against misspelled properties
    -{
    -    "$schema": "https://json-schema.org/draft/2020-12/schema",
    -    "$id": "https://example.com/strict-tree",
    -    "$dynamicAnchor": "node",
    -
    -    "$ref": "tree",
    -    "unevaluatedProperties": false
    -}
    -
    -// instance with misspelled field
    -{
    -    "children": [ { "daat": 1 } ]
    -}
    -
    -
    -
    -

    - When we load these two schemas, we will notice the "$dynamicAnchor" - named "node" (note the lack of "#" as this is just the name) - present in each, resulting in the following full schema URIs:

    -
      -
    • "https://example.com/tree#node" -
    • -
    • "https://example.com/strict-tree#node" -
    • -
    -

    - In addition, JSON Schema implementations keep track of the fact - that these fragments were created with "$dynamicAnchor".

    -

    - If we apply the "strict-tree" schema to the instance, we will follow - the "$ref" to the "tree" schema, examine its "children" subschema, - and find the "$dynamicRef": to "#node" (note the "#" for URI fragment syntax) - in its "items" subschema. That reference resolves to - "https://example.com/tree#node", which is a URI with a fragment - created by "$dynamicAnchor". Therefore we must examine the dynamic - scope before following the reference.

    -

    - At this point, the dynamic path is - "#/$ref/properties/children/items/$dynamicRef", with a dynamic scope - containing (from the outermost scope to the innermost):

    -
      -
    1. "https://example.com/strict-tree#" -
    2. -
    3. "https://example.com/tree#" -
    4. -
    5. "https://example.com/tree#/properties/children" -
    6. -
    7. "https://example.com/tree#/properties/children/items" -
    8. -
    -

    - Since we are looking for a plain name fragment, which can be - defined anywhere within a schema resource, the JSON Pointer fragments - are irrelevant to this check. That means that we can remove those - fragments and eliminate consecutive duplicates, producing:

    -
      -
    1. "https://example.com/strict-tree" -
    2. -
    3. "https://example.com/tree" -
    4. -
    -

    - In this case, the outermost resource also has a "node" fragment - defined by "$dynamicAnchor". Therefore instead of resolving the - "$dynamicRef" to "https://example.com/tree#node", we resolve it to - "https://example.com/strict-tree#node".

    -

    - This way, the recursion in the "tree" schema recurses to the root - of "strict-tree", instead of only applying "strict-tree" to the - instance root, but applying "tree" to instance children.

    -

    - This example shows both "$dynamicAnchor"s in the same place - in each schema, specifically the resource root schema. - Since plain-name fragments are independent of the JSON structure, - this would work just as well if one or both of the node schema objects - were moved under "$defs". It is the matching "$dynamicAnchor" values - which tell us how to resolve the dynamic reference, not any sort of - correlation in JSON structure.

    -
    -
    -
    -

    -Appendix D. Working with vocabularies -

    -
    -

    -D.1. Best practices for vocabulary and meta-schema authors -

    -

    - Vocabulary authors should - take care to avoid keyword name collisions if the vocabulary is intended - for broad use, and potentially combined with other vocabularies. JSON - Schema does not provide any formal namespacing system, but also does - not constrain keyword names, allowing for any number of namespacing - approaches.

    -

    - Vocabularies may build on each other, such as by defining the behavior - of their keywords with respect to the behavior of keywords from another - vocabulary, or by using a keyword from another vocabulary with - a restricted or expanded set of acceptable values. Not all such - vocabulary re-use will result in a new vocabulary that is compatible - with the vocabulary on which it is built. Vocabulary authors should - clearly document what level of compatibility, if any, is expected.

    -

    - Meta-schema authors should not use "$vocabulary" to combine multiple - vocabularies that define conflicting syntax or semantics for the same - keyword. As semantic conflicts are not generally detectable through - schema validation, implementations are not expected to detect such - conflicts. If conflicting vocabularies are declared, the resulting - behavior is undefined.

    -

    - Vocabulary authors SHOULD provide a meta-schema that validates the - expected usage of the vocabulary's keywords on their own. Such meta-schemas - SHOULD not forbid additional keywords, and MUST not forbid any - keywords from the Core vocabulary.

    -

    - It is recommended that meta-schema authors reference each vocabulary's - meta-schema using the "allOf" (Section 10.2.1.1) keyword, - although other mechanisms for constructing the meta-schema may be - appropriate for certain use cases.

    -

    - The recursive nature of meta-schemas makes the "$dynamicAnchor" - and "$dynamicRef" keywords particularly useful for extending - existing meta-schemas, as can be seen in the JSON Hyper-Schema meta-schema - which extends the Validation meta-schema.

    -

    - Meta-schemas may impose additional constraints, including describing - keywords not present in any vocabulary, beyond what the meta-schemas - associated with the declared vocabularies describe. This allows for - restricting usage to a subset of a vocabulary, and for validating - locally defined keywords not intended for re-use.

    -

    - However, meta-schemas should not contradict any vocabularies that - they declare, such as by requiring a different JSON type than - the vocabulary expects. The resulting behavior is undefined.

    -

    - Meta-schemas intended for local use, with no need to test for - vocabulary support in arbitrary implementations, can safely omit - "$vocabulary" entirely.

    -
    -
    -
    -

    -D.2. Example meta-schema with vocabulary declarations -

    -

    - This meta-schema explicitly declares both the Core and Applicator vocabularies, - together with an extension vocabulary, and combines their meta-schemas with - an "allOf". The extension vocabulary's meta-schema, which describes only the - keywords in that vocabulary, is shown after the main example meta-schema.

    -

    - The main example meta-schema also restricts the usage of the Unevaluated - vocabulary by forbidding the keywords prefixed with "unevaluated", which - are particularly complex to implement. This does not change the semantics - or set of keywords defined by the other vocabularies. It just ensures - that schemas using this meta-schema that attempt to use the keywords - prefixed with "unevaluated" will fail validation against this meta-schema.

    -

    - Finally, this meta-schema describes the syntax of a keyword, "localKeyword", - that is not part of any vocabulary. Presumably, the implementors and users - of this meta-schema will understand the semantics of "localKeyword". - JSON Schema does not define any mechanism for expressing keyword semantics - outside of vocabularies, making them unsuitable for use except in a - specific environment in which they are understood.

    -

    - This meta-schema combines several vocabularies for general use.

    -
    -
    -
    -{
    -  "$schema": "https://json-schema.org/draft/2020-12/schema",
    -  "$id": "https://example.com/meta/general-use-example",
    -  "$dynamicAnchor": "meta",
    -  "$vocabulary": {
    -    "https://json-schema.org/draft/2020-12/vocab/core": true,
    -    "https://json-schema.org/draft/2020-12/vocab/applicator": true,
    -    "https://json-schema.org/draft/2020-12/vocab/validation": true,
    -    "https://example.com/vocab/example-vocab": true
    -  },
    -  "allOf": [
    -    {"$ref": "https://json-schema.org/draft/2020-12/meta/core"},
    -    {"$ref": "https://json-schema.org/draft/2020-12/meta/applicator"},
    -    {"$ref": "https://json-schema.org/draft/2020-12/meta/validation"},
    -    {"$ref": "https://example.com/meta/example-vocab"}
    -  ],
    -  "patternProperties": {
    -    "^unevaluated": false
    -  },
    -  "properties": {
    -    "localKeyword": {
    -      "$comment": "Not in vocabulary, but validated if used",
    -      "type": "string"
    -    }
    -  }
    -}
    -
    -
    -
    -

    - This meta-schema describes only a single extension vocabulary.

    -
    -
    -
    -{
    -  "$schema": "https://json-schema.org/draft/2020-12/schema",
    -  "$id": "https://example.com/meta/example-vocab",
    -  "$dynamicAnchor": "meta",
    -  "$vocabulary": {
    -    "https://example.com/vocab/example-vocab": true,
    -  },
    -  "type": ["object", "boolean"],
    -  "properties": {
    -    "minDate": {
    -      "type": "string",
    -      "pattern": "\d\d\d\d-\d\d-\d\d",
    -      "format": "date",
    -    }
    -  }
    -}
    -
    -
    -
    -

    - As shown above, even though each of the single-vocabulary meta-schemas - referenced in the general-use meta-schema's "allOf" declares its - corresponding vocabulary, this new meta-schema must re-declare them.

    -

    - The standard meta-schemas that combine all vocabularies defined by - the Core and Validation specification, and that combine all vocabularies - defined by those specifications as well as the Hyper-Schema specification, - demonstrate additional complex combinations. These URIs for these - meta-schemas may be found in the Validation and Hyper-Schema specifications, - respectively.

    -

    - While the general-use meta-schema can validate the syntax of "minDate", - it is the vocabulary that defines the logic behind the semantic meaning - of "minDate". Without an understanding of the semantics (in this example, - that the instance value must be a date equal to or after the date - provided as the keyword's value in the schema), an implementation can - only validate the syntactic usage. In this case, that means validating - that it is a date-formatted string (using "pattern" to ensure that it is - validated even when "format" functions purely as an annotation, as explained - in the Validation specification [json-schema-validation].

    -
    -
    -
    -
    -

    -Appendix E. References and generative use cases -

    -

    - While the presence of references is expected to be transparent - to validation results, generative use cases such as code generators - and UI renderers often consider references to be semantically significant.

    -

    - To make such use case-specific semantics explicit, the best practice - is to create an annotation keyword for use in the same - schema object alongside of a reference keyword such as "$ref".

    -

    - For example, here is a hypothetical keyword for determining - whether a code generator should consider the reference - target to be a distinct class, and how those classes are related. - Note that this example is solely for illustrative purposes, and is - not intended to propose a functional code generation keyword.

    -
    -
    -
    -{
    -    "allOf": [
    -        {
    -            "classRelation": "is-a",
    -            "$ref": "classes/base.json"
    -        },
    -        {
    -            "$ref": "fields/common.json"
    -        }
    -    ],
    -    "properties": {
    -        "foo": {
    -            "classRelation": "has-a",
    -            "$ref": "classes/foo.json"
    -        },
    -        "date": {
    -            "$ref": "types/dateStruct.json",
    -        }
    -    }
    -}
    -
    -
    -
    -

    - Here, this schema represents some sort of object-oriented class. - The first reference in the "allOf" is noted as the base class. - The second is not assigned a class relationship, meaning that the - code generator should combine the target's definition with this - one as if no reference were involved.

    -

    - Looking at the properties, "foo" is flagged as object composition, - while the "date" property is not. It is simply a field with - sub-fields, rather than an instance of a distinct class.

    -

    - This style of usage requires the annotation to be in the same object - as the reference, which must be recognizable as a reference.

    -
    -
    -

    -Appendix F. Acknowledgments -

    -

    - Thanks to - Gary Court, - Francis Galiegue, - Kris Zyp, - and Geraint Luff - for their work on the initial drafts of JSON Schema.

    -

    - Thanks to - Jason Desrosiers, - Daniel Perrett, - Erik Wilde, - Evgeny Poberezkin, - Brad Bowman, - Gowry Sankar, - Donald Pipowitch, - Dave Finlay, - Denis Laxalde, - Phil Sturgeon, - Shawn Silverman, - and Karen Etheridge - for their submissions and patches to the document.

    -
    -
    -

    -Appendix G. ChangeLog -

    -

    - This section to be removed before leaving Internet-Draft status.

    -
    -
    draft-bhutton-json-schema-00
    -
    -
      -
    • "$schema" MAY change for embedded resources -
    • -
    • Array-value "items" functionality is now "prefixItems" -
    • -
    • "items" subsumes the old function of "additionalItems" -
    • -
    • "contains" annotation behavior, and "contains" and "unevaluatedItems" interactions now specified -
    • -
    • Rename $recursive* to $dynamic*, with behavior modification -
    • -
    • $dynamicAnchor defines a fragment like $anchor -
    • -
    • $dynamic* (previously $recursive) no longer use runtime base URI determination -
    • -
    • Define Compound Schema Documents (bundle) and processing -
    • -
    • Reference ECMA-262, 11th edition for regular expression support -
    • -
    • Regular expression should support unicode -
    • -
    • Remove media type parameters -
    • -
    • Specify Unknown keywords are collected as annotations -
    • -
    • Moved "unevaluatedItems" and "unevaluatedProperties" from core into their own vocabulary -
    • -
    -
    -
    -
    draft-handrews-json-schema-02
    -
    -
      -
    • Update to RFC 8259 for JSON specification -
    • -
    • Moved "definitions" from the Validation specification here as "$defs" -
    • -
    • Moved applicator keywords from the Validation specification as their own vocabulary -
    • -
    • Moved the schema form of "dependencies" from the Validation specification as "dependentSchemas" -
    • -
    • Formalized annotation collection -
    • -
    • Specified recommended output formats -
    • -
    • Defined keyword interactions in terms of annotation and assertion results -
    • -
    • Added "unevaluatedProperties" and "unevaluatedItems" -
    • -
    • Define "$ref" behavior in terms of the assertion, applicator, and annotation model -
    • -
    • Allow keywords adjacent to "$ref" -
    • -
    • Note undefined behavior for "$ref" targets involving unknown keywords -
    • -
    • Add recursive referencing, primarily for meta-schema extension -
    • -
    • Add the concept of formal vocabularies, and how they can be recognized through meta-schemas -
    • -
    • Additional guidance on initial base URIs beyond network retrieval -
    • -
    • Allow "schema" media type parameter for "application/schema+json" -
    • -
    • Better explanation of media type parameters and the HTTP Accept header -
    • -
    • Use "$id" to establish canonical and base absolute-URIs only, no fragments -
    • -
    • Replace plain-name-fragment-only form of "$id" with "$anchor" -
    • -
    • Clarified that the behavior of JSON Pointers across "$id" boundary is unreliable -
    • -
    -
    -
    -
    draft-handrews-json-schema-01
    -
    -
      -
    • This draft is purely a clarification with no functional changes -
    • -
    • Emphasized annotations as a primary usage of JSON Schema -
    • -
    • Clarified $id by use cases -
    • -
    • Exhaustive schema identification examples -
    • -
    • Replaced "external referencing" with how and when an implementation might know of a schema from another document -
    • -
    • Replaced "internal referencing" with how an implementation should recognized schema identifiers during parsing -
    • -
    • Dereferencing the former "internal" or "external" references is always the same process -
    • -
    • Minor formatting improvements -
    • -
    -
    -
    -
    draft-handrews-json-schema-00
    -
    -
      -
    • Make the concept of a schema keyword vocabulary more clear -
    • -
    • Note that the concept of "integer" is from a vocabulary, not the data model -
    • -
    • Classify keywords as assertions or annotations and describe their general behavior -
    • -
    • Explain the boolean schemas in terms of generalized assertions -
    • -
    • Reserve "$comment" for non-user-visible notes about the schema -
    • -
    • Wording improvements around "$id" and fragments -
    • -
    • Note the challenges of extending meta-schemas with recursive references -
    • -
    • Add "application/schema-instance+json" media type -
    • -
    • Recommend a "schema" link relation / parameter instead of "profile" -
    • -
    -
    -
    -
    draft-wright-json-schema-01
    -
    -
      -
    • Updated intro -
    • -
    • Allowed for any schema to be a boolean -
    • -
    • "$schema" SHOULD NOT appear in subschemas, although that may change -
    • -
    • Changed "id" to "$id"; all core keywords prefixed with "$" -
    • -
    • Clarify and formalize fragments for application/schema+json -
    • -
    • Note applicability to formats such as CBOR that can be represented in the JSON data model -
    • -
    -
    -
    -
    draft-wright-json-schema-00
    -
    -
      -
    • Updated references to JSON -
    • -
    • Updated references to HTTP -
    • -
    • Updated references to JSON Pointer -
    • -
    • Behavior for "id" is now specified in terms of RFC3986 -
    • -
    • Aligned vocabulary usage for URIs with RFC3986 -
    • -
    • Removed reference to draft-pbryan-zyp-json-ref-03 -
    • -
    • Limited use of "$ref" to wherever a schema is expected -
    • -
    • Added definition of the "JSON Schema data model" -
    • -
    • Added additional security considerations -
    • -
    • Defined use of subschema identifiers for "id" -
    • -
    • Rewrote section on usage with HTTP -
    • -
    • Rewrote section on usage with rel="describedBy" and rel="profile" -
    • -
    • Fixed numerous invalid examples -
    • -
    -
    -
    -
    draft-zyp-json-schema-04
    -
    -
      -
    • Salvaged from draft v3. -
    • -
    • Split validation keywords into separate document. -
    • -
    • Split hypermedia keywords into separate document. -
    • -
    • Initial post-split draft. -
    • -
    • Mandate the use of JSON Reference, JSON Pointer. -
    • -
    • Define the role of "id". Define URI resolution scope. -
    • -
    • Add interoperability considerations. -
    • -
    -
    -
    -
    draft-zyp-json-schema-00
    -
    -
      -
    • Initial draft. -
    • -
    -
    -
    -
    -
    -
    -
    -

    -Authors' Addresses -

    -
    -
    Austin Wright (editor)
    - -
    -
    -
    Henry Andrews (editor)
    - -
    -
    -
    Ben Hutton (editor)
    - - -
    -
    -
    Greg Dennis
    - - -
    -
    -
    - - - diff --git a/draft/preview/2020-12-p1-rc-0/jsonschema-validation.html b/draft/preview/2020-12-p1-rc-0/jsonschema-validation.html deleted file mode 100644 index 758eeeb3..00000000 --- a/draft/preview/2020-12-p1-rc-0/jsonschema-validation.html +++ /dev/null @@ -1,3173 +0,0 @@ - - - - - - -JSON Schema Validation: A Vocabulary for Structural Validation of JSON - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Internet-DraftJSON Schema ValidationApril 2022
    Wright, et al.Expires 30 October 2022[Page]
    -
    -
    -
    -
    Workgroup:
    -
    Internet Engineering Task Force
    -
    Internet-Draft:
    -
    draft-bhutton-json-schema-validation-01
    -
    Published:
    -
    - -
    -
    Intended Status:
    -
    Informational
    -
    Expires:
    -
    -
    Authors:
    -
    -
    -
    A. Wright, Ed. -
    -
    -
    -
    H. Andrews, Ed. -
    -
    -
    -
    B. Hutton, Ed. -
    -
    -
    -
    -
    -

    JSON Schema Validation: A Vocabulary for Structural Validation of JSON

    -
    -

    Abstract

    -

    - JSON Schema (application/schema+json) has several purposes, one of which is JSON - instance validation. - This document specifies a vocabulary for JSON Schema to describe the meaning of JSON - documents, provide hints for user interfaces working with JSON data, and to make - assertions about what a valid document must look like.

    -
    -
    -

    -Note to Readers -

    -

    - The issues list for this draft can be found at - https://github.com/json-schema-org/json-schema-spec/issues.

    -

    - For additional information, see https://json-schema.org/.

    -

    - To provide feedback, use this issue tracker, the communication methods listed on the - homepage, or email the document editors.

    -
    -
    -
    -

    -Status of This Memo -

    -

    - This Internet-Draft is submitted in full conformance with the - provisions of BCP 78 and BCP 79.

    -

    - Internet-Drafts are working documents of the Internet Engineering Task - Force (IETF). Note that other groups may also distribute working - documents as Internet-Drafts. The list of current Internet-Drafts is - at https://datatracker.ietf.org/drafts/current/.

    -

    - Internet-Drafts are draft documents valid for a maximum of six months - and may be updated, replaced, or obsoleted by other documents at any - time. It is inappropriate to use Internet-Drafts as reference - material or to cite them other than as "work in progress."

    -

    - This Internet-Draft will expire on 30 October 2022.

    -
    -
    - -
    -
    -

    -Table of Contents -

    - -
    -
    -
    -

    -1. Introduction -

    -

    - JSON Schema can be used to require that a given JSON document (an instance) - satisfies a certain number of criteria. These criteria are asserted by using - keywords described in this specification. In addition, a set of keywords - is also defined to assist in interactive user interface instance generation.

    -

    - This specification will use the concepts, syntax, and terminology defined - by the JSON Schema core [json-schema] specification.

    -
    -
    -

    -2. Conventions and Terminology -

    -

    - - - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", - "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be - interpreted as described in RFC 2119 [RFC2119].

    -

    - This specification uses the term "container instance" to refer to both array and - object instances. It uses the term "children instances" to refer to array elements - or object member values.

    -

    - Elements in an array value are said to be unique if no two elements of this array - are equal [json-schema].

    -
    -
    -

    -3. Overview -

    -

    - JSON Schema validation asserts constraints on the structure of instance data. - An instance location that satisfies all asserted constraints is then - annotated with any keywords that contain non-assertion information, - such as descriptive metadata and usage hints. If all locations within - the instance satisfy all asserted constraints, then the instance is - said to be valid against the schema.

    -

    - Each schema object is independently evaluated against each instance location - to which it applies. This greatly simplifies the implementation requirements - for validators by ensuring that they do not need to maintain state across - the document-wide validation process.

    -

    - This specification defines a set of assertion keywords, as well as a small vocabulary - of metadata keywords that can be used to annotate the JSON instance with - useful information. The Section 7 keyword is intended primarily - as an annotation, but can optionally be used as an assertion. The - Section 8 keywords are annotations for working with documents - embedded as JSON strings.

    -
    -
    -

    -4. Interoperability Considerations -

    -
    -

    -4.1. Validation of String Instances -

    -

    - It should be noted that the nul character (\u0000) is valid in a JSON string. An - instance to validate may contain a string value with this character, regardless - of the ability of the underlying programming language to deal with such data.

    -
    -
    -

    -4.2. Validation of Numeric Instances -

    -

    - The JSON specification allows numbers with arbitrary precision, and JSON Schema - does not add any such bounds. - This means that numeric instances processed by JSON Schema can be arbitrarily large and/or - have an arbitrarily long decimal part, regardless of the ability of the - underlying programming language to deal with such data.

    -
    -
    -
    -

    -4.3. Regular Expressions -

    -

    - Keywords that use regular expressions, or constrain the instance value - to be a regular expression, are subject to the interoperability - considerations for regular expressions in the - JSON Schema Core [json-schema] specification.

    -
    -
    -
    -
    -
    -

    -5. Meta-Schema -

    -

    - The current URI for the default JSON Schema dialect meta-schema is - https://json-schema.org/draft/2020-12/schema. - For schema author convenience, this meta-schema describes a dialect - consisting of all vocabularies - defined in this specification and the JSON Schema Core specification, - as well as two former keywords which are reserved for a transitional period. - Individual vocabulary and vocabulary meta-schema URIs are given for - each section below. Certain vocabularies are optional to support, which - is explained in detail in the relevant sections.

    -

    - Updated vocabulary and meta-schema URIs MAY be published between - specification drafts in order to correct errors. Implementations - SHOULD consider URIs dated after this specification draft and - before the next to indicate the same syntax and semantics - as those listed here.

    -
    -
    -
    -

    -6. A Vocabulary for Structural Validation -

    -

    - Validation keywords in a schema impose requirements for successful validation of an - instance. These keywords are all assertions without any annotation behavior.

    -

    - Meta-schemas that do not use "$vocabulary" SHOULD be considered to - require this vocabulary as if its URI were present with a value of true.

    -

    - The current URI for this vocabulary, known as the Validation vocabulary, is: - <https://json-schema.org/draft/2020-12/vocab/validation>.

    -

    - The current URI for the corresponding meta-schema is: - https://json-schema.org/draft/2020-12/meta/validation.

    -
    -
    -

    -6.1. Validation Keywords for Any Instance Type -

    -
    -

    -6.1.1. type -

    -

    - The value of this keyword MUST be either a string or an array. If it is - an array, elements of the array MUST be strings and MUST be unique.

    -

    - String values MUST be one of the six primitive types - ("null", "boolean", "object", "array", "number", or "string"), - or "integer" which matches any number with a zero fractional part.

    -

    - If the value of "type" is a string, then an instance validates successfully if - its type matches the type represented by the value of the string. - - If the value of "type" is an array, then an instance validates successfully if - its type matches any of the types indicated by the strings in the array.

    -
    -
    -
    -

    -6.1.2. enum -

    -

    - The value of this keyword MUST be an array. This array SHOULD have at - least one element. Elements in the array SHOULD be unique.

    -

    - An instance validates successfully against this keyword if its value is - equal to one of the elements in this keyword's array value.

    -

    - Elements in the array might be of any type, including null.

    -
    -
    -
    -

    -6.1.3. const -

    -

    - The value of this keyword MAY be of any type, including null.

    -

    - Use of this keyword is functionally equivalent to an - "enum" (Section 6.1.2) with a single value.

    -

    - An instance validates successfully against this keyword if its value is - equal to the value of the keyword.

    -
    -
    -
    -
    -
    -

    -6.2. Validation Keywords for Numeric Instances (number and integer) -

    -
    -

    -6.2.1. multipleOf -

    -

    - The value of "multipleOf" MUST be a number, strictly greater than 0.

    -

    - A numeric instance is valid only if division by this keyword's value results in - an integer.

    -
    -
    -

    -6.2.2. maximum -

    -

    - The value of "maximum" MUST be a number, representing an inclusive upper limit - for a numeric instance.

    -

    - If the instance is a number, then this keyword validates only if the instance is - less than or exactly equal to "maximum".

    -
    -
    -

    -6.2.3. exclusiveMaximum -

    -

    - The value of "exclusiveMaximum" MUST be a number, representing an exclusive upper - limit for a numeric instance.

    -

    - If the instance is a number, then the instance is valid only if it has a value - strictly less than (not equal to) "exclusiveMaximum".

    -
    -
    -

    -6.2.4. minimum -

    -

    - The value of "minimum" MUST be a number, representing an inclusive lower limit - for a numeric instance.

    -

    - If the instance is a number, then this keyword validates only if the instance is - greater than or exactly equal to "minimum".

    -
    -
    -

    -6.2.5. exclusiveMinimum -

    -

    - The value of "exclusiveMinimum" MUST be a number, representing an exclusive lower - limit for a numeric instance.

    -

    - If the instance is a number, then the instance is valid only if it has a value - strictly greater than (not equal to) "exclusiveMinimum".

    -
    -
    -
    -
    -
    -

    -6.3. Validation Keywords for Strings -

    -
    -

    -6.3.1. maxLength -

    -

    - The value of this keyword MUST be a non-negative integer.

    -

    - A string instance is valid against this keyword if its - length is less than, or equal to, the value of this keyword.

    -

    - The length of a string instance is defined as the number of its - characters as defined by RFC 8259 [RFC8259].

    -
    -
    -

    -6.3.2. minLength -

    -

    - The value of this keyword MUST be a non-negative integer.

    -

    - A string instance is valid against this keyword if its - length is greater than, or equal to, the value of this keyword.

    -

    - The length of a string instance is defined as the number of its - characters as defined by RFC 8259 [RFC8259].

    -

    - Omitting this keyword has the same behavior as a value of 0.

    -
    -
    -
    -

    -6.3.3. pattern -

    -

    - The value of this keyword MUST be a string. This string SHOULD be a - valid regular expression, according to the ECMA-262 regular expression - dialect.

    -

    - A string instance is considered valid if the regular - expression matches the instance successfully. Recall: regular - expressions are not implicitly anchored.

    -
    -
    -
    -
    -
    -

    -6.4. Validation Keywords for Arrays -

    -
    -

    -6.4.1. maxItems -

    -

    - The value of this keyword MUST be a non-negative integer.

    -

    - An array instance is valid against "maxItems" if its size is - less than, or equal to, the value of this keyword.

    -
    -
    -

    -6.4.2. minItems -

    -

    - The value of this keyword MUST be a non-negative integer.

    -

    - An array instance is valid against "minItems" if its size is - greater than, or equal to, the value of this keyword.

    -

    - Omitting this keyword has the same behavior as a value of 0.

    -
    -
    -

    -6.4.3. uniqueItems -

    -

    - The value of this keyword MUST be a boolean.

    -

    - If this keyword has boolean value false, the instance validates - successfully. If it has boolean value true, the instance validates - successfully if all of its elements are unique.

    -

    - Omitting this keyword has the same behavior as a value of false.

    -
    -
    -

    -6.4.4. maxContains -

    -

    - The value of this keyword MUST be a non-negative integer.

    -

    - If "contains" is not present within the same schema object, - then this keyword has no effect.

    -

    - An instance array is valid against "maxContains" in two ways, depending on - the form of the annotation result of an adjacent - "contains" [json-schema] keyword. The first way is if - the annotation result is an array and the length of that array is less than - or equal to the "maxContains" value. The second way is if the annotation - result is a boolean "true" and the instance array length is less than or - equal to the "maxContains" value.

    -
    -
    -

    -6.4.5. minContains -

    -

    - The value of this keyword MUST be a non-negative integer.

    -

    - If "contains" is not present within the same schema object, - then this keyword has no effect.

    -

    - An instance array is valid against "minContains" in two ways, depending on - the form of the annotation result of an adjacent - "contains" [json-schema] keyword. The first way is if - the annotation result is an array and the length of that array is greater - than or equal to the "minContains" value. The second way is if the - annotation result is a boolean "true" and the instance array length is - greater than or equal to the "minContains" value.

    -

    - A value of 0 is allowed, but is only useful for setting a range - of occurrences from 0 to the value of "maxContains". A value of - 0 causes "minContains" to always pass validation (but validation can - still fail against a "maxContains" keyword).

    -

    - Omitting this keyword has the same behavior as a value of 1.

    -
    -
    -
    -

    -6.5. Validation Keywords for Objects -

    -
    -

    -6.5.1. maxProperties -

    -

    - The value of this keyword MUST be a non-negative integer.

    -

    - An object instance is valid against "maxProperties" if its - number of properties is less than, or equal to, the value of this - keyword.

    -
    -
    -

    -6.5.2. minProperties -

    -

    - The value of this keyword MUST be a non-negative integer.

    -

    - An object instance is valid against "minProperties" if its - number of properties is greater than, or equal to, the value of this - keyword.

    -

    - Omitting this keyword has the same behavior as a value of 0.

    -
    -
    -

    -6.5.3. required -

    -

    - The value of this keyword MUST be an array. - Elements of this array, if any, MUST be strings, and MUST be unique.

    -

    - An object instance is valid against this keyword if every item in the array is - the name of a property in the instance.

    -

    - Omitting this keyword has the same behavior as an empty array.

    -
    -
    -

    -6.5.4. dependentRequired -

    -

    - The value of this keyword MUST be an object. Properties in - this object, if any, MUST be arrays. Elements in each array, - if any, MUST be strings, and MUST be unique.

    -

    - This keyword specifies properties that are required if a specific - other property is present. Their requirement is dependent on the - presence of the other property.

    -

    - Validation succeeds if, for each name that appears in both - the instance and as a name within this keyword's value, every - item in the corresponding array is also the name of a property - in the instance.

    -

    - Omitting this keyword has the same behavior as an empty object.

    -
    -
    -
    -
    -
    -

    -7. Vocabularies for Semantic Content With "format" -

    -
    -

    -7.1. Foreword -

    -

    - Structural validation alone may be insufficient to allow an application to correctly - utilize certain values. The "format" annotation keyword is defined to allow schema - authors to convey semantic information for a fixed subset of values which are - accurately described by authoritative resources, be they RFCs or other external - specifications.

    -

    - The value of this keyword is called a format attribute. It MUST be a string. A - format attribute can generally only validate a given set of instance types. If - the type of the instance to validate is not in this set, validation for this - format attribute and instance SHOULD succeed. All format attributes defined - in this section apply to strings, but a format attribute can be specified - to apply to any instance types defined in the data model defined in the - core JSON Schema. [json-schema] - - Note that the "type" keyword in this specification defines an "integer" type - which is not part of the data model. Therefore a format attribute can be - limited to numbers, but not specifically to integers. However, a numeric - format can be used alongside the "type" keyword with a value of "integer", - or could be explicitly defined to always pass if the number is not an integer, - which produces essentially the same behavior as only applying to integers. -

    -

    - The current URI for this vocabulary, known as the Format-Annotation vocabulary, is: - <https://json-schema.org/draft/2020-12/vocab/format-annotation>. The current - URI for the corresponding meta-schema is: - https://json-schema.org/draft/2020-12/meta/format-annotation. - Implementing support for this vocabulary is REQUIRED.

    -

    - In addition to the Format-Annotation vocabulary, a secondary vocabulary is available - for custom meta-schemas that defines "format" as an assertion. The URI for the - Format-Assertion vocabulary, is: - <https://json-schema.org/draft/2020-12/vocab/format-assertion>. The current - URI for the corresponding meta-schema is: - https://json-schema.org/draft/2020-12/meta/format-assertion. - Implementing support for the Format-Assertion vocabulary is OPTIONAL.

    -

    - Specifying both the Format-Annotation and the Format-Assertion vocabularies is functionally - equivalent to specifying only the Format-Assertion vocabulary since its requirements - are a superset of the Format-Annotation vocabulary.

    -
    -
    -

    -7.2. Implementation Requirements -

    -

    - The "format" keyword functions as defined by the vocabulary which is referenced.

    -
    -

    -7.2.1. Format-Annotation Vocabulary -

    -

    - The value of format MUST be collected as an annotation, if the implementation - supports annotation collection. This enables application-level validation when - schema validation is unavailable or inadequate.

    -

    - Implementations MAY still treat "format" as an assertion in addition to an - annotation and attempt to validate the value's conformance to the specified - semantics. The implementation MUST provide options to enable and disable such - evaluation and MUST be disabled by default. Implementations SHOULD document - their level of support for such validation. - - Specifying the Format-Annotation vocabulary and enabling validation in an - implementation should not be viewed as being equivalent to specifying - the Format-Assertion vocabulary since implementations are not required to - provide full validation support when the Format-Assertion vocabulary - is not specified. -

    -

    - When the implementation is configured for assertion behavior, it:

    -
      -
    • - SHOULD provide an implementation-specific best effort validation - for each format attribute defined below; -
    • -
    • - MAY choose to implement validation of any or all format attributes - as a no-op by always producing a validation result of true; -
    • -
    -

    - - This matches the current reality of implementations, which provide - widely varying levels of validation, including no validation at all, - for some or all format attributes. It is also designed to encourage - relying only on the annotation behavior and performing semantic - validation in the application, which is the recommended best practice. -

    -
    -
    -

    -7.2.2. Format-Assertion Vocabulary -

    -

    - When the Format-Assertion vocabulary is declared with a value of true, - implementations MUST provide full validation support for all of the formats - defined by this specificaion. Implementations that cannot provide full - validation support MUST refuse to process the schema.

    -

    - An implementation that supports the Format-Assertion vocabulary:

    -
      -
    • - MUST still collect "format" as an annotation if the implementation - supports annotation collection; -
    • -
    • - MUST evaluate "format" as an assertion; -
    • -
    • - MUST implement syntactic validation for all format attributes defined - in this specification, and for any additional format attributes that - it recognizes, such that there exist possible instance values - of the correct type that will fail validation. -
    • -
    -

    - The requirement for minimal validation of format attributes is intentionally - vague and permissive, due to the complexity involved in many of the attributes. - Note in particular that the requirement is limited to syntactic checking; it is - not to be expected that an implementation would send an email, attempt to connect - to a URL, or otherwise check the existence of an entity identified by a format - instance. - - The expectation is that for simple formats such as date-time, syntactic - validation will be thorough. For a complex format such as email addresses, - which are the amalgamation of various standards and numerous adjustments - over time, with obscure and/or obsolete rules that may or may not be - restricted by other applications making use of the value, a minimal validation - is sufficient. For example, an instance string that does not contain - an "@" is clearly not a valid email address, and an "email" or "hostname" - containing characters outside of 7-bit ASCII is likewise clearly invalid. -

    -

    - It is RECOMMENDED that implementations use a common parsing library for each format, - or a well-known regular expression. Implementations SHOULD clearly document - how and to what degree each format attribute is validated.

    -

    - The standard core and validation meta-schema (Section 5) - includes this vocabulary in its "$vocabulary" keyword with a value of false, - since by default implementations are not required to support this keyword - as an assertion. Supporting the format vocabulary with a value of true is - understood to greatly increase code size and in some cases execution time, - and will not be appropriate for all implementations.

    -
    -
    -

    -7.2.3. Custom format attributes -

    -

    - Implementations MAY support custom format attributes. Save for agreement between - parties, schema authors SHALL NOT expect a peer implementation to support such - custom format attributes. An implementation MUST NOT fail to collect unknown formats - as annotations. When the Format-Assertion vocabulary is specified, implementations - MUST fail upon encountering unknown formats.

    -

    - Vocabularies do not support specifically declaring different value sets for keywords. - Due to this limitation, and the historically uneven implementation of this keyword, - it is RECOMMENDED to define additional keywords in a custom vocabulary rather than - additional format attributes if interoperability is desired.

    -
    -
    -
    -

    -7.3. Defined Formats -

    -
    -

    -7.3.1. Dates, Times, and Duration -

    -

    - These attributes apply to string instances.

    -

    - Date and time format names are derived from - RFC 3339, section 5.6 [RFC3339]. - The duration format is from the ISO 8601 ABNF as given - in Appendix A of RFC 3339.

    -

    - Implementations supporting formats SHOULD implement support for - the following attributes:

    -
    -
    date-time:
    -
    - A string instance is valid against this attribute if it is - a valid representation according to the "date-time' ABNF rule - (referenced above) -
    -
    -
    date:
    -
    - A string instance is valid against this attribute if it is - a valid representation according to the "full-date" ABNF rule - (referenced above) -
    -
    -
    time:
    -
    - A string instance is valid against this attribute if it is - a valid representation according to the "full-time" ABNF rule - (referenced above) -
    -
    -
    duration:
    -
    - A string instance is valid against this attribute if it is - a valid representation according to the "duration" ABNF rule - (referenced above) -
    -
    -
    -

    - Implementations MAY support additional attributes using the other - format names defined anywhere in that RFC. If "full-date" or "full-time" - are implemented, the corresponding short form ("date" or "time" - respectively) MUST be implemented, and MUST behave identically. - Implementations SHOULD NOT define extension attributes - with any name matching an RFC 3339 format unless it validates - according to the rules of that format. - - There is not currently consensus on the need for supporting - all RFC 3339 formats, so this approach of reserving the - namespace will encourage experimentation without committing - to the entire set. Either the format implementation requirements - will become more flexible in general, or these will likely - either be promoted to fully specified attributes or dropped. -

    -
    -
    -

    -7.3.2. Email Addresses -

    -

    - These attributes apply to string instances.

    -

    - A string instance is valid against these attributes if it is a valid - Internet email address as follows:

    -
    -
    email:
    -
    - As defined by the "Mailbox" ABNF rule in - RFC 5321, section 4.1.2 [RFC5321]. -
    -
    -
    idn-email:
    -
    - As defined by the extended "Mailbox" ABNF rule in - RFC 6531, section 3.3 [RFC6531]. -
    -
    -
    -

    - Note that all strings valid against the "email" attribute are also - valid against the "idn-email" attribute.

    -
    -
    -

    -7.3.3. Hostnames -

    -

    - These attributes apply to string instances.

    -

    - A string instance is valid against these attributes if it is a valid - representation for an Internet hostname as follows:

    -
    -
    hostname:
    -
    - As defined by RFC 1123, section 2.1 [RFC1123], - including host names produced using the Punycode algorithm - specified in RFC 5891, section 4.4 [RFC5891]. -
    -
    -
    idn-hostname:
    -
    - As defined by either RFC 1123 as for hostname, or an - internationalized hostname as defined by - RFC 5890, section 2.3.2.3 [RFC5890]. -
    -
    -
    -

    - Note that all strings valid against the "hostname" attribute are also - valid against the "idn-hostname" attribute.

    -
    -
    -

    -7.3.4. IP Addresses -

    -

    - These attributes apply to string instances.

    -

    - A string instance is valid against these attributes if it is a valid - representation of an IP address as follows:

    -
    -
    ipv4:
    -
    - An IPv4 address according to the "dotted-quad" ABNF - syntax as defined in - RFC 2673, section 3.2 [RFC2673]. -
    -
    -
    ipv6:
    -
    - An IPv6 address as defined in - RFC 4291, section 2.2 [RFC4291]. -
    -
    -
    -
    -
    -

    -7.3.5. Resource Identifiers -

    -

    - These attributes apply to string instances.

    -
    -
    uri:
    -
    - A string instance is valid against this attribute if it is - a valid URI, according to [RFC3986]. -
    -
    -
    uri-reference:
    -
    - A string instance is valid against this attribute if it is a valid URI - Reference (either a URI or a relative-reference), - according to [RFC3986]. -
    -
    -
    iri:
    -
    - A string instance is valid against this attribute if it is - a valid IRI, according to [RFC3987]. -
    -
    -
    iri-reference:
    -
    - A string instance is valid against this attribute if it is a valid IRI - Reference (either an IRI or a relative-reference), - according to [RFC3987]. -
    -
    -
    uuid:
    -
    - A string instance is valid against this attribute if it is a valid - string representation of a UUID, according to [RFC4122]. -
    -
    -
    -

    - Note that all valid URIs are valid IRIs, and all valid URI References are - also valid IRI References.

    -

    - Note also that the "uuid" format is for plain UUIDs, not UUIDs in URNs. An example - is "f81d4fae-7dec-11d0-a765-00a0c91e6bf6". For UUIDs as URNs, use the "uri" format, - with a "pattern" regular expression of "^urn:uuid:" to indicate the URI scheme and - URN namespace.

    -
    -
    -

    -7.3.6. uri-template -

    -

    - This attribute applies to string instances.

    -

    - A string instance is valid against this attribute if it is a valid URI Template - (of any level), according to [RFC6570].

    -

    - Note that URI Templates may be used for IRIs; there is no separate - IRI Template specification.

    -
    -
    -

    -7.3.7. JSON Pointers -

    -

    - These attributes apply to string instances.

    -
    -
    json-pointer:
    -
    - A string instance is valid against this attribute if it - is a valid JSON string representation of a JSON Pointer, - according to RFC 6901, section 5 [RFC6901]. -
    -
    -
    relative-json-pointer:
    -
    - A string instance is valid against this attribute if it is a valid - Relative JSON Pointer [relative-json-pointer]. -
    -
    -
    -

    - To allow for both absolute and relative JSON Pointers, use "anyOf" or - "oneOf" to indicate support for either format.

    -
    -
    -

    -7.3.8. regex -

    -

    - This attribute applies to string instances.

    -

    - A regular expression, which SHOULD be valid according to the - ECMA-262 [ecma262] regular expression dialect.

    -

    - Implementations that validate formats MUST accept at least the subset of - ECMA-262 defined in the Regular Expressions (Section 4.3) - section of this specification, and SHOULD accept all valid ECMA-262 expressions.

    -
    -
    -
    -
    -
    -
    -

    -8. A Vocabulary for the Contents of String-Encoded Data -

    -
    -

    -8.1. Foreword -

    -

    - Annotations defined in this section indicate that an instance contains - non-JSON data encoded in a JSON string.

    -

    - These properties provide additional information required to interpret JSON data - as rich multimedia documents. They describe the type of content, how it is encoded, - and/or how it may be validated. They do not function as validation assertions; - a malformed string-encoded document MUST NOT cause the containing instance - to be considered invalid.

    -

    - Meta-schemas that do not use "$vocabulary" SHOULD be considered to - require this vocabulary as if its URI were present with a value of true.

    -

    - The current URI for this vocabulary, known as the Content vocabulary, is: - <https://json-schema.org/draft/2020-12/vocab/content>.

    -

    - The current URI for the corresponding meta-schema is: - https://json-schema.org/draft/2020-12/meta/content.

    -
    -
    -

    -8.2. Implementation Requirements -

    -

    - Due to security and performance concerns, as well as the open-ended nature of - possible content types, implementations MUST NOT automatically decode, parse, - and/or validate the string contents by default. This additionally supports - the use case of embedded documents intended for processing by a different - consumer than that which processed the containing document.

    -

    - All keywords in this section apply only to strings, and have no - effect on other data types.

    -

    - Implementations MAY offer the ability to decode, parse, and/or validate - the string contents automatically. However, it MUST NOT perform these - operations by default, and MUST provide the validation result of each - string-encoded document separately from the enclosing document. This - process SHOULD be equivalent to fully evaluating the instance against - the original schema, followed by using the annotations to decode, parse, - and/or validate each string-encoded document. - - For now, the exact mechanism of performing and returning parsed - data and/or validation results from such an automatic decoding, parsing, - and validating feature is left unspecified. Should such a feature - prove popular, it may be specified more thoroughly in a future draft. -

    -

    - See also the Security Considerations (Section 10) - sections for possible vulnerabilities introduced by automatically - processing the instance string according to these keywords.

    -
    -
    -

    -8.3. contentEncoding -

    -

    - If the instance value is a string, this property defines that the string - SHOULD be interpreted as encoded binary data and decoded using the encoding - named by this property.

    -

    - Possible values indicating base 16, 32, and 64 encodings with several - variations are listed in RFC 4648 [RFC4648]. Additionally, - sections 6.7 and 6.8 of RFC 2045 [RFC2045] provide - encodings used in MIME. This keyword is derived from MIME's - Content-Transfer-Encoding header, which was designed to map binary data - into ASCII characters. It is not related to HTTP's Content-Encoding header, - which is used to encode (e.g. compress or encrypt) - the content of HTTP request and responses.

    -

    - As "base64" is defined in both RFCs, the definition - from RFC 4648 SHOULD be assumed unless the string is specifically intended - for use in a MIME context. Note that all of these encodings result in - strings consisting only of 7-bit ASCII characters. Therefore, this keyword - has no meaning for strings containing characters outside of that range.

    -

    - If this keyword is absent, but "contentMediaType" is present, this - indicates that the encoding is the identity encoding, meaning that - no transformation was needed in order to represent the content in - a UTF-8 string.

    -

    - The value of this property MUST be a string.

    -
    -
    -

    -8.4. contentMediaType -

    -

    - If the instance is a string, this property indicates the media type - of the contents of the string. If "contentEncoding" is present, - this property describes the decoded string.

    -

    - The value of this property MUST be a string, which MUST be a media type, - as defined by RFC 2046 [RFC2046].

    -
    -
    -

    -8.5. contentSchema -

    -

    - If the instance is a string, and if "contentMediaType" is present, this - property contains a schema which describes the structure of the string.

    -

    - This keyword MAY be used with any media type that can be mapped into - JSON Schema's data model.

    -

    - The value of this property MUST be a valid JSON schema. It SHOULD be ignored if - "contentMediaType" is not present.

    -
    -
    -

    -8.6. Example -

    -

    - Here is an example schema, illustrating the use of "contentEncoding" and - "contentMediaType":

    -
    -
    -
    -{
    -    "type": "string",
    -    "contentEncoding": "base64",
    -    "contentMediaType": "image/png"
    -}
    -
    -
    -
    -

    - Instances described by this schema are expected to be strings, - and their values should be interpretable as base64-encoded PNG images.

    -

    - Another example:

    -
    -
    -
    -{
    -    "type": "string",
    -    "contentMediaType": "text/html"
    -}
    -
    -
    -
    -

    - Instances described by this schema are expected to be strings containing HTML, - using whatever character set the JSON string was decoded into. - Per section 8.1 of - RFC 8259 [RFC8259], outside of an entirely closed - system, this MUST be UTF-8.

    -

    - This example describes a JWT that is MACed using the HMAC SHA-256 - algorithm, and requires the "iss" and "exp" fields in its claim set.

    -
    -
    -
    -{
    -    "type": "string",
    -    "contentMediaType": "application/jwt",
    -    "contentSchema": {
    -        "type": "array",
    -        "minItems": 2,
    -        "prefixItems": [
    -            {
    -                "const": {
    -                    "typ": "JWT",
    -                    "alg": "HS256"
    -                }
    -            },
    -            {
    -                "type": "object",
    -                "required": ["iss", "exp"],
    -                "properties": {
    -                    "iss": {"type": "string"},
    -                    "exp": {"type": "integer"}
    -                }
    -            }
    -        ]
    -    }
    -}
    -
    -
    -

    - Note that "contentEncoding" does not appear. While the "application/jwt" - media type makes use of base64url encoding, that is defined by the media - type, which determines how the JWT string is decoded into a list of two - JSON data structures: first the header, and then the payload. Since the - JWT media type ensures that the JWT can be represented in a JSON string, - there is no need for further encoding or decoding.

    -
    -
    -
    -
    -

    -9. A Vocabulary for Basic Meta-Data Annotations -

    -

    - These general-purpose annotation keywords provide commonly used information - for documentation and user interface display purposes. They are not intended - to form a comprehensive set of features. Rather, additional vocabularies - can be defined for more complex annotation-based applications.

    -

    - Meta-schemas that do not use "$vocabulary" SHOULD be considered to - require this vocabulary as if its URI were present with a value of true.

    -

    - The current URI for this vocabulary, known as the Meta-Data vocabulary, is: - <https://json-schema.org/draft/2020-12/vocab/meta-data>.

    -

    - The current URI for the corresponding meta-schema is: - https://json-schema.org/draft/2020-12/meta/meta-data.

    -
    -

    -9.1. "title" and "description" -

    -

    - The value of both of these keywords MUST be a string.

    -

    - Both of these keywords can be used to decorate a user interface with - information about the data produced by this user interface. A title will - preferably be short, whereas a description will provide explanation about - the purpose of the instance described by this schema.

    -
    -
    -

    -9.2. "default" -

    -

    - There are no restrictions placed on the value of this keyword. When - multiple occurrences of this keyword are applicable to a single - sub-instance, implementations SHOULD remove duplicates.

    -

    - This keyword can be used to supply a default JSON value associated with a - particular schema. It is RECOMMENDED that a default value be valid against - the associated schema.

    -
    -
    -

    -9.3. "deprecated" -

    -

    - The value of this keyword MUST be a boolean. When multiple occurrences - of this keyword are applicable to a single sub-instance, applications - SHOULD consider the instance location to be deprecated if any occurrence - specifies a true value.

    -

    - If "deprecated" has a value of boolean true, it indicates that applications - SHOULD refrain from usage of the declared property. It MAY mean the property - is going to be removed in the future.

    -

    - A root schema containing "deprecated" with a value of true indicates that - the entire resource being described MAY be removed in the future.

    -

    - The "deprecated" keyword applies to each instance location to which the - schema object containing the keyword successfully applies. This can - result in scenarios where every array item or object property - is deprecated even though the containing array or object is not.

    -

    - Omitting this keyword has the same behavior as a value of false.

    -
    -
    -

    -9.4. "readOnly" and "writeOnly" -

    -

    - The value of these keywords MUST be a boolean. When multiple occurrences - of these keywords are applicable to a single sub-instance, the resulting - behavior SHOULD be as for a true value if any occurrence specifies a true value, - and SHOULD be as for a false value otherwise.

    -

    - If "readOnly" has a value of boolean true, it indicates that the value - of the instance is managed exclusively by the owning authority, and - attempts by an application to modify the value of this property are - expected to be ignored or rejected by that owning authority.

    -

    - An instance document that is marked as "readOnly" for the entire document - MAY be ignored if sent to the owning authority, or MAY result in an - error, at the authority's discretion.

    -

    - If "writeOnly" has a value of boolean true, it indicates that the value - is never present when the instance is retrieved from the owning authority. - It can be present when sent to the owning authority to update or create - the document (or the resource it represents), but it will not be included - in any updated or newly created version of the instance.

    -

    - An instance document that is marked as "writeOnly" for the entire document - MAY be returned as a blank document of some sort, or MAY produce an error - upon retrieval, or have the retrieval request ignored, at the authority's - discretion.

    -

    - For example, "readOnly" would be used to mark a database-generated serial - number as read-only, while "writeOnly" would be used to mark a password - input field.

    -

    - These keywords can be used to assist in user interface instance generation. - In particular, an application MAY choose to use a widget that hides - input values as they are typed for write-only fields.

    -

    - Omitting these keywords has the same behavior as values of false.

    -
    -
    -

    -9.5. "examples" -

    -

    - The value of this keyword MUST be an array. - There are no restrictions placed on the values within the array. - When multiple occurrences of this keyword are applicable to a single - sub-instance, implementations MUST provide a flat array of all - values rather than an array of arrays.

    -

    - This keyword can be used to provide sample JSON values associated with a - particular schema, for the purpose of illustrating usage. It is - RECOMMENDED that these values be valid against the associated schema.

    -

    - Implementations MAY use the value(s) of "default", if present, as - an additional example. If "examples" is absent, "default" - MAY still be used in this manner.

    -
    -
    -
    -
    -

    -10. Security Considerations -

    -

    - JSON Schema validation defines a vocabulary for JSON Schema core and concerns all - the security considerations listed there.

    -

    - JSON Schema validation allows the use of Regular Expressions, which have numerous - different (often incompatible) implementations. - Some implementations allow the embedding of arbitrary code, which is outside the - scope of JSON Schema and MUST NOT be permitted. - Regular expressions can often also be crafted to be extremely expensive to compute - (with so-called "catastrophic backtracking"), resulting in a denial-of-service - attack.

    -

    - Implementations that support validating or otherwise evaluating instance - string data based on "contentEncoding" and/or "contentMediaType" are at - risk of evaluating data in an unsafe way based on misleading information. - Applications can mitigate this risk by only performing such processing - when a relationship between the schema and instance is established - (e.g., they share the same authority).

    -

    - Processing a media type or encoding is subject to the security considerations - of that media type or encoding. For example, the security considerations - of RFC 4329 Scripting Media Types [RFC4329] apply when - processing JavaScript or ECMAScript encoded within a JSON string.

    -
    -
    -
    -

    -11. References -

    -
    -

    -11.1. Normative References -

    -
    -
    [RFC2119]
    -
    -Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://www.rfc-editor.org/info/rfc2119>.
    -
    -
    [RFC1123]
    -
    -Braden, R., Ed., "Requirements for Internet Hosts - Application and Support", STD 3, RFC 1123, DOI 10.17487/RFC1123, , <https://www.rfc-editor.org/info/rfc1123>.
    -
    -
    [RFC2045]
    -
    -Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", RFC 2045, DOI 10.17487/RFC2045, , <https://www.rfc-editor.org/info/rfc2045>.
    -
    -
    [RFC2046]
    -
    -Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types", RFC 2046, DOI 10.17487/RFC2046, , <https://www.rfc-editor.org/info/rfc2046>.
    -
    -
    [RFC2673]
    -
    -Crawford, M., "Binary Labels in the Domain Name System", RFC 2673, DOI 10.17487/RFC2673, , <https://www.rfc-editor.org/info/rfc2673>.
    -
    -
    [RFC3339]
    -
    -Klyne, G. and C. Newman, "Date and Time on the Internet: Timestamps", RFC 3339, DOI 10.17487/RFC3339, , <https://www.rfc-editor.org/info/rfc3339>.
    -
    -
    [RFC3986]
    -
    -Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, , <https://www.rfc-editor.org/info/rfc3986>.
    -
    -
    [RFC3987]
    -
    -Duerst, M. and M. Suignard, "Internationalized Resource Identifiers (IRIs)", RFC 3987, DOI 10.17487/RFC3987, , <https://www.rfc-editor.org/info/rfc3987>.
    -
    -
    [RFC4122]
    -
    -Leach, P., Mealling, M., and R. Salz, "A Universally Unique IDentifier (UUID) URN Namespace", RFC 4122, DOI 10.17487/RFC4122, , <https://www.rfc-editor.org/info/rfc4122>.
    -
    -
    [RFC4291]
    -
    -Hinden, R. and S. Deering, "IP Version 6 Addressing Architecture", RFC 4291, DOI 10.17487/RFC4291, , <https://www.rfc-editor.org/info/rfc4291>.
    -
    -
    [RFC4648]
    -
    -Josefsson, S., "The Base16, Base32, and Base64 Data Encodings", RFC 4648, DOI 10.17487/RFC4648, , <https://www.rfc-editor.org/info/rfc4648>.
    -
    -
    [RFC5321]
    -
    -Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, DOI 10.17487/RFC5321, , <https://www.rfc-editor.org/info/rfc5321>.
    -
    -
    [RFC5890]
    -
    -Klensin, J., "Internationalized Domain Names for Applications (IDNA): Definitions and Document Framework", RFC 5890, DOI 10.17487/RFC5890, , <https://www.rfc-editor.org/info/rfc5890>.
    -
    -
    [RFC5891]
    -
    -Klensin, J., "Internationalized Domain Names in Applications (IDNA): Protocol", RFC 5891, DOI 10.17487/RFC5891, , <https://www.rfc-editor.org/info/rfc5891>.
    -
    -
    [RFC6570]
    -
    -Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, "URI Template", RFC 6570, DOI 10.17487/RFC6570, , <https://www.rfc-editor.org/info/rfc6570>.
    -
    -
    [RFC6531]
    -
    -Yao, J. and W. Mao, "SMTP Extension for Internationalized Email", RFC 6531, DOI 10.17487/RFC6531, , <https://www.rfc-editor.org/info/rfc6531>.
    -
    -
    [RFC6901]
    -
    -Bryan, P., Ed., Zyp, K., and M. Nottingham, Ed., "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, , <https://www.rfc-editor.org/info/rfc6901>.
    -
    -
    [RFC8259]
    -
    -Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, , <https://www.rfc-editor.org/info/rfc8259>.
    -
    -
    [ecma262]
    -
    -"ECMA-262, 11th edition specification", , <https://www.ecma-international.org/ecma-262/11.0>.
    -
    -
    [relative-json-pointer]
    -
    -Luff, G., Andrews, H., and B. Hutton, Ed., "Relative JSON Pointers", Work in Progress, Internet-Draft, draft-handrews-relative-json-pointer-01, , <https://datatracker.ietf.org/doc/html/draft-handrews-relative-json-pointer-01>.
    -
    -
    [json-schema]
    -
    -Wright, A., Andrews, H., Hutton, B., and G. Dennis, "JSON Schema: A Media Type for Describing JSON Documents", Work in Progress, Internet-Draft, draft-bhutton-json-schema-01, , <https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-01>.
    -
    -
    -
    -
    -

    -11.2. Informative References -

    -
    -
    [RFC4329]
    -
    -Hoehrmann, B., "Scripting Media Types", RFC 4329, DOI 10.17487/RFC4329, , <https://www.rfc-editor.org/info/rfc4329>.
    -
    -
    -
    -
    -
    -

    -Appendix A. Keywords Moved from Validation to Core -

    -

    - Several keywords have been moved from this document into the - Core Specification [json-schema] as of this draft, in some - cases with re-naming or other changes. This affects the following former - validation keywords:

    -
    -
    "definitions"
    -
    - Renamed to "$defs" to match "$ref" and be shorter to type. - Schema vocabulary authors SHOULD NOT define a "definitions" keyword - with different behavior in order to avoid invalidating schemas that - still use the older name. While "definitions" is absent in the - single-vocabulary meta-schemas referenced by this document, it - remains present in the default meta-schema, and implementations - SHOULD assume that "$defs" and "definitions" have the same - behavior when that meta-schema is used. -
    -
    -
    "allOf", "anyOf", "oneOf", "not", "if", "then", "else", "items", "additionalItems", "contains", "propertyNames", "properties", "patternProperties", "additionalProperties"
    -
    - All of these keywords apply subschemas to the instance and combine - their results, without asserting any conditions of their own. - Without assertion keywords, these applicators can only cause assertion - failures by using the false boolean schema, or by inverting the result - of the true boolean schema (or equivalent schema objects). - For this reason, they are better defined as a generic mechanism on which - validation, hyper-schema, and extension vocabularies can all be based. -
    -
    -
    "dependencies"
    -
    - This keyword had two different modes of behavior, which made it - relatively challenging to implement and reason about. - The schema form has been moved to Core and renamed to - "dependentSchemas", as part of the applicator vocabulary. - It is analogous to "properties", except that instead of applying - its subschema to the property value, it applies it to the object - containing the property. - The property name array form is retained here and renamed to - "dependentRequired", as it is an assertion which is a shortcut - for the conditional use of the "required" assertion keyword. -
    -
    -
    -
    -
    -

    -Appendix B. Acknowledgments -

    -

    - Thanks to - Gary Court, - Francis Galiegue, - Kris Zyp, - and Geraint Luff - for their work on the initial drafts of JSON Schema.

    -

    - Thanks to - Jason Desrosiers, - Daniel Perrett, - Erik Wilde, - Evgeny Poberezkin, - Brad Bowman, - Gowry Sankar, - Donald Pipowitch, - Dave Finlay, - Denis Laxalde, - Phil Sturgeon, - Shawn Silverman, - and Karen Etheridge - for their submissions and patches to the document.

    -
    -
    -

    -Appendix C. ChangeLog -

    -

    - This section to be removed before leaving Internet-Draft status.

    -
    -
    draft-bhutton-json-schema-validation-00
    -
    -
      -
    • Correct email format RFC reference to 5321 instead of 5322 -
    • -
    • Clarified the set and meaning of "contentEncoding" values -
    • -
    • Reference ECMA-262, 11th edition for regular expression support -
    • -
    • Split "format" into an annotation only vocabulary and an assertion vocabulary -
    • -
    • Clarify "deprecated" when applicable to arrays -
    • -
    -
    -
    -
    draft-handrews-json-schema-validation-02
    -
    -
      -
    • Grouped keywords into formal vocabularies -
    • -
    • Update "format" implementation requirements in terms of vocabularies -
    • -
    • By default, "format" MUST NOT be validated, although validation can be enabled -
    • -
    • A vocabulary declaration can be used to require "format" validation -
    • -
    • Moved "definitions" to the core spec as "$defs" -
    • -
    • Moved applicator keywords to the core spec -
    • -
    • Renamed the array form of "dependencies" to "dependentRequired", moved the schema form to the core spec -
    • -
    • Specified all "content*" keywords as annotations, not assertions -
    • -
    • Added "contentSchema" to allow applying a schema to a string-encoded document -
    • -
    • Also allow RFC 4648 encodings in "contentEncoding" -
    • -
    • Added "minContains" and "maxContains" -
    • -
    • Update RFC reference for "hostname" and "idn-hostname" -
    • -
    • Add "uuid" and "duration" formats -
    • -
    -
    -
    -
    draft-handrews-json-schema-validation-01
    -
    -
      -
    • This draft is purely a clarification with no functional changes -
    • -
    • Provided the general principle behind ignoring annotations under "not" and similar cases -
    • -
    • Clarified "if"/"then"/"else" validation interactions -
    • -
    • Clarified "if"/"then"/"else" behavior for annotation -
    • -
    • Minor formatting and cross-referencing improvements -
    • -
    -
    -
    -
    draft-handrews-json-schema-validation-00
    -
    -
      -
    • Added "if"/"then"/"else" -
    • -
    • Classify keywords as assertions or annotations per the core spec -
    • -
    • Warn of possibly removing "dependencies" in the future -
    • -
    • Grouped validation keywords into sub-sections for readability -
    • -
    • Moved "readOnly" from hyper-schema to validation meta-data -
    • -
    • Added "writeOnly" -
    • -
    • Added string-encoded media section, with former hyper-schema "media" keywords -
    • -
    • Restored "regex" format (removal was unintentional) -
    • -
    • Added "date" and "time" formats, and reserved additional RFC 3339 format names -
    • -
    • I18N formats: "iri", "iri-reference", "idn-hostname", "idn-email" -
    • -
    • Clarify that "json-pointer" format means string encoding, not URI fragment -
    • -
    • Fixed typo that inverted the meaning of "minimum" and "exclusiveMinimum" -
    • -
    • Move format syntax references into Normative References -
    • -
    • JSON is a normative requirement -
    • -
    -
    -
    -
    draft-wright-json-schema-validation-01
    -
    -
      -
    • Standardized on hyphenated format names with full words ("uriref" becomes "uri-reference") -
    • -
    • Add the formats "uri-template" and "json-pointer" -
    • -
    • Changed "exclusiveMaximum"/"exclusiveMinimum" from boolean modifiers of "maximum"/"minimum" to independent numeric fields. -
    • -
    • Split the additionalItems/items into two sections -
    • -
    • Reworked properties/patternProperties/additionalProperties definition -
    • -
    • Added "examples" keyword -
    • -
    • Added "contains" keyword -
    • -
    • Allow empty "required" and "dependencies" arrays -
    • -
    • Fixed "type" reference to primitive types -
    • -
    • Added "const" keyword -
    • -
    • Added "propertyNames" keyword -
    • -
    -
    -
    -
    draft-wright-json-schema-validation-00
    -
    -
      -
    • Added additional security considerations -
    • -
    • Removed reference to "latest version" meta-schema, use numbered version instead -
    • -
    • Rephrased many keyword definitions for brevity -
    • -
    • Added "uriref" format that also allows relative URI references -
    • -
    -
    -
    -
    draft-fge-json-schema-validation-00
    -
    -
      -
    • Initial draft. -
    • -
    • Salvaged from draft v3. -
    • -
    • Redefine the "required" keyword. -
    • -
    • Remove "extends", "disallow" -
    • -
    • Add "anyOf", "allOf", "oneOf", "not", "definitions", "minProperties", - "maxProperties". -
    • -
    • "dependencies" member values can no longer be single strings; at - least one element is required in a property dependency array. -
    • -
    • Rename "divisibleBy" to "multipleOf". -
    • -
    • "type" arrays can no longer have schemas; remove "any" as a possible - value. -
    • -
    • Rework the "format" section; make support optional. -
    • -
    • "format": remove attributes "phone", "style", "color"; rename - "ip-address" to "ipv4"; add references for all attributes. -
    • -
    • Provide algorithms to calculate schema(s) for array/object - instances. -
    • -
    • Add interoperability considerations. -
    • -
    -
    -
    -
    -
    -
    -
    -

    -Authors' Addresses -

    -
    -
    Austin Wright (editor)
    - -
    -
    -
    Henry Andrews (editor)
    - -
    -
    -
    Ben Hutton (editor)
    - - -
    -
    -
    - - - diff --git a/work-in-progress/index.md b/work-in-progress/index.md index 81f5f427..ba28d738 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -7,44 +7,6 @@ permalink: /work-in-progress * TOC {:toc} -## Right now - -We're working towards JSON Schema 2022-NN. - -Additionally, we're working on draft 2020-12-patch-1 ([Associated GitHub milestone](https://github.com/json-schema-org/json-schema-spec/milestone/9)) - -## Release latest news - -On 2022-04-29, we published Release Candiate 0 for this release. - -These documents will be given the IETF identifiers `draft-bhutton-*-01`. - -## RC-0 preview - -You can find RC-0 preview of the following documents: -- [JSON Schema Core specification](/draft/preview/2020-12-p1-rc-0/jsonschema-core.html) -- [JSON Schema Validation specification](/draft/preview/2020-12-p1-rc-0/jsonschema-validation.html) - -There are no changes to the Relative JSON Pointer specification. - -View the git diff on GitHub for: -- [draft 2020-12 release to 2020-12-patch-01-rc0](https://github.com/json-schema-org/json-schema-spec/compare/2020-12...draft-bhutton--01-rc0) (git tag `draft-bhutton--01-rc0) -- [draft 2020-12 release to master](https://github.com/json-schema-org/json-schema-spec/compare/2020-12...master) (This may include changes based on Release Candidate feedback) - -This "work in progress" page will be updated as the release progress for 2020-12-patch-1 progresses. - -## How to provide feedback for RC-0 -Note, feedback for RC-0 closes on 2022-05-14. - -Please make use of the two week feedback window for RC-0 by either: -- Filing issues on the [specification repository](https://github.com/json-schema-org/json-schema-spec/issues), making it clear the issue relates to 2020-12-patch-1-RC-0 -- Discuss in the [#specification channel on our Slack server](https://json-schema.slack.com/archives/CT7FF623C) - You will need to join if you haven't already - -**Please note, only feedback relating specifically to the changes found in the above diff are useful. This release is not making functional changes.** - -The previous `draft 2020-12` specification documents will become obsolete, as did draft-07 specification documents when they were patched. - -If you have suggestions for changes to the specification in general, we invite you to open a [Discussion on our GitHub organization](https://github.com/orgs/json-schema-org/discussions) and/or chat with us in the #general or #specificaiton channels on our [Slack server](/slack). - +We're working towards draft 2022-NN. See the [GitHub repository](https://github.com/json-schema-org/json-schema-spec) for ongoing spec work. From 656fe08a2a15b342198974a82c6c8dea02f14b4a Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Tue, 14 Jun 2022 10:44:53 +0100 Subject: [PATCH 200/311] Update specification page links to IETF specification documents for 2020-12 to patched version (bhutton-*-01) where applicable --- specification.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification.md b/specification.md index ab8e91c2..e70419a9 100644 --- a/specification.md +++ b/specification.md @@ -23,8 +23,8 @@ Validation in any significant way. | [Relative JSON Pointers](draft/2020-12/relative-json-pointer.html) | extends the JSON Pointer syntax for relative pointers | They are also available on the IETF main site: -* [draft-bhutton-json-schema-00 (core)](https://tools.ietf.org/html/draft-bhutton-json-schema-00) -* [draft-bhutton-json-schema-validation-00](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-00) +* [draft-bhutton-json-schema-01 (core)](https://tools.ietf.org/html/draft-bhutton-json-schema-01) +* [draft-bhutton-json-schema-validation-01](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-01) * [draft-bhutton-relative-json-pointer-00](https://tools.ietf.org/html/draft-bhutton-relative-json-pointer-00) Meta-schemas From d7ff4258a3b18585f783ed83d63400d5b677db4b Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 16 Jun 2022 18:01:13 +0100 Subject: [PATCH 201/311] Update specification links page with links to new 2020-12 patch documents --- specification-links.md | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/specification-links.md b/specification-links.md index 2bf9b018..155bfcca 100644 --- a/specification-links.md +++ b/specification-links.md @@ -249,13 +249,13 @@ For links to the somewhat more readably formatted versions on this web site, and draft‑bhutton‑relative‑json‑pointer‑00

    - + 2020‑12 - + Draft 2020-12 - + Milestone: draft-08-patch-1 @@ -264,6 +264,18 @@ For links to the somewhat more readably formatted versions on this web site, and + + + + + draft‑bhutton‑json‑schema‑01 +
    + + draft‑bhutton‑json‑schema‑validation‑01 +
    +
    + + (TBD) @@ -272,11 +284,11 @@ For links to the somewhat more readably formatted versions on this web site, and (TBD) - Draft 2021-NN + 2022-NN Milestone: - Draft 2021-NN + 2022-NN @@ -288,8 +300,8 @@ For links to the somewhat more readably formatted versions on this web site, and ### 2020-12 - Specifications - - Core: [draft-bhutton-json-schema-00](https://tools.ietf.org/html/draft-bhutton-json-schema-00) ([changes](https://tools.ietf.org/html/draft-bhutton-json-schema-00#appendix-G)) - - Validation: [draft-bhutton-json-schema-validation-00](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-00) ([changes](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-00#appendix-C)) + - Core: [draft-bhutton-json-schema-01](https://tools.ietf.org/html/draft-bhutton-json-schema-01) ([changes](https://tools.ietf.org/html/draft-bhutton-json-schema-01#appendix-G)) + - Validation: [draft-bhutton-json-schema-validation-01](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-01) ([changes](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-01#appendix-C)) - Relative JSON Pointer: [draft-bhutton-relative-json-pointer-00](https://tools.ietf.org/html/draft-bhutton-relative-json-pointer-00) ([changes](https://tools.ietf.org/html/draft-bhutton-relative-json-pointer-00#appendix-A)) - General use meta-schemas - [JSON Schema meta-schema](draft/2020-12/schema) @@ -309,6 +321,13 @@ For links to the somewhat more readably formatted versions on this web site, and - Output examples - [JSON Schema verbose output example](draft/2020-12/output/verbose-example) +#### Obsolete Draft 2020-12 Documents + +_These were updated without changing functionality or meta-schemas due to a few errors and unclear sections._ + +- Core: [draft-bhutton-json-schema-00](https://tools.ietf.org/html/draft-bhutton-json-schema-00) ([changes](https://tools.ietf.org/html/draft-bhutton-json-schema-00#appendix-G)) +- Validation: [draft-bhutton-json-schema-validation-00](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-00) ([changes](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-00#appendix-C)) + ### Draft 2019-09 (formerly known as Draft 8) _**NOTE:** All meta-schema URIs now use `https://`. While currently also available over plain HTTP due to the limitations of GitHub pages and the need to keep prior drafts available over HTTP, only the HTTPS URIs should be used._ From 9756e574eaaac246ac514456f931847d3248d920 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 16 Jun 2022 18:12:08 +0100 Subject: [PATCH 202/311] Update spec files and submodules for 2020-12 patch --- .gitmodules | 3 + _includes/draft/2020-12 | 2 +- draft/2020-12/json-schema-core.html | 5822 +++++++++++++++++++++ draft/2020-12/json-schema-validation.html | 3185 +++++++++++ 4 files changed, 9011 insertions(+), 1 deletion(-) create mode 100644 draft/2020-12/json-schema-core.html create mode 100644 draft/2020-12/json-schema-validation.html diff --git a/.gitmodules b/.gitmodules index ec9c71cd..5b323ddb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,15 +10,18 @@ [submodule "_includes/draft-03"] path = _includes/draft-03 url = https://github.com/json-schema-org/json-schema-spec.git + branch = draft-03 [submodule "_includes/draft-04"] path = _includes/draft-04 url = https://github.com/json-schema-org/json-schema-spec.git + branch = draft-04 [submodule "_includes/draft-05"] path = _includes/draft-05 url = https://github.com/json-schema-org/json-schema-spec.git [submodule "_includes/draft-06"] path = _includes/draft-06 url = https://github.com/json-schema-org/json-schema-spec.git + branch = draft-06 [submodule "_includes/draft-07"] path = _includes/draft-07 url = https://github.com/json-schema-org/json-schema-spec.git diff --git a/_includes/draft/2020-12 b/_includes/draft/2020-12 index 117c05e5..769daad7 160000 --- a/_includes/draft/2020-12 +++ b/_includes/draft/2020-12 @@ -1 +1 @@ -Subproject commit 117c05e55ae0a798a10907f61348c81318971f9d +Subproject commit 769daad75a9553562333a8937a187741cb708c72 diff --git a/draft/2020-12/json-schema-core.html b/draft/2020-12/json-schema-core.html new file mode 100644 index 00000000..e8bd04bf --- /dev/null +++ b/draft/2020-12/json-schema-core.html @@ -0,0 +1,5822 @@ + + + + + + +JSON Schema: A Media Type for Describing JSON Documents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Internet-DraftJSON SchemaJune 2022
    Wright, et al.Expires 18 December 2022[Page]
    +
    +
    +
    +
    Workgroup:
    +
    Internet Engineering Task Force
    +
    Internet-Draft:
    +
    draft-bhutton-json-schema-01
    +
    Published:
    +
    + +
    +
    Intended Status:
    +
    Informational
    +
    Expires:
    +
    +
    Authors:
    +
    +
    +
    A. Wright, Ed. +
    +
    +
    +
    H. Andrews, Ed. +
    +
    +
    +
    B. Hutton, Ed. +
    +
    Postman
    +
    +
    +
    G. Dennis
    +
    +
    +
    +
    +

    JSON Schema: A Media Type for Describing JSON Documents

    +
    +

    Abstract

    +

    + JSON Schema defines the media type "application/schema+json", a JSON-based format + for describing the structure of JSON data. + JSON Schema asserts what a JSON document must look like, + ways to extract information from it, + and how to interact with it. + The "application/schema-instance+json" media type provides additional + feature-rich integration with "application/schema+json" beyond what can be offered + for "application/json" documents.

    +
    +
    +

    +Note to Readers +

    +

    + The issues list for this draft can be found at + https://github.com/json-schema-org/json-schema-spec/issues.

    +

    + For additional information, see https://json-schema.org/.

    +

    + To provide feedback, use this issue tracker, the communication methods listed on the + homepage, or email the document editors.

    +
    +
    +
    +

    +Status of This Memo +

    +

    + This Internet-Draft is submitted in full conformance with the + provisions of BCP 78 and BCP 79.

    +

    + Internet-Drafts are working documents of the Internet Engineering Task + Force (IETF). Note that other groups may also distribute working + documents as Internet-Drafts. The list of current Internet-Drafts is + at https://datatracker.ietf.org/drafts/current/.

    +

    + Internet-Drafts are draft documents valid for a maximum of six months + and may be updated, replaced, or obsoleted by other documents at any + time. It is inappropriate to use Internet-Drafts as reference + material or to cite them other than as "work in progress."

    +

    + This Internet-Draft will expire on 18 December 2022.

    +
    +
    + +
    +
    +

    +Table of Contents +

    + +
    +
    +
    +

    +1. Introduction +

    +

    + JSON Schema is a JSON media type for defining the structure of JSON data. JSON Schema + is intended to define validation, documentation, hyperlink navigation, and interaction + control of JSON data.

    +

    + This specification defines JSON Schema core terminology and mechanisms, including + pointing to another JSON Schema by reference, + dereferencing a JSON Schema reference, + specifying the dialect being used, + specifying a dialect's vocabulary requirements, + and defining the expected output.

    +

    + Other specifications define the vocabularies that perform assertions about validation, + linking, annotation, navigation, and interaction.

    +
    +
    +

    +2. Conventions and Terminology +

    +

    + + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", + "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be + interpreted as described in RFC 2119 [RFC2119].

    +

    + The terms "JSON", "JSON text", "JSON value", "member", "element", "object", "array", + "number", "string", "boolean", "true", "false", and "null" in this document are to + be interpreted as defined in RFC 8259 [RFC8259].

    +
    +
    +

    +3. Overview +

    +

    + This document proposes a new media type "application/schema+json" to identify a JSON + Schema for describing JSON data. + It also proposes a further optional media type, "application/schema-instance+json", + to provide additional integration features. + JSON Schemas are themselves JSON documents. + This, and related specifications, define keywords allowing authors to describe JSON + data in several ways.

    +

    + JSON Schema uses keywords to assert constraints on JSON instances or annotate those + instances with additional information. Additional keywords are used to apply + assertions and annotations to more complex JSON data structures, or based on + some sort of condition.

    +

    + To facilitate re-use, keywords can be organized into vocabularies. A vocabulary + consists of a list of keywords, together with their syntax and semantics. + A dialect is defined as a set of vocabularies and their required support + identified in a meta-schema.

    +

    + JSON Schema can be extended either by defining additional vocabularies, + or less formally by defining additional keywords outside of any vocabulary. + Unrecognized individual keywords simply have their values collected as annotations, + while the behavior with respect to an unrecognized vocabulary can be controlled + when declaring which vocabularies are in use.

    +

    + This document defines a core vocabulary that MUST be supported by any + implementation, and cannot be disabled. Its keywords are each prefixed + with a "$" character to emphasize their required nature. This vocabulary + is essential to the functioning of the "application/schema+json" media + type, and is used to bootstrap the loading of other vocabularies.

    +

    + Additionally, this document defines a RECOMMENDED vocabulary of keywords + for applying subschemas conditionally, and for applying subschemas to + the contents of objects and arrays. Either this vocabulary or one very + much like it is required to write schemas for non-trivial JSON instances, + whether those schemas are intended for assertion validation, annotation, + or both. While not part of the required core vocabulary, for maximum + interoperability this additional vocabulary is included in this document + and its use is strongly encouraged.

    +

    + Further vocabularies for purposes such as structural validation or + hypermedia annotation are defined in other documents. These other + documents each define a dialect collecting the standard sets of + vocabularies needed to write schemas for that document's purpose.

    +
    +
    +

    +4. Definitions +

    +
    +

    +4.1. JSON Document +

    +

    + A JSON document is an information resource (series of octets) described by the + application/json media type.

    +

    + In JSON Schema, the terms "JSON document", "JSON text", and "JSON value" are + interchangeable because of the data model it defines.

    +

    + JSON Schema is only defined over JSON documents. However, any document or memory + structure that can be parsed into or processed according to the JSON Schema data + model can be interpreted against a JSON Schema, including media types like + CBOR [RFC7049].

    +
    +
    +

    +4.2. Instance +

    +

    + A JSON document to which a schema is applied is known as an "instance".

    +

    + JSON Schema is defined over "application/json" or compatible documents, + including media types with the "+json" structured syntax suffix.

    +

    + Among these, this specification defines the "application/schema-instance+json" + media type which defines handling for fragments in the URI.

    +
    +

    +4.2.1. Instance Data Model +

    +

    + JSON Schema interprets documents according to a data model. A JSON value + interpreted according to this data model is called an "instance".

    +

    + An instance has one of six primitive types, and a range of possible values + depending on the type:

    +
    +
    null:
    +
    A JSON "null" value +
    +
    +
    boolean:
    +
    A "true" or "false" value, from the JSON "true" or "false" value +
    +
    +
    object:
    +
    An unordered set of properties mapping a string to an instance, from the JSON "object" value +
    +
    +
    array:
    +
    An ordered list of instances, from the JSON "array" value +
    +
    +
    number:
    +
    An arbitrary-precision, base-10 decimal number value, from the JSON "number" value +
    +
    +
    string:
    +
    A string of Unicode code points, from the JSON "string" value +
    +
    +
    +

    + Whitespace and formatting concerns, including different lexical + representations of numbers that are equal within the data model, are thus + outside the scope of JSON Schema. JSON Schema + vocabularies (Section 8.1) that wish + to work with such differences in lexical representations SHOULD define + keywords to precisely interpret formatted strings within the data model + rather than relying on having the original JSON representation Unicode + characters available.

    +

    + Since an object cannot have two properties with the same key, behavior for a + JSON document that tries to define two properties with + the same key in a single object is undefined.

    +

    + Note that JSON Schema vocabularies are free to define their own extended + type system. This should not be confused with the core data model types + defined here. As an example, "integer" is a reasonable type for a + vocabulary to define as a value for a keyword, but the data model + makes no distinction between integers and other numbers.

    +
    +
    +

    +4.2.2. Instance Equality +

    +

    + Two JSON instances are said to be equal if and only if they are of the same type + and have the same value according to the data model. Specifically, this means:

    +
      +
    • both are null; or +
    • +
    • both are true; or +
    • +
    • both are false; or +
    • +
    • both are strings, and are the same codepoint-for-codepoint; or +
    • +
    • both are numbers, and have the same mathematical value; or +
    • +
    • both are arrays, and have an equal value item-for-item; or +
    • +
    • both are objects, and each property in one has exactly one property with + a key equal to the other's, and that other property has an equal + value. +
    • +
    +

    + Implied in this definition is that arrays must be the same length, + objects must have the same number of members, + properties in objects are unordered, + there is no way to define multiple properties with the same key, + and mere formatting differences (indentation, placement of commas, trailing + zeros) are insignificant.

    +
    +
    +

    +4.2.3. Non-JSON Instances +

    +

    + It is possible to use JSON Schema with a superset of the JSON Schema data model, + where an instance may be outside any of the six JSON data types.

    +

    + In this case, annotations still apply; but most validation keywords will not be useful, + as they will always pass or always fail.

    +

    + A custom vocabulary may define support for a superset of the core data model. + The schema itself may only be expressible in this superset; + for example, to make use of the "const" keyword.

    +
    +
    +
    +
    +

    +4.3. JSON Schema Documents +

    +

    + A JSON Schema document, or simply a schema, is a JSON document used to describe + an instance. + A schema can itself be interpreted as an instance, but SHOULD always be given + the media type "application/schema+json" rather than + "application/schema-instance+json". The "application/schema+json" media + type is defined to offer a superset of the + fragment identifier syntax and semantics provided by + "application/schema-instance+json".

    +

    + A JSON Schema MUST be an object or a boolean.

    +
    +

    +4.3.1. JSON Schema Objects and Keywords +

    +

    + Object properties that are applied to the instance are called keywords, + or schema keywords. Broadly speaking, keywords fall into one + of five categories:

    +
    +
    identifiers:
    +
    + control schema identification through setting a URI + for the schema and/or changing how the base URI is determined +
    +
    +
    assertions:
    +
    + produce a boolean result when applied to an instance +
    +
    +
    annotations:
    +
    + attach information to an instance for application use +
    +
    +
    applicators:
    +
    + apply one or more subschemas to a particular location + in the instance, and combine or modify their results +
    +
    +
    reserved locations:
    +
    + do not directly affect results, but reserve a place + for a specific purpose to ensure interoperability +
    +
    +
    +

    + Keywords may fall into multiple categories, although applicators + SHOULD only produce assertion results based on their subschemas' + results. They should not define additional constraints independent + of their subschemas.

    +

    + Keywords which are properties within the same schema object are referred to as adjacent keywords.

    +

    + Extension keywords, meaning those defined outside of this document + and its companions, are free to define other behaviors as well.

    +

    + A JSON Schema MAY contain properties which are not schema keywords. + Unknown keywords SHOULD be treated as annotations, where the value + of the keyword is the value of the annotation.

    +

    + An empty schema is a JSON Schema with no properties, or only unknown + properties.

    +
    +
    +

    +4.3.2. Boolean JSON Schemas +

    +

    + The boolean schema values "true" and "false" are trivial schemas that + always produce themselves as assertion results, regardless of the + instance value. They never produce annotation results.

    +

    + These boolean schemas exist to clarify schema author intent and + facilitate schema processing optimizations. They behave identically + to the following schema objects (where "not" is part of the + subschema application vocabulary defined in this document).

    +
    +
    true:
    +
    + Always passes validation, as if the empty schema {} +
    +
    +
    false:
    +
    + Always fails validation, as if the schema { "not": {} } +
    +
    +
    +

    + While the empty schema object is unambiguous, there are many + possible equivalents to the "false" schema. Using the boolean + values ensures that the intent is clear to both human readers + and implementations.

    +
    +
    +

    +4.3.3. Schema Vocabularies +

    +

    + A schema vocabulary, or simply a vocabulary, is a set of keywords, + their syntax, and their semantics. A vocabulary is generally organized + around a particular purpose. Different uses of JSON Schema, such + as validation, hypermedia, or user interface generation, will + involve different sets of vocabularies.

    +

    + Vocabularies are the primary unit of re-use in JSON Schema, as schema + authors can indicate what vocabularies are required or optional in + order to process the schema. Since vocabularies are identified by URIs + in the meta-schema, generic implementations can load extensions to support + previously unknown vocabularies. While keywords can be supported outside + of any vocabulary, there is no analogous mechanism to indicate individual + keyword usage.

    +

    + A schema vocabulary can be defined by anything from an informal description + to a standards proposal, depending on the audience and interoperability + expectations. In particular, in order to facilitate vocabulary use within + non-public organizations, a vocabulary specification need not be published + outside of its scope of use.

    +
    +
    +

    +4.3.4. Meta-Schemas +

    +

    + A schema that itself describes a schema is called a meta-schema. + Meta-schemas are used to validate JSON Schemas and specify which vocabularies + they are using.

    +

    + Typically, a meta-schema will specify a set of vocabularies, and validate + schemas that conform to the syntax of those vocabularies. However, meta-schemas + and vocabularies are separate in order to allow meta-schemas to validate + schema conformance more strictly or more loosely than the vocabularies' + specifications call for. Meta-schemas may also describe and validate + additional keywords that are not part of a formal vocabulary.

    +
    +
    +
    +

    +4.3.5. Root Schema and Subschemas and Resources +

    +

    + A JSON Schema resource is a schema which is + canonically [RFC6596] identified by an + absolute URI [RFC3986]. Schema resources MAY + also be identified by URIs, including URIs with fragments, + if the resulting secondary resource (as defined by + section 3.5 of RFC 3986 [RFC3986]) is identical + to the primary resource. This can occur with the empty fragment, + or when one schema resource is embedded in another. Any such URIs + with fragments are considered to be non-canonical.

    +

    + The root schema is the schema that comprises the entire JSON document + in question. The root schema is always a schema resource, where the + URI is determined as described in section + 9.1.1. + + Note that documents that embed schemas in another format will not + have a root schema resource in this sense. Exactly how such usages + fit with the JSON Schema document and resource concepts will be + clarified in a future draft. +

    +

    + Some keywords take schemas themselves, allowing JSON Schemas to be nested:

    +
    +
    +
    +{
    +    "title": "root",
    +    "items": {
    +        "title": "array item"
    +    }
    +}
    +
    +
    +
    +

    + In this example document, the schema titled "array item" is a subschema, + and the schema titled "root" is the root schema.

    +

    + As with the root schema, a subschema is either an object or a boolean.

    +

    + As discussed in section + 8.2.1, a JSON Schema document + can contain multiple JSON Schema resources. When used without qualification, + the term "root schema" refers to the document's root schema. In some + cases, resource root schemas are discussed. A resource's root schema + is its top-level schema object, which would also be a document root schema + if the resource were to be extracted to a standalone JSON Schema document.

    +

    + Whether multiple schema resources are embedded or linked with a reference, + they are processed in the same way, with the same available behaviors.

    +
    +
    +
    +
    +
    +
    +
    +

    +5. Fragment Identifiers +

    +

    + In accordance with section 3.1 of RFC 6839 [RFC6839], + the syntax and semantics of fragment identifiers specified for + any +json media type SHOULD be as specified for "application/json". + (At publication of this document, there is no fragment identification + syntax defined for "application/json".)

    +

    + Additionally, the "application/schema+json" media type supports two + fragment identifier structures: plain names and JSON Pointers. + The "application/schema-instance+json" media type supports one + fragment identifier structure: JSON Pointers.

    +

    + The use of JSON Pointers as URI fragment identifiers is described in + RFC 6901 [RFC6901]. + For "application/schema+json", which supports two fragment identifier syntaxes, + fragment identifiers matching the JSON Pointer syntax, including the empty string, + MUST be interpreted as JSON Pointer fragment identifiers.

    +

    + Per the W3C's + best practices for fragment identifiers [W3C.WD-fragid-best-practices-20121025], + plain name fragment identifiers in "application/schema+json" are reserved for referencing + locally named schemas. All fragment identifiers that do + not match the JSON Pointer syntax MUST be interpreted as + plain name fragment identifiers.

    +

    + Defining and referencing a plain name fragment identifier within an + "application/schema+json" document are specified + in the "$anchor" keyword (Section 8.2.2) section.

    +

    +
    +
    +
    +

    +6. General Considerations +

    +
    +

    +6.1. Range of JSON Values +

    +

    + An instance may be any valid JSON value as defined by JSON [RFC8259]. + JSON Schema imposes no restrictions on type: JSON Schema can describe any JSON + value, including, for example, null.

    +
    +
    +
    +

    +6.2. Programming Language Independence +

    +

    + JSON Schema is programming language agnostic, and supports the full range of + values described in the data model. + Be aware, however, that some languages and JSON parsers may not be able to + represent in memory the full range of values describable by JSON.

    +
    +
    +
    +
    +

    +6.3. Mathematical Integers +

    +

    + Some programming languages and parsers use different internal representations + for floating point numbers than they do for integers.

    +

    + For consistency, integer JSON numbers SHOULD NOT be encoded with a fractional + part.

    +
    +
    +
    +
    +

    +6.4. Regular Expressions +

    +

    + Keywords MAY use regular expressions to express constraints, or constrain + the instance value to be a regular expression. + These regular expressions SHOULD be valid according to the regular expression + dialect described in ECMA-262, section 21.2.1 [ecma262].

    +

    + Regular expressions SHOULD be built with the "u" flag (or equivalent) to provide + Unicode support, or processed in such a way which provides Unicode support as + defined by ECMA-262.

    +

    + Furthermore, given the high disparity in regular expression constructs support, + schema authors SHOULD limit themselves to the following regular expression + tokens:

    +
      +
    • individual Unicode characters, as defined by the JSON specification [RFC8259]; +
    • +
    • simple character classes ([abc]), range character classes ([a-z]); +
    • +
    • complemented character classes ([^abc], [^a-z]); +
    • +
    • simple quantifiers: "+" (one or more), "*" (zero or more), "?" (zero or + one), and their lazy versions ("+?", "*?", "??"); +
    • +
    • range quantifiers: "{x}" (exactly x occurrences), "{x,y}" (at least x, at + most y, occurrences), {x,} (x occurrences or more), and their lazy + versions; +
    • +
    • the beginning-of-input ("^") and end-of-input ("$") anchors; +
    • +
    • simple grouping ("(...)") and alternation ("|"). +
    • +
    +

    + Finally, implementations MUST NOT take regular expressions to be + anchored, neither at the beginning nor at the end. This means, for instance, + the pattern "es" matches "expression".

    +
    +
    +
    +
    +

    +6.5. Extending JSON Schema +

    +

    + Additional schema keywords and schema vocabularies MAY be defined + by any entity. Save for explicit agreement, schema authors SHALL NOT + expect these additional keywords and vocabularies to be supported by + implementations that do not explicitly document such support. + Implementations SHOULD treat keywords they do not support as annotations, + where the value of the keyword is the value of the annotation.

    +

    + Implementations MAY provide the ability to register or load handlers + for vocabularies that they do not support directly. The exact mechanism + for registering and implementing such handlers is implementation-dependent.

    +
    +
    +
    +
    +

    +7. Keyword Behaviors +

    +

    + JSON Schema keywords fall into several general behavior categories. + Assertions validate that an instance satisfies constraints, producing + a boolean result. Annotations attach information that applications + may use in any way they see fit. + Applicators apply subschemas to parts of the instance and combine + their results.

    +

    + Extension keywords SHOULD stay within these categories, keeping in mind + that annotations in particular are extremely flexible. Complex behavior + is usually better delegated to applications on the basis of annotation + data than implemented directly as schema keywords. However, extension + keywords MAY define other behaviors for specialized purposes.

    +

    + Evaluating an instance against a schema involves processing all of the + keywords in the schema against the appropriate locations within the instance. + Typically, applicator keywords are processed until a schema object with no + applicators (and therefore no subschemas) is reached. The appropriate + location in the instance is evaluated against the assertion and + annotation keywords in the schema object, and their results are gathered + into the parent schema according to the rules of the applicator.

    +

    + Evaluation of a parent schema object can complete once all of its + subschemas have been evaluated, although in some circumstances evaluation + may be short-circuited due to assertion results. When annotations are + being collected, some assertion result short-circuiting is not possible + due to the need to examine all subschemas for annotation collection, including + those that cannot further change the assertion result.

    +
    +
    +

    +7.1. Lexical Scope and Dynamic Scope +

    +

    + While most JSON Schema keywords can be evaluated on their own, + or at most need to take into account the values or results of + adjacent keywords in the same schema object, a few have more + complex behavior.

    +

    + The lexical scope of a keyword is determined by the nested JSON + data structure of objects and arrays. The largest such scope + is an entire schema document. The smallest scope is a single + schema object with no subschemas.

    +

    + Keywords MAY be defined with a partial value, such as a URI-reference, + which must be resolved against another value, such as another + URI-reference or a full URI, which is found through the lexical + structure of the JSON document. The "$id", "$ref", and + "$dynamicRef" core keywords, and the "base" JSON Hyper-Schema + keyword, are examples of this sort of behavior.

    +

    + Note that some keywords, such as "$schema", apply to the lexical + scope of the entire schema resource, and therefore MUST only + appear in a schema resource's root schema.

    +

    + Other keywords may take into account the dynamic scope that + exists during the evaluation of a schema, typically together + with an instance document. + The outermost dynamic scope is the schema object at + which processing begins, even if it is not a schema resource root. + The path from this root schema to any particular keyword (that + includes any "$ref" and "$dynamicRef" keywords that may have + been resolved) is considered the keyword's "validation path."

    +

    + Lexical and dynamic scopes align until a reference keyword + is encountered. While following the reference keyword moves processing + from one lexical scope into a different one, from the perspective + of dynamic scope, following a reference is no different from descending + into a subschema present as a value. A keyword on the far side of + that reference that resolves information through the dynamic scope + will consider the originating side of the reference to be their + dynamic parent, rather than examining the local lexically enclosing parent.

    +

    + The concept of dynamic scope is primarily used with "$dynamicRef" and + "$dynamicAnchor", and should be considered an advanced feature + and used with caution when defining additional keywords. It also appears + when reporting errors and collected annotations, as it may be possible + to revisit the same lexical scope repeatedly with different dynamic + scopes. In such cases, it is important to inform the user of the + dynamic path that produced the error or annotation.

    +
    +
    +
    +

    +7.2. Keyword Interactions +

    +

    + Keyword behavior MAY be defined in terms of the annotation results + of subschemas (Section 4.3.5) and/or adjacent keywords + (keywords within the same schema object) and their subschemas. + Such keywords MUST NOT result in a circular dependency. + Keywords MAY modify their behavior based on the presence or absence + of another keyword in the same + schema object (Section 4.3).

    +
    +
    +

    +7.3. Default Behaviors +

    +

    + A missing keyword MUST NOT produce a false assertion result, MUST + NOT produce annotation results, and MUST NOT cause any other schema + to be evaluated as part of its own behavioral definition. + However, given that missing keywords do not contribute annotations, + the lack of annotation results may indirectly change the behavior + of other keywords.

    +

    + In some cases, the missing keyword assertion behavior of a keyword is + identical to that produced by a certain value, and keyword definitions + SHOULD note such values where known. However, even if the value which + produces the default behavior would produce annotation results if + present, the default behavior still MUST NOT result in annotations.

    +

    + Because annotation collection can add significant cost in terms of both + computation and memory, implementations MAY opt out of this feature. + Keywords that are specified in terms of collected annotations SHOULD + describe reasonable alternate approaches when appropriate. + This approach is demonstrated by the + "items" and + "additionalProperties" keywords in this + document.

    +

    + Note that when no such alternate approach is possible for a keyword, + implementations that do not support annotation collections will not + be able to support those keywords or vocabularies that contain them.

    +
    +
    +

    +7.4. Identifiers +

    +

    + Identifiers define URIs for a schema, or affect how such URIs are + resolved in references (Section 8.2.3), or both. + The Core vocabulary defined in this document defines several + identifying keywords, most notably "$id".

    +

    + Canonical schema URIs MUST NOT change while processing an instance, but + keywords that affect URI-reference resolution MAY have behavior that + is only fully determined at runtime.

    +

    + While custom identifier keywords are possible, vocabulary designers should + take care not to disrupt the functioning of core keywords. For example, + the "$dynamicAnchor" keyword in this specification limits its URI resolution + effects to the matching "$dynamicRef" keyword, leaving the behavior + of "$ref" undisturbed.

    +
    +
    +
    +

    +7.5. Applicators +

    +

    + Applicators allow for building more complex schemas than can be accomplished + with a single schema object. Evaluation of an instance against a + schema document (Section 4.3) begins by applying + the root schema (Section 4.3.5) to the complete instance + document. From there, keywords known as applicators are used to determine + which additional schemas are applied. Such schemas may be applied in-place + to the current location, or to a child location.

    +

    + The schemas to be applied may be present as subschemas comprising all or + part of the keyword's value. Alternatively, an applicator may refer to + a schema elsewhere in the same schema document, or in a different one. + The mechanism for identifying such referenced schemas is defined by the + keyword.

    +

    + Applicator keywords also define how subschema or referenced schema + boolean assertion (Section 7.6) + results are modified and/or combined to produce the boolean result + of the applicator. Applicators may apply any boolean logic operation + to the assertion results of subschemas, but MUST NOT introduce new + assertion conditions of their own.

    +

    + Annotation (Section 7.7) results are + preserved along with the instance location and the location of + the schema keyword, so that applications can decide how to + interpret multiple values.

    +
    +
    +

    +7.5.1. Referenced and Referencing Schemas +

    +

    + As noted in Section 7.5, an applicator keyword may + refer to a schema to be applied, rather than including it as a + subschema in the applicator's value. In such situations, the + schema being applied is known as the referenced schema, while + the schema containing the applicator keyword is the referencing schema.

    +

    + While root schemas and subschemas are static concepts based on a + schema's position within a schema document, referenced and referencing + schemas are dynamic. Different pairs of schemas may find themselves + in various referenced and referencing arrangements during the evaluation + of an instance against a schema.

    +

    + For some by-reference applicators, such as + "$ref" (Section 8.2.3.1), the referenced schema can be determined + by static analysis of the schema document's lexical scope. Others, + such as "$dynamicRef" (with "$dynamicAnchor"), may make use of dynamic + scoping, and therefore only be resolvable in the process of evaluating + the schema with an instance.

    +
    +
    +
    +
    +
    +
    +

    +7.6. Assertions +

    +

    + JSON Schema can be used to assert constraints on a JSON document, which + either passes or fails the assertions. This approach can be used to validate + conformance with the constraints, or document what is needed to satisfy them.

    +

    + JSON Schema implementations produce a single boolean result when evaluating + an instance against schema assertions.

    +

    + An instance can only fail an assertion that is present in the schema.

    +
    +

    +7.6.1. Assertions and Instance Primitive Types +

    +

    + Most assertions only constrain values within a certain + primitive type. When the type of the instance is not of the type + targeted by the keyword, the instance is considered to conform + to the assertion.

    +

    + For example, the "maxLength" keyword from the companion + validation vocabulary [json-schema-validation]: + will only restrict certain strings + (that are too long) from being valid. If the instance is a number, + boolean, null, array, or object, then it is valid against this assertion.

    +

    + This behavior allows keywords to be used more easily with instances + that can be of multiple primitive types. The companion validation + vocabulary also includes a "type" keyword which can independently + restrict the instance to one or more primitive types. This allows + for a concise expression of use cases such as a function that might + return either a string of a certain length or a null value:

    +
    +
    +
    +{
    +    "type": ["string", "null"],
    +    "maxLength": 255
    +}
    +
    +
    +
    +

    + If "maxLength" also restricted the instance type to be a string, + then this would be substantially more cumbersome to express because + the example as written would not actually allow null values. + Each keyword is evaluated separately unless explicitly specified + otherwise, so if "maxLength" restricted the instance to strings, + then including "null" in "type" would not have any useful effect.

    +
    +
    +
    +
    +
    +

    +7.7. Annotations +

    +

    + JSON Schema can annotate an instance with information, whenever the instance + validates against the schema object containing the annotation, and all of its + parent schema objects. The information can be a simple value, or can be + calculated based on the instance contents.

    +

    + Annotations are attached to specific locations in an instance. + Since many subschemas can be applied to any single + location, applications may need to decide how to handle differing + annotation values being attached to the same instance location by + the same schema keyword in different schema objects.

    +

    + Unlike assertion results, annotation data can take a wide variety of forms, + which are provided to applications to use as they see fit. JSON Schema + implementations are not expected to make use of the collected information + on behalf of applications.

    +

    + Unless otherwise specified, the value of an annotation keyword + is the keyword's value. However, other behaviors are possible. + For example, JSON Hyper-Schema's [json-hyper-schema] + "links" keyword is a complex annotation that produces a value based + in part on the instance data.

    +

    + While "short-circuit" evaluation is possible for assertions, collecting + annotations requires examining all schemas that apply to an instance + location, even if they cannot change the overall assertion result. + The only exception is that subschemas of a schema object that has + failed validation MAY be skipped, as annotations are not retained + for failing schemas.

    +
    +

    +7.7.1. Collecting Annotations +

    +

    + Annotations are collected by keywords that explicitly define + annotation-collecting behavior. Note that boolean schemas cannot + produce annotations as they do not make use of keywords.

    +

    + A collected annotation MUST include the following information:

    +
      +
    • + The name of the keyword that produces the annotation +
    • +
    • + The instance location to which it is attached, as a JSON Pointer +
    • +
    • + The schema location path, indicating how reference keywords + such as "$ref" were followed to reach the absolute schema location. +
    • +
    • + The absolute schema location of the attaching keyword, as a URI. + This MAY be omitted if it is the same as the schema location path + from above. +
    • +
    • + The attached value(s) +
    • +
    +
    +
    +7.7.1.1. Distinguishing Among Multiple Values +
    +

    + Applications MAY make decisions on which of multiple annotation values + to use based on the schema location that contributed the value. + This is intended to allow flexible usage. Collecting the schema location + facilitates such usage.

    +

    + For example, consider this schema, which uses annotations and assertions from + the Validation specification [json-schema-validation]:

    +

    + Note that some lines are wrapped for clarity.

    +
    +
    +
    +{
    +    "title": "Feature list",
    +    "type": "array",
    +    "prefixItems": [
    +        {
    +            "title": "Feature A",
    +            "properties": {
    +                "enabled": {
    +                    "$ref": "#/$defs/enabledToggle",
    +                    "default": true
    +                }
    +            }
    +        },
    +        {
    +            "title": "Feature B",
    +            "properties": {
    +                "enabled": {
    +                    "description": "If set to null, Feature B
    +                                    inherits the enabled
    +                                    value from Feature A",
    +                    "$ref": "#/$defs/enabledToggle"
    +                }
    +            }
    +        }
    +    ],
    +    "$defs": {
    +        "enabledToggle": {
    +            "title": "Enabled",
    +            "description": "Whether the feature is enabled (true),
    +                            disabled (false), or under
    +                            automatic control (null)",
    +            "type": ["boolean", "null"],
    +            "default": null
    +        }
    +    }
    +}
    +
    +
    +
    +

    + In this example, both Feature A and Feature B make use of the re-usable + "enabledToggle" schema. That schema uses the "title", "description", + and "default" annotations. Therefore the application has to decide how + to handle the additional "default" value for Feature A, and the additional + "description" value for Feature B.

    +

    + The application programmer and the schema author need to agree on the + usage. For this example, let's assume that they agree that the most + specific "default" value will be used, and any additional, more generic + "default" values will be silently ignored. Let's also assume that they + agree that all "description" text is to be used, starting with the most + generic, and ending with the most specific. This requires the schema + author to write descriptions that work when combined in this way.

    +

    + The application can use the schema location path to determine which + values are which. The values in the feature's immediate "enabled" + property schema are more specific, while the values under the re-usable + schema that is referenced to with "$ref" are more generic. The schema + location path will show whether each value was found by crossing a + "$ref" or not.

    +

    + Feature A will therefore use a default value of true, while Feature B + will use the generic default value of null. Feature A will only + have the generic description from the "enabledToggle" schema, while + Feature B will use that description, and also append its locally + defined description that explains how to interpret a null value.

    +

    + Note that there are other reasonable approaches that a different application + might take. For example, an application may consider the presence of + two different values for "default" to be an error, regardless of their + schema locations.

    +
    +
    +
    +7.7.1.2. Annotations and Assertions +
    +

    + Schema objects that produce a false assertion result MUST NOT + produce any annotation results, whether from their own keywords + or from keywords in subschemas.

    +

    + Note that the overall schema results may still include annotations + collected from other schema locations. Given this schema:

    +
    +
    +
    +{
    +    "oneOf": [
    +        {
    +            "title": "Integer Value",
    +            "type": "integer"
    +        },
    +        {
    +            "title": "String Value",
    +            "type": "string"
    +        }
    +    ]
    +}
    +
    +
    +
    +

    + Against the instance "This is a string", the + title annotation "Integer Value" is discarded because the type assertion + in that schema object fails. The title annotation "String Value" + is kept, as the instance passes the string type assertions.

    +
    +
    +
    +7.7.1.3. Annotations and Applicators +
    +

    + In addition to possibly defining annotation results of their own, + applicator keywords aggregate the annotations collected in their + subschema(s) or referenced schema(s).

    +
    +
    +
    +
    +
    +

    +7.8. Reserved Locations +

    +

    + A fourth category of keywords simply reserve a location to hold re-usable + components or data of interest to schema authors that is not suitable + for re-use. These keywords do not affect validation or annotation results. + Their purpose in the core vocabulary is to ensure that locations are + available for certain purposes and will not be redefined by extension + keywords.

    +

    + While these keywords do not directly affect results, as explained in section + 9.4.2 unrecognized + extension keywords that reserve locations for re-usable schemas may have + undesirable interactions with references in certain circumstances.

    +
    +
    +

    +7.9. Loading Instance Data +

    +

    + While none of the vocabularies defined as part of this or the associated documents + define a keyword which may target and/or load instance data, it is possible that + other vocabularies may wish to do so.

    +

    + Keywords MAY be defined to use JSON Pointers or Relative JSON Pointers to examine + parts of an instance outside the current evaluation location.

    +

    + Keywords that allow adjusting the location using a Relative JSON Pointer SHOULD + default to using the current location if a default is desireable.

    +
    +
    +
    +

    +8. The JSON Schema Core Vocabulary +

    +

    + Keywords declared in this section, which all begin with "$", make up + the JSON Schema Core vocabulary. These keywords are either required in + order to process any schema or meta-schema, including those split across + multiple documents, or exist to reserve keywords for purposes that + require guaranteed interoperability.

    +

    + The Core vocabulary MUST be considered mandatory at all times, in order + to bootstrap the processing of further vocabularies. Meta-schemas + that use the "$vocabulary" (Section 8.1) keyword + to declare the vocabularies in use MUST explicitly list the Core vocabulary, + which MUST have a value of true indicating that it is required.

    +

    + The behavior of a false value for this vocabulary (and only this + vocabulary) is undefined, as is the behavior when "$vocabulary" + is present but the Core vocabulary is not included. However, it + is RECOMMENDED that implementations detect these cases and raise + an error when they occur. It is not meaningful to declare that + a meta-schema optionally uses Core.

    +

    + Meta-schemas that do not use "$vocabulary" MUST be considered to + require the Core vocabulary as if its URI were present with a value of true.

    +

    + The current URI for the Core vocabulary is: + <https://json-schema.org/draft/2020-12/vocab/core>.

    +

    + The current URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/core.

    +

    + While the "$" prefix is not formally reserved for the Core vocabulary, + it is RECOMMENDED that extension keywords (in vocabularies or otherwise) + begin with a character other than "$" to avoid possible future collisions.

    +
    +
    +

    +8.1. Meta-Schemas and Vocabularies +

    +

    + Two concepts, meta-schemas and vocabularies, are used to inform an implementation + how to interpret a schema. Every schema has a meta-schema, which can be declared + using the "$schema" keyword.

    +

    + The meta-schema serves two purposes:

    +
    +
    Declaring the vocabularies in use
    +
    + The "$vocabulary" keyword, when it appears in a meta-schema, declares + which vocabularies are available to be used in schemas that refer + to that meta-schema. Vocabularies define keyword semantics, + as well as their general syntax. +
    +
    +
    Describing valid schema syntax
    +
    + A schema MUST successfully validate against its meta-schema, which + constrains the syntax of the available keywords. The syntax described + is expected to be compatible with the vocabularies declared; while + it is possible to describe an incompatible syntax, such a meta-schema + would be unlikely to be useful. +
    +
    +
    +

    + Meta-schemas are separate from vocabularies to allow for + vocabularies to be combined in different ways, and for meta-schema authors + to impose additional constraints such as forbidding certain keywords, or + performing unusually strict syntactical validation, as might be done + during a development and testing cycle. Each vocabulary typically identifies + a meta-schema consisting only of the vocabulary's keywords.

    +

    + Meta-schema authoring is an advanced usage of JSON Schema, so the design of + meta-schema features emphasizes flexibility over simplicity.

    +
    +
    +

    +8.1.1. The "$schema" Keyword +

    +

    + The "$schema" keyword is both used as a JSON Schema dialect identifier and + as the identifier of a resource which is itself a JSON Schema, which describes the + set of valid schemas written for this particular dialect.

    +

    + The value of this keyword MUST be a URI [RFC3986] + (containing a scheme) and this URI MUST be normalized. + The current schema MUST be valid against the meta-schema identified by this URI.

    +

    + If this URI identifies a retrievable resource, that resource SHOULD be of + media type "application/schema+json".

    +

    + The "$schema" keyword SHOULD be used in the document root schema object, + and MAY be used in the root schema objects of embedded schema resources. + It MUST NOT appear in non-resource root schema objects. If absent from + the document root schema, the resulting behavior is implementation-defined.

    +

    + Values for this property are defined elsewhere in this and other documents, + and by other parties.

    +
    +
    +
    +

    +8.1.2. The "$vocabulary" Keyword +

    +

    + The "$vocabulary" keyword is used in meta-schemas to identify the + vocabularies available for use in schemas described by that meta-schema. + It is also used to indicate whether each vocabulary is required or optional, + in the sense that an implementation MUST understand the required vocabularies + in order to successfully process the schema. Together, this information forms + a dialect. Any vocabulary that is understood by the implementation MUST be + processed in a manner consistent with the semantic definitions contained + within the vocabulary.

    +

    + The value of this keyword MUST be an object. The property names in the + object MUST be URIs (containing a scheme) and this URI MUST be normalized. + Each URI that appears as a property name identifies a specific set of + keywords and their semantics.

    +

    + The URI MAY be a URL, but the nature of the retrievable resource is + currently undefined, and reserved for future use. Vocabulary authors + MAY use the URL of the vocabulary specification, in a human-readable + media type such as text/html or text/plain, as the vocabulary URI. + + Vocabulary documents may be added in forthcoming drafts. + For now, identifying the keyword set is deemed sufficient as that, + along with meta-schema validation, is how the current "vocabularies" + work today. Any future vocabulary document format will be specified + as a JSON document, so using text/html or other non-JSON formats + in the meantime will not produce any future ambiguity. +

    +

    + The values of the object properties MUST be booleans. + If the value is true, then implementations that do not recognize + the vocabulary MUST refuse to process any schemas that declare + this meta-schema with "$schema". If the value is false, implementations + that do not recognize the vocabulary SHOULD proceed with processing + such schemas. The value has no impact if the implementation + understands the vocabulary.

    +

    + Per 6.5, unrecognized + keywords SHOULD be treated as annotations. + This remains the case for keywords defined + by unrecognized vocabularies. It is not currently possible to distinguish + between unrecognized keywords that are defined in vocabularies from + those that are not part of any vocabulary.

    +

    + The "$vocabulary" keyword SHOULD be used in the root schema of any schema + document intended for use as a meta-schema. It MUST NOT appear in subschemas.

    +

    + The "$vocabulary" keyword MUST be ignored in schema documents that + are not being processed as a meta-schema. This allows validating + a meta-schema M against its own meta-schema M' without requiring + the validator to understand the vocabularies declared by M.

    +
    +
    +8.1.2.1. Default vocabularies +
    +

    + If "$vocabulary" is absent, an implementation MAY determine + behavior based on the meta-schema if it is recognized from the + URI value of the referring schema's "$schema" keyword. + This is how behavior (such as Hyper-Schema usage) has been + recognized prior to the existence of vocabularies.

    +

    + If the meta-schema, as referenced by the schema, is not recognized, + or is missing, then the behavior is implementation-defined. + If the implementation + proceeds with processing the schema, it MUST assume the use of the + core vocabulary. If the implementation is built for a specific purpose, + then it SHOULD assume the use of all of the most relevant vocabularies + for that purpose.

    +

    + For example, an implementation that is a validator + SHOULD assume the use of all vocabularies in this + specification and the companion Validation specification.

    +
    +
    +
    +8.1.2.2. Non-inheritability of vocabularies +
    +

    + Note that the processing restrictions on "$vocabulary" mean that + meta-schemas that reference other meta-schemas using "$ref" or + similar keywords do not automatically inherit the vocabulary + declarations of those other meta-schemas. All such declarations + must be repeated in the root of each schema document intended + for use as a meta-schema. This is demonstrated in + the example meta-schema (Appendix D.2). + + This requirement allows implementations to find all vocabulary + requirement information in a single place for each meta-schema. + As schema extensibility means that there are endless potential + ways to combine more fine-grained meta-schemas by reference, + requiring implementations to anticipate all possibilities and + search for vocabularies in referenced meta-schemas would + be overly burdensome. +

    +
    +
    +
    +

    +8.1.3. Updates to Meta-Schema and Vocabulary URIs +

    +

    + Updated vocabulary and meta-schema URIs MAY be published between + specification drafts in order to correct errors. Implementations + SHOULD consider URIs dated after this specification draft and + before the next to indicate the same syntax and semantics + as those listed here.

    +
    +
    +
    +
    +

    +8.2. Base URI, Anchors, and Dereferencing +

    +

    + To differentiate between schemas in a vast ecosystem, schemas are + identified by URI [RFC3986], and can embed references + to other schemas by specifying their URI.

    +

    + Several keywords can accept a relative URI-reference [RFC3986], + or a value used to construct a relative URI-reference. For these keywords, + it is necessary to establish a base URI in order to resolve the reference.

    +
    +
    +

    +8.2.1. The "$id" Keyword +

    +

    + The "$id" keyword identifies a schema resource with its + canonical [RFC6596] URI.

    +

    + Note that this URI is an identifier and not necessarily a network locator. + In the case of a network-addressable URL, a schema need not be downloadable + from its canonical URI.

    +

    + If present, the value for this keyword MUST be a string, and MUST represent a + valid URI-reference [RFC3986]. This URI-reference + SHOULD be normalized, and MUST resolve to an + absolute-URI [RFC3986] (without a fragment), + or to a URI with an empty fragment.

    +

    + The empty fragment form is NOT RECOMMENDED and is retained only + for backwards compatibility, and because the + application/schema+json media type defines that a URI with an + empty fragment identifies the same resource as the same URI + with the fragment removed. However, since this equivalence is not + part of the RFC 3986 normalization process [RFC3986], + implementers and schema authors cannot rely on generic URI libraries + understanding it.

    +

    + Therefore, "$id" MUST NOT contain a non-empty fragment, and SHOULD NOT + contain an empty fragment. The absolute-URI form MUST be considered + the canonical URI, regardless of the presence or absence of an empty fragment. + + An empty fragment is currently allowed because older meta-schemas have + an empty fragment in their $id (or previously, id). + A future draft may outright forbid even empty fragments in "$id". +

    +

    + The absolute-URI also serves as the base URI for relative URI-references + in keywords within the schema resource, in accordance with + RFC 3986 section 5.1.1 [RFC3986] regarding base URIs + embedded in content.

    +

    + The presence of "$id" in a subschema indicates that the subschema constitutes + a distinct schema resource within a single schema document. Furthermore, + in accordance with RFC 3986 section 5.1.2 [RFC3986] + regarding encapsulating entities, if an "$id" in a subschema is a relative + URI-reference, the base URI for resolving that reference is the URI of + the parent schema resource.

    +

    + If no parent schema object explicitly identifies itself as a resource + with "$id", the base URI is that of the entire document, as established + by the steps given in the previous section. (Section 9.1.1)

    +
    +
    +8.2.1.1. Identifying the root schema +
    +

    + The root schema of a JSON Schema document SHOULD contain an "$id" keyword + with an absolute-URI [RFC3986] (containing a scheme, + but no fragment).

    +
    +
    +
    +
    +
    +

    +8.2.2. Defining location-independent identifiers +

    +

    + Using JSON Pointer fragments requires knowledge of the structure of the schema. + When writing schema documents with the intention to provide re-usable + schemas, it may be preferable to use a plain name fragment that is not tied to + any particular structural location. This allows a subschema to be relocated + without requiring JSON Pointer references to be updated.

    +

    + The "$anchor" and "$dynamicAnchor" keywords are used to specify such + fragments. They are identifier keywords that can only be used to create + plain name fragments, rather than absolute URIs as seen with "$id".

    +

    + The base URI to which the resulting fragment is appended is the canonical + URI of the schema resource containing the "$anchor" or "$dynamicAnchor" + in question. As discussed in the previous section, this is either the + nearest "$id" in the same or parent schema object, or the base URI + for the document as determined according to RFC 3986.

    +

    + Separately from the usual usage of URIs, "$dynamicAnchor" + indicates that the fragment is an extension point when used with + the "$dynamicRef" keyword. This low-level, advanced feature + makes it easier to extend recursive schemas such as the meta-schemas, + without imposing any particular semantics on that extension. + See the section on "$dynamicRef" (Section 8.2.3.2) + for details.

    +

    + In most cases, the normal fragment behavior both suffices and + is more intuitive. Therefore it is RECOMMENDED that "$anchor" + be used to create plain name fragments unless there is a clear + need for "$dynamicAnchor".

    +

    + If present, the value of this keyword MUST be a string and MUST start with + a letter ([A-Za-z]) or underscore ("_"), followed by any number of letters, + digits ([0-9]), hyphens ("-"), underscores ("_"), and periods ("."). + This matches the US-ASCII part of XML's + NCName production [xml-names]. + + Note that the anchor string does not include the "#" character, + as it is not a URI-reference. An "$anchor": "foo" becomes the + fragment "#foo" when used in a URI. See below for full examples. +

    +

    + The effect of specifying the same fragment name multiple times within + the same resource, using any combination of "$anchor" and/or + "$dynamicAnchor", is undefined. Implementations MAY + raise an error if such usage is detected.

    +
    +
    +
    +
    +

    +8.2.3. Schema References +

    +

    + Several keywords can be used to reference a schema which is to be applied to the + current instance location. "$ref" and "$dynamicRef" are applicator + keywords, applying the referenced schema to the instance.

    +

    + As the values of "$ref" and "$dynamicRef" are URI References, this allows + the possibility to externalise or divide a schema across multiple files, + and provides the ability to validate recursive structures through + self-reference.

    +

    + The resolved URI produced by these keywords is not necessarily a network + locator, only an identifier. A schema need not be downloadable from the + address if it is a network-addressable URL, and implementations SHOULD NOT + assume they should perform a network operation when they encounter + a network-addressable URI.

    +
    +
    +
    +8.2.3.1. Direct References with "$ref" +
    +

    + The "$ref" keyword is an applicator that is used to reference a statically + identified schema. Its results are the results of the referenced schema. + + Note that this definition of how the results are determined means that + other keywords can appear alongside of "$ref" in the same schema object. +

    +

    + The value of the "$ref" keyword MUST be a string which is a URI-Reference. + Resolved against the current URI base, it produces the URI of the schema + to apply. This resolution is safe to perform on schema load, as the + process of evaluating an instance cannot change how the reference resolves.

    +
    +
    +
    +
    +
    +8.2.3.2. Dynamic References with "$dynamicRef" +
    +

    + The "$dynamicRef" keyword is an applicator that allows for deferring the + full resolution until runtime, at which point it is resolved each time it is + encountered while evaluating an instance.

    +

    + Together with "$dynamicAnchor", "$dynamicRef" implements a cooperative + extension mechanism that is primarily useful with recursive schemas + (schemas that reference themselves). Both the extension point and the + runtime-determined extension target are defined with "$dynamicAnchor", + and only exhibit runtime dynamic behavior when referenced with + "$dynamicRef".

    +

    + The value of the "$dynamicRef" property MUST be a string which is + a URI-Reference. Resolved against the current URI base, it produces + the URI used as the starting point for runtime resolution. This initial + resolution is safe to perform on schema load.

    +

    + If the initially resolved starting point URI includes a fragment that + was created by the "$dynamicAnchor" keyword, the initial URI MUST be + replaced by the URI (including the fragment) for the outermost schema + resource in the dynamic scope (Section 7.1) that defines + an identically named fragment with "$dynamicAnchor".

    +

    + Otherwise, its behavior is identical to "$ref", and no runtime + resolution is needed.

    +

    + For a full example using these keyword, see appendix + C. + + The difference between the hyper-schema meta-schema in pre-2019 + drafts and an this draft dramatically demonstrates the utility + of these keywords. +

    +
    +
    +
    +
    +
    +
    +

    +8.2.4. Schema Re-Use With "$defs" +

    +

    + The "$defs" keyword reserves a location for schema + authors to inline re-usable JSON Schemas into a more general schema. + The keyword does not directly affect the validation result.

    +

    + This keyword's value MUST be an object. + Each member value of this object MUST be a valid JSON Schema.

    +

    + As an example, here is a schema describing an array of positive + integers, where the positive integer constraint is a subschema in + "$defs":

    +
    +
    +
    +{
    +    "type": "array",
    +    "items": { "$ref": "#/$defs/positiveInteger" },
    +    "$defs": {
    +        "positiveInteger": {
    +            "type": "integer",
    +            "exclusiveMinimum": 0
    +        }
    +    }
    +}
    +
    +
    +
    +
    +
    +
    +
    +

    +8.3. Comments With "$comment" +

    +

    + This keyword reserves a location for comments from schema authors + to readers or maintainers of the schema.

    +

    + The value of this keyword MUST be a string. Implementations MUST NOT present this + string to end users. Tools for editing schemas SHOULD support displaying and + editing this keyword. The value of this keyword MAY be used in debug or error + output which is intended for developers making use of schemas.

    +

    + Schema vocabularies SHOULD allow "$comment" within any object containing + vocabulary keywords. Implementations MAY assume "$comment" is allowed + unless the vocabulary specifically forbids it. Vocabularies MUST NOT + specify any effect of "$comment" beyond what is described in this + specification.

    +

    + Tools that translate other media types or programming languages + to and from application/schema+json MAY choose to convert that media type or + programming language's native comments to or from "$comment" values. + The behavior of such translation when both native comments and "$comment" + properties are present is implementation-dependent.

    +

    + Implementations MAY strip "$comment" values at any point during processing. + In particular, this allows for shortening schemas when the size of deployed + schemas is a concern.

    +

    + Implementations MUST NOT take any other action based on the presence, absence, + or contents of "$comment" properties. In particular, the value of "$comment" + MUST NOT be collected as an annotation result.

    +
    +
    +
    +

    +9. Loading and Processing Schemas +

    +

    +
    +

    +9.1. Loading a Schema +

    +
    +
    +

    +9.1.1. Initial Base URI +

    +

    + RFC3986 Section 5.1 [RFC3986] defines how to determine the + default base URI of a document.

    +

    + Informatively, the initial base URI of a schema is the URI at which it was + found, whether that was a network location, a local filesystem, or any other + situation identifiable by a URI of any known scheme.

    +

    + If a schema document defines no explicit base URI with "$id" + (embedded in content), the base URI is that determined per + RFC 3986 section 5 [RFC3986].

    +

    + If no source is known, or no URI scheme is known for the source, a suitable + implementation-specific default URI MAY be used as described in + RFC 3986 Section 5.1.4 [RFC3986]. It is RECOMMENDED + that implementations document any default base URI that they assume.

    +

    + If a schema object is embedded in a document of another media type, then + the initial base URI is determined according to the rules of that + media type.

    +

    + Unless the "$id" keyword described in an earlier section is present in the + root schema, this base URI SHOULD be considered the canonical URI of the + schema document's root schema resource.

    +
    +
    +
    +

    +9.1.2. Loading a referenced schema +

    +

    + The use of URIs to identify remote schemas does not necessarily mean anything is downloaded, + but instead JSON Schema implementations SHOULD understand ahead of time which schemas they will be using, + and the URIs that identify them.

    +

    + When schemas are downloaded, + for example by a generic user-agent that does not know until runtime which schemas to download, + see Usage for Hypermedia (Section 9.5.1).

    +

    + Implementations SHOULD be able to associate arbitrary URIs with an arbitrary + schema and/or automatically associate a schema's "$id"-given URI, depending + on the trust that the validator has in the schema. Such URIs and schemas + can be supplied to an implementation prior to processing instances, or may + be noted within a schema document as it is processed, producing associations + as shown in appendix A.

    +

    + A schema MAY (and likely will) have multiple URIs, but there is no way for a + URI to identify more than one schema. When multiple schemas try to identify + as the same URI, validators SHOULD raise an error condition.

    +
    +
    +

    +9.1.3. Detecting a Meta-Schema +

    +

    + Implementations MUST recognize a schema as a meta-schema if it + is being examined because it was identified as such by another + schema's "$schema" keyword. This means that a single schema + document might sometimes be considered a regular schema, and + other times be considered a meta-schema.

    +

    + In the case of examining a schema which is its own meta-schema, + when an implementation begins processing it as a regular schema, + it is processed under those rules. However, when loaded a second + time as a result of checking its own "$schema" value, it is treated + as a meta-schema. So the same document is processed both ways in + the course of one session.

    +

    + Implementations MAY allow a schema to be explicitly passed as a meta-schema, + for implementation-specific purposes, such as pre-loading a commonly + used meta-schema and checking its vocabulary support requirements + up front. Meta-schema authors MUST NOT expect such features to be + interoperable across implementations.

    +
    +
    +
    +

    +9.2. Dereferencing +

    +

    + Schemas can be identified by any URI that has been given to them, including + a JSON Pointer or their URI given directly by "$id". In all cases, + dereferencing a "$ref" reference involves first resolving its value as a + URI reference against the current base URI per + RFC 3986 [RFC3986].

    +

    + If the resulting URI identifies a schema within the current document, or + within another schema document that has been made available to the implementation, + then that schema SHOULD be used automatically.

    +

    + For example, consider this schema:

    +
    +
    +
    +{
    +    "$id": "https://example.net/root.json",
    +    "items": {
    +        "type": "array",
    +        "items": { "$ref": "#item" }
    +    },
    +    "$defs": {
    +        "single": {
    +            "$anchor": "item",
    +            "type": "object",
    +            "additionalProperties": { "$ref": "other.json" }
    +        }
    +    }
    +}
    +
    +
    +
    +

    + When an implementation encounters the <#/$defs/single> schema, + it resolves the "$anchor" value as a fragment name against the current + base URI to form <https://example.net/root.json#item>.

    +

    + When an implementation then looks inside the <#/items> schema, it + encounters the <#item> reference, and resolves this to + <https://example.net/root.json#item>, which it has seen defined in + this same document and can therefore use automatically.

    +

    + When an implementation encounters the reference to "other.json", it resolves + this to <https://example.net/other.json>, which is not defined in this + document. If a schema with that identifier has otherwise been supplied to + the implementation, it can also be used automatically. + + What should implementations do when the referenced schema is not known? + Are there circumstances in which automatic network dereferencing is + allowed? A same origin policy? A user-configurable option? In the + case of an evolving API described by Hyper-Schema, it is expected that + new schemas will be added to the system dynamically, so placing an + absolute requirement of pre-loading schema documents is not feasible. +

    +
    +
    +

    +9.2.1. JSON Pointer fragments and embedded schema resources +

    +

    + Since JSON Pointer URI fragments are constructed based on the structure + of the schema document, an embedded schema resource and its subschemas + can be identified by JSON Pointer fragments relative to either its own + canonical URI, or relative to any containing resource's URI.

    +

    + Conceptually, a set of linked schema resources should behave + identically whether each resource is a separate document connected with + schema references (Section 8.2.3), or is structured as + a single document with one or more schema resources embedded as + subschemas.

    +

    + Since URIs involving JSON Pointer fragments relative to the parent + schema resource's URI cease to be valid when the embedded schema + is moved to a separate document and referenced, applications and schemas + SHOULD NOT use such URIs to identify embedded schema resources or + locations within them.

    +

    + Consider the following schema document that contains another + schema resource embedded within it:

    +
    +
    +
    +{
    +    "$id": "https://example.com/foo",
    +    "items": {
    +        "$id": "https://example.com/bar",
    +        "additionalProperties": { }
    +    }
    +}
    +
    +
    +
    +

    + The URI "https://example.com/foo#/items" points to the "items" schema, + which is an embedded resource. The canonical URI of that schema + resource, however, is "https://example.com/bar".

    +

    + For the "additionalProperties" schema within that embedded resource, + the URI "https://example.com/foo#/items/additionalProperties" points + to the correct object, but that object's URI relative to its resource's + canonical URI is "https://example.com/bar#/additionalProperties".

    +

    + Now consider the following two schema resources linked by reference + using a URI value for "$ref":

    +
    +
    +
    +{
    +    "$id": "https://example.com/foo",
    +    "items": {
    +        "$ref": "bar"
    +    }
    +}
    +
    +{
    +    "$id": "https://example.com/bar",
    +    "additionalProperties": { }
    +}
    +
    +
    +
    +

    + Here we see that "https://example.com/bar#/additionalProperties", + using a JSON Pointer fragment appended to the canonical URI of + the "bar" schema resource, is still valid, while + "https://example.com/foo#/items/additionalProperties", which relied + on a JSON Pointer fragment appended to the canonical URI of the + "foo" schema resource, no longer resolves to anything.

    +

    + Note also that "https://example.com/foo#/items" is valid in both + arrangements, but resolves to a different value. This URI ends up + functioning similarly to a retrieval URI for a resource. While this URI + is valid, it is more robust to use the "$id" of the embedded or referenced + resource unless it is specifically desired to identify the object containing + the "$ref" in the second (non-embedded) arrangement.

    +

    + An implementation MAY choose not to support addressing schema resource + contents by URIs using a base other than the resource's canonical URI, + plus a JSON Pointer fragment relative to that base. Therefore, schema + authors SHOULD NOT rely on such URIs, as using them may reduce interoperability. + + This is to avoid requiring implementations to keep track of a whole + stack of possible base URIs and JSON Pointer fragments for each, + given that all but one will be fragile if the schema resources + are reorganized. Some + have argued that this is easy so there is + no point in forbidding it, while others have argued that it complicates + schema identification and should be forbidden. Feedback on this + topic is encouraged. + After some discussion, we feel that we need to remove the use of + "canonical" in favour of talking about JSON Pointers which reference + across schema resource boundaries as undefined or even forbidden behavior + (https://github.com/json-schema-org/json-schema-spec/issues/937, + https://github.com/json-schema-org/json-schema-spec/issues/1183) +

    +

    + Further examples of such non-canonical URI construction, as well as + the appropriate canonical URI-based fragments to use instead, + are provided in appendix A.

    +
    +
    +
    +
    +

    +9.3. Compound Documents +

    +

    + A Compound Schema Document is defined as a JSON document (sometimes called a "bundled" schema) + which has multiple embedded JSON Schema Resources bundled into the same document to + ease transportation.

    +

    + Each embedded Schema Resource MUST be treated as an individual Schema Resource, following standard + schema loading and processing requirements, including determining vocabulary support.

    +
    +

    +9.3.1. Bundling +

    +

    + The bundling process for creating a Compound Schema Document is defined as taking + references (such as "$ref") to an external Schema Resource and embedding the referenced + Schema Resources within the referring document. Bundling SHOULD be done in such a way that + all URIs (used for referencing) in the base document and any referenced/embedded + documents do not require altering.

    +

    + Each embedded JSON Schema Resource MUST identify itself with a URI using the "$id" keyword, + and SHOULD make use of the "$schema" keyword to identify the dialect it is using, in the root of the + schema resource. It is RECOMMENDED that the URI identifier value of "$id" be an Absolute URI.

    +

    + When the Schema Resource referenced by a by-reference applicator is bundled, it is RECOMMENDED that + the Schema Resource be located as a value of a "$defs" object at the containing schema's root. + The key of the "$defs" for the now embedded Schema Resource MAY be the "$id" of the bundled schema + or some other form of application defined unique identifer (such as a UUID). This key is not + intended to be referenced in JSON Schema, but may be used by an application to aid the + bundling process.

    +

    + A Schema Resource MAY be embedded in a location other than "$defs" where the location is defined + as a schema value.

    +

    + A Bundled Schema Resource MUST NOT be bundled by replacing the schema object from which it was + referenced, or by wrapping the Schema Resource in other applicator keywords.

    +

    + In order to produce identical output, references in the containing schema document to the + previously external Schema Resources MUST NOT be changed, and now resolve to a schema using the + "$id" of an embedded Schema Resource. Such identical output includes validation evaluation and URIs + or paths used in resulting annotations or errors.

    +

    + While the bundling process will often be the main method for creating a Compound Schema Document, + it is also possible and expected that some will be created by hand, potentially without individual + Schema Resources existing on their own previously.

    +
    +
    +

    +9.3.2. Differing and Default Dialects +

    +

    + When multiple schema resources are present in a single document, + schema resources which do not define with which dialect they should be processed + MUST be processed with the same dialect as the enclosing resource.

    +

    + Since any schema that can be referenced can also be embedded, embedded schema resources MAY + specify different processing dialects using the "$schema" values from their enclosing resource.

    +
    +
    +

    +9.3.3. Validating +

    +

    + Given that a Compound Schema Document may have embedded resources which identify as using different + dialects, these documents SHOULD NOT be validated by applying a meta-schema + to the Compound Schema Document as an instance. It is RECOMMENDED that an alternate + validation process be provided in order to validate Schema Documents. Each Schema Resource + SHOULD be separately validated against its associated meta-schema. + + If you know a schema is what's being validated, you can identify if the schemas + is a Compound Schema Document or not, by way of use of "$id", which identifies an + embedded resource when used not at the document's root. +

    +

    + A Compound Schema Document in which all embedded resources identify as using the same + dialect, or in which "$schema" is omitted and therefore defaults to that of the enclosing resource, + MAY be validated by applying the appropriate meta-schema.

    +
    +
    +
    +

    +9.4. Caveats +

    +
    +

    +9.4.1. Guarding Against Infinite Recursion +

    +

    + A schema MUST NOT be run into an infinite loop against an instance. For + example, if two schemas "#alice" and "#bob" both have an "allOf" property + that refers to the other, a naive validator might get stuck in an infinite + recursive loop trying to validate the instance. Schemas SHOULD NOT make + use of infinite recursive nesting like this; the behavior is undefined.

    +
    +
    +
    +

    +9.4.2. References to Possible Non-Schemas +

    +

    + Subschema objects (or booleans) are recognized by their use with known + applicator keywords or with location-reserving keywords such as + "$defs" (Section 8.2.4) that take one or more subschemas + as a value. These keywords may be "$defs" and the standard applicators + from this document, or extension keywords from a known vocabulary, or + implementation-specific custom keywords.

    +

    + Multi-level structures of unknown keywords are capable of introducing + nested subschemas, which would be subject to the processing rules for + "$id". Therefore, having a reference target in such an unrecognized + structure cannot be reliably implemented, and the resulting behavior + is undefined. Similarly, a reference target under a known keyword, + for which the value is known not to be a schema, results in undefined + behavior in order to avoid burdening implementations with the need + to detect such targets. + + These scenarios are analogous to fetching a schema over HTTP + but receiving a response with a Content-Type other than + application/schema+json. An implementation can certainly + try to interpret it as a schema, but the origin server + offered no guarantee that it actually is any such thing. + Therefore, interpreting it as such has security implications + and may produce unpredictable results. +

    +

    + Note that single-level custom keywords with identical syntax and + semantics to "$defs" do not allow for any intervening "$id" keywords, + and therefore will behave correctly under implementations that attempt + to use any reference target as a schema. However, this behavior is + implementation-specific and MUST NOT be relied upon for interoperability.

    +
    +
    +
    +
    +

    +9.5. Associating Instances and Schemas +

    +
    +
    +

    +9.5.1. Usage for Hypermedia +

    +

    + JSON has been adopted widely by HTTP servers for automated APIs and robots. This + section describes how to enhance processing of JSON documents in a more RESTful + manner when used with protocols that support media types and + Web linking [RFC8288].

    +
    +
    +9.5.1.1. Linking to a Schema +
    +

    + It is RECOMMENDED that instances described by a schema provide a link to + a downloadable JSON Schema using the link relation "describedby", as defined by + Linked Data Protocol 1.0, section 8.1 [W3C.REC-ldp-20150226].

    +

    + In HTTP, such links can be attached to any response using the + Link header [RFC8288]. An example of such a header would be:

    +
    +
    +
    +        Link: <https://example.com/my-hyper-schema>; rel="describedby"
    +
    +
    +
    +
    +
    +
    +9.5.1.2. Usage Over HTTP +
    +

    + When used for hypermedia systems over a network, + HTTP [RFC7231] is frequently the protocol of choice for + distributing schemas. Misbehaving clients can pose problems for server + maintainers if they pull a schema over the network more frequently than + necessary, when it's instead possible to cache a schema for a long period of + time.

    +

    + HTTP servers SHOULD set long-lived caching headers on JSON Schemas. + HTTP clients SHOULD observe caching headers and not re-request documents within + their freshness period. + Distributed systems SHOULD make use of a shared cache and/or caching proxy.

    +

    + Clients SHOULD set or prepend a User-Agent header specific to the JSON Schema + implementation or software product. Since symbols are listed in decreasing order + of significance, the JSON Schema library name/version should precede the more + generic HTTP library name (if any). For example:

    +
    +
    +
    +        User-Agent: product-name/5.4.1 so-cool-json-schema/1.0.2 curl/7.43.0
    +
    +
    +
    +

    + Clients SHOULD be able to make requests with a "From" header so that server + operators can contact the owner of a potentially misbehaving script.

    +
    +
    +
    +
    +
    +
    +

    +10. A Vocabulary for Applying Subschemas +

    +

    + This section defines a vocabulary of applicator keywords that + are RECOMMENDED for use as the basis of other vocabularies.

    +

    + Meta-schemas that do not use "$vocabulary" SHOULD be considered to + require this vocabulary as if its URI were present with a value of true.

    +

    + The current URI for this vocabulary, known as the Applicator vocabulary, is: + <https://json-schema.org/draft/2020-12/vocab/applicator>.

    +

    + The current URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/applicator.

    +
    +

    +10.1. Keyword Independence +

    +

    + Schema keywords typically operate independently, without + affecting each other's outcomes.

    +

    + For schema author convenience, there are some exceptions among the + keywords in this vocabulary:

    +
      +
    • + "additionalProperties", whose behavior is defined in terms of + "properties" and "patternProperties" +
    • +
    • + "items", whose behavior is defined in terms of "prefixItems" +
    • +
    • + "contains", whose behavior is affected by the presence and value of + "minContains", in the Validation vocabulary +
    • +
    +
    +
    +
    +

    +10.2. Keywords for Applying Subschemas in Place +

    +

    + These keywords apply subschemas to the same location in the instance + as the parent schema is being applied. They allow combining + or modifying the subschema results in various ways.

    +

    + Subschemas of these keywords evaluate the instance completely independently + such that the results of one such subschema MUST NOT impact the results of sibling + subschemas. Therefore subschemas may be applied in + any order.

    +
    +
    +

    +10.2.1. Keywords for Applying Subschemas With Logic +

    +

    + These keywords correspond to logical operators for combining or modifying + the boolean assertion results of the subschemas. They have no direct + impact on annotation collection, although they enable the same annotation + keyword to be applied to an instance location with different values. + Annotation keywords define their own rules for combining such values.

    +
    +
    +
    +10.2.1.1. allOf +
    +

    + This keyword's value MUST be a non-empty array. + Each item of the array MUST be a valid JSON Schema.

    +

    + An instance validates successfully against this keyword if it validates + successfully against all schemas defined by this keyword's value.

    +
    +
    +
    +
    +10.2.1.2. anyOf +
    +

    + This keyword's value MUST be a non-empty array. + Each item of the array MUST be a valid JSON Schema.

    +

    + An instance validates successfully against this keyword if it validates + successfully against at least one schema defined by this keyword's value. + Note that when annotations are being collected, all subschemas MUST + be examined so that annotations are collected from each subschema + that validates successfully.

    +
    +
    +
    +10.2.1.3. oneOf +
    +

    + This keyword's value MUST be a non-empty array. + Each item of the array MUST be a valid JSON Schema.

    +

    + An instance validates successfully against this keyword if it validates + successfully against exactly one schema defined by this keyword's value.

    +
    +
    +
    +
    +10.2.1.4. not +
    +

    + This keyword's value MUST be a valid JSON Schema.

    +

    + An instance is valid against this keyword if it fails to validate + successfully against the schema defined by this keyword.

    +
    +
    +
    +
    +
    +
    +

    +10.2.2. Keywords for Applying Subschemas Conditionally +

    +

    + Three of these keywords work together to implement conditional + application of a subschema based on the outcome of another subschema. + The fourth is a shortcut for a specific conditional case.

    +

    + "if", "then", and "else" MUST NOT interact with each other across + subschema boundaries. In other words, an "if" in one + branch of an "allOf" MUST NOT have an impact on a "then" + or "else" in another branch.

    +

    + There is no default behavior for "if", "then", or "else" + when they are not present. In particular, they MUST NOT + be treated as if present with an empty schema, and when + "if" is not present, both "then" and "else" MUST be + entirely ignored.

    +
    +
    +10.2.2.1. if +
    +

    + This keyword's value MUST be a valid JSON Schema.

    +

    + This validation outcome of this keyword's subschema + has no direct effect on the overall validation + result. Rather, it controls which of the "then" + or "else" keywords are evaluated.

    +

    + Instances that successfully validate against this + keyword's subschema MUST also be valid against + the subschema value of the "then" keyword, if + present.

    +

    + Instances that fail to validate against this + keyword's subschema MUST also be valid against + the subschema value of the "else" keyword, if + present.

    +

    + If annotations (Section 7.7) + are being collected, they are collected from this + keyword's subschema in the usual way, including when + the keyword is present without either "then" or "else".

    +
    +
    +
    +10.2.2.2. then +
    +

    + This keyword's value MUST be a valid JSON Schema.

    +

    + When "if" is present, and the instance successfully + validates against its subschema, then validation + succeeds against this keyword if the instance also + successfully validates against this keyword's subschema.

    +

    + This keyword has no effect when "if" is absent, or + when the instance fails to validate against its + subschema. Implementations MUST NOT evaluate + the instance against this keyword, for either validation + or annotation collection purposes, in such cases.

    +
    +
    +
    +10.2.2.3. else +
    +

    + This keyword's value MUST be a valid JSON Schema.

    +

    + When "if" is present, and the instance fails to + validate against its subschema, then validation + succeeds against this keyword if the instance + successfully validates against this keyword's subschema.

    +

    + This keyword has no effect when "if" is absent, or + when the instance successfully validates against its + subschema. Implementations MUST NOT evaluate + the instance against this keyword, for either validation + or annotation collection purposes, in such cases.

    +
    +
    +
    +10.2.2.4. dependentSchemas +
    +

    + This keyword specifies subschemas that are evaluated if the instance + is an object and contains a certain property.

    +

    + This keyword's value MUST be an object. + Each value in the object MUST be a valid JSON Schema.

    +

    + If the object key is a property in the instance, the entire + instance must validate against the subschema. Its use is + dependent on the presence of the property.

    +

    + Omitting this keyword has the same behavior as an empty object.

    +
    +
    +
    +
    +
    +
    +

    +10.3. Keywords for Applying Subschemas to Child Instances +

    +

    + Each of these keywords defines a rule for applying its + subschema(s) to child instances, specifically object + properties and array items, and combining their results.

    +
    +

    +10.3.1. Keywords for Applying Subschemas to Arrays +

    +
    +
    +10.3.1.1. prefixItems +
    +

    + The value of "prefixItems" MUST be a non-empty array of valid JSON Schemas.

    +

    + Validation succeeds if each element of the instance validates + against the schema at the same position, if any. This keyword + does not constrain the length of the array. If the array is longer + than this keyword's value, this keyword validates only the + prefix of matching length.

    +

    + This keyword produces an annotation value which is the largest + index to which this keyword applied a subschema. The value + MAY be a boolean true if a subschema was applied to every + index of the instance, such as is produced by the "items" keyword. + This annotation affects the behavior of "items" and "unevaluatedItems".

    +

    + Omitting this keyword has the same assertion behavior as + an empty array.

    +
    +
    +
    +
    +10.3.1.2. items +
    +

    + The value of "items" MUST be a valid JSON Schema.

    +

    + This keyword applies its subschema to all instance elements + at indexes greater than the length of the "prefixItems" array + in the same schema object, as reported by the annotation result + of that "prefixItems" keyword. If no such annotation + result exists, "items" applies its subschema to all instance + array elements. + + Note that the behavior of "items" without "prefixItems" is + identical to that of the schema form of "items" in prior drafts. + When "prefixItems" is present, the behavior of "items" is + identical to the former "additionalItems" keyword. +

    +

    + If the "items" subschema is applied to any + positions within the instance array, it produces an + annotation result of boolean true, indicating that all remaining array + elements have been evaluated against this keyword's subschema. + This annotation affects the behavior of "unevaluatedItems" in the + Unevaluated vocabulary.

    +

    + Omitting this keyword has the same assertion behavior as + an empty schema.

    +

    + Implementations MAY choose to implement or optimize this keyword + in another way that produces the same effect, such as by directly + checking for the presence and size of a "prefixItems" array. + Implementations that do not support annotation collection MUST do so.

    +
    +
    +
    +
    +10.3.1.3. contains +
    +

    + The value of this keyword MUST be a valid JSON Schema.

    +

    + An array instance is valid against "contains" if at least one of + its elements is valid against the given schema, + except when "minContains" is present and has a value of 0, in which + case an array instance MUST be considered valid against the "contains" keyword, + even if none of its elements is valid against the given schema.

    +

    + This keyword produces an annotation value which is an array of + the indexes to which this keyword validates successfully when applying + its subschema, in ascending order. The value MAY be a boolean "true" if + the subschema validates successfully when applied to every index of the + instance. The annotation MUST be present if the instance array to which + this keyword's schema applies is empty.

    +

    + This annotation affects the behavior of "unevaluatedItems" in the + Unevaluated vocabulary, and MAY also be used to implement the + "minContains" and "maxContains" keywords in the Validation vocabulary.

    +

    + The subschema MUST be applied to every array element even after the first + match has been found, in order to collect annotations for use by other + keywords. This is to ensure that all possible annotations are collected.

    +
    +
    +
    +

    +10.3.2. Keywords for Applying Subschemas to Objects +

    +
    +
    +10.3.2.1. properties +
    +

    + The value of "properties" MUST be an object. + Each value of this object MUST be a valid JSON Schema.

    +

    + Validation succeeds if, for each name that appears in both + the instance and as a name within this keyword's value, the child + instance for that name successfully validates against the + corresponding schema.

    +

    + The annotation result of this keyword is the set of instance + property names matched by this keyword. + This annotation affects the behavior of "additionalProperties" (in + this vocabulary) and "unevaluatedProperties" in the Unevaluated vocabulary.

    +

    + Omitting this keyword has the same assertion behavior as + an empty object.

    +
    +
    +
    +10.3.2.2. patternProperties +
    +

    + The value of "patternProperties" MUST be an object. Each property name + of this object SHOULD be a valid regular expression, according to the + ECMA-262 regular expression dialect. Each property value of this object + MUST be a valid JSON Schema.

    +

    + Validation succeeds if, for each instance name that matches any + regular expressions that appear as a property name in this keyword's value, + the child instance for that name successfully validates against each + schema that corresponds to a matching regular expression.

    +

    + The annotation result of this keyword is the set of instance + property names matched by this keyword. + This annotation affects the behavior of "additionalProperties" (in this + vocabulary) and "unevaluatedProperties" (in the Unevaluated vocabulary).

    +

    + Omitting this keyword has the same assertion behavior as + an empty object.

    +
    +
    +
    +
    +10.3.2.3. additionalProperties +
    +

    + The value of "additionalProperties" MUST be a valid JSON Schema.

    +

    + The behavior of this keyword depends on the presence and + annotation results of "properties" and "patternProperties" + within the same schema object. + Validation with "additionalProperties" applies only to the child + values of instance names that do not appear in the annotation + results of either "properties" or "patternProperties".

    +

    + For all such properties, validation succeeds if the child instance + validates against the "additionalProperties" schema.

    +

    + The annotation result of this keyword is the set of instance + property names validated by this keyword's subschema. + This annotation affects the behavior of "unevaluatedProperties" + in the Unevaluated vocabulary.

    +

    + Omitting this keyword has the same assertion behavior as + an empty schema.

    +

    + Implementations MAY choose to implement or optimize this keyword + in another way that produces the same effect, such as by directly + checking the names in "properties" and the patterns in + "patternProperties" against the instance property set. + Implementations that do not support annotation collection MUST do so. + + In defining this option, it seems there is the potential for + ambiguity in the output format. The ambiguity does not affect validation results, + but it does affect the resulting output format. + The ambiguity allows for multiple valid output results depending on whether annotations + are used or a solution that "produces the same effect" as draft-07. It is understood + that annotations from failing schemas are dropped. + See our + [Decision Record](https://github.com/json-schema-org/json-schema-spec/tree/HEAD/adr/2022-04-08-cref-for-ambiguity-and-fix-later-gh-spec-issue-1172.md) + for further details. +

    +
    +
    +
    +
    +10.3.2.4. propertyNames +
    +

    + The value of "propertyNames" MUST be a valid JSON Schema.

    +

    + If the instance is an object, this keyword validates if every property name in + the instance validates against the provided schema. + Note the property name that the schema is testing will always be a string.

    +

    + Omitting this keyword has the same behavior as an empty schema.

    +
    +
    +
    +
    +
    +

    +11. A Vocabulary for Unevaluated Locations +

    +

    + The purpose of these keywords is to enable schema authors to apply + subschemas to array items or object properties that have not been + successfully evaluated against any dynamic-scope subschema of any + adjacent keywords.

    +

    + These instance items or properties may have been unsuccessfully evaluated + against one or more adjacent keyword subschemas, such as when an assertion + in a branch of an "anyOf" fails. Such failed evaluations are not considered + to contribute to whether or not the item or property has been evaluated. + Only successful evaluations are considered.

    +

    + If an item in an array or an object property is "successfully evaluated", it + is logically considered to be valid in terms of the representation of the + object or array that's expected. For example if a subschema represents a car, + which requires between 2-4 wheels, and the value of "wheels" is 6, the instance + object is not "evaluated" to be a car, and the "wheels" property is considered + "unevaluated (successfully as a known thing)", and does not retain any annotations.

    +

    + Recall that adjacent keywords are keywords within the same schema object, + and that the dynamic-scope subschemas include reference targets as well as + lexical subschemas.

    +

    + The behavior of these keywords depend on the annotation results of + adjacent keywords that apply to the instance location being validated.

    +

    + Meta-schemas that do not use "$vocabulary" SHOULD be considered to + require this vocabulary as if its URI were present with a value of true.

    +

    + The current URI for this vocabulary, known as the Unevaluated Applicator + vocabulary, is: + <https://json-schema.org/draft/2020-12/vocab/unevaluated>.

    +

    + The current URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/unevaluated.

    +
    +

    +11.1. Keyword Independence +

    +

    + Schema keywords typically operate independently, without + affecting each other's outcomes. However, the keywords in this + vocabulary are notable exceptions:

    +
      +
    • + "unevaluatedItems", whose behavior is defined in terms of annotations + from "prefixItems", "items", "contains", and itself +
    • +
    • + "unevaluatedProperties", whose behavior is defined in terms of + annotations from "properties", "patternProperties", + "additionalProperties" and itself +
    • +
    +
    +
    +
    +

    +11.2. unevaluatedItems +

    +

    + The value of "unevaluatedItems" MUST be a valid JSON Schema.

    +

    + The behavior of this keyword depends on the annotation results of + adjacent keywords that apply to the instance location being validated. + Specifically, the annotations from "prefixItems", "items", and "contains", + which can come from those keywords when they are adjacent to the + "unevaluatedItems" keyword. Those three annotations, as well as + "unevaluatedItems", can also result from any and all adjacent + in-place applicator (Section 10.2) keywords. + This includes but is not limited to the in-place applicators + defined in this document.

    +

    + If no relevant annotations are present, the "unevaluatedItems" + subschema MUST be applied to all locations in the array. + If a boolean true value is present from any of the relevant annotations, + "unevaluatedItems" MUST be ignored. Otherwise, the subschema + MUST be applied to any index greater than the largest annotation + value for "prefixItems", which does not appear in any annotation + value for "contains".

    +

    + This means that "prefixItems", "items", "contains", and all in-place + applicators MUST be evaluated before this keyword can be evaluated. + Authors of extension keywords MUST NOT define an in-place applicator + that would need to be evaluated after this keyword.

    +

    + If the "unevaluatedItems" subschema is applied to any + positions within the instance array, it produces an + annotation result of boolean true, analogous to the + behavior of "items". + This annotation affects the behavior of "unevaluatedItems" in parent schemas.

    +

    + Omitting this keyword has the same assertion behavior as + an empty schema.

    +
    +
    +
    +
    +

    +11.3. unevaluatedProperties +

    +

    + The value of "unevaluatedProperties" MUST be a valid JSON Schema.

    +

    + The behavior of this keyword depends on the annotation results of + adjacent keywords that apply to the instance location being validated. + Specifically, the annotations from "properties", "patternProperties", + and "additionalProperties", which can come from those keywords when + they are adjacent to the "unevaluatedProperties" keyword. Those + three annotations, as well as "unevaluatedProperties", can also + result from any and all adjacent + in-place applicator (Section 10.2) keywords. + This includes but is not limited to the in-place applicators + defined in this document.

    +

    + Validation with "unevaluatedProperties" applies only to the child + values of instance names that do not appear in the "properties", + "patternProperties", "additionalProperties", or + "unevaluatedProperties" annotation results that apply to the + instance location being validated.

    +

    + For all such properties, validation succeeds if the child instance + validates against the "unevaluatedProperties" schema.

    +

    + This means that "properties", "patternProperties", "additionalProperties", + and all in-place applicators MUST be evaluated before this keyword can + be evaluated. Authors of extension keywords MUST NOT define an in-place + applicator that would need to be evaluated after this keyword.

    +

    + The annotation result of this keyword is the set of instance + property names validated by this keyword's subschema. + This annotation affects the behavior of "unevaluatedProperties" in parent schemas.

    +

    + Omitting this keyword has the same assertion behavior as + an empty schema.

    +
    +
    +
    +
    +
    +

    +12. Output Formatting +

    +

    + JSON Schema is defined to be platform-independent. As such, to increase compatibility + across platforms, implementations SHOULD conform to a standard validation output + format. This section describes the minimum requirements that consumers will need to + properly interpret validation results.

    +
    +

    +12.1. Format +

    +

    + JSON Schema output is defined using the JSON Schema data instance model as described + in section 4.2.1. Implementations MAY deviate from this as supported by their + specific languages and platforms, however it is RECOMMENDED that the output be + convertible to the JSON format defined herein via serialization or other means.

    +
    +
    +

    +12.2. Output Formats +

    +

    + This specification defines four output formats. See the "Output Structure" + section for the requirements of each format.

    +
      +
    • + Flag - A boolean which simply indicates the overall validation result + with no further details. +
    • +
    • + Basic - Provides validation information in a flat list structure. +
    • +
    • + Detailed - Provides validation information in a condensed hierarchical + structure based on the structure of the schema. +
    • +
    • + Verbose - Provides validation information in an uncondensed hierarchical + structure that matches the exact structure of the schema. +
    • +
    +

    + An implementation SHOULD provide at least one of the "flag", "basic", or "detailed" + format and MAY provide the "verbose" format. If it provides one or more of the + "detailed" or "verbose" formats, it MUST also provide the "flag" format. + Implementations SHOULD specify in their documentation which formats they support.

    +
    +
    +

    +12.3. Minimum Information +

    +

    + Beyond the simplistic "flag" output, additional information is useful to aid in + debugging a schema or instance. Each sub-result SHOULD contain the information + contained within this section at a minimum.

    +

    + A single object that contains all of these components is considered an + output unit.

    +

    + Implementations MAY elect to provide additional information.

    +
    +

    +12.3.1. Keyword Relative Location +

    +

    + The relative location of the validating keyword that follows the validation + path. The value MUST be expressed as a JSON Pointer, and it MUST include + any by-reference applicators such as "$ref" or "$dynamicRef".

    +
    +
    +
    +/properties/width/$ref/minimum
    +
    +
    +
    +

    + Note that this pointer may not be resolvable by the normal JSON Pointer process + due to the inclusion of these by-reference applicator keywords.

    +

    + The JSON key for this information is "keywordLocation".

    +
    +
    +

    +12.3.2. Keyword Absolute Location +

    +

    + The absolute, dereferenced location of the validating keyword. The value MUST + be expressed as a full URI using the canonical URI of the relevant schema resource + with a JSON Pointer fragment, and it MUST NOT include by-reference applicators + such as "$ref" or "$dynamicRef" as non-terminal path components. + It MAY end in such keywords if the error or annotation is for that + keyword, such as an unresolvable reference. + + Note that "absolute" here is in the sense of "absolute filesystem path" + (meaning the complete location) rather than the "absolute-URI" + terminology from RFC 3986 (meaning with scheme but without fragment). + Keyword absolute locations will have a fragment in order to + identify the keyword. +

    +
    +
    +
    +https://example.com/schemas/common#/$defs/count/minimum
    +
    +
    +
    +

    + This information MAY be omitted only if either the dynamic scope did not pass + over a reference or if the schema does not declare an absolute URI as its "$id".

    +

    + The JSON key for this information is "absoluteKeywordLocation".

    +
    +
    +

    +12.3.3. Instance Location +

    +

    + The location of the JSON value within the instance being validated. The + value MUST be expressed as a JSON Pointer.

    +

    + The JSON key for this information is "instanceLocation".

    +
    +
    +

    +12.3.4. Error or Annotation +

    +

    + The error or annotation that is produced by the validation.

    +

    + For errors, the specific wording for the message is not defined by this + specification. Implementations will need to provide this.

    +

    + For annotations, each keyword that produces an annotation specifies its + format. By default, it is the keyword's value.

    +

    + The JSON key for failed validations is "error"; for successful validations + it is "annotation".

    +
    +
    +

    +12.3.5. Nested Results +

    +

    + For the two hierarchical structures, this property will hold nested errors + and annotations.

    +

    + The JSON key for nested results in failed validations is "errors"; for + successful validations it is "annotations". Note the plural forms, as + a keyword with nested results can also have a local error or annotation.

    +
    +
    +
    +

    +12.4. Output Structure +

    +

    + The output MUST be an object containing a boolean property named "valid". When + additional information about the result is required, the output MUST also contain + "errors" or "annotations" as described below.

    +
      +
    • + "valid" - a boolean value indicating the overall validation success or + failure +
    • +
    • + "errors" - the collection of errors or annotations produced by a failed + validation +
    • +
    • + "annotations" - the collection of errors or annotations produced by a + successful validation +
    • +
    +

    + For these examples, the following schema and instance will be used.

    +
    +
    +
    +{
    +  "$id": "https://example.com/polygon",
    +  "$schema": "https://json-schema.org/draft/2020-12/schema",
    +  "$defs": {
    +    "point": {
    +      "type": "object",
    +      "properties": {
    +        "x": { "type": "number" },
    +        "y": { "type": "number" }
    +      },
    +      "additionalProperties": false,
    +      "required": [ "x", "y" ]
    +    }
    +  },
    +  "type": "array",
    +  "items": { "$ref": "#/$defs/point" },
    +  "minItems": 3
    +}
    +
    +[
    +  {
    +    "x": 2.5,
    +    "y": 1.3
    +  },
    +  {
    +    "x": 1,
    +    "z": 6.7
    +  }
    +]
    +
    +
    +
    +

    + This instance will fail validation and produce errors, but it's trivial to deduce + examples for passing schemas that produce annotations.

    +

    + Specifically, the errors it will produce are:

    +
      +
    • + The second object is missing a "y" property. +
    • +
    • + The second object has a disallowed "z" property. +
    • +
    • + There are only two objects, but three are required. +
    • +
    +

    + Note that the error message wording as depicted in these examples is not a + requirement of this specification. Implementations SHOULD craft error messages + tailored for their audience or provide a templating mechanism that allows their + users to craft their own messages.

    +
    +

    +12.4.1. Flag +

    +

    + In the simplest case, merely the boolean result for the "valid" valid property + needs to be fulfilled.

    +
    +
    +
    +{
    +  "valid": false
    +}
    +
    +
    +
    +

    + Because no errors or annotations are returned with this format, it is + RECOMMENDED that implementations use short-circuiting logic to return + failure or success as soon as the outcome can be determined. For example, + if an "anyOf" keyword contains five sub-schemas, and the second one + passes, there is no need to check the other three. The logic can simply + return with success.

    +
    +
    +

    +12.4.2. Basic +

    +

    + The "Basic" structure is a flat list of output units.

    +
    +
    +
    +{
    +  "valid": false,
    +  "errors": [
    +    {
    +      "keywordLocation": "",
    +      "instanceLocation": "",
    +      "error": "A subschema had errors."
    +    },
    +    {
    +      "keywordLocation": "/items/$ref",
    +      "absoluteKeywordLocation":
    +        "https://example.com/polygon#/$defs/point",
    +      "instanceLocation": "/1",
    +      "error": "A subschema had errors."
    +    },
    +    {
    +      "keywordLocation": "/items/$ref/required",
    +      "absoluteKeywordLocation":
    +        "https://example.com/polygon#/$defs/point/required",
    +      "instanceLocation": "/1",
    +      "error": "Required property 'y' not found."
    +    },
    +    {
    +      "keywordLocation": "/items/$ref/additionalProperties",
    +      "absoluteKeywordLocation":
    +        "https://example.com/polygon#/$defs/point/additionalProperties",
    +      "instanceLocation": "/1/z",
    +      "error": "Additional property 'z' found but was invalid."
    +    },
    +    {
    +      "keywordLocation": "/minItems",
    +      "instanceLocation": "",
    +      "error": "Expected at least 3 items but found 2"
    +    }
    +  ]
    +}
    +
    +
    +
    +
    +
    +

    +12.4.3. Detailed +

    +

    + The "Detailed" structure is based on the schema and can be more readable + for both humans and machines. Having the structure organized this way makes + associations between the errors more apparent. For example, the fact that + the missing "y" property and the extra "z" property both stem from the same + location in the instance is not immediately obvious in the "Basic" structure. + In a hierarchy, the correlation is more easily identified.

    +

    + The following rules govern the construction of the results object:

    +
      +
    • + All applicator keywords ("*Of", "$ref", "if"/"then"/"else", etc.) require + a node. +
    • +
    • + Nodes that have no children are removed. +
    • +
    • + Nodes that have a single child are replaced by the child. +
    • +
    +

    + Branch nodes do not require an error message or an annotation.

    +
    +
    +
    +{
    +  "valid": false,
    +  "keywordLocation": "",
    +  "instanceLocation": "",
    +  "errors": [
    +    {
    +      "valid": false,
    +      "keywordLocation": "/items/$ref",
    +      "absoluteKeywordLocation":
    +        "https://example.com/polygon#/$defs/point",
    +      "instanceLocation": "/1",
    +      "errors": [
    +        {
    +          "valid": false,
    +          "keywordLocation": "/items/$ref/required",
    +          "absoluteKeywordLocation":
    +            "https://example.com/polygon#/$defs/point/required",
    +          "instanceLocation": "/1",
    +          "error": "Required property 'y' not found."
    +        },
    +        {
    +          "valid": false,
    +          "keywordLocation": "/items/$ref/additionalProperties",
    +          "absoluteKeywordLocation":
    +            "https://example.com/polygon#/$defs/point/additionalProperties",
    +          "instanceLocation": "/1/z",
    +          "error": "Additional property 'z' found but was invalid."
    +        }
    +      ]
    +    },
    +    {
    +      "valid": false,
    +      "keywordLocation": "/minItems",
    +      "instanceLocation": "",
    +      "error": "Expected at least 3 items but found 2"
    +    }
    +  ]
    +}
    +
    +
    +
    +
    +
    +

    +12.4.4. Verbose +

    +

    + The "Verbose" structure is a fully realized hierarchy that exactly matches + that of the schema. This structure has applications in form generation and + validation where the error's location is important.

    +

    + The primary difference between this and the "Detailed" structure is that + all results are returned. This includes sub-schema validation results that + would otherwise be removed (e.g. annotations for failed validations, + successful validations inside a `not` keyword, etc.). Because of this, it + is RECOMMENDED that each node also carry a `valid` property to indicate the + validation result for that node.

    +

    + Because this output structure can be quite large, a smaller example is given + here for brevity. The URI of the full output structure of the example above is: + https://json-schema.org/draft/2020-12/output/verbose-example.

    +
    +
    +
    +// schema
    +{
    +  "$id": "https://example.com/polygon",
    +  "$schema": "https://json-schema.org/draft/2020-12/schema",
    +  "type": "object",
    +  "properties": {
    +    "validProp": true,
    +  },
    +  "additionalProperties": false
    +}
    +
    +// instance
    +{
    +  "validProp": 5,
    +  "disallowedProp": "value"
    +}
    +
    +// result
    +{
    +  "valid": false,
    +  "keywordLocation": "",
    +  "instanceLocation": "",
    +  "errors": [
    +    {
    +      "valid": true,
    +      "keywordLocation": "/type",
    +      "instanceLocation": ""
    +    },
    +    {
    +      "valid": true,
    +      "keywordLocation": "/properties",
    +      "instanceLocation": ""
    +    },
    +    {
    +      "valid": false,
    +      "keywordLocation": "/additionalProperties",
    +      "instanceLocation": "",
    +      "errors": [
    +        {
    +          "valid": false,
    +          "keywordLocation": "/additionalProperties",
    +          "instanceLocation": "/disallowedProp",
    +          "error": "Additional property 'disallowedProp' found but was invalid."
    +        }
    +      ]
    +    }
    +  ]
    +}
    +
    +
    +
    +
    +
    +

    +12.4.5. Output validation schemas +

    +

    + For convenience, JSON Schema has been provided to validate output generated + by implementations. Its URI is: + https://json-schema.org/draft/2020-12/output/schema.

    +
    +
    +
    +
    +
    +
    +

    +13. Security Considerations +

    +

    + Both schemas and instances are JSON values. As such, all security considerations + defined in RFC 8259 [RFC8259] apply.

    +

    + Instances and schemas are both frequently written by untrusted third parties, to be + deployed on public Internet servers. + Validators should take care that the parsing and validating against schemas does not consume excessive + system resources. + Validators MUST NOT fall into an infinite loop.

    +

    + A malicious party could cause an implementation to repeatedly collect a copy + of a very large value as an annotation. Implementations SHOULD guard against + excessive consumption of system resources in such a scenario.

    +

    + Servers MUST ensure that malicious parties cannot change the functionality of + existing schemas by uploading a schema with a pre-existing or very similar "$id".

    +

    + Individual JSON Schema vocabularies are liable to also have their own security + considerations. Consult the respective specifications for more information.

    +

    + Schema authors should take care with "$comment" contents, as a malicious + implementation can display them to end-users in violation of a spec, or + fail to strip them if such behavior is expected.

    +

    + A malicious schema author could place executable code or other dangerous + material within a "$comment". Implementations MUST NOT parse or otherwise + take action based on "$comment" contents.

    +
    +
    +
    +

    +14. IANA Considerations +

    +
    +

    +14.1. application/schema+json +

    +

    + The proposed MIME media type for JSON Schema is defined as follows:

    +
      +
    • Type name: application +
    • +
    • Subtype name: schema+json +
    • +
    • Required parameters: N/A +
    • +
    • + Encoding considerations: Encoding considerations are + identical to those specified for the "application/json" + media type. See JSON [RFC8259]. +
    • +
    • + Security considerations: See Section + 13 above. +
    • +
    • + Interoperability considerations: See Sections + 6.2, + 6.3, and + 6.4 above. +
    • +
    • + Fragment identifier considerations: See Section + 5 +
    • +
    +
    +
    +

    +14.2. application/schema-instance+json +

    +

    + The proposed MIME media type for JSON Schema Instances that require + a JSON Schema-specific media type is defined as follows:

    +
      +
    • Type name: application +
    • +
    • Subtype name: schema-instance+json +
    • +
    • Required parameters: N/A +
    • +
    • + Encoding considerations: Encoding considerations are + identical to those specified for the "application/json" + media type. See JSON [RFC8259]. +
    • +
    • + Security considerations: See Section + 13 above. +
    • +
    • + Interoperability considerations: See Sections + 6.2, + 6.3, and + 6.4 above. +
    • +
    • + Fragment identifier considerations: See Section + 5 +
    • +
    +
    +
    +
    +

    +15. References +

    +
    +

    +15.1. Normative References +

    +
    +
    [RFC2119]
    +
    +Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://www.rfc-editor.org/info/rfc2119>.
    +
    +
    [RFC3986]
    +
    +Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, , <https://www.rfc-editor.org/info/rfc3986>.
    +
    +
    [RFC6839]
    +
    +Hansen, T. and A. Melnikov, "Additional Media Type Structured Syntax Suffixes", RFC 6839, DOI 10.17487/RFC6839, , <https://www.rfc-editor.org/info/rfc6839>.
    +
    +
    [RFC6901]
    +
    +Bryan, P., Ed., Zyp, K., and M. Nottingham, Ed., "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, , <https://www.rfc-editor.org/info/rfc6901>.
    +
    +
    [RFC8259]
    +
    +Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, , <https://www.rfc-editor.org/info/rfc8259>.
    +
    +
    [W3C.REC-ldp-20150226]
    +
    +Speicher, S., Arwe, J., and A. Malhotra, "Linked Data Platform 1.0", World Wide Web Consortium Recommendation REC-ldp-20150226, , <https://www.w3.org/TR/2015/REC-ldp-20150226>.
    +
    +
    [ecma262]
    +
    +"ECMA-262, 11th edition specification", , <https://www.ecma-international.org/ecma-262/11.0/index.html>.
    +
    +
    +
    +
    +

    +15.2. Informative References +

    +
    +
    [RFC6596]
    +
    +Ohye, M. and J. Kupke, "The Canonical Link Relation", RFC 6596, DOI 10.17487/RFC6596, , <https://www.rfc-editor.org/info/rfc6596>.
    +
    +
    [RFC7049]
    +
    +Bormann, C. and P. Hoffman, "Concise Binary Object Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, , <https://www.rfc-editor.org/info/rfc7049>.
    +
    +
    [RFC7231]
    +
    +Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content", RFC 7231, DOI 10.17487/RFC7231, , <https://www.rfc-editor.org/info/rfc7231>.
    +
    +
    [RFC8288]
    +
    +Nottingham, M., "Web Linking", RFC 8288, DOI 10.17487/RFC8288, , <https://www.rfc-editor.org/info/rfc8288>.
    +
    +
    [W3C.WD-fragid-best-practices-20121025]
    +
    +Tennison, J., "Best Practices for Fragment Identifiers and Media Type Definitions", World Wide Web Consortium WD WD-fragid-best-practices-20121025, , <https://www.w3.org/TR/2012/WD-fragid-best-practices-20121025>.
    +
    +
    [json-schema-validation]
    +
    +Wright, A., Andrews, H., and B. Hutton, "JSON Schema Validation: A Vocabulary for Structural Validation of JSON", Work in Progress, Internet-Draft, draft-bhutton-json-schema-validation-01, , <https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-01>.
    +
    +
    [json-hyper-schema]
    +
    +Andrews, H. and A. Wright, "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON", Work in Progress, Internet-Draft, draft-handrews-json-schema-hyperschema-02, , <https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-hyperschema-02>.
    +
    +
    [xml-names]
    +
    +Bray, T., Ed., Hollander, D., Ed., Layman, A., Ed., and R. Tobin, Ed., "Namespaces in XML 1.1 (Second Edition)", , <http://www.w3.org/TR/2006/REC-xml-names11-20060816>.
    +
    +
    +
    +
    +
    +
    +

    +Appendix A. Schema identification examples +

    +

    + Consider the following schema, which shows "$id" being used to identify + both the root schema and various subschemas, and "$anchor" being used + to define plain name fragment identifiers.

    +
    +
    +
    +{
    +    "$id": "https://example.com/root.json",
    +    "$defs": {
    +        "A": { "$anchor": "foo" },
    +        "B": {
    +            "$id": "other.json",
    +            "$defs": {
    +                "X": { "$anchor": "bar" },
    +                "Y": {
    +                    "$id": "t/inner.json",
    +                    "$anchor": "bar"
    +                }
    +            }
    +        },
    +        "C": {
    +            "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f"
    +        }
    +    }
    +}
    +
    +
    +
    +

    + The schemas at the following URI-encoded JSON + Pointers [RFC6901] (relative to the root schema) have the following + base URIs, and are identifiable by any listed URI in accordance with + sections 5 and + 9.2.1 above.

    +
    +
    # (document root)
    +
    +
    +
    canonical (and base) URI
    +
    + https://example.com/root.json +
    +
    +
    canonical resource URI plus pointer fragment
    +
    + https://example.com/root.json# +
    +
    +
    +
    +
    +
    #/$defs/A
    +
    +
    +
    base URI
    +
    https://example.com/root.json +
    +
    +
    canonical resource URI plus plain fragment
    +
    + https://example.com/root.json#foo +
    +
    +
    canonical resource URI plus pointer fragment
    +
    + https://example.com/root.json#/$defs/A +
    +
    +
    +
    +
    +
    #/$defs/B
    +
    +
    +
    canonical (and base) URI
    +
    https://example.com/other.json +
    +
    +
    canonical resource URI plus pointer fragment
    +
    + https://example.com/other.json# +
    +
    +
    base URI of enclosing (root.json) resource plus fragment
    +
    + https://example.com/root.json#/$defs/B +
    +
    +
    +
    +
    +
    #/$defs/B/$defs/X
    +
    +
    +
    base URI
    +
    https://example.com/other.json +
    +
    +
    canonical resource URI plus plain fragment
    +
    + https://example.com/other.json#bar +
    +
    +
    canonical resource URI plus pointer fragment
    +
    + https://example.com/other.json#/$defs/X +
    +
    +
    base URI of enclosing (root.json) resource plus fragment
    +
    + https://example.com/root.json#/$defs/B/$defs/X +
    +
    +
    +
    +
    +
    #/$defs/B/$defs/Y
    +
    +
    +
    canonical (and base) URI
    +
    https://example.com/t/inner.json +
    +
    +
    canonical URI plus plain fragment
    +
    + https://example.com/t/inner.json#bar +
    +
    +
    canonical URI plus pointer fragment
    +
    + https://example.com/t/inner.json# +
    +
    +
    base URI of enclosing (other.json) resource plus fragment
    +
    + https://example.com/other.json#/$defs/Y +
    +
    +
    base URI of enclosing (root.json) resource plus fragment
    +
    + https://example.com/root.json#/$defs/B/$defs/Y +
    +
    +
    +
    +
    +
    #/$defs/C
    +
    +
    +
    canonical (and base) URI
    +
    + urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f +
    +
    +
    canonical URI plus pointer fragment
    +
    + urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f# +
    +
    +
    base URI of enclosing (root.json) resource plus fragment
    +
    + https://example.com/root.json#/$defs/C +
    +
    +
    +
    +
    +
    +

    + Note: The fragment part of the URI does not make it canonical or non-canonical, + rather, the base URI used (as part of the full URI with any fragment) is what + determines the canonical nature of the resulting full URI. + + Multiple "canonical" URIs? We Acknowledge this is potentially confusing, and + direct you to read the CREF located in the + JSON Pointer fragments and embedded schema resources (Section 9.2.1) + section for futher comments. +

    +
    +
    +
    +

    +Appendix B. Manipulating schema documents and references +

    +

    + Various tools have been created to rearrange schema documents + based on how and where references ("$ref") appear. This appendix discusses + which use cases and actions are compliant with this specification.

    +
    +

    +B.1. Bundling schema resources into a single document +

    +

    + A set of schema resources intended for use together can be organized + with each in its own schema document, all in the same schema document, + or any granularity of document grouping in between.

    +

    + Numerous tools exist to perform various sorts of reference removal. + A common case of this is producing a single file where all references + can be resolved within that file. This is typically done to simplify + distribution, or to simplify coding so that various invocations + of JSON Schema libraries do not have to keep track of and load + a large number of resources.

    +

    + This transformation can be safely and reversibly done as long as + all static references (e.g. "$ref") use URI-references that resolve + to URIs using the canonical resource URI as the base, and all schema + resources have an absolute-URI as the "$id" in their root schema.

    +

    + With these conditions met, each external resource can be copied + under "$defs", without breaking any references among the resources' + schema objects, and without changing any aspect of validation or + annotation results. The names of the schemas under "$defs" do + not affect behavior, assuming they are each unique, as they + do not appear in the canonical URIs for the embedded resources.

    +
    +
    +

    +B.2. Reference removal is not always safe +

    +

    + Attempting to remove all references and produce a single schema document does not, + in all cases, produce a schema with identical behavior to the original form.

    +

    + Since "$ref" is now treated like any other keyword, with other keywords allowed + in the same schema objects, fully supporting non-recursive "$ref" removal in + all cases can require relatively complex schema manipulations. It is beyond + the scope of this specification to determine or provide a set of safe "$ref" + removal transformations, as they depend not only on the schema structure + but also on the intended usage.

    +
    +
    +
    +
    +

    +Appendix C. Example of recursive schema extension +

    +

    + Consider the following two schemas describing a simple + recursive tree structure, where each node in the tree + can have a "data" field of any type. The first schema + allows and ignores other instance properties. The second is + more strict and only allows the "data" and "children" properties. + An example instance with "data" misspelled as "daat" is also shown.

    +
    +
    +
    +// tree schema, extensible
    +{
    +    "$schema": "https://json-schema.org/draft/2020-12/schema",
    +    "$id": "https://example.com/tree",
    +    "$dynamicAnchor": "node",
    +
    +    "type": "object",
    +    "properties": {
    +        "data": true,
    +        "children": {
    +            "type": "array",
    +            "items": {
    +                "$dynamicRef": "#node"
    +            }
    +        }
    +    }
    +}
    +
    +// strict-tree schema, guards against misspelled properties
    +{
    +    "$schema": "https://json-schema.org/draft/2020-12/schema",
    +    "$id": "https://example.com/strict-tree",
    +    "$dynamicAnchor": "node",
    +
    +    "$ref": "tree",
    +    "unevaluatedProperties": false
    +}
    +
    +// instance with misspelled field
    +{
    +    "children": [ { "daat": 1 } ]
    +}
    +
    +
    +
    +

    + When we load these two schemas, we will notice the "$dynamicAnchor" + named "node" (note the lack of "#" as this is just the name) + present in each, resulting in the following full schema URIs:

    +
      +
    • "https://example.com/tree#node" +
    • +
    • "https://example.com/strict-tree#node" +
    • +
    +

    + In addition, JSON Schema implementations keep track of the fact + that these fragments were created with "$dynamicAnchor".

    +

    + If we apply the "strict-tree" schema to the instance, we will follow + the "$ref" to the "tree" schema, examine its "children" subschema, + and find the "$dynamicRef": to "#node" (note the "#" for URI fragment syntax) + in its "items" subschema. That reference resolves to + "https://example.com/tree#node", which is a URI with a fragment + created by "$dynamicAnchor". Therefore we must examine the dynamic + scope before following the reference.

    +

    + At this point, the dynamic path is + "#/$ref/properties/children/items/$dynamicRef", with a dynamic scope + containing (from the outermost scope to the innermost):

    +
      +
    1. "https://example.com/strict-tree#" +
    2. +
    3. "https://example.com/tree#" +
    4. +
    5. "https://example.com/tree#/properties/children" +
    6. +
    7. "https://example.com/tree#/properties/children/items" +
    8. +
    +

    + Since we are looking for a plain name fragment, which can be + defined anywhere within a schema resource, the JSON Pointer fragments + are irrelevant to this check. That means that we can remove those + fragments and eliminate consecutive duplicates, producing:

    +
      +
    1. "https://example.com/strict-tree" +
    2. +
    3. "https://example.com/tree" +
    4. +
    +

    + In this case, the outermost resource also has a "node" fragment + defined by "$dynamicAnchor". Therefore instead of resolving the + "$dynamicRef" to "https://example.com/tree#node", we resolve it to + "https://example.com/strict-tree#node".

    +

    + This way, the recursion in the "tree" schema recurses to the root + of "strict-tree", instead of only applying "strict-tree" to the + instance root, but applying "tree" to instance children.

    +

    + This example shows both "$dynamicAnchor"s in the same place + in each schema, specifically the resource root schema. + Since plain-name fragments are independent of the JSON structure, + this would work just as well if one or both of the node schema objects + were moved under "$defs". It is the matching "$dynamicAnchor" values + which tell us how to resolve the dynamic reference, not any sort of + correlation in JSON structure.

    +
    +
    +
    +

    +Appendix D. Working with vocabularies +

    +
    +

    +D.1. Best practices for vocabulary and meta-schema authors +

    +

    + Vocabulary authors should + take care to avoid keyword name collisions if the vocabulary is intended + for broad use, and potentially combined with other vocabularies. JSON + Schema does not provide any formal namespacing system, but also does + not constrain keyword names, allowing for any number of namespacing + approaches.

    +

    + Vocabularies may build on each other, such as by defining the behavior + of their keywords with respect to the behavior of keywords from another + vocabulary, or by using a keyword from another vocabulary with + a restricted or expanded set of acceptable values. Not all such + vocabulary re-use will result in a new vocabulary that is compatible + with the vocabulary on which it is built. Vocabulary authors should + clearly document what level of compatibility, if any, is expected.

    +

    + Meta-schema authors should not use "$vocabulary" to combine multiple + vocabularies that define conflicting syntax or semantics for the same + keyword. As semantic conflicts are not generally detectable through + schema validation, implementations are not expected to detect such + conflicts. If conflicting vocabularies are declared, the resulting + behavior is undefined.

    +

    + Vocabulary authors SHOULD provide a meta-schema that validates the + expected usage of the vocabulary's keywords on their own. Such meta-schemas + SHOULD not forbid additional keywords, and MUST not forbid any + keywords from the Core vocabulary.

    +

    + It is recommended that meta-schema authors reference each vocabulary's + meta-schema using the "allOf" (Section 10.2.1.1) keyword, + although other mechanisms for constructing the meta-schema may be + appropriate for certain use cases.

    +

    + The recursive nature of meta-schemas makes the "$dynamicAnchor" + and "$dynamicRef" keywords particularly useful for extending + existing meta-schemas, as can be seen in the JSON Hyper-Schema meta-schema + which extends the Validation meta-schema.

    +

    + Meta-schemas may impose additional constraints, including describing + keywords not present in any vocabulary, beyond what the meta-schemas + associated with the declared vocabularies describe. This allows for + restricting usage to a subset of a vocabulary, and for validating + locally defined keywords not intended for re-use.

    +

    + However, meta-schemas should not contradict any vocabularies that + they declare, such as by requiring a different JSON type than + the vocabulary expects. The resulting behavior is undefined.

    +

    + Meta-schemas intended for local use, with no need to test for + vocabulary support in arbitrary implementations, can safely omit + "$vocabulary" entirely.

    +
    +
    +
    +

    +D.2. Example meta-schema with vocabulary declarations +

    +

    + This meta-schema explicitly declares both the Core and Applicator vocabularies, + together with an extension vocabulary, and combines their meta-schemas with + an "allOf". The extension vocabulary's meta-schema, which describes only the + keywords in that vocabulary, is shown after the main example meta-schema.

    +

    + The main example meta-schema also restricts the usage of the Unevaluated + vocabulary by forbidding the keywords prefixed with "unevaluated", which + are particularly complex to implement. This does not change the semantics + or set of keywords defined by the other vocabularies. It just ensures + that schemas using this meta-schema that attempt to use the keywords + prefixed with "unevaluated" will fail validation against this meta-schema.

    +

    + Finally, this meta-schema describes the syntax of a keyword, "localKeyword", + that is not part of any vocabulary. Presumably, the implementors and users + of this meta-schema will understand the semantics of "localKeyword". + JSON Schema does not define any mechanism for expressing keyword semantics + outside of vocabularies, making them unsuitable for use except in a + specific environment in which they are understood.

    +

    + This meta-schema combines several vocabularies for general use.

    +
    +
    +
    +{
    +  "$schema": "https://json-schema.org/draft/2020-12/schema",
    +  "$id": "https://example.com/meta/general-use-example",
    +  "$dynamicAnchor": "meta",
    +  "$vocabulary": {
    +    "https://json-schema.org/draft/2020-12/vocab/core": true,
    +    "https://json-schema.org/draft/2020-12/vocab/applicator": true,
    +    "https://json-schema.org/draft/2020-12/vocab/validation": true,
    +    "https://example.com/vocab/example-vocab": true
    +  },
    +  "allOf": [
    +    {"$ref": "https://json-schema.org/draft/2020-12/meta/core"},
    +    {"$ref": "https://json-schema.org/draft/2020-12/meta/applicator"},
    +    {"$ref": "https://json-schema.org/draft/2020-12/meta/validation"},
    +    {"$ref": "https://example.com/meta/example-vocab"}
    +  ],
    +  "patternProperties": {
    +    "^unevaluated": false
    +  },
    +  "properties": {
    +    "localKeyword": {
    +      "$comment": "Not in vocabulary, but validated if used",
    +      "type": "string"
    +    }
    +  }
    +}
    +
    +
    +
    +

    + This meta-schema describes only a single extension vocabulary.

    +
    +
    +
    +{
    +  "$schema": "https://json-schema.org/draft/2020-12/schema",
    +  "$id": "https://example.com/meta/example-vocab",
    +  "$dynamicAnchor": "meta",
    +  "$vocabulary": {
    +    "https://example.com/vocab/example-vocab": true,
    +  },
    +  "type": ["object", "boolean"],
    +  "properties": {
    +    "minDate": {
    +      "type": "string",
    +      "pattern": "\d\d\d\d-\d\d-\d\d",
    +      "format": "date",
    +    }
    +  }
    +}
    +
    +
    +
    +

    + As shown above, even though each of the single-vocabulary meta-schemas + referenced in the general-use meta-schema's "allOf" declares its + corresponding vocabulary, this new meta-schema must re-declare them.

    +

    + The standard meta-schemas that combine all vocabularies defined by + the Core and Validation specification, and that combine all vocabularies + defined by those specifications as well as the Hyper-Schema specification, + demonstrate additional complex combinations. These URIs for these + meta-schemas may be found in the Validation and Hyper-Schema specifications, + respectively.

    +

    + While the general-use meta-schema can validate the syntax of "minDate", + it is the vocabulary that defines the logic behind the semantic meaning + of "minDate". Without an understanding of the semantics (in this example, + that the instance value must be a date equal to or after the date + provided as the keyword's value in the schema), an implementation can + only validate the syntactic usage. In this case, that means validating + that it is a date-formatted string (using "pattern" to ensure that it is + validated even when "format" functions purely as an annotation, as explained + in the Validation specification [json-schema-validation].

    +
    +
    +
    +
    +

    +Appendix E. References and generative use cases +

    +

    + While the presence of references is expected to be transparent + to validation results, generative use cases such as code generators + and UI renderers often consider references to be semantically significant.

    +

    + To make such use case-specific semantics explicit, the best practice + is to create an annotation keyword for use in the same + schema object alongside of a reference keyword such as "$ref".

    +

    + For example, here is a hypothetical keyword for determining + whether a code generator should consider the reference + target to be a distinct class, and how those classes are related. + Note that this example is solely for illustrative purposes, and is + not intended to propose a functional code generation keyword.

    +
    +
    +
    +{
    +    "allOf": [
    +        {
    +            "classRelation": "is-a",
    +            "$ref": "classes/base.json"
    +        },
    +        {
    +            "$ref": "fields/common.json"
    +        }
    +    ],
    +    "properties": {
    +        "foo": {
    +            "classRelation": "has-a",
    +            "$ref": "classes/foo.json"
    +        },
    +        "date": {
    +            "$ref": "types/dateStruct.json",
    +        }
    +    }
    +}
    +
    +
    +
    +

    + Here, this schema represents some sort of object-oriented class. + The first reference in the "allOf" is noted as the base class. + The second is not assigned a class relationship, meaning that the + code generator should combine the target's definition with this + one as if no reference were involved.

    +

    + Looking at the properties, "foo" is flagged as object composition, + while the "date" property is not. It is simply a field with + sub-fields, rather than an instance of a distinct class.

    +

    + This style of usage requires the annotation to be in the same object + as the reference, which must be recognizable as a reference.

    +
    +
    +

    +Appendix F. Acknowledgments +

    +

    + Thanks to + Gary Court, + Francis Galiegue, + Kris Zyp, + and Geraint Luff + for their work on the initial drafts of JSON Schema.

    +

    + Thanks to + Jason Desrosiers, + Daniel Perrett, + Erik Wilde, + Evgeny Poberezkin, + Brad Bowman, + Gowry Sankar, + Donald Pipowitch, + Dave Finlay, + Denis Laxalde, + Phil Sturgeon, + Shawn Silverman, + and Karen Etheridge + for their submissions and patches to the document.

    +
    +
    +

    +Appendix G. ChangeLog +

    +

    + This section to be removed before leaving Internet-Draft status.

    +
    +
    draft-bhutton-json-schema-01
    +
    +
      +
    • Improve and clarify the "type", "contains", "unevaluatedProperties", and "unevaluatedItems" keyword explanations +
    • +
    • Clarify various aspects of "canonical URIs" +
    • +
    • Comment on ambiguity around annotations and "additionalProperties" +
    • +
    • Clarify Vocabularies need not be formally defined +
    • +
    • Remove references to remaining media-type parameters +
    • +
    • Fix multiple examples +
    • +
    +
    +
    +
    draft-bhutton-json-schema-00
    +
    +
      +
    • "$schema" MAY change for embedded resources +
    • +
    • Array-value "items" functionality is now "prefixItems" +
    • +
    • "items" subsumes the old function of "additionalItems" +
    • +
    • "contains" annotation behavior, and "contains" and "unevaluatedItems" interactions now specified +
    • +
    • Rename $recursive* to $dynamic*, with behavior modification +
    • +
    • $dynamicAnchor defines a fragment like $anchor +
    • +
    • $dynamic* (previously $recursive) no longer use runtime base URI determination +
    • +
    • Define Compound Schema Documents (bundle) and processing +
    • +
    • Reference ECMA-262, 11th edition for regular expression support +
    • +
    • Regular expression should support unicode +
    • +
    • Remove media type parameters +
    • +
    • Specify Unknown keywords are collected as annotations +
    • +
    • Moved "unevaluatedItems" and "unevaluatedProperties" from core into their own vocabulary +
    • +
    +
    +
    +
    draft-handrews-json-schema-02
    +
    +
      +
    • Update to RFC 8259 for JSON specification +
    • +
    • Moved "definitions" from the Validation specification here as "$defs" +
    • +
    • Moved applicator keywords from the Validation specification as their own vocabulary +
    • +
    • Moved the schema form of "dependencies" from the Validation specification as "dependentSchemas" +
    • +
    • Formalized annotation collection +
    • +
    • Specified recommended output formats +
    • +
    • Defined keyword interactions in terms of annotation and assertion results +
    • +
    • Added "unevaluatedProperties" and "unevaluatedItems" +
    • +
    • Define "$ref" behavior in terms of the assertion, applicator, and annotation model +
    • +
    • Allow keywords adjacent to "$ref" +
    • +
    • Note undefined behavior for "$ref" targets involving unknown keywords +
    • +
    • Add recursive referencing, primarily for meta-schema extension +
    • +
    • Add the concept of formal vocabularies, and how they can be recognized through meta-schemas +
    • +
    • Additional guidance on initial base URIs beyond network retrieval +
    • +
    • Allow "schema" media type parameter for "application/schema+json" +
    • +
    • Better explanation of media type parameters and the HTTP Accept header +
    • +
    • Use "$id" to establish canonical and base absolute-URIs only, no fragments +
    • +
    • Replace plain-name-fragment-only form of "$id" with "$anchor" +
    • +
    • Clarified that the behavior of JSON Pointers across "$id" boundary is unreliable +
    • +
    +
    +
    +
    draft-handrews-json-schema-01
    +
    +
      +
    • This draft is purely a clarification with no functional changes +
    • +
    • Emphasized annotations as a primary usage of JSON Schema +
    • +
    • Clarified $id by use cases +
    • +
    • Exhaustive schema identification examples +
    • +
    • Replaced "external referencing" with how and when an implementation might know of a schema from another document +
    • +
    • Replaced "internal referencing" with how an implementation should recognized schema identifiers during parsing +
    • +
    • Dereferencing the former "internal" or "external" references is always the same process +
    • +
    • Minor formatting improvements +
    • +
    +
    +
    +
    draft-handrews-json-schema-00
    +
    +
      +
    • Make the concept of a schema keyword vocabulary more clear +
    • +
    • Note that the concept of "integer" is from a vocabulary, not the data model +
    • +
    • Classify keywords as assertions or annotations and describe their general behavior +
    • +
    • Explain the boolean schemas in terms of generalized assertions +
    • +
    • Reserve "$comment" for non-user-visible notes about the schema +
    • +
    • Wording improvements around "$id" and fragments +
    • +
    • Note the challenges of extending meta-schemas with recursive references +
    • +
    • Add "application/schema-instance+json" media type +
    • +
    • Recommend a "schema" link relation / parameter instead of "profile" +
    • +
    +
    +
    +
    draft-wright-json-schema-01
    +
    +
      +
    • Updated intro +
    • +
    • Allowed for any schema to be a boolean +
    • +
    • "$schema" SHOULD NOT appear in subschemas, although that may change +
    • +
    • Changed "id" to "$id"; all core keywords prefixed with "$" +
    • +
    • Clarify and formalize fragments for application/schema+json +
    • +
    • Note applicability to formats such as CBOR that can be represented in the JSON data model +
    • +
    +
    +
    +
    draft-wright-json-schema-00
    +
    +
      +
    • Updated references to JSON +
    • +
    • Updated references to HTTP +
    • +
    • Updated references to JSON Pointer +
    • +
    • Behavior for "id" is now specified in terms of RFC3986 +
    • +
    • Aligned vocabulary usage for URIs with RFC3986 +
    • +
    • Removed reference to draft-pbryan-zyp-json-ref-03 +
    • +
    • Limited use of "$ref" to wherever a schema is expected +
    • +
    • Added definition of the "JSON Schema data model" +
    • +
    • Added additional security considerations +
    • +
    • Defined use of subschema identifiers for "id" +
    • +
    • Rewrote section on usage with HTTP +
    • +
    • Rewrote section on usage with rel="describedBy" and rel="profile" +
    • +
    • Fixed numerous invalid examples +
    • +
    +
    +
    +
    draft-zyp-json-schema-04
    +
    +
      +
    • Salvaged from draft v3. +
    • +
    • Split validation keywords into separate document. +
    • +
    • Split hypermedia keywords into separate document. +
    • +
    • Initial post-split draft. +
    • +
    • Mandate the use of JSON Reference, JSON Pointer. +
    • +
    • Define the role of "id". Define URI resolution scope. +
    • +
    • Add interoperability considerations. +
    • +
    +
    +
    +
    draft-zyp-json-schema-00
    +
    +
      +
    • Initial draft. +
    • +
    +
    +
    +
    +
    +
    +
    +

    +Authors' Addresses +

    +
    +
    Austin Wright (editor)
    + +
    +
    +
    Henry Andrews (editor)
    + +
    +
    +
    Ben Hutton (editor)
    +
    Postman
    + + +
    +
    +
    Greg Dennis
    + + +
    +
    +
    + + + diff --git a/draft/2020-12/json-schema-validation.html b/draft/2020-12/json-schema-validation.html new file mode 100644 index 00000000..82d22aad --- /dev/null +++ b/draft/2020-12/json-schema-validation.html @@ -0,0 +1,3185 @@ + + + + + + +JSON Schema Validation: A Vocabulary for Structural Validation of JSON + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Internet-DraftJSON Schema ValidationJune 2022
    Wright, et al.Expires 18 December 2022[Page]
    +
    +
    +
    +
    Workgroup:
    +
    Internet Engineering Task Force
    +
    Internet-Draft:
    +
    draft-bhutton-json-schema-validation-01
    +
    Published:
    +
    + +
    +
    Intended Status:
    +
    Informational
    +
    Expires:
    +
    +
    Authors:
    +
    +
    +
    A. Wright, Ed. +
    +
    +
    +
    H. Andrews, Ed. +
    +
    +
    +
    B. Hutton, Ed. +
    +
    Postman
    +
    +
    +
    +
    +

    JSON Schema Validation: A Vocabulary for Structural Validation of JSON

    +
    +

    Abstract

    +

    + JSON Schema (application/schema+json) has several purposes, one of which is JSON + instance validation. + This document specifies a vocabulary for JSON Schema to describe the meaning of JSON + documents, provide hints for user interfaces working with JSON data, and to make + assertions about what a valid document must look like.

    +
    +
    +

    +Note to Readers +

    +

    + The issues list for this draft can be found at + https://github.com/json-schema-org/json-schema-spec/issues.

    +

    + For additional information, see https://json-schema.org/.

    +

    + To provide feedback, use this issue tracker, the communication methods listed on the + homepage, or email the document editors.

    +
    +
    +
    +

    +Status of This Memo +

    +

    + This Internet-Draft is submitted in full conformance with the + provisions of BCP 78 and BCP 79.

    +

    + Internet-Drafts are working documents of the Internet Engineering Task + Force (IETF). Note that other groups may also distribute working + documents as Internet-Drafts. The list of current Internet-Drafts is + at https://datatracker.ietf.org/drafts/current/.

    +

    + Internet-Drafts are draft documents valid for a maximum of six months + and may be updated, replaced, or obsoleted by other documents at any + time. It is inappropriate to use Internet-Drafts as reference + material or to cite them other than as "work in progress."

    +

    + This Internet-Draft will expire on 18 December 2022.

    +
    +
    + +
    +
    +

    +Table of Contents +

    + +
    +
    +
    +

    +1. Introduction +

    +

    + JSON Schema can be used to require that a given JSON document (an instance) + satisfies a certain number of criteria. These criteria are asserted by using + keywords described in this specification. In addition, a set of keywords + is also defined to assist in interactive user interface instance generation.

    +

    + This specification will use the concepts, syntax, and terminology defined + by the JSON Schema core [json-schema] specification.

    +
    +
    +

    +2. Conventions and Terminology +

    +

    + + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", + "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be + interpreted as described in RFC 2119 [RFC2119].

    +

    + This specification uses the term "container instance" to refer to both array and + object instances. It uses the term "children instances" to refer to array elements + or object member values.

    +

    + Elements in an array value are said to be unique if no two elements of this array + are equal [json-schema].

    +
    +
    +

    +3. Overview +

    +

    + JSON Schema validation asserts constraints on the structure of instance data. + An instance location that satisfies all asserted constraints is then + annotated with any keywords that contain non-assertion information, + such as descriptive metadata and usage hints. If all locations within + the instance satisfy all asserted constraints, then the instance is + said to be valid against the schema.

    +

    + Each schema object is independently evaluated against each instance location + to which it applies. This greatly simplifies the implementation requirements + for validators by ensuring that they do not need to maintain state across + the document-wide validation process.

    +

    + This specification defines a set of assertion keywords, as well as a small vocabulary + of metadata keywords that can be used to annotate the JSON instance with + useful information. The Section 7 keyword is intended primarily + as an annotation, but can optionally be used as an assertion. The + Section 8 keywords are annotations for working with documents + embedded as JSON strings.

    +
    +
    +

    +4. Interoperability Considerations +

    +
    +

    +4.1. Validation of String Instances +

    +

    + It should be noted that the nul character (\u0000) is valid in a JSON string. An + instance to validate may contain a string value with this character, regardless + of the ability of the underlying programming language to deal with such data.

    +
    +
    +

    +4.2. Validation of Numeric Instances +

    +

    + The JSON specification allows numbers with arbitrary precision, and JSON Schema + does not add any such bounds. + This means that numeric instances processed by JSON Schema can be arbitrarily large and/or + have an arbitrarily long decimal part, regardless of the ability of the + underlying programming language to deal with such data.

    +
    +
    +
    +

    +4.3. Regular Expressions +

    +

    + Keywords that use regular expressions, or constrain the instance value + to be a regular expression, are subject to the interoperability + considerations for regular expressions in the + JSON Schema Core [json-schema] specification.

    +
    +
    +
    +
    +
    +

    +5. Meta-Schema +

    +

    + The current URI for the default JSON Schema dialect meta-schema is + https://json-schema.org/draft/2020-12/schema. + For schema author convenience, this meta-schema describes a dialect + consisting of all vocabularies + defined in this specification and the JSON Schema Core specification, + as well as two former keywords which are reserved for a transitional period. + Individual vocabulary and vocabulary meta-schema URIs are given for + each section below. Certain vocabularies are optional to support, which + is explained in detail in the relevant sections.

    +

    + Updated vocabulary and meta-schema URIs MAY be published between + specification drafts in order to correct errors. Implementations + SHOULD consider URIs dated after this specification draft and + before the next to indicate the same syntax and semantics + as those listed here.

    +
    +
    +
    +

    +6. A Vocabulary for Structural Validation +

    +

    + Validation keywords in a schema impose requirements for successful validation of an + instance. These keywords are all assertions without any annotation behavior.

    +

    + Meta-schemas that do not use "$vocabulary" SHOULD be considered to + require this vocabulary as if its URI were present with a value of true.

    +

    + The current URI for this vocabulary, known as the Validation vocabulary, is: + <https://json-schema.org/draft/2020-12/vocab/validation>.

    +

    + The current URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/validation.

    +
    +
    +

    +6.1. Validation Keywords for Any Instance Type +

    +
    +

    +6.1.1. type +

    +

    + The value of this keyword MUST be either a string or an array. If it is + an array, elements of the array MUST be strings and MUST be unique.

    +

    + String values MUST be one of the six primitive types + ("null", "boolean", "object", "array", "number", or "string"), + or "integer" which matches any number with a zero fractional part.

    +

    + If the value of "type" is a string, then an instance validates successfully if + its type matches the type represented by the value of the string. + + If the value of "type" is an array, then an instance validates successfully if + its type matches any of the types indicated by the strings in the array.

    +
    +
    +
    +

    +6.1.2. enum +

    +

    + The value of this keyword MUST be an array. This array SHOULD have at + least one element. Elements in the array SHOULD be unique.

    +

    + An instance validates successfully against this keyword if its value is + equal to one of the elements in this keyword's array value.

    +

    + Elements in the array might be of any type, including null.

    +
    +
    +
    +

    +6.1.3. const +

    +

    + The value of this keyword MAY be of any type, including null.

    +

    + Use of this keyword is functionally equivalent to an + "enum" (Section 6.1.2) with a single value.

    +

    + An instance validates successfully against this keyword if its value is + equal to the value of the keyword.

    +
    +
    +
    +
    +
    +

    +6.2. Validation Keywords for Numeric Instances (number and integer) +

    +
    +

    +6.2.1. multipleOf +

    +

    + The value of "multipleOf" MUST be a number, strictly greater than 0.

    +

    + A numeric instance is valid only if division by this keyword's value results in + an integer.

    +
    +
    +

    +6.2.2. maximum +

    +

    + The value of "maximum" MUST be a number, representing an inclusive upper limit + for a numeric instance.

    +

    + If the instance is a number, then this keyword validates only if the instance is + less than or exactly equal to "maximum".

    +
    +
    +

    +6.2.3. exclusiveMaximum +

    +

    + The value of "exclusiveMaximum" MUST be a number, representing an exclusive upper + limit for a numeric instance.

    +

    + If the instance is a number, then the instance is valid only if it has a value + strictly less than (not equal to) "exclusiveMaximum".

    +
    +
    +

    +6.2.4. minimum +

    +

    + The value of "minimum" MUST be a number, representing an inclusive lower limit + for a numeric instance.

    +

    + If the instance is a number, then this keyword validates only if the instance is + greater than or exactly equal to "minimum".

    +
    +
    +

    +6.2.5. exclusiveMinimum +

    +

    + The value of "exclusiveMinimum" MUST be a number, representing an exclusive lower + limit for a numeric instance.

    +

    + If the instance is a number, then the instance is valid only if it has a value + strictly greater than (not equal to) "exclusiveMinimum".

    +
    +
    +
    +
    +
    +

    +6.3. Validation Keywords for Strings +

    +
    +

    +6.3.1. maxLength +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + A string instance is valid against this keyword if its + length is less than, or equal to, the value of this keyword.

    +

    + The length of a string instance is defined as the number of its + characters as defined by RFC 8259 [RFC8259].

    +
    +
    +

    +6.3.2. minLength +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + A string instance is valid against this keyword if its + length is greater than, or equal to, the value of this keyword.

    +

    + The length of a string instance is defined as the number of its + characters as defined by RFC 8259 [RFC8259].

    +

    + Omitting this keyword has the same behavior as a value of 0.

    +
    +
    +
    +

    +6.3.3. pattern +

    +

    + The value of this keyword MUST be a string. This string SHOULD be a + valid regular expression, according to the ECMA-262 regular expression + dialect.

    +

    + A string instance is considered valid if the regular + expression matches the instance successfully. Recall: regular + expressions are not implicitly anchored.

    +
    +
    +
    +
    +
    +

    +6.4. Validation Keywords for Arrays +

    +
    +

    +6.4.1. maxItems +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + An array instance is valid against "maxItems" if its size is + less than, or equal to, the value of this keyword.

    +
    +
    +

    +6.4.2. minItems +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + An array instance is valid against "minItems" if its size is + greater than, or equal to, the value of this keyword.

    +

    + Omitting this keyword has the same behavior as a value of 0.

    +
    +
    +

    +6.4.3. uniqueItems +

    +

    + The value of this keyword MUST be a boolean.

    +

    + If this keyword has boolean value false, the instance validates + successfully. If it has boolean value true, the instance validates + successfully if all of its elements are unique.

    +

    + Omitting this keyword has the same behavior as a value of false.

    +
    +
    +

    +6.4.4. maxContains +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + If "contains" is not present within the same schema object, + then this keyword has no effect.

    +

    + An instance array is valid against "maxContains" in two ways, depending on + the form of the annotation result of an adjacent + "contains" [json-schema] keyword. The first way is if + the annotation result is an array and the length of that array is less than + or equal to the "maxContains" value. The second way is if the annotation + result is a boolean "true" and the instance array length is less than or + equal to the "maxContains" value.

    +
    +
    +

    +6.4.5. minContains +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + If "contains" is not present within the same schema object, + then this keyword has no effect.

    +

    + An instance array is valid against "minContains" in two ways, depending on + the form of the annotation result of an adjacent + "contains" [json-schema] keyword. The first way is if + the annotation result is an array and the length of that array is greater + than or equal to the "minContains" value. The second way is if the + annotation result is a boolean "true" and the instance array length is + greater than or equal to the "minContains" value.

    +

    + A value of 0 is allowed, but is only useful for setting a range + of occurrences from 0 to the value of "maxContains". A value of + 0 causes "minContains" and "contains" to always pass validation + (but validation can still fail against a "maxContains" keyword).

    +

    + Omitting this keyword has the same behavior as a value of 1.

    +
    +
    +
    +

    +6.5. Validation Keywords for Objects +

    +
    +

    +6.5.1. maxProperties +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + An object instance is valid against "maxProperties" if its + number of properties is less than, or equal to, the value of this + keyword.

    +
    +
    +

    +6.5.2. minProperties +

    +

    + The value of this keyword MUST be a non-negative integer.

    +

    + An object instance is valid against "minProperties" if its + number of properties is greater than, or equal to, the value of this + keyword.

    +

    + Omitting this keyword has the same behavior as a value of 0.

    +
    +
    +

    +6.5.3. required +

    +

    + The value of this keyword MUST be an array. + Elements of this array, if any, MUST be strings, and MUST be unique.

    +

    + An object instance is valid against this keyword if every item in the array is + the name of a property in the instance.

    +

    + Omitting this keyword has the same behavior as an empty array.

    +
    +
    +

    +6.5.4. dependentRequired +

    +

    + The value of this keyword MUST be an object. Properties in + this object, if any, MUST be arrays. Elements in each array, + if any, MUST be strings, and MUST be unique.

    +

    + This keyword specifies properties that are required if a specific + other property is present. Their requirement is dependent on the + presence of the other property.

    +

    + Validation succeeds if, for each name that appears in both + the instance and as a name within this keyword's value, every + item in the corresponding array is also the name of a property + in the instance.

    +

    + Omitting this keyword has the same behavior as an empty object.

    +
    +
    +
    +
    +
    +

    +7. Vocabularies for Semantic Content With "format" +

    +
    +

    +7.1. Foreword +

    +

    + Structural validation alone may be insufficient to allow an application to correctly + utilize certain values. The "format" annotation keyword is defined to allow schema + authors to convey semantic information for a fixed subset of values which are + accurately described by authoritative resources, be they RFCs or other external + specifications.

    +

    + The value of this keyword is called a format attribute. It MUST be a string. A + format attribute can generally only validate a given set of instance types. If + the type of the instance to validate is not in this set, validation for this + format attribute and instance SHOULD succeed. All format attributes defined + in this section apply to strings, but a format attribute can be specified + to apply to any instance types defined in the data model defined in the + core JSON Schema. [json-schema] + + Note that the "type" keyword in this specification defines an "integer" type + which is not part of the data model. Therefore a format attribute can be + limited to numbers, but not specifically to integers. However, a numeric + format can be used alongside the "type" keyword with a value of "integer", + or could be explicitly defined to always pass if the number is not an integer, + which produces essentially the same behavior as only applying to integers. +

    +

    + The current URI for this vocabulary, known as the Format-Annotation vocabulary, is: + <https://json-schema.org/draft/2020-12/vocab/format-annotation>. The current + URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/format-annotation. + Implementing support for this vocabulary is REQUIRED.

    +

    + In addition to the Format-Annotation vocabulary, a secondary vocabulary is available + for custom meta-schemas that defines "format" as an assertion. The URI for the + Format-Assertion vocabulary, is: + <https://json-schema.org/draft/2020-12/vocab/format-assertion>. The current + URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/format-assertion. + Implementing support for the Format-Assertion vocabulary is OPTIONAL.

    +

    + Specifying both the Format-Annotation and the Format-Assertion vocabularies is functionally + equivalent to specifying only the Format-Assertion vocabulary since its requirements + are a superset of the Format-Annotation vocabulary.

    +
    +
    +

    +7.2. Implementation Requirements +

    +

    + The "format" keyword functions as defined by the vocabulary which is referenced.

    +
    +

    +7.2.1. Format-Annotation Vocabulary +

    +

    + The value of format MUST be collected as an annotation, if the implementation + supports annotation collection. This enables application-level validation when + schema validation is unavailable or inadequate.

    +

    + Implementations MAY still treat "format" as an assertion in addition to an + annotation and attempt to validate the value's conformance to the specified + semantics. The implementation MUST provide options to enable and disable such + evaluation and MUST be disabled by default. Implementations SHOULD document + their level of support for such validation. + + Specifying the Format-Annotation vocabulary and enabling validation in an + implementation should not be viewed as being equivalent to specifying + the Format-Assertion vocabulary since implementations are not required to + provide full validation support when the Format-Assertion vocabulary + is not specified. +

    +

    + When the implementation is configured for assertion behavior, it:

    +
      +
    • + SHOULD provide an implementation-specific best effort validation + for each format attribute defined below; +
    • +
    • + MAY choose to implement validation of any or all format attributes + as a no-op by always producing a validation result of true; +
    • +
    +

    + + This matches the current reality of implementations, which provide + widely varying levels of validation, including no validation at all, + for some or all format attributes. It is also designed to encourage + relying only on the annotation behavior and performing semantic + validation in the application, which is the recommended best practice. +

    +
    +
    +

    +7.2.2. Format-Assertion Vocabulary +

    +

    + When the Format-Assertion vocabulary is declared with a value of true, + implementations MUST provide full validation support for all of the formats + defined by this specificaion. Implementations that cannot provide full + validation support MUST refuse to process the schema.

    +

    + An implementation that supports the Format-Assertion vocabulary:

    +
      +
    • + MUST still collect "format" as an annotation if the implementation + supports annotation collection; +
    • +
    • + MUST evaluate "format" as an assertion; +
    • +
    • + MUST implement syntactic validation for all format attributes defined + in this specification, and for any additional format attributes that + it recognizes, such that there exist possible instance values + of the correct type that will fail validation. +
    • +
    +

    + The requirement for minimal validation of format attributes is intentionally + vague and permissive, due to the complexity involved in many of the attributes. + Note in particular that the requirement is limited to syntactic checking; it is + not to be expected that an implementation would send an email, attempt to connect + to a URL, or otherwise check the existence of an entity identified by a format + instance. + + The expectation is that for simple formats such as date-time, syntactic + validation will be thorough. For a complex format such as email addresses, + which are the amalgamation of various standards and numerous adjustments + over time, with obscure and/or obsolete rules that may or may not be + restricted by other applications making use of the value, a minimal validation + is sufficient. For example, an instance string that does not contain + an "@" is clearly not a valid email address, and an "email" or "hostname" + containing characters outside of 7-bit ASCII is likewise clearly invalid. +

    +

    + It is RECOMMENDED that implementations use a common parsing library for each format, + or a well-known regular expression. Implementations SHOULD clearly document + how and to what degree each format attribute is validated.

    +

    + The standard core and validation meta-schema (Section 5) + includes this vocabulary in its "$vocabulary" keyword with a value of false, + since by default implementations are not required to support this keyword + as an assertion. Supporting the format vocabulary with a value of true is + understood to greatly increase code size and in some cases execution time, + and will not be appropriate for all implementations.

    +
    +
    +

    +7.2.3. Custom format attributes +

    +

    + Implementations MAY support custom format attributes. Save for agreement between + parties, schema authors SHALL NOT expect a peer implementation to support such + custom format attributes. An implementation MUST NOT fail to collect unknown formats + as annotations. When the Format-Assertion vocabulary is specified, implementations + MUST fail upon encountering unknown formats.

    +

    + Vocabularies do not support specifically declaring different value sets for keywords. + Due to this limitation, and the historically uneven implementation of this keyword, + it is RECOMMENDED to define additional keywords in a custom vocabulary rather than + additional format attributes if interoperability is desired.

    +
    +
    +
    +

    +7.3. Defined Formats +

    +
    +

    +7.3.1. Dates, Times, and Duration +

    +

    + These attributes apply to string instances.

    +

    + Date and time format names are derived from + RFC 3339, section 5.6 [RFC3339]. + The duration format is from the ISO 8601 ABNF as given + in Appendix A of RFC 3339.

    +

    + Implementations supporting formats SHOULD implement support for + the following attributes:

    +
    +
    date-time:
    +
    + A string instance is valid against this attribute if it is + a valid representation according to the "date-time' ABNF rule + (referenced above) +
    +
    +
    date:
    +
    + A string instance is valid against this attribute if it is + a valid representation according to the "full-date" ABNF rule + (referenced above) +
    +
    +
    time:
    +
    + A string instance is valid against this attribute if it is + a valid representation according to the "full-time" ABNF rule + (referenced above) +
    +
    +
    duration:
    +
    + A string instance is valid against this attribute if it is + a valid representation according to the "duration" ABNF rule + (referenced above) +
    +
    +
    +

    + Implementations MAY support additional attributes using the other + format names defined anywhere in that RFC. If "full-date" or "full-time" + are implemented, the corresponding short form ("date" or "time" + respectively) MUST be implemented, and MUST behave identically. + Implementations SHOULD NOT define extension attributes + with any name matching an RFC 3339 format unless it validates + according to the rules of that format. + + There is not currently consensus on the need for supporting + all RFC 3339 formats, so this approach of reserving the + namespace will encourage experimentation without committing + to the entire set. Either the format implementation requirements + will become more flexible in general, or these will likely + either be promoted to fully specified attributes or dropped. +

    +
    +
    +

    +7.3.2. Email Addresses +

    +

    + These attributes apply to string instances.

    +

    + A string instance is valid against these attributes if it is a valid + Internet email address as follows:

    +
    +
    email:
    +
    + As defined by the "Mailbox" ABNF rule in + RFC 5321, section 4.1.2 [RFC5321]. +
    +
    +
    idn-email:
    +
    + As defined by the extended "Mailbox" ABNF rule in + RFC 6531, section 3.3 [RFC6531]. +
    +
    +
    +

    + Note that all strings valid against the "email" attribute are also + valid against the "idn-email" attribute.

    +
    +
    +

    +7.3.3. Hostnames +

    +

    + These attributes apply to string instances.

    +

    + A string instance is valid against these attributes if it is a valid + representation for an Internet hostname as follows:

    +
    +
    hostname:
    +
    + As defined by RFC 1123, section 2.1 [RFC1123], + including host names produced using the Punycode algorithm + specified in RFC 5891, section 4.4 [RFC5891]. +
    +
    +
    idn-hostname:
    +
    + As defined by either RFC 1123 as for hostname, or an + internationalized hostname as defined by + RFC 5890, section 2.3.2.3 [RFC5890]. +
    +
    +
    +

    + Note that all strings valid against the "hostname" attribute are also + valid against the "idn-hostname" attribute.

    +
    +
    +

    +7.3.4. IP Addresses +

    +

    + These attributes apply to string instances.

    +

    + A string instance is valid against these attributes if it is a valid + representation of an IP address as follows:

    +
    +
    ipv4:
    +
    + An IPv4 address according to the "dotted-quad" ABNF + syntax as defined in + RFC 2673, section 3.2 [RFC2673]. +
    +
    +
    ipv6:
    +
    + An IPv6 address as defined in + RFC 4291, section 2.2 [RFC4291]. +
    +
    +
    +
    +
    +

    +7.3.5. Resource Identifiers +

    +

    + These attributes apply to string instances.

    +
    +
    uri:
    +
    + A string instance is valid against this attribute if it is + a valid URI, according to [RFC3986]. +
    +
    +
    uri-reference:
    +
    + A string instance is valid against this attribute if it is a valid URI + Reference (either a URI or a relative-reference), + according to [RFC3986]. +
    +
    +
    iri:
    +
    + A string instance is valid against this attribute if it is + a valid IRI, according to [RFC3987]. +
    +
    +
    iri-reference:
    +
    + A string instance is valid against this attribute if it is a valid IRI + Reference (either an IRI or a relative-reference), + according to [RFC3987]. +
    +
    +
    uuid:
    +
    + A string instance is valid against this attribute if it is a valid + string representation of a UUID, according to [RFC4122]. +
    +
    +
    +

    + Note that all valid URIs are valid IRIs, and all valid URI References are + also valid IRI References.

    +

    + Note also that the "uuid" format is for plain UUIDs, not UUIDs in URNs. An example + is "f81d4fae-7dec-11d0-a765-00a0c91e6bf6". For UUIDs as URNs, use the "uri" format, + with a "pattern" regular expression of "^urn:uuid:" to indicate the URI scheme and + URN namespace.

    +
    +
    +

    +7.3.6. uri-template +

    +

    + This attribute applies to string instances.

    +

    + A string instance is valid against this attribute if it is a valid URI Template + (of any level), according to [RFC6570].

    +

    + Note that URI Templates may be used for IRIs; there is no separate + IRI Template specification.

    +
    +
    +

    +7.3.7. JSON Pointers +

    +

    + These attributes apply to string instances.

    +
    +
    json-pointer:
    +
    + A string instance is valid against this attribute if it + is a valid JSON string representation of a JSON Pointer, + according to RFC 6901, section 5 [RFC6901]. +
    +
    +
    relative-json-pointer:
    +
    + A string instance is valid against this attribute if it is a valid + Relative JSON Pointer [relative-json-pointer]. +
    +
    +
    +

    + To allow for both absolute and relative JSON Pointers, use "anyOf" or + "oneOf" to indicate support for either format.

    +
    +
    +

    +7.3.8. regex +

    +

    + This attribute applies to string instances.

    +

    + A regular expression, which SHOULD be valid according to the + ECMA-262 [ecma262] regular expression dialect.

    +

    + Implementations that validate formats MUST accept at least the subset of + ECMA-262 defined in the Regular Expressions (Section 4.3) + section of this specification, and SHOULD accept all valid ECMA-262 expressions.

    +
    +
    +
    +
    +
    +
    +

    +8. A Vocabulary for the Contents of String-Encoded Data +

    +
    +

    +8.1. Foreword +

    +

    + Annotations defined in this section indicate that an instance contains + non-JSON data encoded in a JSON string.

    +

    + These properties provide additional information required to interpret JSON data + as rich multimedia documents. They describe the type of content, how it is encoded, + and/or how it may be validated. They do not function as validation assertions; + a malformed string-encoded document MUST NOT cause the containing instance + to be considered invalid.

    +

    + Meta-schemas that do not use "$vocabulary" SHOULD be considered to + require this vocabulary as if its URI were present with a value of true.

    +

    + The current URI for this vocabulary, known as the Content vocabulary, is: + <https://json-schema.org/draft/2020-12/vocab/content>.

    +

    + The current URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/content.

    +
    +
    +

    +8.2. Implementation Requirements +

    +

    + Due to security and performance concerns, as well as the open-ended nature of + possible content types, implementations MUST NOT automatically decode, parse, + and/or validate the string contents by default. This additionally supports + the use case of embedded documents intended for processing by a different + consumer than that which processed the containing document.

    +

    + All keywords in this section apply only to strings, and have no + effect on other data types.

    +

    + Implementations MAY offer the ability to decode, parse, and/or validate + the string contents automatically. However, it MUST NOT perform these + operations by default, and MUST provide the validation result of each + string-encoded document separately from the enclosing document. This + process SHOULD be equivalent to fully evaluating the instance against + the original schema, followed by using the annotations to decode, parse, + and/or validate each string-encoded document. + + For now, the exact mechanism of performing and returning parsed + data and/or validation results from such an automatic decoding, parsing, + and validating feature is left unspecified. Should such a feature + prove popular, it may be specified more thoroughly in a future draft. +

    +

    + See also the Security Considerations (Section 10) + sections for possible vulnerabilities introduced by automatically + processing the instance string according to these keywords.

    +
    +
    +

    +8.3. contentEncoding +

    +

    + If the instance value is a string, this property defines that the string + SHOULD be interpreted as encoded binary data and decoded using the encoding + named by this property.

    +

    + Possible values indicating base 16, 32, and 64 encodings with several + variations are listed in RFC 4648 [RFC4648]. Additionally, + sections 6.7 and 6.8 of RFC 2045 [RFC2045] provide + encodings used in MIME. This keyword is derived from MIME's + Content-Transfer-Encoding header, which was designed to map binary data + into ASCII characters. It is not related to HTTP's Content-Encoding header, + which is used to encode (e.g. compress or encrypt) + the content of HTTP request and responses.

    +

    + As "base64" is defined in both RFCs, the definition + from RFC 4648 SHOULD be assumed unless the string is specifically intended + for use in a MIME context. Note that all of these encodings result in + strings consisting only of 7-bit ASCII characters. Therefore, this keyword + has no meaning for strings containing characters outside of that range.

    +

    + If this keyword is absent, but "contentMediaType" is present, this + indicates that the encoding is the identity encoding, meaning that + no transformation was needed in order to represent the content in + a UTF-8 string.

    +

    + The value of this property MUST be a string.

    +
    +
    +

    +8.4. contentMediaType +

    +

    + If the instance is a string, this property indicates the media type + of the contents of the string. If "contentEncoding" is present, + this property describes the decoded string.

    +

    + The value of this property MUST be a string, which MUST be a media type, + as defined by RFC 2046 [RFC2046].

    +
    +
    +

    +8.5. contentSchema +

    +

    + If the instance is a string, and if "contentMediaType" is present, this + property contains a schema which describes the structure of the string.

    +

    + This keyword MAY be used with any media type that can be mapped into + JSON Schema's data model.

    +

    + The value of this property MUST be a valid JSON schema. It SHOULD be ignored if + "contentMediaType" is not present.

    +
    +
    +

    +8.6. Example +

    +

    + Here is an example schema, illustrating the use of "contentEncoding" and + "contentMediaType":

    +
    +
    +
    +{
    +    "type": "string",
    +    "contentEncoding": "base64",
    +    "contentMediaType": "image/png"
    +}
    +
    +
    +
    +

    + Instances described by this schema are expected to be strings, + and their values should be interpretable as base64-encoded PNG images.

    +

    + Another example:

    +
    +
    +
    +{
    +    "type": "string",
    +    "contentMediaType": "text/html"
    +}
    +
    +
    +
    +

    + Instances described by this schema are expected to be strings containing HTML, + using whatever character set the JSON string was decoded into. + Per section 8.1 of + RFC 8259 [RFC8259], outside of an entirely closed + system, this MUST be UTF-8.

    +

    + This example describes a JWT that is MACed using the HMAC SHA-256 + algorithm, and requires the "iss" and "exp" fields in its claim set.

    +
    +
    +
    +{
    +    "type": "string",
    +    "contentMediaType": "application/jwt",
    +    "contentSchema": {
    +        "type": "array",
    +        "minItems": 2,
    +        "prefixItems": [
    +            {
    +                "const": {
    +                    "typ": "JWT",
    +                    "alg": "HS256"
    +                }
    +            },
    +            {
    +                "type": "object",
    +                "required": ["iss", "exp"],
    +                "properties": {
    +                    "iss": {"type": "string"},
    +                    "exp": {"type": "integer"}
    +                }
    +            }
    +        ]
    +    }
    +}
    +
    +
    +

    + Note that "contentEncoding" does not appear. While the "application/jwt" + media type makes use of base64url encoding, that is defined by the media + type, which determines how the JWT string is decoded into a list of two + JSON data structures: first the header, and then the payload. Since the + JWT media type ensures that the JWT can be represented in a JSON string, + there is no need for further encoding or decoding.

    +
    +
    +
    +
    +

    +9. A Vocabulary for Basic Meta-Data Annotations +

    +

    + These general-purpose annotation keywords provide commonly used information + for documentation and user interface display purposes. They are not intended + to form a comprehensive set of features. Rather, additional vocabularies + can be defined for more complex annotation-based applications.

    +

    + Meta-schemas that do not use "$vocabulary" SHOULD be considered to + require this vocabulary as if its URI were present with a value of true.

    +

    + The current URI for this vocabulary, known as the Meta-Data vocabulary, is: + <https://json-schema.org/draft/2020-12/vocab/meta-data>.

    +

    + The current URI for the corresponding meta-schema is: + https://json-schema.org/draft/2020-12/meta/meta-data.

    +
    +

    +9.1. "title" and "description" +

    +

    + The value of both of these keywords MUST be a string.

    +

    + Both of these keywords can be used to decorate a user interface with + information about the data produced by this user interface. A title will + preferably be short, whereas a description will provide explanation about + the purpose of the instance described by this schema.

    +
    +
    +

    +9.2. "default" +

    +

    + There are no restrictions placed on the value of this keyword. When + multiple occurrences of this keyword are applicable to a single + sub-instance, implementations SHOULD remove duplicates.

    +

    + This keyword can be used to supply a default JSON value associated with a + particular schema. It is RECOMMENDED that a default value be valid against + the associated schema.

    +
    +
    +

    +9.3. "deprecated" +

    +

    + The value of this keyword MUST be a boolean. When multiple occurrences + of this keyword are applicable to a single sub-instance, applications + SHOULD consider the instance location to be deprecated if any occurrence + specifies a true value.

    +

    + If "deprecated" has a value of boolean true, it indicates that applications + SHOULD refrain from usage of the declared property. It MAY mean the property + is going to be removed in the future.

    +

    + A root schema containing "deprecated" with a value of true indicates that + the entire resource being described MAY be removed in the future.

    +

    + The "deprecated" keyword applies to each instance location to which the + schema object containing the keyword successfully applies. This can + result in scenarios where every array item or object property + is deprecated even though the containing array or object is not.

    +

    + Omitting this keyword has the same behavior as a value of false.

    +
    +
    +

    +9.4. "readOnly" and "writeOnly" +

    +

    + The value of these keywords MUST be a boolean. When multiple occurrences + of these keywords are applicable to a single sub-instance, the resulting + behavior SHOULD be as for a true value if any occurrence specifies a true value, + and SHOULD be as for a false value otherwise.

    +

    + If "readOnly" has a value of boolean true, it indicates that the value + of the instance is managed exclusively by the owning authority, and + attempts by an application to modify the value of this property are + expected to be ignored or rejected by that owning authority.

    +

    + An instance document that is marked as "readOnly" for the entire document + MAY be ignored if sent to the owning authority, or MAY result in an + error, at the authority's discretion.

    +

    + If "writeOnly" has a value of boolean true, it indicates that the value + is never present when the instance is retrieved from the owning authority. + It can be present when sent to the owning authority to update or create + the document (or the resource it represents), but it will not be included + in any updated or newly created version of the instance.

    +

    + An instance document that is marked as "writeOnly" for the entire document + MAY be returned as a blank document of some sort, or MAY produce an error + upon retrieval, or have the retrieval request ignored, at the authority's + discretion.

    +

    + For example, "readOnly" would be used to mark a database-generated serial + number as read-only, while "writeOnly" would be used to mark a password + input field.

    +

    + These keywords can be used to assist in user interface instance generation. + In particular, an application MAY choose to use a widget that hides + input values as they are typed for write-only fields.

    +

    + Omitting these keywords has the same behavior as values of false.

    +
    +
    +

    +9.5. "examples" +

    +

    + The value of this keyword MUST be an array. + There are no restrictions placed on the values within the array. + When multiple occurrences of this keyword are applicable to a single + sub-instance, implementations MUST provide a flat array of all + values rather than an array of arrays.

    +

    + This keyword can be used to provide sample JSON values associated with a + particular schema, for the purpose of illustrating usage. It is + RECOMMENDED that these values be valid against the associated schema.

    +

    + Implementations MAY use the value(s) of "default", if present, as + an additional example. If "examples" is absent, "default" + MAY still be used in this manner.

    +
    +
    +
    +
    +

    +10. Security Considerations +

    +

    + JSON Schema validation defines a vocabulary for JSON Schema core and concerns all + the security considerations listed there.

    +

    + JSON Schema validation allows the use of Regular Expressions, which have numerous + different (often incompatible) implementations. + Some implementations allow the embedding of arbitrary code, which is outside the + scope of JSON Schema and MUST NOT be permitted. + Regular expressions can often also be crafted to be extremely expensive to compute + (with so-called "catastrophic backtracking"), resulting in a denial-of-service + attack.

    +

    + Implementations that support validating or otherwise evaluating instance + string data based on "contentEncoding" and/or "contentMediaType" are at + risk of evaluating data in an unsafe way based on misleading information. + Applications can mitigate this risk by only performing such processing + when a relationship between the schema and instance is established + (e.g., they share the same authority).

    +

    + Processing a media type or encoding is subject to the security considerations + of that media type or encoding. For example, the security considerations + of RFC 4329 Scripting Media Types [RFC4329] apply when + processing JavaScript or ECMAScript encoded within a JSON string.

    +
    +
    +
    +

    +11. References +

    +
    +

    +11.1. Normative References +

    +
    +
    [RFC2119]
    +
    +Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://www.rfc-editor.org/info/rfc2119>.
    +
    +
    [RFC1123]
    +
    +Braden, R., Ed., "Requirements for Internet Hosts - Application and Support", STD 3, RFC 1123, DOI 10.17487/RFC1123, , <https://www.rfc-editor.org/info/rfc1123>.
    +
    +
    [RFC2045]
    +
    +Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", RFC 2045, DOI 10.17487/RFC2045, , <https://www.rfc-editor.org/info/rfc2045>.
    +
    +
    [RFC2046]
    +
    +Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types", RFC 2046, DOI 10.17487/RFC2046, , <https://www.rfc-editor.org/info/rfc2046>.
    +
    +
    [RFC2673]
    +
    +Crawford, M., "Binary Labels in the Domain Name System", RFC 2673, DOI 10.17487/RFC2673, , <https://www.rfc-editor.org/info/rfc2673>.
    +
    +
    [RFC3339]
    +
    +Klyne, G. and C. Newman, "Date and Time on the Internet: Timestamps", RFC 3339, DOI 10.17487/RFC3339, , <https://www.rfc-editor.org/info/rfc3339>.
    +
    +
    [RFC3986]
    +
    +Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, , <https://www.rfc-editor.org/info/rfc3986>.
    +
    +
    [RFC3987]
    +
    +Duerst, M. and M. Suignard, "Internationalized Resource Identifiers (IRIs)", RFC 3987, DOI 10.17487/RFC3987, , <https://www.rfc-editor.org/info/rfc3987>.
    +
    +
    [RFC4122]
    +
    +Leach, P., Mealling, M., and R. Salz, "A Universally Unique IDentifier (UUID) URN Namespace", RFC 4122, DOI 10.17487/RFC4122, , <https://www.rfc-editor.org/info/rfc4122>.
    +
    +
    [RFC4291]
    +
    +Hinden, R. and S. Deering, "IP Version 6 Addressing Architecture", RFC 4291, DOI 10.17487/RFC4291, , <https://www.rfc-editor.org/info/rfc4291>.
    +
    +
    [RFC4648]
    +
    +Josefsson, S., "The Base16, Base32, and Base64 Data Encodings", RFC 4648, DOI 10.17487/RFC4648, , <https://www.rfc-editor.org/info/rfc4648>.
    +
    +
    [RFC5321]
    +
    +Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, DOI 10.17487/RFC5321, , <https://www.rfc-editor.org/info/rfc5321>.
    +
    +
    [RFC5890]
    +
    +Klensin, J., "Internationalized Domain Names for Applications (IDNA): Definitions and Document Framework", RFC 5890, DOI 10.17487/RFC5890, , <https://www.rfc-editor.org/info/rfc5890>.
    +
    +
    [RFC5891]
    +
    +Klensin, J., "Internationalized Domain Names in Applications (IDNA): Protocol", RFC 5891, DOI 10.17487/RFC5891, , <https://www.rfc-editor.org/info/rfc5891>.
    +
    +
    [RFC6570]
    +
    +Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, "URI Template", RFC 6570, DOI 10.17487/RFC6570, , <https://www.rfc-editor.org/info/rfc6570>.
    +
    +
    [RFC6531]
    +
    +Yao, J. and W. Mao, "SMTP Extension for Internationalized Email", RFC 6531, DOI 10.17487/RFC6531, , <https://www.rfc-editor.org/info/rfc6531>.
    +
    +
    [RFC6901]
    +
    +Bryan, P., Ed., Zyp, K., and M. Nottingham, Ed., "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, , <https://www.rfc-editor.org/info/rfc6901>.
    +
    +
    [RFC8259]
    +
    +Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, , <https://www.rfc-editor.org/info/rfc8259>.
    +
    +
    [ecma262]
    +
    +"ECMA-262, 11th edition specification", , <https://www.ecma-international.org/ecma-262/11.0>.
    +
    +
    [relative-json-pointer]
    +
    +Luff, G., Andrews, H., and B. Hutton, Ed., "Relative JSON Pointers", Work in Progress, Internet-Draft, draft-handrews-relative-json-pointer-01, , <https://datatracker.ietf.org/doc/html/draft-handrews-relative-json-pointer-01>.
    +
    +
    [json-schema]
    +
    +Wright, A., Andrews, H., Hutton, B., and G. Dennis, "JSON Schema: A Media Type for Describing JSON Documents", Work in Progress, Internet-Draft, draft-bhutton-json-schema-01, , <https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-01>.
    +
    +
    +
    +
    +

    +11.2. Informative References +

    +
    +
    [RFC4329]
    +
    +Hoehrmann, B., "Scripting Media Types", RFC 4329, DOI 10.17487/RFC4329, , <https://www.rfc-editor.org/info/rfc4329>.
    +
    +
    +
    +
    +
    +

    +Appendix A. Keywords Moved from Validation to Core +

    +

    + Several keywords have been moved from this document into the + Core Specification [json-schema] as of this draft, in some + cases with re-naming or other changes. This affects the following former + validation keywords:

    +
    +
    "definitions"
    +
    + Renamed to "$defs" to match "$ref" and be shorter to type. + Schema vocabulary authors SHOULD NOT define a "definitions" keyword + with different behavior in order to avoid invalidating schemas that + still use the older name. While "definitions" is absent in the + single-vocabulary meta-schemas referenced by this document, it + remains present in the default meta-schema, and implementations + SHOULD assume that "$defs" and "definitions" have the same + behavior when that meta-schema is used. +
    +
    +
    "allOf", "anyOf", "oneOf", "not", "if", "then", "else", "items", "additionalItems", "contains", "propertyNames", "properties", "patternProperties", "additionalProperties"
    +
    + All of these keywords apply subschemas to the instance and combine + their results, without asserting any conditions of their own. + Without assertion keywords, these applicators can only cause assertion + failures by using the false boolean schema, or by inverting the result + of the true boolean schema (or equivalent schema objects). + For this reason, they are better defined as a generic mechanism on which + validation, hyper-schema, and extension vocabularies can all be based. +
    +
    +
    "dependencies"
    +
    + This keyword had two different modes of behavior, which made it + relatively challenging to implement and reason about. + The schema form has been moved to Core and renamed to + "dependentSchemas", as part of the applicator vocabulary. + It is analogous to "properties", except that instead of applying + its subschema to the property value, it applies it to the object + containing the property. + The property name array form is retained here and renamed to + "dependentRequired", as it is an assertion which is a shortcut + for the conditional use of the "required" assertion keyword. +
    +
    +
    +
    +
    +

    +Appendix B. Acknowledgments +

    +

    + Thanks to + Gary Court, + Francis Galiegue, + Kris Zyp, + and Geraint Luff + for their work on the initial drafts of JSON Schema.

    +

    + Thanks to + Jason Desrosiers, + Daniel Perrett, + Erik Wilde, + Evgeny Poberezkin, + Brad Bowman, + Gowry Sankar, + Donald Pipowitch, + Dave Finlay, + Denis Laxalde, + Phil Sturgeon, + Shawn Silverman, + and Karen Etheridge + for their submissions and patches to the document.

    +
    +
    +

    +Appendix C. ChangeLog +

    +

    + This section to be removed before leaving Internet-Draft status.

    +
    +
    draft-bhutton-json-schema-validation-01
    +
    +
      +
    • Improve and clarify the "minContains" keyword explanation +
    • +
    • Remove the use of "production" in favour of "ABNF rule" +
    • +
    +
    +
    +
    draft-bhutton-json-schema-validation-00
    +
    +
      +
    • Correct email format RFC reference to 5321 instead of 5322 +
    • +
    • Clarified the set and meaning of "contentEncoding" values +
    • +
    • Reference ECMA-262, 11th edition for regular expression support +
    • +
    • Split "format" into an annotation only vocabulary and an assertion vocabulary +
    • +
    • Clarify "deprecated" when applicable to arrays +
    • +
    +
    +
    +
    draft-handrews-json-schema-validation-02
    +
    +
      +
    • Grouped keywords into formal vocabularies +
    • +
    • Update "format" implementation requirements in terms of vocabularies +
    • +
    • By default, "format" MUST NOT be validated, although validation can be enabled +
    • +
    • A vocabulary declaration can be used to require "format" validation +
    • +
    • Moved "definitions" to the core spec as "$defs" +
    • +
    • Moved applicator keywords to the core spec +
    • +
    • Renamed the array form of "dependencies" to "dependentRequired", moved the schema form to the core spec +
    • +
    • Specified all "content*" keywords as annotations, not assertions +
    • +
    • Added "contentSchema" to allow applying a schema to a string-encoded document +
    • +
    • Also allow RFC 4648 encodings in "contentEncoding" +
    • +
    • Added "minContains" and "maxContains" +
    • +
    • Update RFC reference for "hostname" and "idn-hostname" +
    • +
    • Add "uuid" and "duration" formats +
    • +
    +
    +
    +
    draft-handrews-json-schema-validation-01
    +
    +
      +
    • This draft is purely a clarification with no functional changes +
    • +
    • Provided the general principle behind ignoring annotations under "not" and similar cases +
    • +
    • Clarified "if"/"then"/"else" validation interactions +
    • +
    • Clarified "if"/"then"/"else" behavior for annotation +
    • +
    • Minor formatting and cross-referencing improvements +
    • +
    +
    +
    +
    draft-handrews-json-schema-validation-00
    +
    +
      +
    • Added "if"/"then"/"else" +
    • +
    • Classify keywords as assertions or annotations per the core spec +
    • +
    • Warn of possibly removing "dependencies" in the future +
    • +
    • Grouped validation keywords into sub-sections for readability +
    • +
    • Moved "readOnly" from hyper-schema to validation meta-data +
    • +
    • Added "writeOnly" +
    • +
    • Added string-encoded media section, with former hyper-schema "media" keywords +
    • +
    • Restored "regex" format (removal was unintentional) +
    • +
    • Added "date" and "time" formats, and reserved additional RFC 3339 format names +
    • +
    • I18N formats: "iri", "iri-reference", "idn-hostname", "idn-email" +
    • +
    • Clarify that "json-pointer" format means string encoding, not URI fragment +
    • +
    • Fixed typo that inverted the meaning of "minimum" and "exclusiveMinimum" +
    • +
    • Move format syntax references into Normative References +
    • +
    • JSON is a normative requirement +
    • +
    +
    +
    +
    draft-wright-json-schema-validation-01
    +
    +
      +
    • Standardized on hyphenated format names with full words ("uriref" becomes "uri-reference") +
    • +
    • Add the formats "uri-template" and "json-pointer" +
    • +
    • Changed "exclusiveMaximum"/"exclusiveMinimum" from boolean modifiers of "maximum"/"minimum" to independent numeric fields. +
    • +
    • Split the additionalItems/items into two sections +
    • +
    • Reworked properties/patternProperties/additionalProperties definition +
    • +
    • Added "examples" keyword +
    • +
    • Added "contains" keyword +
    • +
    • Allow empty "required" and "dependencies" arrays +
    • +
    • Fixed "type" reference to primitive types +
    • +
    • Added "const" keyword +
    • +
    • Added "propertyNames" keyword +
    • +
    +
    +
    +
    draft-wright-json-schema-validation-00
    +
    +
      +
    • Added additional security considerations +
    • +
    • Removed reference to "latest version" meta-schema, use numbered version instead +
    • +
    • Rephrased many keyword definitions for brevity +
    • +
    • Added "uriref" format that also allows relative URI references +
    • +
    +
    +
    +
    draft-fge-json-schema-validation-00
    +
    +
      +
    • Initial draft. +
    • +
    • Salvaged from draft v3. +
    • +
    • Redefine the "required" keyword. +
    • +
    • Remove "extends", "disallow" +
    • +
    • Add "anyOf", "allOf", "oneOf", "not", "definitions", "minProperties", + "maxProperties". +
    • +
    • "dependencies" member values can no longer be single strings; at + least one element is required in a property dependency array. +
    • +
    • Rename "divisibleBy" to "multipleOf". +
    • +
    • "type" arrays can no longer have schemas; remove "any" as a possible + value. +
    • +
    • Rework the "format" section; make support optional. +
    • +
    • "format": remove attributes "phone", "style", "color"; rename + "ip-address" to "ipv4"; add references for all attributes. +
    • +
    • Provide algorithms to calculate schema(s) for array/object + instances. +
    • +
    • Add interoperability considerations. +
    • +
    +
    +
    +
    +
    +
    +
    +

    +Authors' Addresses +

    +
    +
    Austin Wright (editor)
    + +
    +
    +
    Henry Andrews (editor)
    + +
    +
    +
    Ben Hutton (editor)
    +
    Postman
    + + +
    +
    +
    + + + From c5d76f2de721d63651b93720ea85cca1009f924f Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 16 Jun 2022 18:12:35 +0100 Subject: [PATCH 203/311] Mention the updated spec documents on the home page --- index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.md b/index.md index 57313053..9e0f6d8d 100644 --- a/index.md +++ b/index.md @@ -64,6 +64,10 @@ We monitor the `jsonschema` tag on StackOverflow. ## Project Status +2021-06-10: A patch release of Draft 2020-12 has been published with no functional changes. + +The new IETF document IDs are of the form `draft-bhutton-*-01`. + 2021-02-01: Draft 2020-12 has been published! The IETF document IDs are of the form `draft-bhutton-*-00`. From 73f1d961ae72758a9ae1748e34633fb75e5434d3 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Fri, 17 Jun 2022 09:28:08 +0100 Subject: [PATCH 204/311] Correct date for latest project update --- index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.md b/index.md index 9e0f6d8d..f30d9e8e 100644 --- a/index.md +++ b/index.md @@ -64,7 +64,7 @@ We monitor the `jsonschema` tag on StackOverflow. ## Project Status -2021-06-10: A patch release of Draft 2020-12 has been published with no functional changes. +2022-06-10: A patch release of Draft 2020-12 has been published with no functional changes. The new IETF document IDs are of the form `draft-bhutton-*-01`. From d54787c7ec752afa1b6a86a66bd124181112ba73 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Wed, 22 Jun 2022 12:27:47 +0100 Subject: [PATCH 205/311] Fix indentation for .gitmodules file --- .gitmodules | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 5b323ddb..d2f583c4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,18 +10,18 @@ [submodule "_includes/draft-03"] path = _includes/draft-03 url = https://github.com/json-schema-org/json-schema-spec.git - branch = draft-03 + branch = draft-03 [submodule "_includes/draft-04"] path = _includes/draft-04 url = https://github.com/json-schema-org/json-schema-spec.git - branch = draft-04 + branch = draft-04 [submodule "_includes/draft-05"] path = _includes/draft-05 url = https://github.com/json-schema-org/json-schema-spec.git [submodule "_includes/draft-06"] path = _includes/draft-06 url = https://github.com/json-schema-org/json-schema-spec.git - branch = draft-06 + branch = draft-06 [submodule "_includes/draft-07"] path = _includes/draft-07 url = https://github.com/json-schema-org/json-schema-spec.git From 751a1757a16f1c2a5cf12dbc0d6f015d63ff2358 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 Jun 2022 12:29:04 +0000 Subject: [PATCH 206/311] Bump addressable from 2.5.2 to 2.8.0 Bumps [addressable](https://github.com/sporkmonger/addressable) from 2.5.2 to 2.8.0. - [Release notes](https://github.com/sporkmonger/addressable/releases) - [Changelog](https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md) - [Commits](https://github.com/sporkmonger/addressable/compare/addressable-2.5.2...addressable-2.8.0) --- updated-dependencies: - dependency-name: addressable dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 57 +++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 25dd3da2..94b93244 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,8 +6,8 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) + addressable (2.8.0) + public_suffix (>= 2.0.2, < 5.0) coffee-script (2.4.1) coffee-script-source execjs @@ -15,17 +15,19 @@ GEM colorator (1.1.0) commonmarker (0.17.9) ruby-enum (~> 0.5) - concurrent-ruby (1.0.5) - em-websocket (0.5.1) + concurrent-ruby (1.1.10) + em-websocket (0.5.3) eventmachine (>= 0.12.9) - http_parser.rb (~> 0.6.0) - ethon (0.11.0) - ffi (>= 1.3.0) - eventmachine (1.2.5) + http_parser.rb (~> 0) + ethon (0.15.0) + ffi (>= 1.15.0) + eventmachine (1.2.7) execjs (2.7.0) - faraday (0.14.0) - multipart-post (>= 1.2, < 3) - ffi (1.9.23) + faraday (2.3.0) + faraday-net_http (~> 2.0) + ruby2_keywords (>= 0.0.4) + faraday-net_http (2.0.3) + ffi (1.15.5) forwardable-extended (2.6.0) gemoji (3.0.0) github-pages (182) @@ -82,7 +84,7 @@ GEM html-pipeline (2.7.1) activesupport (>= 2) nokogiri (>= 1.4) - http_parser.rb (0.6.0) + http_parser.rb (0.8.0) i18n (0.9.5) concurrent-ruby (~> 1.0) jekyll (3.7.3) @@ -185,7 +187,7 @@ GEM jekyll-seo-tag (~> 2.0) jekyll-titles-from-headings (0.5.1) jekyll (~> 3.3) - jekyll-watch (2.0.0) + jekyll-watch (2.2.1) listen (~> 3.0) jemoji (0.9.0) activesupport (~> 4.0, >= 4.2.9) @@ -205,38 +207,39 @@ GEM jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) minitest (5.11.3) - multipart-post (2.0.0) - net-dns (0.8.0) + net-dns (0.9.0) nokogiri (1.13.6) mini_portile2 (~> 2.8.0) racc (~> 1.4) - octokit (4.8.0) - sawyer (~> 0.8.0, >= 0.5.3) - pathutil (0.16.1) + octokit (4.25.0) + faraday (>= 1, < 3) + sawyer (~> 0.9) + pathutil (0.16.2) forwardable-extended (~> 2.6) public_suffix (2.0.5) racc (1.6.0) - rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) + rb-fsevent (0.11.1) + rb-inotify (0.10.1) + ffi (~> 1.0) rouge (2.2.1) ruby-enum (0.7.2) i18n + ruby2_keywords (0.0.5) ruby_dep (1.5.0) rubyzip (2.0.0) - safe_yaml (1.0.4) - sass (3.5.6) + safe_yaml (1.0.5) + sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sawyer (0.8.1) - addressable (>= 2.3.5, < 2.6) - faraday (~> 0.8, < 1.0) + sawyer (0.9.2) + addressable (>= 2.3.5) + faraday (>= 0.17.3, < 3) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) thread_safe (0.3.6) - typhoeus (1.3.0) + typhoeus (1.4.0) ethon (>= 0.9.0) tzinfo (1.2.5) thread_safe (~> 0.1) From fe609af26e5eb6af03ef2d1c915c5beb44ebb9d8 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 22 Jun 2022 10:25:40 -0400 Subject: [PATCH 207/311] Update github-pages (and transitive deps of it). Should solve the remaining dependabot alert about kramdown, which otherwise is refusing to send a PR (because the version of github-pages was too old). --- Gemfile.lock | 274 ++++++++++++++++++++++++++------------------------- 1 file changed, 141 insertions(+), 133 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 94b93244..1f5915d2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,11 +1,12 @@ GEM remote: https://rubygems.org/ specs: - activesupport (4.2.9) - i18n (~> 0.7) + activesupport (6.0.5) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) + zeitwerk (~> 2.2, >= 2.2.2) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) coffee-script (2.4.1) @@ -13,201 +14,204 @@ GEM execjs coffee-script-source (1.11.1) colorator (1.1.0) - commonmarker (0.17.9) - ruby-enum (~> 0.5) + commonmarker (0.23.5) concurrent-ruby (1.1.10) + dnsruby (1.61.9) + simpleidn (~> 0.1) em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) ethon (0.15.0) ffi (>= 1.15.0) eventmachine (1.2.7) - execjs (2.7.0) + execjs (2.8.1) faraday (2.3.0) faraday-net_http (~> 2.0) ruby2_keywords (>= 0.0.4) faraday-net_http (2.0.3) ffi (1.15.5) forwardable-extended (2.6.0) - gemoji (3.0.0) - github-pages (182) - activesupport (= 4.2.9) - github-pages-health-check (= 1.4.0) - jekyll (= 3.7.3) - jekyll-avatar (= 0.5.0) + gemoji (3.0.1) + github-pages (226) + github-pages-health-check (= 1.17.9) + jekyll (= 3.9.2) + jekyll-avatar (= 0.7.0) jekyll-coffeescript (= 1.1.1) - jekyll-commonmark-ghpages (= 0.1.5) + jekyll-commonmark-ghpages (= 0.2.0) jekyll-default-layout (= 0.1.4) - jekyll-feed (= 0.9.3) + jekyll-feed (= 0.15.1) jekyll-gist (= 1.5.0) - jekyll-github-metadata (= 2.9.4) - jekyll-mentions (= 1.3.0) - jekyll-optional-front-matter (= 0.3.0) + jekyll-github-metadata (= 2.13.0) + jekyll-include-cache (= 0.2.1) + jekyll-mentions (= 1.6.0) + jekyll-optional-front-matter (= 0.3.2) jekyll-paginate (= 1.1.0) - jekyll-readme-index (= 0.2.0) - jekyll-redirect-from (= 0.13.0) - jekyll-relative-links (= 0.5.3) - jekyll-remote-theme (= 0.2.3) + jekyll-readme-index (= 0.3.0) + jekyll-redirect-from (= 0.16.0) + jekyll-relative-links (= 0.6.1) + jekyll-remote-theme (= 0.4.3) jekyll-sass-converter (= 1.5.2) - jekyll-seo-tag (= 2.4.0) - jekyll-sitemap (= 1.2.0) - jekyll-swiss (= 0.4.0) - jekyll-theme-architect (= 0.1.1) - jekyll-theme-cayman (= 0.1.1) - jekyll-theme-dinky (= 0.1.1) - jekyll-theme-hacker (= 0.1.1) - jekyll-theme-leap-day (= 0.1.1) - jekyll-theme-merlot (= 0.1.1) - jekyll-theme-midnight (= 0.1.1) - jekyll-theme-minimal (= 0.1.1) - jekyll-theme-modernist (= 0.1.1) - jekyll-theme-primer (= 0.5.3) - jekyll-theme-slate (= 0.1.1) - jekyll-theme-tactile (= 0.1.1) - jekyll-theme-time-machine (= 0.1.1) - jekyll-titles-from-headings (= 0.5.1) - jemoji (= 0.9.0) - kramdown (= 1.16.2) - liquid (= 4.0.0) - listen (= 3.1.5) + jekyll-seo-tag (= 2.8.0) + jekyll-sitemap (= 1.4.0) + jekyll-swiss (= 1.0.0) + jekyll-theme-architect (= 0.2.0) + jekyll-theme-cayman (= 0.2.0) + jekyll-theme-dinky (= 0.2.0) + jekyll-theme-hacker (= 0.2.0) + jekyll-theme-leap-day (= 0.2.0) + jekyll-theme-merlot (= 0.2.0) + jekyll-theme-midnight (= 0.2.0) + jekyll-theme-minimal (= 0.2.0) + jekyll-theme-modernist (= 0.2.0) + jekyll-theme-primer (= 0.6.0) + jekyll-theme-slate (= 0.2.0) + jekyll-theme-tactile (= 0.2.0) + jekyll-theme-time-machine (= 0.2.0) + jekyll-titles-from-headings (= 0.5.3) + jemoji (= 0.12.0) + kramdown (= 2.3.2) + kramdown-parser-gfm (= 1.1.0) + liquid (= 4.0.3) mercenary (~> 0.3) - minima (= 2.4.1) - nokogiri (>= 1.8.1, < 2.0) - rouge (= 2.2.1) + minima (= 2.5.1) + nokogiri (>= 1.13.4, < 2.0) + rouge (= 3.26.0) terminal-table (~> 1.4) - github-pages-health-check (1.4.0) + github-pages-health-check (1.17.9) addressable (~> 2.3) - net-dns (~> 0.8) + dnsruby (~> 1.60) octokit (~> 4.0) - public_suffix (~> 2.0) + public_suffix (>= 3.0, < 5.0) typhoeus (~> 1.3) - html-pipeline (2.7.1) + html-pipeline (2.14.2) activesupport (>= 2) nokogiri (>= 1.4) http_parser.rb (0.8.0) i18n (0.9.5) concurrent-ruby (~> 1.0) - jekyll (3.7.3) + jekyll (3.9.2) addressable (~> 2.4) colorator (~> 1.0) em-websocket (~> 0.5) i18n (~> 0.7) jekyll-sass-converter (~> 1.0) jekyll-watch (~> 2.0) - kramdown (~> 1.14) + kramdown (>= 1.17, < 3) liquid (~> 4.0) mercenary (~> 0.3.3) pathutil (~> 0.9) rouge (>= 1.7, < 4) safe_yaml (~> 1.0) - jekyll-avatar (0.5.0) - jekyll (~> 3.0) + jekyll-avatar (0.7.0) + jekyll (>= 3.0, < 5.0) jekyll-coffeescript (1.1.1) coffee-script (~> 2.2) coffee-script-source (~> 1.11.1) - jekyll-commonmark (1.2.0) - commonmarker (~> 0.14) - jekyll (>= 3.0, < 4.0) - jekyll-commonmark-ghpages (0.1.5) - commonmarker (~> 0.17.6) - jekyll-commonmark (~> 1) - rouge (~> 2) + jekyll-commonmark (1.4.0) + commonmarker (~> 0.22) + jekyll-commonmark-ghpages (0.2.0) + commonmarker (~> 0.23.4) + jekyll (~> 3.9.0) + jekyll-commonmark (~> 1.4.0) + rouge (>= 2.0, < 4.0) jekyll-default-layout (0.1.4) jekyll (~> 3.0) - jekyll-feed (0.9.3) - jekyll (~> 3.3) + jekyll-feed (0.15.1) + jekyll (>= 3.7, < 5.0) jekyll-gist (1.5.0) octokit (~> 4.2) - jekyll-github-metadata (2.9.4) - jekyll (~> 3.1) + jekyll-github-metadata (2.13.0) + jekyll (>= 3.4, < 5.0) octokit (~> 4.0, != 4.4.0) - jekyll-mentions (1.3.0) - activesupport (~> 4.0) + jekyll-include-cache (0.2.1) + jekyll (>= 3.7, < 5.0) + jekyll-mentions (1.6.0) html-pipeline (~> 2.3) - jekyll (~> 3.0) - jekyll-optional-front-matter (0.3.0) - jekyll (~> 3.0) + jekyll (>= 3.7, < 5.0) + jekyll-optional-front-matter (0.3.2) + jekyll (>= 3.0, < 5.0) jekyll-paginate (1.1.0) - jekyll-readme-index (0.2.0) - jekyll (~> 3.0) - jekyll-redirect-from (0.13.0) - jekyll (~> 3.3) - jekyll-relative-links (0.5.3) - jekyll (~> 3.3) - jekyll-remote-theme (0.2.3) - jekyll (~> 3.5) - rubyzip (>= 1.2.1, < 3.0) - typhoeus (>= 0.7, < 2.0) + jekyll-readme-index (0.3.0) + jekyll (>= 3.0, < 5.0) + jekyll-redirect-from (0.16.0) + jekyll (>= 3.3, < 5.0) + jekyll-relative-links (0.6.1) + jekyll (>= 3.3, < 5.0) + jekyll-remote-theme (0.4.3) + addressable (~> 2.0) + jekyll (>= 3.5, < 5.0) + jekyll-sass-converter (>= 1.0, <= 3.0.0, != 2.0.0) + rubyzip (>= 1.3.0, < 3.0) jekyll-sass-converter (1.5.2) sass (~> 3.4) - jekyll-seo-tag (2.4.0) - jekyll (~> 3.3) - jekyll-sitemap (1.2.0) - jekyll (~> 3.3) - jekyll-swiss (0.4.0) - jekyll-theme-architect (0.1.1) - jekyll (~> 3.5) + jekyll-seo-tag (2.8.0) + jekyll (>= 3.8, < 5.0) + jekyll-sitemap (1.4.0) + jekyll (>= 3.7, < 5.0) + jekyll-swiss (1.0.0) + jekyll-theme-architect (0.2.0) + jekyll (> 3.5, < 5.0) jekyll-seo-tag (~> 2.0) - jekyll-theme-cayman (0.1.1) - jekyll (~> 3.5) + jekyll-theme-cayman (0.2.0) + jekyll (> 3.5, < 5.0) jekyll-seo-tag (~> 2.0) - jekyll-theme-dinky (0.1.1) - jekyll (~> 3.5) + jekyll-theme-dinky (0.2.0) + jekyll (> 3.5, < 5.0) jekyll-seo-tag (~> 2.0) - jekyll-theme-hacker (0.1.1) - jekyll (~> 3.5) + jekyll-theme-hacker (0.2.0) + jekyll (> 3.5, < 5.0) jekyll-seo-tag (~> 2.0) - jekyll-theme-leap-day (0.1.1) - jekyll (~> 3.5) + jekyll-theme-leap-day (0.2.0) + jekyll (> 3.5, < 5.0) jekyll-seo-tag (~> 2.0) - jekyll-theme-merlot (0.1.1) - jekyll (~> 3.5) + jekyll-theme-merlot (0.2.0) + jekyll (> 3.5, < 5.0) jekyll-seo-tag (~> 2.0) - jekyll-theme-midnight (0.1.1) - jekyll (~> 3.5) + jekyll-theme-midnight (0.2.0) + jekyll (> 3.5, < 5.0) jekyll-seo-tag (~> 2.0) - jekyll-theme-minimal (0.1.1) - jekyll (~> 3.5) + jekyll-theme-minimal (0.2.0) + jekyll (> 3.5, < 5.0) jekyll-seo-tag (~> 2.0) - jekyll-theme-modernist (0.1.1) - jekyll (~> 3.5) + jekyll-theme-modernist (0.2.0) + jekyll (> 3.5, < 5.0) jekyll-seo-tag (~> 2.0) - jekyll-theme-primer (0.5.3) - jekyll (~> 3.5) + jekyll-theme-primer (0.6.0) + jekyll (> 3.5, < 5.0) jekyll-github-metadata (~> 2.9) jekyll-seo-tag (~> 2.0) - jekyll-theme-slate (0.1.1) - jekyll (~> 3.5) + jekyll-theme-slate (0.2.0) + jekyll (> 3.5, < 5.0) jekyll-seo-tag (~> 2.0) - jekyll-theme-tactile (0.1.1) - jekyll (~> 3.5) + jekyll-theme-tactile (0.2.0) + jekyll (> 3.5, < 5.0) jekyll-seo-tag (~> 2.0) - jekyll-theme-time-machine (0.1.1) - jekyll (~> 3.5) + jekyll-theme-time-machine (0.2.0) + jekyll (> 3.5, < 5.0) jekyll-seo-tag (~> 2.0) - jekyll-titles-from-headings (0.5.1) - jekyll (~> 3.3) + jekyll-titles-from-headings (0.5.3) + jekyll (>= 3.3, < 5.0) jekyll-watch (2.2.1) listen (~> 3.0) - jemoji (0.9.0) - activesupport (~> 4.0, >= 4.2.9) + jemoji (0.12.0) gemoji (~> 3.0) html-pipeline (~> 2.2) - jekyll (~> 3.0) - kramdown (1.16.2) - liquid (4.0.0) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) + jekyll (>= 3.0, < 5.0) + kramdown (2.3.2) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + liquid (4.0.3) + listen (3.7.1) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) mercenary (0.3.6) mini_portile2 (2.8.0) - minima (2.4.1) - jekyll (~> 3.5) + minima (2.5.1) + jekyll (>= 3.5, < 5.0) jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) - minitest (5.11.3) - net-dns (0.9.0) + minitest (5.16.1) nokogiri (1.13.6) mini_portile2 (~> 2.8.0) racc (~> 1.4) @@ -216,17 +220,15 @@ GEM sawyer (~> 0.9) pathutil (0.16.2) forwardable-extended (~> 2.6) - public_suffix (2.0.5) + public_suffix (4.0.7) racc (1.6.0) rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) - rouge (2.2.1) - ruby-enum (0.7.2) - i18n + rexml (3.2.5) + rouge (3.26.0) ruby2_keywords (0.0.5) - ruby_dep (1.5.0) - rubyzip (2.0.0) + rubyzip (2.3.2) safe_yaml (1.0.5) sass (3.7.4) sass-listen (~> 4.0.0) @@ -236,14 +238,20 @@ GEM sawyer (0.9.2) addressable (>= 2.3.5) faraday (>= 0.17.3, < 3) + simpleidn (0.2.1) + unf (~> 0.1.4) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) thread_safe (0.3.6) typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (1.2.5) + tzinfo (1.2.9) thread_safe (~> 0.1) - unicode-display_width (1.3.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.8.2) + unicode-display_width (1.8.0) + zeitwerk (2.6.0) PLATFORMS ruby From bd21c05b50996bfb9003f833f371ff270d1e689e Mon Sep 17 00:00:00 2001 From: Clemens Uhlenhut Date: Wed, 29 Jun 2022 09:55:12 +0200 Subject: [PATCH 208/311] Added JSONBuddy Cli tool --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index ca0a2517..e947896d 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -362,3 +362,9 @@ date-draft: draft: [7, 6, 4] notes: wraps [xeipuuv/gojsonschema](https://github.com/xeipuuv/gojsonschema) + - name: valbuddy + license: Free and commercial versions + url: 'https://www.json-buddy.com/json-validator-command-line-tool.htm' + date-draft: + draft: [2019-09, 7, 6, 4] + notes: JSONBuddy cli tool. Windows platform. Support for large data and streaming validation. \ No newline at end of file From 51d141618b708e169ea750303e71341164b381c5 Mon Sep 17 00:00:00 2001 From: Clemens Uhlenhut Date: Wed, 29 Jun 2022 12:37:11 +0200 Subject: [PATCH 209/311] Update _data/validator-libraries-modern.yml Co-authored-by: Ben Hutton --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index e947896d..86ef7bb8 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -363,7 +363,7 @@ draft: [7, 6, 4] notes: wraps [xeipuuv/gojsonschema](https://github.com/xeipuuv/gojsonschema) - name: valbuddy - license: Free and commercial versions + license: Free and commercial versions (proprietary) url: 'https://www.json-buddy.com/json-validator-command-line-tool.htm' date-draft: draft: [2019-09, 7, 6, 4] From 2714cae4526b4b5b68b964b2114790a6dc02adc9 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Mon, 11 Jul 2022 09:38:22 +0100 Subject: [PATCH 210/311] Update day and time for Open Community Working Meetings --- index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.md b/index.md index f30d9e8e..df042724 100644 --- a/index.md +++ b/index.md @@ -41,7 +41,7 @@ We hold weekly Office Hours and twice monthly Open Community Working Meetings. Office Hours are every first Tuesday of the month at 15:00 UTC, and by appointment. -Open Community Working Meetings are every First and Third Friday of the month at 12:00 PT. +Open Community Working Meetings are every First and Third Monday of the month at 14:00 PT. ## Need more? From 08d994de463b8a7b59b73d73a772b37d425ce258 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Jul 2022 09:36:08 +0000 Subject: [PATCH 211/311] Bump tzinfo from 1.2.9 to 1.2.10 Bumps [tzinfo](https://github.com/tzinfo/tzinfo) from 1.2.9 to 1.2.10. - [Release notes](https://github.com/tzinfo/tzinfo/releases) - [Changelog](https://github.com/tzinfo/tzinfo/blob/master/CHANGES.md) - [Commits](https://github.com/tzinfo/tzinfo/compare/v1.2.9...v1.2.10) --- updated-dependencies: - dependency-name: tzinfo dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1f5915d2..a406fa2a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -245,7 +245,7 @@ GEM thread_safe (0.3.6) typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (1.2.9) + tzinfo (1.2.10) thread_safe (~> 0.1) unf (0.1.4) unf_ext From bbc6caaa81181d3ad881c146e8c822e5ce246a3e Mon Sep 17 00:00:00 2001 From: datensen <46059055+datensen@users.noreply.github.com> Date: Fri, 29 Jul 2022 15:11:47 +0200 Subject: [PATCH 212/311] add Perseid Modeler --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index 9ff96380..92197240 100644 --- a/implementations.md +++ b/implementations.md @@ -268,6 +268,7 @@ _None currently support draft-06 or later._ - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Liquid JSON Schema Editor](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON Schema editor for draft-04, draft-06, draft-07 and 2019-09, with split source code and grphical editing. Includes validation of JSON files based on JSON Schema, JSON Sample Generator and JSON Schema Documentation Generator.* - [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* +- [Perseid Modeler](https://www.datensen.com/data-modeling/perseid-modeler-for-json-schema.html) - *a modeling tool for JSON Schema and OpenAPI. Key features include: visual JSON schema creation using tree and ERD-like diagrams, support for JSON schema structures including operators and conditions, import of existing schemas from files, creation of detailed HTML reports, export to PDF, script generation, and more.* - [Stoplight Studio](https://stoplight.io/) - *JSON Schema IDE (text-based and GUI) with support for JSON/YAML linting, which can also be based on JSON Schema rules via Spectral. Support for draft-4, draft-6 and draft-7.* - [Visual Studio Code](https://code.visualstudio.com/) - *Schema driven code completion, hovers and validation for editing JSON files (including schemas)* - [WebStorm](https://www.jetbrains.com/webstorm/), [IntelliJ IDEA](https://www.jetbrains.com/idea/), and other [JetBrains IDEs](https://www.jetbrains.com/products.html?fromMenu#type=ide) - *Code completion, documentation, and validation for JSON and YAML files using JSON Schema. Support for draft-4, draft-6, and draft-7.* From c2d3acd658953087f0b0a859185aef87a0519c7a Mon Sep 17 00:00:00 2001 From: datensen <46059055+datensen@users.noreply.github.com> Date: Fri, 29 Jul 2022 17:48:55 +0200 Subject: [PATCH 213/311] updated version supported by Perseid Modeler --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 92197240..d82ce3f9 100644 --- a/implementations.md +++ b/implementations.md @@ -268,7 +268,7 @@ _None currently support draft-06 or later._ - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Liquid JSON Schema Editor](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON Schema editor for draft-04, draft-06, draft-07 and 2019-09, with split source code and grphical editing. Includes validation of JSON files based on JSON Schema, JSON Sample Generator and JSON Schema Documentation Generator.* - [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* -- [Perseid Modeler](https://www.datensen.com/data-modeling/perseid-modeler-for-json-schema.html) - *a modeling tool for JSON Schema and OpenAPI. Key features include: visual JSON schema creation using tree and ERD-like diagrams, support for JSON schema structures including operators and conditions, import of existing schemas from files, creation of detailed HTML reports, export to PDF, script generation, and more.* +- [Perseid Modeler](https://www.datensen.com/data-modeling/perseid-modeler-for-json-schema.html) - *a modeling tool for JSON Schema and OpenAPI. Key features include: visual JSON schema creation using tree and ERD-like diagrams, support for JSON schema structures including operators and conditions, import of existing schemas from files, creation of detailed HTML reports, export to PDF, script generation, and more. Supported versions: draft 4, 6,7, 2019-09 and 2020-12* - [Stoplight Studio](https://stoplight.io/) - *JSON Schema IDE (text-based and GUI) with support for JSON/YAML linting, which can also be based on JSON Schema rules via Spectral. Support for draft-4, draft-6 and draft-7.* - [Visual Studio Code](https://code.visualstudio.com/) - *Schema driven code completion, hovers and validation for editing JSON files (including schemas)* - [WebStorm](https://www.jetbrains.com/webstorm/), [IntelliJ IDEA](https://www.jetbrains.com/idea/), and other [JetBrains IDEs](https://www.jetbrains.com/products.html?fromMenu#type=ide) - *Code completion, documentation, and validation for JSON and YAML files using JSON Schema. Support for draft-4, draft-6, and draft-7.* From e342d397f5f6df9d5bc06542c929bb32ea9bf840 Mon Sep 17 00:00:00 2001 From: datensen <46059055+datensen@users.noreply.github.com> Date: Fri, 29 Jul 2022 17:50:03 +0200 Subject: [PATCH 214/311] Minor update for Perseid Modeler --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index d82ce3f9..8cffdd0d 100644 --- a/implementations.md +++ b/implementations.md @@ -268,7 +268,7 @@ _None currently support draft-06 or later._ - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Liquid JSON Schema Editor](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON Schema editor for draft-04, draft-06, draft-07 and 2019-09, with split source code and grphical editing. Includes validation of JSON files based on JSON Schema, JSON Sample Generator and JSON Schema Documentation Generator.* - [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* -- [Perseid Modeler](https://www.datensen.com/data-modeling/perseid-modeler-for-json-schema.html) - *a modeling tool for JSON Schema and OpenAPI. Key features include: visual JSON schema creation using tree and ERD-like diagrams, support for JSON schema structures including operators and conditions, import of existing schemas from files, creation of detailed HTML reports, export to PDF, script generation, and more. Supported versions: draft 4, 6,7, 2019-09 and 2020-12* +- [Perseid Modeler](https://www.datensen.com/data-modeling/perseid-modeler-for-json-schema.html) - *a modeling tool for JSON Schema and OpenAPI. Key features include: visual JSON schema creation using tree and ERD-like diagrams, support for JSON schema structures including operators and conditions, import of existing schemas from files, creation of detailed HTML reports, export to PDF, script generation, and more. Supported versions: draft 4, 6, 7, 2019-09 and 2020-12* - [Stoplight Studio](https://stoplight.io/) - *JSON Schema IDE (text-based and GUI) with support for JSON/YAML linting, which can also be based on JSON Schema rules via Spectral. Support for draft-4, draft-6 and draft-7.* - [Visual Studio Code](https://code.visualstudio.com/) - *Schema driven code completion, hovers and validation for editing JSON files (including schemas)* - [WebStorm](https://www.jetbrains.com/webstorm/), [IntelliJ IDEA](https://www.jetbrains.com/idea/), and other [JetBrains IDEs](https://www.jetbrains.com/products.html?fromMenu#type=ide) - *Code completion, documentation, and validation for JSON and YAML files using JSON Schema. Support for draft-4, draft-6, and draft-7.* From 90416a4885cb1d9654f852e177770a1a0fbb7eb6 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 4 Aug 2022 19:04:20 -0400 Subject: [PATCH 215/311] Add Alterschema to the implementations list Signed-off-by: Juan Cruz Viotti --- implementations.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 9ff96380..a6799cbc 100644 --- a/implementations.md +++ b/implementations.md @@ -240,7 +240,8 @@ the utility, and decided on a case-by-case basis. #### Schema draft migration -_None currently support draft-06 or later._ +- JavaScript + - [AlterSchema](https://github.com/sourcemeta/alterschema) _JSON Schema 2020-12, 2019-09, draft-07, -06, -04_ #### Format converters From d19bf5270fa04451fdffca3a51d4858bef847982 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 9 Aug 2022 10:40:34 +0300 Subject: [PATCH 216/311] Add a Glossary page with 2 initial entries. Doing so should hopefully now allow farming out additional entries. Refs: json-schema-org/community#199. --- learn/glossary.md | 33 +++++++++++++++++++++++++++++++++ learn/index.md | 1 + 2 files changed, 34 insertions(+) create mode 100644 learn/glossary.md diff --git a/learn/glossary.md b/learn/glossary.md new file mode 100644 index 00000000..858b9e41 --- /dev/null +++ b/learn/glossary.md @@ -0,0 +1,33 @@ +# JSON Schema Glossary + +This document collects short explanations of terminology one may encounter within the JSON Schema community. + +Whilst many of the entries below have precise technical definitions, preference is given to explanations of their conversational use, with additional references linked for further information. +This page is not meant to be [normative](#normative), nor is it meant to contain fully original research or explanation. +It is meant to aid the understanding of those less familiar with formal language used within JSON Schema, or within specifications more broadly. +(In fact, entries below make effort to avoid terminology like "normative" itself for reasons just mentioned.) + +The entries on this page can be linked to via anchor links (e.g. `https://json-schema.org/learn/glossary.html#vocabulary`) when sharing a definition with others. + +### draft + +An individual release of the JSON Schema specification. + +JSON Schema drafts are not intended to be provisional documents, as the layman's use of the word "draft" might indicate. + +While future drafts may introduce new behavior or changes to existing behavior, each draft is a completed, released document, batching together changes to the specification, and intended for implementation and use. + +The current list of drafts can be found [here](https://json-schema.org/specification-links.html#published-drafts). + +### normative + +In the context of JSON Schema, and formal specifications more broadly, a document which outlines standardized behavior. +This is as distinct from *non*-normative or informational documents, meant to explain, simplify or offer opinions. + +Distinguishing between whether a document is normative or not is intended to clarify to those using the document whether its contents are allowed to contradict or augment behavior described in other normative documents. +JSON Schema's normative documents notably include its [specification](https://json-schema.org/specification.html). +This page for instance, not being a normative document, is not able to proscribe new JSON Schema behavior not already covered by the specification. + +##### See also + +* [normative](https://developer.mozilla.org/en-US/docs/Glossary/Normative) and [non-normative](https://developer.mozilla.org/en-US/docs/Glossary/non-normative) in the Mozilla Glossary, and its links diff --git a/learn/index.md b/learn/index.md index 32716050..37c3a883 100644 --- a/learn/index.md +++ b/learn/index.md @@ -12,3 +12,4 @@ title: Learn * [card.schema.json](./examples/card.schema.json) * [geographical-location.schema.json](./examples/geographical-location.schema.json) * [Understanding JSON Schema](/understanding-json-schema/) +* [JSON Schema Glossary](./glossary.md) which attempts to explain conversational terminology From fee524d04abc93e3f615053aafa38cfc1d6ef2b1 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 9 Aug 2022 21:44:53 +0300 Subject: [PATCH 217/311] Add the proper header for the glossary markdown file. --- learn/glossary.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/learn/glossary.md b/learn/glossary.md index 858b9e41..52284449 100644 --- a/learn/glossary.md +++ b/learn/glossary.md @@ -1,4 +1,7 @@ -# JSON Schema Glossary +--- +layout: page +title: JSON Schema Glossary +--- This document collects short explanations of terminology one may encounter within the JSON Schema community. From 4e0d93ba2a38f6c53f2cd31f96acfe79819555b8 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 10 Aug 2022 16:43:32 +0300 Subject: [PATCH 218/311] Add a solicitation for further glossary entries. --- learn/glossary.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/learn/glossary.md b/learn/glossary.md index 52284449..ce4ed2fb 100644 --- a/learn/glossary.md +++ b/learn/glossary.md @@ -10,6 +10,8 @@ This page is not meant to be [normative](#normative), nor is it meant to contain It is meant to aid the understanding of those less familiar with formal language used within JSON Schema, or within specifications more broadly. (In fact, entries below make effort to avoid terminology like "normative" itself for reasons just mentioned.) +If you encounter a term you wish were defined here, please feel free to [file an issue requesting it](https://github.com/json-schema-org/json-schema-org.github.io/issues/new?title=Add%20a%20glossary%20entry%20for%20). + The entries on this page can be linked to via anchor links (e.g. `https://json-schema.org/learn/glossary.html#vocabulary`) when sharing a definition with others. ### draft From 77d5a40f69923b269a7ddd28efda1c235ab92036 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 10 Aug 2022 16:46:33 +0300 Subject: [PATCH 219/311] Try including anchor headings via allejo/jekyll-anchor-headings. --- _includes/anchor_headings.html | 172 +++++++++++++++++++++++++++++++++ _layouts/default.html | 2 +- 2 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 _includes/anchor_headings.html diff --git a/_includes/anchor_headings.html b/_includes/anchor_headings.html new file mode 100644 index 00000000..f8e22d6a --- /dev/null +++ b/_includes/anchor_headings.html @@ -0,0 +1,172 @@ +{% capture headingsWorkspace %} + {% comment %} + Copyright (c) 2018 Vladimir "allejo" Jimenez + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + {% endcomment %} + {% comment %} + Version 1.0.11 + https://github.com/allejo/jekyll-anchor-headings + + "Be the pull request you wish to see in the world." ~Ben Balter + + Usage: + {% include anchor_headings.html html=content anchorBody="#" %} + + Parameters: + * html (string) - the HTML of compiled markdown generated by kramdown in Jekyll + + Optional Parameters: + * beforeHeading (bool) : false - Set to true if the anchor should be placed _before_ the heading's content + * headerAttrs (string) : '' - Any custom HTML attributes that will be added to the heading tag; you may NOT use `id`; + the `%heading%` and `%html_id%` placeholders are available + * anchorAttrs (string) : '' - Any custom HTML attributes that will be added to the `` tag; you may NOT use `href`, `class` or `title`; + the `%heading%` and `%html_id%` placeholders are available + * anchorBody (string) : '' - The content that will be placed inside the anchor; the `%heading%` placeholder is available + * anchorClass (string) : '' - The class(es) that will be used for each anchor. Separate multiple classes with a space + * anchorTitle (string) : '' - The `title` attribute that will be used for anchors + * h_min (int) : 1 - The minimum header level to build an anchor for; any header lower than this value will be ignored + * h_max (int) : 6 - The maximum header level to build an anchor for; any header greater than this value will be ignored + * bodyPrefix (string) : '' - Anything that should be inserted inside of the heading tag _before_ its anchor and content + * bodySuffix (string) : '' - Anything that should be inserted inside of the heading tag _after_ its anchor and content + * generateId (true) : false - Set to true if a header without id should generate an id to use. + + Output: + The original HTML with the addition of anchors inside of all of the h1-h6 headings. + {% endcomment %} + + {% assign minHeader = include.h_min | default: 1 %} + {% assign maxHeader = include.h_max | default: 6 %} + {% assign beforeHeading = include.beforeHeading %} + {% assign headerAttrs = include.headerAttrs %} + {% assign nodes = include.html | split: ' + {% if headerLevel == 0 %} + + {% assign firstChunk = node | split: '>' | first %} + + + {% unless firstChunk contains '<' %} + {% capture node %}{% endcapture %} + {% assign _workspace = node | split: _closingTag %} + {% capture _hAttrToStrip %}{{ _workspace[0] | split: '>' | first }}>{% endcapture %} + {% assign header = _workspace[0] | replace: _hAttrToStrip, '' %} + {% assign escaped_header = header | strip_html | strip %} + + {% assign _classWorkspace = _workspace[0] | split: 'class="' %} + {% assign _classWorkspace = _classWorkspace[1] | split: '"' %} + {% assign _html_class = _classWorkspace[0] %} + + {% if _html_class contains "no_anchor" %} + {% assign skip_anchor = true %} + {% else %} + {% assign skip_anchor = false %} + {% endif %} + + {% assign _idWorkspace = _workspace[0] | split: 'id="' %} + {% if _idWorkspace[1] %} + {% assign _idWorkspace = _idWorkspace[1] | split: '"' %} + {% assign html_id = _idWorkspace[0] %} + {% elsif include.generateId %} + + {% assign html_id = escaped_header | slugify %} + {% if html_id == "" %} + {% assign html_id = false %} + {% endif %} + {% capture headerAttrs %}{{ headerAttrs }} id="%html_id%"{% endcapture %} + {% endif %} + + + {% capture anchor %}{% endcapture %} + + {% if skip_anchor == false and html_id and headerLevel >= minHeader and headerLevel <= maxHeader %} + {% if headerAttrs %} + {% capture _hAttrToStrip %}{{ _hAttrToStrip | split: '>' | first }} {{ headerAttrs | replace: '%heading%', escaped_header | replace: '%html_id%', html_id }}>{% endcapture %} + {% endif %} + + {% capture anchor %}href="#{{ html_id }}"{% endcapture %} + + {% if include.anchorClass %} + {% capture anchor %}{{ anchor }} class="{{ include.anchorClass }}"{% endcapture %} + {% endif %} + + {% if include.anchorTitle %} + {% capture anchor %}{{ anchor }} title="{{ include.anchorTitle | replace: '%heading%', escaped_header }}"{% endcapture %} + {% endif %} + + {% if include.anchorAttrs %} + {% capture anchor %}{{ anchor }} {{ include.anchorAttrs | replace: '%heading%', escaped_header | replace: '%html_id%', html_id }}{% endcapture %} + {% endif %} + + {% capture anchor %}{{ include.anchorBody | replace: '%heading%', escaped_header | default: '' }}{% endcapture %} + + + {% if beforeHeading %} + {% capture anchor %}{{ anchor }} {% endcapture %} + {% else %} + {% capture anchor %} {{ anchor }}{% endcapture %} + {% endif %} + {% endif %} + + {% capture new_heading %} + + {% endcapture %} + + + {% assign chunkCount = _workspace | size %} + {% if chunkCount > 1 %} + {% capture new_heading %}{{ new_heading }}{{ _workspace | last }}{% endcapture %} + {% endif %} + + {% capture edited_headings %}{{ edited_headings }}{{ new_heading }}{% endcapture %} + {% endfor %} +{% endcapture %}{% assign headingsWorkspace = '' %}{{ edited_headings | strip }} diff --git a/_layouts/default.html b/_layouts/default.html index 751e0dcc..7796462a 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -12,7 +12,7 @@ {% endif %}
    - {{ content }} + {% include anchor_headings.html html=content anchorBody="#" %}
    From 7f57b0faef4040a0e6eb1b1b411b5d8c339ec092 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 10 Aug 2022 16:57:25 +0300 Subject: [PATCH 220/311] H4 for see also, as our H5 is smaller than Lean's. --- learn/glossary.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learn/glossary.md b/learn/glossary.md index ce4ed2fb..31d308b6 100644 --- a/learn/glossary.md +++ b/learn/glossary.md @@ -33,6 +33,6 @@ Distinguishing between whether a document is normative or not is intended to cla JSON Schema's normative documents notably include its [specification](https://json-schema.org/specification.html). This page for instance, not being a normative document, is not able to proscribe new JSON Schema behavior not already covered by the specification. -##### See also +#### See also * [normative](https://developer.mozilla.org/en-US/docs/Glossary/Normative) and [non-normative](https://developer.mozilla.org/en-US/docs/Glossary/non-normative) in the Mozilla Glossary, and its links From 9783f12ccecc19784c7fe9c27e03a6796fe78c99 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Fri, 12 Aug 2022 13:40:40 +0300 Subject: [PATCH 221/311] Add glossary entries for schema and instance. --- learn/glossary.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/learn/glossary.md b/learn/glossary.md index 31d308b6..0b585c7a 100644 --- a/learn/glossary.md +++ b/learn/glossary.md @@ -24,6 +24,15 @@ While future drafts may introduce new behavior or changes to existing behavior, The current list of drafts can be found [here](https://json-schema.org/specification-links.html#published-drafts). +### instance + +A piece of JSON data which is to be validated by a [schema](#schema). + +JSON Schema can be used to validate JSON values of any type (as well as values from many JSON-like formats which can be reasonably represented as JSON). + +The JSON Schema specification makes no broad assumptions about the structure of instances themselves beyond those of the JSON specification itself. +In particular it does not reserve any properties within a JSON object for its own use, or require parsers of JSON to support features beyond those already mandated of JSON implementations. + ### normative In the context of JSON Schema, and formal specifications more broadly, a document which outlines standardized behavior. @@ -36,3 +45,13 @@ This page for instance, not being a normative document, is not able to proscribe #### See also * [normative](https://developer.mozilla.org/en-US/docs/Glossary/Normative) and [non-normative](https://developer.mozilla.org/en-US/docs/Glossary/non-normative) in the Mozilla Glossary, and its links + +### schema + +A document, written according to the proscribed structure of the JSON Schema specification, which can be used to validate [instances](#instance). + +The rules constituting what schemas are *valid* JSON Schemas, as well as the rules governing their behavior when validating instances, are defined by the JSON Schema specification. + +Strictly speaking, according to the specification, schemas are themselves JSON documents, though it is somewhat common for them to be authored or maintained in other languages which are easily translated to JSON, such as YAML. + +In recent [drafts](#draft) of the specification, a schema is either a JSON object or a JSON boolean value. From 5a15c9930b03f3fc0a17e867449d4efdf641d694 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Mon, 15 Aug 2022 13:39:07 +0100 Subject: [PATCH 222/311] Fix using `type` rather than `$ref` in 2020-12 release notes Some schemas in the 2020-12 release notes used `type` rather than `$ref` where the value was clearly a relative reference URI. https://groups.google.com/g/json-schema/c/v1fwFPA2PFU?pli=1 --- draft/2020-12/release-notes.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/draft/2020-12/release-notes.md b/draft/2020-12/release-notes.md index e4fb5c2b..7fad89da 100644 --- a/draft/2020-12/release-notes.md +++ b/draft/2020-12/release-notes.md @@ -350,8 +350,8 @@ external references that we want to bundle. "properties": { "address": { "type": "string" }, "city": { "type": "string" }, - "postalCode": { "type": "/schema/common#/$defs/usaPostalCode" }, - "state": { "type": "/$defs/states" } + "postalCode": { "$ref": "/schema/common#/$defs/usaPostalCode" }, + "state": { "$ref": "/$defs/states" } }, "$defs": { @@ -407,8 +407,8 @@ embedded schemas using `$defs`. Here's what the bundled schema would look like. "properties": { "address": { "type": "string" }, "city": { "type": "string" }, - "postalCode": { "type": "/schema/common#/$defs/usaPostalCode" }, - "state": { "type": "#/$defs/states" } + "postalCode": { "$ref": "/schema/common#/$defs/usaPostalCode" }, + "state": { "$ref": "#/$defs/states" } }, "$defs": { From 30f0b15730faba6c8147ae647c0ce6a68cb1f5a6 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Fri, 19 Aug 2022 13:27:24 -0700 Subject: [PATCH 223/311] Fix local build error --- Gemfile | 1 + Gemfile.lock | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Gemfile b/Gemfile index 37f5eaa4..d74d7c0d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,3 @@ source 'https://rubygems.org' gem 'github-pages', group: :jekyll_plugins +gem 'webrick', '~> 1.7' diff --git a/Gemfile.lock b/Gemfile.lock index a406fa2a..94427aa0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -251,6 +251,7 @@ GEM unf_ext unf_ext (0.0.8.2) unicode-display_width (1.8.0) + webrick (1.7.0) zeitwerk (2.6.0) PLATFORMS @@ -258,6 +259,7 @@ PLATFORMS DEPENDENCIES github-pages + webrick (~> 1.7) BUNDLED WITH 2.2.7 From aa96d4b08ab1d4210ea15d52007986bf1c4e5977 Mon Sep 17 00:00:00 2001 From: boneyao Date: Mon, 22 Aug 2022 09:08:01 +0800 Subject: [PATCH 224/311] Java Implementation update Vert.x Json Schema, jsonschemafriend, networknt/json-schema-validator implement 2020-12 --- _data/validator-libraries-modern.yml | 39 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index ca0a2517..ea2303bb 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -109,19 +109,31 @@ notes: includes custom validator support, rich error returns - name: Java implementations: - - name: Snow - url: https://github.com/ssilverman/snowy-json - notes: Uses Maven for the project and Gson under the hood. - date-draft: [2019-09] - draft: [7, 6] - license: GNU Affero General Public License v3.0 - name: Vert.x Json Schema url: https://github.com/eclipse-vertx/vertx-json-schema notes: Validator for Eclipse Vert.x project JSON types. - date-draft: [2019-09] + date-draft: [2020-12, 2019-09] draft: [7] license: Apache License, Version 2.0 notes: includes custom keywords support, custom dialect support, asynchronous validation + - name: jsonschemafriend + url: https://github.com/jimblackler/jsonschemafriend + notes: + date-draft: [2020-12, 2019-09] + draft: [7, 6, 4, 3] + license: Apache License 2.0 + - name: networknt/json-schema-validator + url: https://github.com/networknt/json-schema-validator + notes: Support OpenAPI 3.0 with Jackson parser + date-draft: [2020-12, 2019-09] + draft: [7, 6, 4] + license: Apache License 2.0 + - name: Snow + url: https://github.com/ssilverman/snowy-json + notes: Uses Maven for the project and Gson under the hood. + date-draft: [2019-09] + draft: [7, 6] + license: GNU Affero General Public License v3.0 - name: everit-org/json-schema url: https://github.com/everit-org/json-schema notes: @@ -134,18 +146,7 @@ date-draft: draft: [7, 6, 4] license: Apache License 2.0 - - name: networknt/json-schema-validator - url: https://github.com/networknt/json-schema-validator - notes: Support OpenAPI 3.0 with Jackson parser - date-draft: [2019-09] - draft: [7, 6, 4] - license: Apache License 2.0 - - name: jsonschemafriend - url: https://github.com/jimblackler/jsonschemafriend - notes: - date-draft: [2019-09] - draft: [7, 6, 4, 3] - license: Apache License 2.0 + - name: Kotlin implementations: - name: Medeia-validator From 33b89001486e434d7dbd2e8a8de78e92c2ce5a1c Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Mon, 22 Aug 2022 08:58:23 +1200 Subject: [PATCH 225/311] sort implementations by most recent draft support --- _data/validator-libraries-modern.yml | 79 ++++++++++++++-------------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 005de682..58d7f6ec 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -1,16 +1,16 @@ - name: .NET anchor-name: dotnet implementations: - - name: Json.NET Schema - url: https://www.newtonsoft.com/jsonschema - date-draft: [2019-09] - draft: [7, 6, 4, 3] - license: "AGPL-3.0-only" - name: JsonSchema.Net url: https://github.com/gregsdennis/json-everything date-draft: [2020-12, 2019-09] draft: [7, 6] license: MIT + - name: Json.NET Schema + url: https://www.newtonsoft.com/jsonschema + date-draft: [2019-09] + draft: [7, 6, 4, 3] + license: "AGPL-3.0-only" - name: C implementations: - name: WJElement @@ -71,17 +71,17 @@ license: LGPL - name: Elixir implementations: + - name: JsonXema + url: https://github.com/hrzndhrn/json_xema + date-draft: + draft: [7, 6, 4] + license: MIT - name: Elixir JSON Schema validator url: https://github.com/jonasschmidt/ex_json_schema date-draft: draft: [4] notes: "Draft-06+ progress: issue [24](https://github.com/jonasschmidt/ex_json_schema/issues/24); branch [multi-draft-support](https://github.com/jonasschmidt/ex_json_schema/tree/multi-draft-support)" license: MIT - - name: JsonXema - url: https://github.com/hrzndhrn/json_xema - date-draft: - draft: [7, 6, 4] - license: MIT - name: Erlang implementations: - name: JeSSE @@ -90,11 +90,6 @@ license: "Apache 2.0" - name: Go implementations: - - name: gojsonschema - url: https://github.com/xeipuuv/gojsonschema - date-draft: - draft: [7, 6, 4] - license: "Apache 2.0" - name: santhosh-tekuri/jsonschema url: https://github.com/santhosh-tekuri/jsonschema notes: includes custom keywords, output formats @@ -107,6 +102,11 @@ draft: [7] license: MIT notes: includes custom validator support, rich error returns + - name: gojsonschema + url: https://github.com/xeipuuv/gojsonschema + date-draft: + draft: [7, 6, 4] + license: "Apache 2.0" - name: Java implementations: - name: Vert.x Json Schema @@ -146,7 +146,6 @@ date-draft: draft: [7, 6, 4] license: Apache License 2.0 - - name: Kotlin implementations: - name: Medeia-validator @@ -166,22 +165,22 @@ license: MIT - name: JavaScript implementations: + - name: Hyperjump JSV + url: https://github.com/jdesrosiers/json-schema + notes: "Built for Node.js and browsers. Includes support for custom vocabularies." + date-draft: [2019-09, 2020-12] + draft: [7, 6, 4] + license: MIT - name: ajv url: https://github.com/ajv-validator/ajv notes: "for Node.js and browsers - supports [user-defined keywords](https://github.com/ajv-validator/ajv/blob/master/docs/keywords.md) and [$data reference](https://github.com/json-schema-org/json-schema-spec/issues/51)" date-draft: [2019-09, 2020-12] draft: [7, 6, 4] license: MIT - - name: djv - url: https://github.com/korzio/djv - notes: "for Node.js and browsers" - date-draft: - draft: [6, 4] - license: MIT - - name: Hyperjump JSV - url: https://github.com/jdesrosiers/json-schema - notes: "Built for Node.js and browsers. Includes support for custom vocabularies." - date-draft: [2019-09, 2020-12] + - name: "@cfworker/json-schema" + url: https://github.com/cfworker/cfworker/blob/master/packages/json-schema/README.md + notes: "Built for Cloudflare workers, browsers, and Node.js" + date-draft: [2019-09] draft: [7, 6, 4] license: MIT - name: JSON Schema Library @@ -190,17 +189,17 @@ date-draft: draft: [7, 6, 4] license: MIT + - name: djv + url: https://github.com/korzio/djv + notes: "for Node.js and browsers" + date-draft: + draft: [6, 4] + license: MIT - name: vue-vuelidate-jsonschema url: https://github.com/mokkabonna/vue-vuelidate-jsonschema date-draft: draft: [6] license: MIT - - name: "@cfworker/json-schema" - url: https://github.com/cfworker/cfworker/blob/master/packages/json-schema/README.md - notes: "Built for Cloudflare workers, browsers, and Node.js" - date-draft: [2019-09] - draft: [7, 6, 4] - license: MIT - name: Perl implementations: - name: JSON::Schema::Modern @@ -322,7 +321,7 @@ url: https://json-everything.net date-draft: [2020-12, 2019-09] draft: [7, 6] - notes: Powered by JsonSchema.Net; server-side validation + notes: Powered by JsonSchema.Net in Blazor WASM for client-side validation - name: jsonschema.dev url: https://jsonschema.dev draft: [7] @@ -351,12 +350,6 @@ url: 'https://www.npmjs.com/package/ajv-cli' date-draft: draft: [7, 6, 4] - - name: Polyglottal JSON Schema Validator - license: MIT - url: 'https://www.npmjs.com/package/pajv' - date-draft: - draft: [6, 4] - notes: can be used with YAML and many other formats besides JSON - name: yajsv license: MIT url: 'https://github.com/neilpa/yajsv' @@ -368,4 +361,10 @@ url: 'https://www.json-buddy.com/json-validator-command-line-tool.htm' date-draft: draft: [2019-09, 7, 6, 4] - notes: JSONBuddy cli tool. Windows platform. Support for large data and streaming validation. \ No newline at end of file + notes: JSONBuddy cli tool. Windows platform. Support for large data and streaming validation. + - name: Polyglottal JSON Schema Validator + license: MIT + url: 'https://www.npmjs.com/package/pajv' + date-draft: + draft: [6, 4] + notes: can be used with YAML and many other formats besides JSON From ee7eaf0cab1483d7fbf5a594b62b8b605f34f41d Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Mon, 22 Aug 2022 09:23:28 +1200 Subject: [PATCH 226/311] move impls with no draft-6 or later support to obsolete --- _data/validator-libraries-modern.yml | 16 +--------------- _data/validator-libraries-obsolete.yml | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 58d7f6ec..e2a0a024 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -11,14 +11,6 @@ date-draft: [2019-09] draft: [7, 6, 4, 3] license: "AGPL-3.0-only" -- name: C - implementations: - - name: WJElement - url: https://github.com/netmail-open/wjelement - date-draft: - draft: [4, 3] - license: LGPL-3.0 - notes: "Draft-06+ progress: issue [17](https://github.com/netmail-open/wjelement/issues/17#issuecomment-390899432)" - name: C++ implementations: - name: f5-json-schema @@ -67,7 +59,7 @@ - name: json-schema url: https://github.com/fisxoj/json-schema date-draft: [2019-09] - draft: [4, 6, 7] + draft: [7, 6, 4] license: LGPL - name: Elixir implementations: @@ -76,12 +68,6 @@ date-draft: draft: [7, 6, 4] license: MIT - - name: Elixir JSON Schema validator - url: https://github.com/jonasschmidt/ex_json_schema - date-draft: - draft: [4] - notes: "Draft-06+ progress: issue [24](https://github.com/jonasschmidt/ex_json_schema/issues/24); branch [multi-draft-support](https://github.com/jonasschmidt/ex_json_schema/tree/multi-draft-support)" - license: MIT - name: Erlang implementations: - name: JeSSE diff --git a/_data/validator-libraries-obsolete.yml b/_data/validator-libraries-obsolete.yml index 6cc5bd40..952b28ce 100644 --- a/_data/validator-libraries-obsolete.yml +++ b/_data/validator-libraries-obsolete.yml @@ -11,6 +11,14 @@ date-draft: [2019-09] draft: [7, 6, 4] license: MIT +- name: C + implementations: + - name: WJElement + url: https://github.com/netmail-open/wjelement + date-draft: + draft: [4, 3] + license: LGPL-3.0 + notes: "Draft-06+ progress: issue [17](https://github.com/netmail-open/wjelement/issues/17#issuecomment-390899432)" - name: C++ anchor-name: cpp implementations: @@ -53,6 +61,14 @@ notes: draft: [4] license: BSL-1.0 +- name: Elixir + implementations: + - name: Elixir JSON Schema validator + url: https://github.com/jonasschmidt/ex_json_schema + date-draft: + draft: [4] + notes: "Draft-06+ progress: issue [24](https://github.com/jonasschmidt/ex_json_schema/issues/24); branch [multi-draft-support](https://github.com/jonasschmidt/ex_json_schema/tree/multi-draft-support)" + license: MIT - name: Go implementations: - name: validate-json From 6127552790d5ccf69351f708ef1793016f8dce78 Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Mon, 22 Aug 2022 11:39:57 +1200 Subject: [PATCH 227/311] add a note for C-lang now missing an impl --- _data/validator-libraries-modern.yml | 2 ++ implementations.md | 3 +++ 2 files changed, 5 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index e2a0a024..82bfb332 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -11,6 +11,8 @@ date-draft: [2019-09] draft: [7, 6, 4, 3] license: "AGPL-3.0-only" +- name: C + notes: All known implementations are now obsolete. - name: C++ implementations: - name: f5-json-schema diff --git a/implementations.md b/implementations.md index a6799cbc..7b6eba77 100644 --- a/implementations.md +++ b/implementations.md @@ -40,6 +40,9 @@ Validators {% for language in validator-libraries %}
  • {{language.name}} + {% if language.notes %} + {{ implementation.notes }} + {% endif %}
      {% for implementation in language.implementations %}
    • From d500e001257afcdd89645698baf0a4c6be9d05e1 Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Mon, 22 Aug 2022 14:29:19 +1200 Subject: [PATCH 228/311] move valbuddy up --- _data/validator-libraries-modern.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 82bfb332..f23522c5 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -333,6 +333,12 @@ draft: [7] - name: Command Line implementations: + - name: valbuddy + license: Free and commercial versions (proprietary) + url: 'https://www.json-buddy.com/json-validator-command-line-tool.htm' + date-draft: + draft: [2019-09, 7, 6, 4] + notes: JSONBuddy cli tool. Windows platform. Support for large data and streaming validation. - name: ajv-cli license: MIT url: 'https://www.npmjs.com/package/ajv-cli' @@ -344,12 +350,6 @@ date-draft: draft: [7, 6, 4] notes: wraps [xeipuuv/gojsonschema](https://github.com/xeipuuv/gojsonschema) - - name: valbuddy - license: Free and commercial versions (proprietary) - url: 'https://www.json-buddy.com/json-validator-command-line-tool.htm' - date-draft: - draft: [2019-09, 7, 6, 4] - notes: JSONBuddy cli tool. Windows platform. Support for large data and streaming validation. - name: Polyglottal JSON Schema Validator license: MIT url: 'https://www.npmjs.com/package/pajv' From 1b3f0f3a4dbf50862ac069a66f751b6738f7fbd4 Mon Sep 17 00:00:00 2001 From: Greg Dennis Date: Mon, 22 Aug 2022 15:35:22 +1200 Subject: [PATCH 229/311] a few more updates --- _data/validator-libraries-modern.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index f23522c5..47b225b2 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -12,7 +12,7 @@ draft: [7, 6, 4, 3] license: "AGPL-3.0-only" - name: C - notes: All known implementations are now obsolete. + notes: No known implementations support draft-06 or later. - name: C++ implementations: - name: f5-json-schema @@ -310,10 +310,6 @@ date-draft: [2020-12, 2019-09] draft: [7, 6] notes: Powered by JsonSchema.Net in Blazor WASM for client-side validation - - name: jsonschema.dev - url: https://jsonschema.dev - draft: [7] - notes: Powered by ajv; client-side validation - name: jschon.dev url: https://jschon.dev/ date-draft: [2020-12, 2019-09] @@ -323,6 +319,10 @@ date-draft: [2019-09] draft: [7, 6, 4, 3] notes: Powered by JSON.Net; server-side validation + - name: jsonschema.dev + url: https://jsonschema.dev + draft: [7] + notes: Powered by ajv; client-side validation - name: JSON Schema Lint url: http://jsonschemalint.com/ date-draft: From 57b87d4e7f495dc2a6d382f13507c54480940774 Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Fri, 19 Aug 2022 12:48:22 -0700 Subject: [PATCH 230/311] Warn people about AJV's noncompliant strict mode. --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 47b225b2..8188421d 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -161,7 +161,7 @@ license: MIT - name: ajv url: https://github.com/ajv-validator/ajv - notes: "for Node.js and browsers - supports [user-defined keywords](https://github.com/ajv-validator/ajv/blob/master/docs/keywords.md) and [$data reference](https://github.com/json-schema-org/json-schema-spec/issues/51)" + notes: "for Node.js and browsers - supports [user-defined keywords](https://github.com/ajv-validator/ajv/blob/master/docs/keywords.md) and [$data reference](https://github.com/json-schema-org/json-schema-spec/issues/51); _Only specification-compliant when strict mode is **disabled.**_" date-draft: [2019-09, 2020-12] draft: [7, 6, 4] license: MIT From 0d8017b48afe4f0431b0b1bc1eb2c44a3f675abf Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Mon, 22 Aug 2022 22:19:50 -0700 Subject: [PATCH 231/311] Add link to how to turn off AJV's strict mode --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 8188421d..db9bce97 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -161,7 +161,7 @@ license: MIT - name: ajv url: https://github.com/ajv-validator/ajv - notes: "for Node.js and browsers - supports [user-defined keywords](https://github.com/ajv-validator/ajv/blob/master/docs/keywords.md) and [$data reference](https://github.com/json-schema-org/json-schema-spec/issues/51); _Only specification-compliant when strict mode is **disabled.**_" + notes: "for Node.js and browsers - supports [user-defined keywords](https://github.com/ajv-validator/ajv/blob/master/docs/keywords.md) and [$data reference](https://github.com/json-schema-org/json-schema-spec/issues/51); _Only specification-compliant when [strict mode](https://ajv.js.org/strict-mode.html) is **disabled.**_" date-draft: [2019-09, 2020-12] draft: [7, 6, 4] license: MIT From a0c4a67b206df186a185c7e03861ca58addfd8f2 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sun, 28 Aug 2022 12:41:20 +0300 Subject: [PATCH 232/311] Add glossary entries for keyword and meta-schema. --- learn/glossary.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/learn/glossary.md b/learn/glossary.md index 0b585c7a..94f1afbc 100644 --- a/learn/glossary.md +++ b/learn/glossary.md @@ -24,6 +24,12 @@ While future drafts may introduce new behavior or changes to existing behavior, The current list of drafts can be found [here](https://json-schema.org/specification-links.html#published-drafts). +### keyword + +A property appearing within a [schema](#schema) object. + +The [JSON Schema specification](https://json-schema.org/specification.html) defines behavior for a large library of keywords which can be used to describe [instances](#instance). + ### instance A piece of JSON data which is to be validated by a [schema](#schema). @@ -33,6 +39,15 @@ JSON Schema can be used to validate JSON values of any type (as well as values f The JSON Schema specification makes no broad assumptions about the structure of instances themselves beyond those of the JSON specification itself. In particular it does not reserve any properties within a JSON object for its own use, or require parsers of JSON to support features beyond those already mandated of JSON implementations. +### meta-schema + +A [schema](#schema) which is itself intended to describe other *schemas*. + +JSON Schema defines a language for describing any [instance](#instance) using a schema written in JSON. +Since schemas are themselves JSON values, they may be opaquely treated as *instances*, and therefore described by other schemas. + +We refer to the schema-of-a-schema as a "meta-schema" to express this use. + ### normative In the context of JSON Schema, and formal specifications more broadly, a document which outlines standardized behavior. From d6e3a4899366dbd73d8f1a9a43c7b5c6c0f4a759 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sun, 28 Aug 2022 12:41:46 +0300 Subject: [PATCH 233/311] Loosen the verbiage around the schema<->instance interaction in the glossary. --- learn/glossary.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/learn/glossary.md b/learn/glossary.md index 94f1afbc..8cbbda00 100644 --- a/learn/glossary.md +++ b/learn/glossary.md @@ -32,9 +32,9 @@ The [JSON Schema specification](https://json-schema.org/specification.html) defi ### instance -A piece of JSON data which is to be validated by a [schema](#schema). +A piece of JSON data which is to be described by a [schema](#schema). -JSON Schema can be used to validate JSON values of any type (as well as values from many JSON-like formats which can be reasonably represented as JSON). +JSON Schema can be used to describe JSON values of any type (as well as values from many JSON-like formats which can be reasonably represented as JSON). The JSON Schema specification makes no broad assumptions about the structure of instances themselves beyond those of the JSON specification itself. In particular it does not reserve any properties within a JSON object for its own use, or require parsers of JSON to support features beyond those already mandated of JSON implementations. @@ -63,9 +63,9 @@ This page for instance, not being a normative document, is not able to proscribe ### schema -A document, written according to the proscribed structure of the JSON Schema specification, which can be used to validate [instances](#instance). +A document, written according to the proscribed structure of the JSON Schema specification, which can be used to describe [instances](#instance). -The rules constituting what schemas are *valid* JSON Schemas, as well as the rules governing their behavior when validating instances, are defined by the JSON Schema specification. +The rules constituting which schemas are conformant, as well as the rules governing their behavior when validating instances, are defined by the [JSON Schema specification](https://json-schema.org/specification.html). Strictly speaking, according to the specification, schemas are themselves JSON documents, though it is somewhat common for them to be authored or maintained in other languages which are easily translated to JSON, such as YAML. From 75ec41479f39e55d8e8e850c7beb1197ef8a7a1c Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Mon, 29 Aug 2022 11:46:18 -0700 Subject: [PATCH 234/311] Sort languages and drafts automatically Several languages and date drafts were out of order. Fix it in code instead of trying to keep the data file consistent. --- _data/validator-libraries-modern.yml | 10 ++++++---- implementations.md | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index db9bce97..89302900 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -193,12 +193,14 @@ - name: JSON::Schema::Modern url: https://github.com/karenetheridge/JSON-Schema-Modern notes: - date-draft: [7, 2019-09, 2020-12] + date-draft: [2019-09, 2020-12] + draft: [7] license: "GNU General Public License, Version 1 + The Artistic License 1.0" - name: JSON::Schema::Tiny url: https://github.com/karenetheridge/JSON-Schema-Tiny notes: - date-draft: [7, 2019-09, 2020-12] + date-draft: [2019-09, 2020-12] + draft: [7] license: "GNU General Public License, Version 1 + The Artistic License 1.0" - name: JSON::Validator url: https://github.com/mojolicious/json-validator @@ -336,8 +338,8 @@ - name: valbuddy license: Free and commercial versions (proprietary) url: 'https://www.json-buddy.com/json-validator-command-line-tool.htm' - date-draft: - draft: [2019-09, 7, 6, 4] + date-draft: [2019-09] + draft: [7, 6, 4] notes: JSONBuddy cli tool. Windows platform. Support for large data and streaming validation. - name: ajv-cli license: MIT diff --git a/implementations.md b/implementations.md index 7b6eba77..c7e35057 100644 --- a/implementations.md +++ b/implementations.md @@ -26,7 +26,7 @@ Validators
    • {% endif %} + {% if implementation.last-updated %} +
    • Information last updated: + {{ implementation.last-updated }} +
    • + {% endif %} +
  • {% endfor %} @@ -338,6 +344,13 @@ Hyper-Schema ({{ implementation.license | join: ", " }}) {% endif %} + {% if implementation.last-updated %} +
    + Information last updated: + {{ implementation.last-updated }} + {% endif %} + + {% endfor %} From f6158efbd446235d88ee2f8dfef7f682e52085d7 Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Mon, 29 Aug 2022 21:35:18 -0700 Subject: [PATCH 240/311] Add a compliance section to the impl data This adds a structured section on compliance, specifically how to configure for it. This is *not* intended to be the same sort of compliance information that the test suite provides. Rather, it is about things that implementations document that don't necessarily show up in test suite results. This format includes brief instructions and optionally (ideally) a documentation link. I think this langauge is appropriately neutral, and particularly when there is a doc link it feels more like calling attention to something that is already advertised rather than being judgemental. The AJV and Opis cases are straightfoward. The Common Lisp implementation's case of needing to disable automatic downloading is worth a bit of thought as that is a SHOULD NOT rather than a MUST NOT, but this is why the schema description notes that it is the _most_ compliant config, and other configs may still be compliant. Similary, the networknt Java implementation having `nullable` on by default is not technically non-compliant, but it is more compliant to not have it. There may be other compliance configuration changes that need documenting, but these were the ones that I could find with a reasonable amount of effort. --- _data/schema.yml | 48 ++++++++++++++++++++++++++++ _data/validator-libraries-modern.yml | 23 ++++++++++++- implementations.md | 11 +++++++ 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/_data/schema.yml b/_data/schema.yml index a1e65f2e..bb696653 100644 --- a/_data/schema.yml +++ b/_data/schema.yml @@ -95,6 +95,8 @@ $defs: Additional information. Overly promotional (or critical) wording should be avoided. type: string + compliance: + $ref: "#/$defs/compliance" last-updated: description: | The date (in whatever timezone was relevant at the time) @@ -108,3 +110,49 @@ $defs: type: string format: date pattern: '^\d\d\d\d-[01]\d-[0123]\d$' + compliance: + description: | + The compliance section notes aspects of an implementation's + _default configuration_ that are non-compliant with the + specification in ways that are _not necessarily_ detected + by the test suite. This information is provided based on + implementation documentation. + type: object + unevaluatedProperties: false + properties: + constraints: + description: | + A brief note of design constraints that impacted choices + regarding compliance. This includes things like + targeting memory-constrained environments, or trading + off features for performance. It does not include + opinions regarding the value (or lack thereof) of + the specification requirements. + type: string + config: + description: | + Documents how to configure an implementation to produce + the most specification-compliant behavior if it does + not do so by default. The resulting configuration + may still have incomplete compliance (such as not + having implemented all keywords), but will not + have additional behavior that contradicts the + specification (such as modifying the instance + by filling in default values). + type: object + unevaluatedProperties: false + required: [instructions] + properties: + docs: + description: | + A link to the implementation's configuration + documentation, ideally to whatever part addresses + configuration and compliance. + type: string + format: uri + instructions: + description: | + Instructions to configure for compliance. Will + appear in a sentence after "you must" and before + "to produce specification-compliant behavior." + type: string diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index ea67caf0..db785618 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -73,6 +73,11 @@ date-draft: [2019-09] draft: [7, 6, 4] license: LGPL + compliance: + config: + docs: https://github.com/fisxoj/json-schema/blob/master/README.rst + instructions: | + set `resolve-remote-references` to `nil` last-updated: "2022-08-31" - name: Elixir implementations: @@ -134,6 +139,10 @@ date-draft: [2020-12, 2019-09] draft: [7, 6, 4] license: Apache License 2.0 + compliance: + config: + docs: https://github.com/networknt/json-schema-validator/blob/master/doc/config.md + instructions: "set `handleNullableField` to `false`" last-updated: "2022-08-31" - name: Snow url: https://github.com/ssilverman/snowy-json @@ -165,10 +174,14 @@ last-updated: "2022-08-31" - name: ajv url: https://github.com/ajv-validator/ajv - notes: "for Node.js and browsers - supports [user-defined keywords](https://github.com/ajv-validator/ajv/blob/master/docs/keywords.md) and [$data reference](https://github.com/json-schema-org/json-schema-spec/issues/51); _Only specification-compliant when [strict mode](https://ajv.js.org/strict-mode.html) is **disabled.**_" + notes: "for Node.js and browsers - supports [user-defined keywords](https://github.com/ajv-validator/ajv/blob/master/docs/keywords.md) and [$data reference](https://github.com/json-schema-org/json-schema-spec/issues/51)" date-draft: [2019-09, 2020-12] draft: [7, 6, 4] license: MIT + compliance: + config: + docs: https://ajv.js.org/strict-mode.html + instructions: "set option `strict: false`" last-updated: "2022-08-31" - name: "@cfworker/json-schema" url: https://github.com/cfworker/cfworker/blob/master/packages/json-schema/README.md @@ -249,6 +262,10 @@ date-draft: [2020-12, 2019-09] draft: [7, 6] license: "Apache License 2.0" + compliance: + config: + docs: https://opis.io/json-schema/2.x/php-loader.html#parser-options + instructions: 'set several options to their "vanilla" values' last-updated: "2022-08-31" - name: Swaggest Json Schema url: https://github.com/swaggest/php-json-schema @@ -386,6 +403,10 @@ url: 'https://www.npmjs.com/package/ajv-cli' date-draft: [2020-12, 2019-09] draft: [7, 6, 4] + compliance: + config: + docs: https://github.com/ajv-validator/ajv-cli#ajv-options + instructions: "pass `--strict=false`" last-updated: "2022-08-31" - name: yajsv license: MIT diff --git a/implementations.md b/implementations.md index fc65be59..90d4aff0 100644 --- a/implementations.md +++ b/implementations.md @@ -57,6 +57,17 @@ Validators {% endif %} + {% if implementation.compliance %} +
  • Compliance: + {% if implementation.compliance.config.docs %} + This implementation documents that you must + {% endif %} + {% if implementation.compliance.config.instructions %} + {{ implementation.compliance.config.instructions | markdownify | remove: '

    ' | remove: '

    ' }}
    to produce specification-compliant behavior. +
  • + {% endif %} + {% endif %} + {% if implementation.license %}
  • License: {{ implementation.license | join: ", " }} From ebdd0b57fca34030709a4de418c7d11b8bb7b1da Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Wed, 31 Aug 2022 14:11:36 -0700 Subject: [PATCH 241/311] Add built-on field Some implementations, particularly but not exclusively CLI and web ones, are implemented on top of other validator libraries. This adds a structured field to account for that, and updates all known cases where it is relevant. It was necessary to also support an anchor-name field for implementations as with programming languages, and in the process disambiguate a few duplicate names. --- _data/schema.yml | 41 ++++++++++++++++++++++------ _data/validator-libraries-modern.yml | 41 ++++++++++++++++++++++------ implementations.md | 9 +++++- 3 files changed, 74 insertions(+), 17 deletions(-) diff --git a/_data/schema.yml b/_data/schema.yml index bb696653..43a2cdb9 100644 --- a/_data/schema.yml +++ b/_data/schema.yml @@ -31,12 +31,8 @@ $defs: oneOf: - required: [implementations] - required: [notes] + $ref: "#/$defs/name-and-anchor-name" properties: - name: - type: string - anchor-name: - type: string - description: A name suitable for us as an HTML id. implementations: description: | The list of implementations for this language/environment, @@ -55,6 +51,30 @@ $defs: required: [last-updated] notes: type: [string, "null"] + name-and-anchor-name: + $comment: | + Require an anchor-name if the name is not suitable for + use as an anchor (HTML id attribute) + if: + required: [name] + not: + properties: + name: + $ref: "#/$defs/anchor-name" + then: + required: [anchor-name] + properties: + name: + type: string + anchor-name: + $ref: "#/$defs/anchor-name" + anchor-name: + description: | + A name suitable for us as an HTML id, if the regular name + is not a vald id. The regex is looser than the HTML spec + but is based on what was already working on the page. + type: string + pattern: '^[A-Za-z][A-Za-z0-9+-_:./ ()]*$' implementation: description: | An implementation and its associated information. @@ -64,10 +84,8 @@ $defs: anyOf: - required: [draft] - required: [date-draft] + $ref: "#/$defs/name-and-anchor-name" properties: - name: - description: The human-friendly name of the implementation - type: string url: description: | The URL of the implementation's repository or documentation @@ -95,6 +113,13 @@ $defs: Additional information. Overly promotional (or critical) wording should be avoided. type: string + built-on: + description: | + Indicates that this implementation is built on another + implementation, typically to make it available through + a web page, CLI, or a different programming language. + type: object + $ref: "#/$defs/name-and-anchor-name" compliance: $ref: "#/$defs/compliance" last-updated: diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index db785618..aaf6455e 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -52,7 +52,7 @@ draft: [7] license: MIT last-updated: "2022-08-31" - - name: json-schema + - name: json-schema (luposlip) url: https://github.com/luposlip/json-schema date-draft: [] draft: [4, 6, 7] @@ -61,6 +61,7 @@ - name: COM/ActiveX implementations: - name: JSON Essentials for COM/ActiveX + anchor-name: JSONEssentials url: https://pinery.systems/json-essentials-com/index.html draft: [7] license: proprietary @@ -68,7 +69,7 @@ last-updated: "2022-08-31" - name: Common Lisp implementations: - - name: json-schema + - name: json-schema (fisxoj) url: https://github.com/fisxoj/json-schema date-draft: [2019-09] draft: [7, 6, 4] @@ -135,7 +136,7 @@ last-updated: "2022-08-31" - name: networknt/json-schema-validator url: https://github.com/networknt/json-schema-validator - notes: Support OpenAPI 3.0 with Jackson parser + notes: Support OpenAPI 3.0 with Jackson parser date-draft: [2020-12, 2019-09] draft: [7, 6, 4] license: Apache License 2.0 @@ -184,6 +185,7 @@ instructions: "set option `strict: false`" last-updated: "2022-08-31" - name: "@cfworker/json-schema" + anchor-name: cfworker url: https://github.com/cfworker/cfworker/blob/master/packages/json-schema/README.md notes: "Built for Cloudflare workers, browsers, and Node.js" date-draft: [2019-09] @@ -294,11 +296,13 @@ draft: [7, 6, 4] license: BSD-3-Clause last-updated: "2022-08-31" - - name: jsonschema-rs + - name: jsonschema-rs (Python) url: https://github.com/Stranger6667/jsonschema-rs/tree/master/bindings/python notes: Python bindings to Rust's jsonschema crate date-draft: [] draft: [7, 6, 4] + built-on: + name: jsonschema-rs license: MIT last-updated: "2022-08-31" - name: Ruby @@ -351,43 +355,59 @@ last-updated: "2022-08-31" - name: Web (Online) implementations: - - name: Hyperjump JSV + - name: Hyperjump JSV (online) url: https://json-schema.hyperjump.io date-draft: [2020-12, 2019-09] draft: [7, 6, 4] notes: Supports multiple schemas and multiple instances; client-side validation + built-on: + name: Hyperjump JSV last-updated: "2022-08-31" - name: json-everything url: https://json-everything.net date-draft: [2020-12, 2019-09] draft: [7, 6] notes: Powered by JsonSchema.Net in Blazor WASM for client-side validation + built-on: + name: JsonSchema.Net last-updated: "2022-08-31" - name: jschon.dev url: https://jschon.dev/ date-draft: [2020-12, 2019-09] draft: [] + built-on: + name: jschon last-updated: "2022-08-31" - name: JSON Schema Validator url: https://www.jsonschemavalidator.net/ date-draft: [2019-09] draft: [7, 6, 4, 3] - notes: Powered by JSON.Net; server-side validation + notes: server-side validation + built-on: + name: Json.NET Schema last-updated: "2022-08-31" - name: jsonschema.dev url: https://jsonschema.dev draft: [7] - notes: Powered by ajv; client-side validation + notes: client-side validation + built-on: + name: ajv last-updated: "2022-08-31" - name: JSON Schema Lint url: http://jsonschemalint.com/ date-draft: [] draft: [7, 6, 4, 3, 2, 1] + built-on: + name: ajv + notes: Uses JSV for draft-03 and earlier last-updated: "2022-08-31" - name: ExtendsClass's JSON Schema Validator + anchor-name: ExtendsClass url: https://extendsclass.com/json-schema-validator.html date-draft: [] draft: [7] + built-on: + name: ajv last-updated: "2022-08-31" - name: Command Line implementations: @@ -407,13 +427,16 @@ config: docs: https://github.com/ajv-validator/ajv-cli#ajv-options instructions: "pass `--strict=false`" + built-on: + name: ajv last-updated: "2022-08-31" - name: yajsv license: MIT url: 'https://github.com/neilpa/yajsv' date-draft: [] draft: [7, 6, 4] - notes: wraps [xeipuuv/gojsonschema](https://github.com/xeipuuv/gojsonschema) + built-on: + name: gojsonschema last-updated: "2022-08-31" - name: Polyglottal JSON Schema Validator license: MIT @@ -422,3 +445,5 @@ draft: [6, 4] notes: can be used with YAML and many other formats besides JSON last-updated: "2022-08-31" + built-on: + name: ajv diff --git a/implementations.md b/implementations.md index 90d4aff0..d9356576 100644 --- a/implementations.md +++ b/implementations.md @@ -46,7 +46,8 @@ Validators
      {% for implementation in language.implementations %}
    • - {{ implementation.name }} + + {{ implementation.name }}
      • Supports: {% if implementation.date-draft %} @@ -68,6 +69,12 @@ Validators {% endif %} {% endif %} + {% if implementation.built-on %} +
      • Built on: + {{ implementation.built-on.name }} +
      • + {% endif %} + {% if implementation.license %}
      • License: {{ implementation.license | join: ", " }} From 1e7b146243f5f2426f99eb2f24b44e6e05002f1f Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Wed, 31 Aug 2022 18:55:05 -0700 Subject: [PATCH 242/311] Update ajv-cli, validate implementations data This updates ajv-cli and changes it to use the current syntax to validate everything under 2020-12. I'm not sure why it was using draft-07 for the learn/examples schemas as they declare 2020-12. --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 724b3497..886aa1a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,10 @@ sudo: false node_js: - node before_script: -- npm install ajv-cli@3.1.0 +- npm install ajv-cli@5.0.0 ajv-formats@2.1.1 - PATH="./node_modules/.bin/:$PATH" script: - bundle exec jekyll build -- ajv test -s draft-07/schema -d "learn/examples/*.json" --valid --add-used-schema=false +- ajv compile --spec=draft2020 --strict=false -s learn/examples/geographical-location.schema.json -s learn/examples/address.schema.json -s learn/examples/card.schema.json -s learn/examples/calendar.schema.json +- ajv compile --spec=draft2020 --strict=false -c ajv-formats -s _data/schema.yml +- ajv --spec=draft2020 --strict=false -c ajv-formats test -s _data/schema.yml -d "_data/*-libraries-*.yml" --valid From 723f3212710f5e7eaca54f6b681a58dfb70c086c Mon Sep 17 00:00:00 2001 From: Jim Crist-Harif Date: Wed, 14 Sep 2022 15:36:58 -0500 Subject: [PATCH 243/311] Add msgspec to implementations --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index e6034160..92aae02c 100644 --- a/implementations.md +++ b/implementations.md @@ -155,6 +155,7 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - [typescript-json-schema](https://github.com/YousefED/typescript-json-schema) - Python - [Pydantic](https://pydantic-docs.helpmanual.io/) (MIT) - generates schemas from Python models based on Python 3.6+ type hints. + - [msgspec](https://jcristharif.com/msgspec/) (BSD-3-Clause) - generates schemas from Python type annotations. - Java - [jsonschema-generator](https://github.com/victools/jsonschema-generator) (Apache 2.0) - generates schemas from Java types *supports Draft 7 and Draft 2019-09* - Scala From 2ced0f2c2ddf9e277674d1ccdabd3dd23400976f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Sep 2022 02:20:58 +0000 Subject: [PATCH 244/311] Bump commonmarker from 0.23.5 to 0.23.6 Bumps [commonmarker](https://github.com/gjtorikian/commonmarker) from 0.23.5 to 0.23.6. - [Release notes](https://github.com/gjtorikian/commonmarker/releases) - [Changelog](https://github.com/gjtorikian/commonmarker/blob/main/CHANGELOG.md) - [Commits](https://github.com/gjtorikian/commonmarker/compare/v0.23.5...v0.23.6) --- updated-dependencies: - dependency-name: commonmarker dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 94427aa0..ce7c576b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,7 +14,7 @@ GEM execjs coffee-script-source (1.11.1) colorator (1.1.0) - commonmarker (0.23.5) + commonmarker (0.23.6) concurrent-ruby (1.1.10) dnsruby (1.61.9) simpleidn (~> 0.1) From bcf15746137770483a74285caa488f157749855d Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Sat, 24 Sep 2022 10:00:09 -0700 Subject: [PATCH 245/311] Trigger site publishing after master->main rename From c3b7cb9a15dbceda7e1789ac63eb23456eaf0495 Mon Sep 17 00:00:00 2001 From: DJ Adams Date: Thu, 29 Sep 2022 07:26:04 +0000 Subject: [PATCH 246/311] fix specification reference links Looks like the doc fragment links in json-schema-core and json-schema-validation changed, so fixing the references, in this super useful getting started doc (thanks, btw!). --- learn/getting-started-step-by-step.md | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/learn/getting-started-step-by-step.md b/learn/getting-started-step-by-step.md index 5c2e51d5..5e299de1 100644 --- a/learn/getting-started-step-by-step.md +++ b/learn/getting-started-step-by-step.md @@ -50,10 +50,10 @@ We start with four properties called **keywords** which are expressed as [JSON]( > Yes. the standard uses a JSON data document to describe data documents, most often that are also JSON data documents but could be in any number of other content types like `text/xml`. -* The [`$schema`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1) keyword states that this schema is written according to a specific draft of the standard and used for a variety of reasons, primarily version control. -* The [`$id`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.1) keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. -* The [`title`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) and [`description`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keywords are descriptive only. They do not add constraints to the data being validated. The intent of the schema is stated with these two keywords. -* The [`type`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1) validation keyword defines the first constraint on our JSON data and in this case it has to be a JSON Object. +* The [`$schema`](https://json-schema.org/draft/2020-12/json-schema-core.html#section-8.1.1) keyword states that this schema is written according to a specific draft of the standard and used for a variety of reasons, primarily version control. +* The [`$id`](https://json-schema.org/draft/2020-12/json-schema-core.html#section-8.2.1) keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. +* The [`title`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-9.1) and [`description`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-9.1) annotation keywords are descriptive only. They do not add constraints to the data being validated. The intent of the schema is stated with these two keywords. +* The [`type`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.1.1) validation keyword defines the first constraint on our JSON data and in this case it has to be a JSON Object. ```json { @@ -67,9 +67,9 @@ We start with four properties called **keywords** which are expressed as [JSON]( We introduce the following pieces of terminology when we start the schema: -* [Schema Keyword](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1): `$schema` and `$id`. -* [Schema Annotations](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1): `title` and `description`. -* [Validation Keyword](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1): `type`. +* [Schema Keyword](https://json-schema.org/draft/2020-12/json-schema-core.html#section-8.1.1): `$schema` and `$id`. +* [Schema Annotations](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-9.1): `title` and `description`. +* [Validation Keyword](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.1.1): `type`. ## Defining the properties @@ -77,10 +77,10 @@ We introduce the following pieces of terminology when we start the schema: In JSON Schema terms, we update our schema to add: -* The [`properties`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.1) validation keyword. +* The [`properties`](https://json-schema.org/draft/2020-12/json-schema-core.html#section-10.3.2.1) validation keyword. * The `productId` key. * `description` schema annotation and `type` validation keyword is noted -- we covered both of these in the previous section. -* The [`required`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.5.3) validation keyword listing `productId`. +* The [`required`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.5.3) validation keyword listing `productId`. ```json @@ -130,8 +130,8 @@ In JSON Schema terms, we update our schema to add: According to the store owner there are no free products. ;) * The `price` key is added with the usual `description` schema annotation and `type` validation keywords covered previously. It is also included in the array of keys defined by the `required` validation keyword. -* We specify the value of `price` must be something other than zero using the [`exclusiveMinimum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.5) validation keyword. - * If we wanted to include zero as a valid price we would have specified the [`minimum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword. +* We specify the value of `price` must be something other than zero using the [`exclusiveMinimum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.2.5) validation keyword. + * If we wanted to include zero as a valid price we would have specified the [`minimum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.2.4) validation keyword. ```json { @@ -172,9 +172,9 @@ Therefore: * The `tags` key is added with the usual annotations and keywords. * This time the `type` validation keyword is `array`. -* We introduce the [`items`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.1.2) validation keyword so we can define what appears in the array. In this case: `string` values via the `type` validation keyword. -* The [`minItems`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.2) validation keyword is used to make sure there is at least one item in the array. -* The [`uniqueItems`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.3) validation keyword notes all of the items in the array must be unique relative to one another. +* We introduce the [`items`](https://json-schema.org/draft/2020-12/json-schema-core.html#section-10.3.1.2) validation keyword so we can define what appears in the array. In this case: `string` values via the `type` validation keyword. +* The [`minItems`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.4.2) validation keyword is used to make sure there is at least one item in the array. +* The [`uniqueItems`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.4.3) validation keyword notes all of the items in the array must be unique relative to one another. * We did not add this key to the `required` validation keyword array because it is optional. ```json @@ -276,7 +276,7 @@ So far our JSON schema has been wholly self contained. It is very common to shar For this example we introduce a new JSON Schema resource and for both properties therein: * We use the `minimum` validation keyword noted earlier. -* We add the [`maximum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.2) validation keyword. +* We add the [`maximum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.2.2) validation keyword. * Combined, these give us a range to use in validation. ```json From 7ea91eb034b44c3578d1b0c7049643dd7e6a2be5 Mon Sep 17 00:00:00 2001 From: DJ Adams Date: Thu, 29 Sep 2022 07:48:18 +0000 Subject: [PATCH 247/311] fix spec links in file-system learning resource --- learn/file-system.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/learn/file-system.md b/learn/file-system.md index da7630b9..0544e423 100644 --- a/learn/file-system.md +++ b/learn/file-system.md @@ -66,16 +66,16 @@ We will start with a base JSON Schema expressing the following constraints: Building out our JSON Schema from top to bottom: -* The [`$id`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.1) keyword. -* The [`$schema`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.1.1) keyword. -* The [`type`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.1) validation keyword. -* The [`required`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.5.3) validation keyword. -* The [`properties`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.1) validation keyword. +* The [`$id`](https://json-schema.org/draft/2020-12/json-schema-core.html#section-8.2.1) keyword. +* The [`$schema`](https://json-schema.org/draft/2020-12/json-schema-core.html#section-8.1.1) keyword. +* The [`type`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.1.1) validation keyword. +* The [`required`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.5.3) validation keyword. +* The [`properties`](https://json-schema.org/draft/2020-12/json-schema-core.html#section-10.3.2.1) validation keyword. * The `/` key is empty now; We will fill it out later. -* The [`patternProperties`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.2) validation keyword. +* The [`patternProperties`](https://json-schema.org/draft/2020-12/json-schema-core.html#section-10.3.2.2) validation keyword. * This matches other property names via a regular expression. Note: it does not match `/`. * The `^(/[^/]+)+$` key is empty now; We will fill it out later. -* The [`additionalProperties`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.2.3) validation keyword. +* The [`additionalProperties`](https://json-schema.org/draft/2020-12/json-schema-core.html#section-10.3.2.3) validation keyword. * The value here is `false` to constrain object properties to be either `/` or to match the regular expression. > You will notice that the regular expression is explicitly anchored (with `^` and `$`): in JSON Schema, regular expressions (in `patternProperties` and in `pattern`) are not anchored by default. @@ -104,11 +104,11 @@ We saw these keywords in the prior exercise: `$id`, `$schema`, `type`, `required To this we add: -* The [`description`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.1) annotation keyword. -* The [`oneOf`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.2.1.3) keyword. -* The [`$ref`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.3.1) keyword. +* The [`description`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-9.1) annotation keyword. +* The [`oneOf`](https://json-schema.org/draft/2020-12/json-schema-core.html#section-10.2.1.3) keyword. +* The [`$ref`](https://json-schema.org/draft/2020-12/json-schema-core.html#section-8.2.3.1) keyword. * In this case, all references used are local to the schema using a relative fragment URI (`#/...`). -* The [`$defs`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.8.2.4) keyword. +* The [`$defs`](https://json-schema.org/draft/2020-12/json-schema-core.html#section-8.2.4) keyword. * Including several key names which we will define later. ```json @@ -142,12 +142,12 @@ To this we add: Let's now extend this skeleton to add constraints to some of the properties. -* Our `fstype` key uses the [`enum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.2) validation keyword. +* Our `fstype` key uses the [`enum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.1.2) validation keyword. * Our `options` key uses the following: * The `type` validation keyword (see above). - * The [`minItems`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.2) validation keyword. - * The [`items`](https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10.3.1.2) validation keyword. - * The [`uniqueItems`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.4.3) validation keyword. + * The [`minItems`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.4.2) validation keyword. + * The [`items`](https://json-schema.org/draft/2020-12/json-schema-core.html#section-10.3.1.2) validation keyword. + * The [`uniqueItems`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.4.3) validation keyword. * Together these say: `options` must be an array, and the items therein must be strings, there must be at least one item, and all items should be unique. * We have a `readonly` key. @@ -198,7 +198,7 @@ With these added constraints, the schema now looks like this: One new keyword is introduced here: -* The [`pattern`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.3.3) validation keyword notes the `device` key must be an absolute path starting with */dev*. +* The [`pattern`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.3.3) validation keyword notes the `device` key must be an absolute path starting with */dev*. ```json { @@ -246,7 +246,7 @@ We do have a new key: `label` and the `pattern` validation keyword states it mus We find another new keyword: -* The [`format`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.7) annotation and assertion keyword. +* The [`format`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-7) annotation and assertion keyword. ```json { @@ -276,8 +276,8 @@ We find another new keyword: Our last definition introduces two new keywords: -* The [`minimum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.4) validation keyword. -* The [`maximum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.2.2) validation keyword. +* The [`minimum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.2.4) validation keyword. +* The [`maximum`](https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.2.2) validation keyword. * Together these require the size be between 16 and 512, inclusive. ```json From b420f375bc1867553d93c278923d611d35627d23 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 29 Sep 2022 08:56:00 +0100 Subject: [PATCH 248/311] Update schedule for our open community meetings And add link to calendar --- index.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.md b/index.md index df042724..3b64e05c 100644 --- a/index.md +++ b/index.md @@ -41,8 +41,10 @@ We hold weekly Office Hours and twice monthly Open Community Working Meetings. Office Hours are every first Tuesday of the month at 15:00 UTC, and by appointment. -Open Community Working Meetings are every First and Third Monday of the month at 14:00 PT. +Open Community Working Meetings are every Monday at 14:00 PT. +If either of these are cancelled or moved for any reason, we will aim to announce such via the Slack announcement channel and Twitter. +See our [community calendar](https://calendar.google.com/calendar/u/0/embed?src=c_8r4g9r3etmrmt83fm2gljbatos@group.calendar.google.com) (and make sure to check the time zone). ## Need more? @@ -110,6 +112,7 @@ Similarly to most specifications, the JSON schema specification will continue to When the _draft_ designation is dropped this may indicate that the frequency of releases and amount of changes in each release will decrease, but it won't indicate that no new releases will be made, or that all future releases will be backwards compatible. + ## Quickstart The JSON document being validated or described we call the *instance*, and the document containing the description is called the *schema*. From a822bf3be51e19e25367ad9c9d440413beee4273 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Thu, 29 Sep 2022 08:14:48 -0500 Subject: [PATCH 249/311] Fix a whitespace typo --- specification.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification.md b/specification.md index e70419a9..742d633c 100644 --- a/specification.md +++ b/specification.md @@ -30,7 +30,7 @@ They are also available on the IETF main site: Meta-schemas ------------ -The meta-schemas are schemas against which other schemas can be validated.It is self-descriptive: the JSON Schema meta-schema validates itself. +The meta-schemas are schemas against which other schemas can be validated. It is self-descriptive: the JSON Schema meta-schema validates itself. The latest meta-schema is **2020-12**. For an explanation of the change to date-based identifiers, see the [Specification Links](specification-links.html) page. From 2aa6daaa828c85ece632439b884f2105e01f23d7 Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Sat, 1 Oct 2022 20:34:04 -0700 Subject: [PATCH 250/311] Announce several things about process changes This addresses some of the most commonly-heard questions and misconceptions about our recent process announcement. --- index.md | 44 ++++++++++---------------------------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/index.md b/index.md index 3b64e05c..be134af2 100644 --- a/index.md +++ b/index.md @@ -20,6 +20,16 @@ permalink: / +## Announcements and Feedback Solicitation: Specification Process + +* The JSON Schema media types (`application/schema+json` and `application/schema-instance+json`) will be published as an [IETF RFC](https://datatracker.ietf.org/doc/draft-ietf-httpapi-rest-api-mediatypes/), which has already been adopted by the HTTP APIs working group. +* As an [Incubation-status OpenJS Foundation project](https://openjsf.org/projects/#incubating), we continue to work through our governance [todo list](https://github.com/json-schema-org/community/issues/129) to move to either At-Large or Impact status. +* The bulk of our specification will be published under a new process currently [under public discussion](https://github.com/orgs/json-schema-org/discussions/234). All are encouraged to provide feedback! Our goals with this process include: + * In the next release, offer stability guarantees for long-stable aspects of JSON Schema. + * Provide clarity regarding which other aspects are close to a stable form, and which are more experimental. + * Publish our specifications in a way similar to OpenAPI and AsyncAPI, which are also part of the Linux Foundation (the larger umbrella under which the OpenJS Foundation exists). +* We are working on finding the right path for Relative JSON Pointer to reach standardization in the near future. An IETF RFC currently remains the most likely path, although several details are still being worked out. + ## What now? Learn, Get help, Shape the Community, Chat, with the JSON Schema team and Community! @@ -79,40 +89,6 @@ so we will usually refer to `2020-12` (without the word "draft") on this web sit See the [Specification page](specification.html) for details about naming and numbering. -### The Path to Standardization - -The JSON Schema project intends to shepherd all three draft series to either: RFC status, the equivalent within another standards body, and/or join a foundation and establish self publication rules. - -
        -Read more - -Currently, we are continuing to improve our self-published Internet-Drafts. We are not actively pursuing joining a standards organisation. - -We have a few contacts related to each potential path, but if you have experience with such things and would like to help, please still contact us! - -In the meantime, publication of Internet-Draft documents can be tracked through the IETF: -* [JSON Schema (core)](https://datatracker.ietf.org/doc/draft-bhutton-json-schema/) -* [JSON Schema Validation](https://datatracker.ietf.org/doc/draft-bhutton-json-schema-validation/) -* [Relative JSON Pointers](https://datatracker.ietf.org/doc/draft-bhutton-relative-json-pointer/) - -Internet-Drafts expire after six months, so our goal is to publish often enough to always have a set of unexpired drafts available. There may be brief gaps as we wrap up each draft and finalize the text. -
        - -### Use of the _draft_ designation -Releases of the JSON schema specification and meta schemas use the _draft_ designation primarily for historical reasons stemming from the relationship of this specification to IETF ([explained here](https://json-schema.org/specification-links.html#understanding-draft-names-and-numbers)). -The use of this designation is under review but will continue until this review process completes to avoid changing the designation style multiple times. -
        -Read more - -The JSON schema project recognizes, condones, and advocates for the use of the JSON schema standard in production. - -Each release of the JSON schema specification is treated as a production release by the JSON schema project. All changes in each new release are made judiciously, with great care, thorough review and careful consideration of how the changes will impact existing users and implementations of the JSON schema specification. - -Similarly to most specifications, the JSON schema specification will continue to evolve, and not all releases will be backwards compatible. The intention, particularly for vocabularies such as validation which have been widely implemented, is to remain as compatible as possible from release to release. However, major changes can still occur given a clear enough need validated with the user community. - -When the _draft_ designation is dropped this may indicate that the frequency of releases and amount of changes in each release will decrease, but it won't indicate that no new releases will be made, or that all future releases will be backwards compatible. -
        - ## Quickstart The JSON document being validated or described we call the *instance*, and the document containing the description is called the *schema*. From c76c6771a6df418dfc0e70af8b13dbdee3c1df41 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Tue, 4 Oct 2022 14:37:01 +0100 Subject: [PATCH 251/311] Fix office hours time! --- index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.md b/index.md index 3b64e05c..84fcfde3 100644 --- a/index.md +++ b/index.md @@ -39,7 +39,7 @@ We hold weekly Office Hours and twice monthly Open Community Working Meetings. 👷 Open Community Working Meetings -Office Hours are every first Tuesday of the month at 15:00 UTC, and by appointment. +Office Hours are every first Tuesday of the month at 15:00 BST, and by appointment. Open Community Working Meetings are every Monday at 14:00 PT. From 537e4ee29c5b1296b7b25fb124244fb07cb429b0 Mon Sep 17 00:00:00 2001 From: Michael Mior Date: Tue, 4 Oct 2022 11:24:31 -0400 Subject: [PATCH 252/311] Add JSONoid to implementations --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index 92aae02c..54a3c251 100644 --- a/implementations.md +++ b/implementations.md @@ -169,6 +169,7 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - [saasquatch/json-schema-inferrer](https://github.com/saasquatch/json-schema-inferrer) _draft-07, -06, -04_ (Apache 2.0) - Java library for inferring JSON Schemas from one or multiple JSON samples. - Scala - [Schema Guru](https://github.com/snowplow/schema-guru) (Apache 2.0) - CLI util, Spark Job and Web UI for deriving JSON Schemas out of corpus of JSON instances; see issue [178](https://github.com/snowplow/schema-guru/issues/178) for progress towards draft-06+ support + - [JSONoid](https://github.com/michaelmior/jsonoid-discovery/) (MIT) - command line tool and Spark application for inferring schemas from JSON documents, supports draft 2019-09 - Clojure - [luposlip/json-schema](https://github.com/luposlip/json-schema) (Apache 2.0) - infer JSON Schema from Clojure data - Online (web tool) From 2705881a6b8a43c5b011915a777c29088894a32d Mon Sep 17 00:00:00 2001 From: Waldir Pimenta Date: Thu, 6 Oct 2022 00:27:21 +0100 Subject: [PATCH 253/311] Link directly to json-everything.net's validator --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index aaf6455e..fe9725ff 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -364,7 +364,7 @@ name: Hyperjump JSV last-updated: "2022-08-31" - name: json-everything - url: https://json-everything.net + url: https://json-everything.net/json-schema date-draft: [2020-12, 2019-09] draft: [7, 6] notes: Powered by JsonSchema.Net in Blazor WASM for client-side validation From 9ae616e7ab0eaed7afd3c68ce1e2b725c334fbf8 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 7 Oct 2022 12:07:30 +0200 Subject: [PATCH 254/311] Add go-jsonschema --- implementations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implementations.md b/implementations.md index 92aae02c..84705166 100644 --- a/implementations.md +++ b/implementations.md @@ -195,6 +195,8 @@ are the only keywords that changed. - Elm - [json-schema-to-elm](https://github.com/dragonwasrobot/json-schema-to-elm) - generates Elm types, JSON decoders+encoders, and fuzz tests from one or more JSON Schema files, using [dragonwasrobot/json_schema](https://github.com/dragonwasrobot/json_schema) *supports Draft 7* +- Go + - [go-jsonschema](https://git.sr.ht/~emersion/go-jsonschema) - generates Go types and helpers from JSON schema files *supports Draft 2020-12* - Java - [jsonCodeGen](https://github.com/schlothauer-wauer/jsoncodegen) (MIT) - Groovy based generation tasks from JSON schema. Already includes templates/generators for Java Beans, Swagger specification files and PlantUML diagrams. - [jsonschema2pojo](https://github.com/joelittlejohn/jsonschema2pojo) (Apache 2.0) - generates Java types from JSON Schema (or example JSON) and can annotate those types for data-binding with Jackson 2.x or Gson. *draft-07* From 2f0f2ff5372340d18361cc9024b7bf6658908788 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 11 Oct 2022 11:50:18 +0000 Subject: [PATCH 255/311] Add glossary entries for dialect and vocabulary. --- learn/glossary.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/learn/glossary.md b/learn/glossary.md index 6ffd5392..8f0cc815 100644 --- a/learn/glossary.md +++ b/learn/glossary.md @@ -14,6 +14,15 @@ If you encounter a term you wish were defined here, please feel free to [file an The entries on this page can be linked to via anchor links (e.g. `https://json-schema.org/learn/glossary.html#vocabulary`) when sharing a definition with others. +### dialect + +A collection of [vocabularies](#vocabulary), along with an indication of whether supporting each vocabulary is required to process schemas written in the dialect. + +Dialects are identified by a URI, which [schemas](#schema) may then reference in their `$schema` [keyword](#keyword). +Doing so identifies the schema as being written in the dialect, and thereby indicates which keywords are usable within it, along with their intended meaning. + +The JSON Schema specification [defines](https://json-schema.org/specification.html#general-purpose-meta-schema) a number of dialects, each of which enable vocabularies suitable for the dialect's specific use case. + ### draft An individual release of the JSON Schema specification. @@ -70,3 +79,18 @@ The rules constituting which schemas are conformant, as well as the rules govern Strictly speaking, according to the specification, schemas are themselves JSON documents, though it is somewhat common for them to be authored or maintained in other languages which are easily translated to JSON, such as YAML. In recent [drafts](#draft) of the specification, a schema is either a JSON object or a JSON boolean value. + +### vocabulary + +A collection of related [keywords](keyword), grouped to facilitate re-use. + +A vocabulary typically includes both a [meta-schema](#meta-schema) which formally defines the keywords it contains, as well as a prose document or specification which explains the semantics of its keywords in a way suitable for implementers and users of the vocabulary. + +Anyone can create and publish a vocabulary, and implementations generally will include facilities for extending themselves with support for additional vocabularies and their keywords. +The JSON Schema specification includes a number of vocabularies which cover each of the keywords it defines. + +Vocabularies are identified by a URI which may be referenced via the `$vocabulary` keyword in order to enable the vocabulary within a [dialect](#dialect). + +#### See also + +* [`json-schema-vocabularies`](https://github.com/json-schema-org/json-schema-vocabularies), a repository which collects known third-party JSON Schema vocabularies From fe3f20bf46a7abc3b6427e49af1af35aa4f83446 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 12 Oct 2022 15:56:49 +0000 Subject: [PATCH 256/311] The vocabulary document is considered authoritative. --- learn/glossary.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/learn/glossary.md b/learn/glossary.md index 8f0cc815..1fd68007 100644 --- a/learn/glossary.md +++ b/learn/glossary.md @@ -84,7 +84,8 @@ In recent [drafts](#draft) of the specification, a schema is either a JSON objec A collection of related [keywords](keyword), grouped to facilitate re-use. -A vocabulary typically includes both a [meta-schema](#meta-schema) which formally defines the keywords it contains, as well as a prose document or specification which explains the semantics of its keywords in a way suitable for implementers and users of the vocabulary. +A vocabulary is specified by a prose document or specification which explains the semantics of its keywords in a way suitable for implementers and users of the vocabulary. +It often also includes a [meta-schema](#meta-schema) (or multiple metaschemas) which define the syntax of its keywords. Anyone can create and publish a vocabulary, and implementations generally will include facilities for extending themselves with support for additional vocabularies and their keywords. The JSON Schema specification includes a number of vocabularies which cover each of the keywords it defines. From 67002b6e20c1f745b74115caaccce06e8b9ef3a5 Mon Sep 17 00:00:00 2001 From: Octavian Date: Wed, 19 Oct 2022 15:59:02 +0300 Subject: [PATCH 257/311] Update implementations.md - Updated Oxygen JSON Schema editor description - Added XSD to JSON schema converter - Added Oxygen Documentation generator --- implementations.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 121eb8d5..22015395 100644 --- a/implementations.md +++ b/implementations.md @@ -293,6 +293,9 @@ the utility, and decided on a case-by-case basis. - Webpack - [@cloudflare/json-schema-ref-loader](https://github.com/cloudflare/json-schema-tools/tree/master/workspaces/json-schema-ref-loader) ([JSON Schema Tools](https://github.com/cloudflare/json-schema-tools)), (BSD-3-Clause) Webpack loader for dereference-able schemas in JSON, JSON5, YAML, or JavaScript - [@cloudflare/json-schema-apidoc-loader](https://github.com/cloudflare/json-schema-tools/tree/master/workspaces/json-schema-apidoc-loader) ([JSON Schema Tools](https://github.com/cloudflare/json-schema-tools)), Back-end for [@cloudflare/doca](https://github.com/cloudflare/json-schema-tools/tree/master/workspaces/doca), _draft-04, -06, -07, and Doca extensions_ +- XSD + - [Oxygen XSD to JSON Schema](https://www.oxygenxml.com/json_converter.html#xsd-to-json-schema) - Generate from an XSD file a similar JSON Schema structure. + - [XSD to JSON Schema IntellJ plugin](https://plugins.jetbrains.com/plugin/19024-xsd-to-json-schema) - Plugin for converting an XML Schema (XSD) file to a JSON Schema file. #### Testing @@ -307,7 +310,7 @@ the utility, and decided on a case-by-case basis. - [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator with JSON schema analyzer, context sensitive entry-helpers and sample data generation based on JSON schema. Support for draft-4, draft-6, draft-7 and 2019-09. JSON Schema validation debugger: Step through the validation process and set breakpoints.* - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Liquid JSON Schema Editor](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON Schema editor for draft-04, draft-06, draft-07 and 2019-09, with split source code and grphical editing. Includes validation of JSON files based on JSON Schema, JSON Sample Generator and JSON Schema Documentation Generator.* -- [Oxygen JSON Editor](https://www.oxygenxml.com/xml_editor/json.html) - *JSON editor with a variety of editing features and helper views. Support for validation and editing JSON Schema draft-4, draft-6, and draft-7. Validation and editing of JSON files based on JSON Schema.* +- [Oxygen JSON Schema Editor](https://www.oxygenxml.com/xml_developer/json_schema_editor.html) - *JSON Schema editor with a variety of editing features and helper views (Design/Text/Author). Support for validation and editing JSON Schema draft-4, draft-6, and draft-7, 2019-09, 2020-12. Validation and editing of JSON files based on JSON Schema.* - [Perseid Modeler](https://www.datensen.com/data-modeling/perseid-modeler-for-json-schema.html) - *a modeling tool for JSON Schema and OpenAPI. Key features include: visual JSON schema creation using tree and ERD-like diagrams, support for JSON schema structures including operators and conditions, import of existing schemas from files, creation of detailed HTML reports, export to PDF, script generation, and more. Supported versions: draft 4, 6, 7, 2019-09 and 2020-12* - [Stoplight Studio](https://stoplight.io/) - *JSON Schema IDE (text-based and GUI) with support for JSON/YAML linting, which can also be based on JSON Schema rules via Spectral. Support for draft-4, draft-6 and draft-7.* - [Visual Studio Code](https://code.visualstudio.com/) - *Schema driven code completion, hovers and validation for editing JSON files (including schemas)* @@ -319,6 +322,7 @@ the utility, and decided on a case-by-case basis. - [jsonschematic](https://github.com/yanick/jsonschematic/) - Svelte-based schema viewer. Runs as a local web app. Supports draft-7. - [docson](https://github.com/lbovet/docson) - Javascript-based schema viewer. Runs as a local web app. Supports draft-4. - [json-schema-for-humans](https://pypi.org/project/json-schema-for-humans/) - Generate HTML representation of a schema. Python-based. Supports draft-7. +- [oXygen JSON Schema Documentation](https://www.oxygenxml.com/json_converter.html#generate-json-schema-documentation) - Generate JSON Schema documentation in HTML format including diagrams. - [wetzel](https://github.com/CesiumGS/wetzel) - Generates Markdown and AsciiDoc. With some limitations, supports draft-3, draft-4, draft-7, and 2020-12. Schema Repositories From 3d0a123bfcce2928f654d0db77c66485c16e5b6f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Oct 2022 03:39:16 +0000 Subject: [PATCH 258/311] Bump nokogiri from 1.13.6 to 1.13.9 Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.6 to 1.13.9. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.6...v1.13.9) --- updated-dependencies: - dependency-name: nokogiri dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index ce7c576b..4cf839f2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -212,7 +212,7 @@ GEM jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) minitest (5.16.1) - nokogiri (1.13.6) + nokogiri (1.13.9) mini_portile2 (~> 2.8.0) racc (~> 1.4) octokit (4.25.0) From 5cabad53abf871e0362056b0f78ab77a08cb5724 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 3 Nov 2022 14:43:09 +0000 Subject: [PATCH 259/311] Updated primer Opened in favour of https://github.com/json-schema-org/json-schema-org.github.io/pull/423 --- index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.md b/index.md index 0755d820..e276482b 100644 --- a/index.md +++ b/index.md @@ -5,7 +5,7 @@ permalink: / --- -**JSON Schema** is a vocabulary that allows you to **annotate** and **validate** JSON documents. +**JSON Schema** is a declarative domain specific language that allows you to **annotate** and **validate** JSON documents. JSON Schema enables the confident and reliable use of the JSON data format. ## Benefits From 4fd1feef51659b36f7edc6dd9fccd306c65c80e6 Mon Sep 17 00:00:00 2001 From: Octavian Date: Fri, 4 Nov 2022 08:42:32 +0200 Subject: [PATCH 260/311] Update implementations.md Updated the description for Oxygen JSON Schema implementation 2019-09 and 2020-12 --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 22015395..6aa68b33 100644 --- a/implementations.md +++ b/implementations.md @@ -310,7 +310,7 @@ the utility, and decided on a case-by-case basis. - [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator with JSON schema analyzer, context sensitive entry-helpers and sample data generation based on JSON schema. Support for draft-4, draft-6, draft-7 and 2019-09. JSON Schema validation debugger: Step through the validation process and set breakpoints.* - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Liquid JSON Schema Editor](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON Schema editor for draft-04, draft-06, draft-07 and 2019-09, with split source code and grphical editing. Includes validation of JSON files based on JSON Schema, JSON Sample Generator and JSON Schema Documentation Generator.* -- [Oxygen JSON Schema Editor](https://www.oxygenxml.com/xml_developer/json_schema_editor.html) - *JSON Schema editor with a variety of editing features and helper views (Design/Text/Author). Support for validation and editing JSON Schema draft-4, draft-6, and draft-7, 2019-09, 2020-12. Validation and editing of JSON files based on JSON Schema.* +- [Oxygen JSON Schema Editor](https://www.oxygenxml.com/xml_developer/json_schema_editor.html) - *JSON Schema editor with a variety of editing features and helper views (Design/Text/Author). Support for validation and editing JSON Schema draft-4, draft-6, and draft-7, 2019-09 (partial), 2020-12 (partial). Validation and editing of JSON files based on JSON Schema.* - [Perseid Modeler](https://www.datensen.com/data-modeling/perseid-modeler-for-json-schema.html) - *a modeling tool for JSON Schema and OpenAPI. Key features include: visual JSON schema creation using tree and ERD-like diagrams, support for JSON schema structures including operators and conditions, import of existing schemas from files, creation of detailed HTML reports, export to PDF, script generation, and more. Supported versions: draft 4, 6, 7, 2019-09 and 2020-12* - [Stoplight Studio](https://stoplight.io/) - *JSON Schema IDE (text-based and GUI) with support for JSON/YAML linting, which can also be based on JSON Schema rules via Spectral. Support for draft-4, draft-6 and draft-7.* - [Visual Studio Code](https://code.visualstudio.com/) - *Schema driven code completion, hovers and validation for editing JSON files (including schemas)* From 1f8bd34dc8014e3c17d4e53d66a52e296e2ddc98 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 9 Nov 2022 11:07:19 -0500 Subject: [PATCH 261/311] Update the link for python-jsonschema (It now lives in a GitHub organization, though the old link redirects.) --- _data/validator-libraries-modern.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index fe9725ff..a5229060 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -284,11 +284,11 @@ license: MIT last-updated: "2022-08-31" - name: jsonschema - url: https://github.com/Julian/jsonschema + url: https://github.com/python-jsonschema/jsonschema date-draft: [2019-09, 2020-12] draft: [7, 6, 4, 3] license: "MIT" - last-updated: "2022-08-31" + last-updated: "2022-11-09" - name: fastjsonschema url: https://github.com/horejsek/python-fastjsonschema notes: Great performance thanks to code generation. From 645fd3cf9e23bded416d315ab84efc356b83167d Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Mon, 14 Nov 2022 10:51:45 +0000 Subject: [PATCH 262/311] Remove "domain specific" --- index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.md b/index.md index e276482b..44c03f0c 100644 --- a/index.md +++ b/index.md @@ -5,7 +5,7 @@ permalink: / --- -**JSON Schema** is a declarative domain specific language that allows you to **annotate** and **validate** JSON documents. JSON Schema enables the confident and reliable use of the JSON data format. +**JSON Schema** is a declarative language that allows you to **annotate** and **validate** JSON documents. JSON Schema enables the confident and reliable use of the JSON data format. ## Benefits From 24df7c6fca226e5ccfbe39343b7d330105e75105 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Mon, 14 Nov 2022 11:41:33 +0000 Subject: [PATCH 263/311] Fix primer layout (#489) * Fix primer layout --- index.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.md b/index.md index 44c03f0c..6d2a709c 100644 --- a/index.md +++ b/index.md @@ -4,8 +4,11 @@ title: JSON Schema permalink: / --- +
        +**JSON Schema** is a declarative language that allows you to **annotate** and **validate** JSON documents. -**JSON Schema** is a declarative language that allows you to **annotate** and **validate** JSON documents. JSON Schema enables the confident and reliable use of the JSON data format. +JSON Schema enables the confident and reliable use of the JSON data format. +
        ## Benefits From d5a750e327d67e5757f10bd21b71f7290e568b29 Mon Sep 17 00:00:00 2001 From: Thomas Collins Date: Tue, 17 Jan 2023 22:25:58 +0000 Subject: [PATCH 264/311] Adding json-schema-static-docs to documentation generators Adding [json-schema-static-docs](https://tomcollins.github.io/json-schema-static-docs/) to the documentation generators section of the implementations page. --- implementations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implementations.md b/implementations.md index 6aa68b33..701f398d 100644 --- a/implementations.md +++ b/implementations.md @@ -319,6 +319,8 @@ the utility, and decided on a case-by-case basis. #### Documentation generators + +- [json-schema-static-docs]([https://github.com/yanick/jsonschematic/](https://tomcollins.github.io/json-schema-static-docs/)) - Generates human friendly markdown documentation from JSON Schema. Includes links between pages based on $ref values. Supports draft-7. - [jsonschematic](https://github.com/yanick/jsonschematic/) - Svelte-based schema viewer. Runs as a local web app. Supports draft-7. - [docson](https://github.com/lbovet/docson) - Javascript-based schema viewer. Runs as a local web app. Supports draft-4. - [json-schema-for-humans](https://pypi.org/project/json-schema-for-humans/) - Generate HTML representation of a schema. Python-based. Supports draft-7. From a40957c9abdda88a56a2f102083952acf257bd82 Mon Sep 17 00:00:00 2001 From: Thomas Collins Date: Wed, 18 Jan 2023 08:55:23 +0000 Subject: [PATCH 265/311] Correcting URL for json-schema-static-docs --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 701f398d..b253e5a0 100644 --- a/implementations.md +++ b/implementations.md @@ -320,7 +320,7 @@ the utility, and decided on a case-by-case basis. #### Documentation generators -- [json-schema-static-docs]([https://github.com/yanick/jsonschematic/](https://tomcollins.github.io/json-schema-static-docs/)) - Generates human friendly markdown documentation from JSON Schema. Includes links between pages based on $ref values. Supports draft-7. +- [json-schema-static-docs](https://tomcollins.github.io/json-schema-static-docs/) - Generates human friendly markdown documentation from JSON Schema. Includes links between pages based on $ref values. Supports draft-7. - [jsonschematic](https://github.com/yanick/jsonschematic/) - Svelte-based schema viewer. Runs as a local web app. Supports draft-7. - [docson](https://github.com/lbovet/docson) - Javascript-based schema viewer. Runs as a local web app. Supports draft-4. - [json-schema-for-humans](https://pypi.org/project/json-schema-for-humans/) - Generate HTML representation of a schema. Python-based. Supports draft-7. From ed8505e7b2b621f57eddee070d446267f1dc9d58 Mon Sep 17 00:00:00 2001 From: Clemens Uhlenhut Date: Mon, 6 Feb 2023 08:54:38 +0100 Subject: [PATCH 266/311] Update implementations.md Added information about the latest release of JSONBuddy and support of draft 2020-12. --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index b253e5a0..88107db8 100644 --- a/implementations.md +++ b/implementations.md @@ -307,7 +307,7 @@ the utility, and decided on a case-by-case basis. - [Altova XMLSpy 2019r3](https://www.altova.com/xmlspy-xml-editor#json_schema) - *Graphical JSON Schema editor for draft-06 and draft-7, as well as validation of JSON files based on JSON Schema* - [Dashjoin JSON Schema editor](https://dashjoin.github.io/#/schema) - *Graphical online JSON Schema editor for draft-06 (minus oneOf, anyOf, allOf, not). The generated schema can be tested immediately via a form that is driven by it.* - [Hackolade Studio](https://hackolade.com/help/JSONSchemaEditor.html) - *Visual JSON Schema editor for draft-04, draft-06, draft-07, 2019-09, 2020-12, as well as data modeling tool for NoSQL databases, storage formats, REST APIs, and JSON in RDBMS. Also converts to and from: different draft specifications, DDL, XSD, Swagger, OpenAPI, YAML, Avro, Parquet, Protobuf, and most of the NoSQL script syntaxes. Includes a GUI for Entity-Relationship Diagrams and a Command-Line Interface.* -- [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator with JSON schema analyzer, context sensitive entry-helpers and sample data generation based on JSON schema. Support for draft-4, draft-6, draft-7 and 2019-09. JSON Schema validation debugger: Step through the validation process and set breakpoints.* +- [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator. Complete JSON Schema development environment with JSON Schema analyzer, context sensitive entry-helpers, sample data generation based on JSON Schema and JSON Schema validation debugger: Step through the validation process and set breakpoints. Support for draft-4, draft-6, draft-7, 2019-09 and 2020-12.* - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Liquid JSON Schema Editor](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON Schema editor for draft-04, draft-06, draft-07 and 2019-09, with split source code and grphical editing. Includes validation of JSON files based on JSON Schema, JSON Sample Generator and JSON Schema Documentation Generator.* - [Oxygen JSON Schema Editor](https://www.oxygenxml.com/xml_developer/json_schema_editor.html) - *JSON Schema editor with a variety of editing features and helper views (Design/Text/Author). Support for validation and editing JSON Schema draft-4, draft-6, and draft-7, 2019-09 (partial), 2020-12 (partial). Validation and editing of JSON files based on JSON Schema.* From 500a0be86c0e258e2f982a79328cac5193effc80 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Tue, 21 Feb 2023 12:42:00 -0800 Subject: [PATCH 267/311] Don't serve docker files --- _config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/_config.yml b/_config.yml index 3a16502f..8540af95 100644 --- a/_config.yml +++ b/_config.yml @@ -36,6 +36,7 @@ exclude: - Gemfile - node_modules - vendor +- docker-compose.yml plugins: - jekyll-relative-links From db80fab9c7240929dd57336f7654ec9eb5d5003e Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Tue, 21 Feb 2023 13:13:54 -0800 Subject: [PATCH 268/311] Fix Netlify build --- .ruby-version | 1 + Gemfile | 1 + Gemfile.lock | 80 +++++++++++++++++++++++++-------------------------- _config.yml | 1 + 4 files changed, 42 insertions(+), 41 deletions(-) create mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 00000000..94ff29cc --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.1.1 diff --git a/Gemfile b/Gemfile index d74d7c0d..a3a27a46 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,4 @@ source 'https://rubygems.org' +ruby '3.1.1' gem 'github-pages', group: :jekyll_plugins gem 'webrick', '~> 1.7' diff --git a/Gemfile.lock b/Gemfile.lock index 4cf839f2..9111ff7b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,43 +1,42 @@ GEM remote: https://rubygems.org/ specs: - activesupport (6.0.5) + activesupport (7.0.4.2) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.11.1) colorator (1.1.0) - commonmarker (0.23.6) - concurrent-ruby (1.1.10) + commonmarker (0.23.8) + concurrent-ruby (1.2.0) dnsruby (1.61.9) simpleidn (~> 0.1) em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) - ethon (0.15.0) + ethon (0.16.0) ffi (>= 1.15.0) eventmachine (1.2.7) execjs (2.8.1) - faraday (2.3.0) - faraday-net_http (~> 2.0) + faraday (2.7.4) + faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) - faraday-net_http (2.0.3) + faraday-net_http (3.0.2) ffi (1.15.5) forwardable-extended (2.6.0) gemoji (3.0.1) - github-pages (226) + github-pages (228) github-pages-health-check (= 1.17.9) - jekyll (= 3.9.2) + jekyll (= 3.9.3) jekyll-avatar (= 0.7.0) jekyll-coffeescript (= 1.1.1) - jekyll-commonmark-ghpages (= 0.2.0) + jekyll-commonmark-ghpages (= 0.4.0) jekyll-default-layout (= 0.1.4) jekyll-feed (= 0.15.1) jekyll-gist (= 1.5.0) @@ -71,10 +70,10 @@ GEM jemoji (= 0.12.0) kramdown (= 2.3.2) kramdown-parser-gfm (= 1.1.0) - liquid (= 4.0.3) + liquid (= 4.0.4) mercenary (~> 0.3) minima (= 2.5.1) - nokogiri (>= 1.13.4, < 2.0) + nokogiri (>= 1.13.6, < 2.0) rouge (= 3.26.0) terminal-table (~> 1.4) github-pages-health-check (1.17.9) @@ -83,17 +82,17 @@ GEM octokit (~> 4.0) public_suffix (>= 3.0, < 5.0) typhoeus (~> 1.3) - html-pipeline (2.14.2) + html-pipeline (2.14.3) activesupport (>= 2) nokogiri (>= 1.4) http_parser.rb (0.8.0) - i18n (0.9.5) + i18n (1.12.0) concurrent-ruby (~> 1.0) - jekyll (3.9.2) + jekyll (3.9.3) addressable (~> 2.4) colorator (~> 1.0) em-websocket (~> 0.5) - i18n (~> 0.7) + i18n (>= 0.7, < 2) jekyll-sass-converter (~> 1.0) jekyll-watch (~> 2.0) kramdown (>= 1.17, < 3) @@ -109,11 +108,11 @@ GEM coffee-script-source (~> 1.11.1) jekyll-commonmark (1.4.0) commonmarker (~> 0.22) - jekyll-commonmark-ghpages (0.2.0) - commonmarker (~> 0.23.4) + jekyll-commonmark-ghpages (0.4.0) + commonmarker (~> 0.23.7) jekyll (~> 3.9.0) jekyll-commonmark (~> 1.4.0) - rouge (>= 2.0, < 4.0) + rouge (>= 2.0, < 5.0) jekyll-default-layout (0.1.4) jekyll (~> 3.0) jekyll-feed (0.15.1) @@ -201,28 +200,26 @@ GEM rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) - liquid (4.0.3) - listen (3.7.1) + liquid (4.0.4) + listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) mercenary (0.3.6) - mini_portile2 (2.8.0) minima (2.5.1) jekyll (>= 3.5, < 5.0) jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) - minitest (5.16.1) - nokogiri (1.13.9) - mini_portile2 (~> 2.8.0) + minitest (5.17.0) + nokogiri (1.14.2-x86_64-linux) racc (~> 1.4) - octokit (4.25.0) + octokit (4.25.1) faraday (>= 1, < 3) sawyer (~> 0.9) pathutil (0.16.2) forwardable-extended (~> 2.6) public_suffix (4.0.7) - racc (1.6.0) - rb-fsevent (0.11.1) + racc (1.6.2) + rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) rexml (3.2.5) @@ -242,24 +239,25 @@ GEM unf (~> 0.1.4) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) - thread_safe (0.3.6) typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (1.2.10) - thread_safe (~> 0.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) unf (0.1.4) unf_ext unf_ext (0.0.8.2) unicode-display_width (1.8.0) - webrick (1.7.0) - zeitwerk (2.6.0) + webrick (1.8.1) PLATFORMS - ruby + x86_64-linux-musl DEPENDENCIES github-pages webrick (~> 1.7) +RUBY VERSION + ruby 3.1.1p18 + BUNDLED WITH - 2.2.7 + 2.3.25 diff --git a/_config.yml b/_config.yml index 8540af95..3fd3064f 100644 --- a/_config.yml +++ b/_config.yml @@ -36,6 +36,7 @@ exclude: - Gemfile - node_modules - vendor +- cache - docker-compose.yml plugins: From 1577d2b2a30a41f7bdda28f90dbf82cb786747a6 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Tue, 21 Feb 2023 10:53:34 -0800 Subject: [PATCH 269/311] Expose 2020-12 hyper-schema vocabulary --- draft/2020-12/meta/hyper-schema | 1 + 1 file changed, 1 insertion(+) create mode 120000 draft/2020-12/meta/hyper-schema diff --git a/draft/2020-12/meta/hyper-schema b/draft/2020-12/meta/hyper-schema new file mode 120000 index 00000000..29e3d6ac --- /dev/null +++ b/draft/2020-12/meta/hyper-schema @@ -0,0 +1 @@ +../../../_includes/draft/2020-12/meta/hyper-schema.json \ No newline at end of file From 5f4340aa4ba4c6d7f46c9e69c86594b9e923f471 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Tue, 21 Feb 2023 13:44:07 -0800 Subject: [PATCH 270/311] Pull updated draft-07 hyper-schema-outout schema --- _includes/draft-07 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/draft-07 b/_includes/draft-07 index 6e2b4251..567f7685 160000 --- a/_includes/draft-07 +++ b/_includes/draft-07 @@ -1 +1 @@ -Subproject commit 6e2b42516dc7e8845c980d284c61bd44c9f95cd2 +Subproject commit 567f768506aaa33a38e552c85bf0586029ef1b32 From 6cff5deaebc773b2a34a6c4bb47591dfde0636b1 Mon Sep 17 00:00:00 2001 From: Jacques Yakoub Date: Wed, 22 Feb 2023 11:50:52 +0100 Subject: [PATCH 271/311] docs: add a extra "Documentation generator" --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index 88107db8..e0cc8bce 100644 --- a/implementations.md +++ b/implementations.md @@ -320,6 +320,7 @@ the utility, and decided on a case-by-case basis. #### Documentation generators +- [docusaurus-json-schema-plugin](https://github.com/jy95/docusaurus-json-schema-plugin) - Schema viewer. Runs within a [Docusaurus](https://docusaurus.io/) web app. Supports draft-7, 2019-09, Draft 2020-12 - [json-schema-static-docs](https://tomcollins.github.io/json-schema-static-docs/) - Generates human friendly markdown documentation from JSON Schema. Includes links between pages based on $ref values. Supports draft-7. - [jsonschematic](https://github.com/yanick/jsonschematic/) - Svelte-based schema viewer. Runs as a local web app. Supports draft-7. - [docson](https://github.com/lbovet/docson) - Javascript-based schema viewer. Runs as a local web app. Supports draft-4. From b05b08d31bda2673d202b7967346b992a528e207 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Tekuri Date: Fri, 24 Feb 2023 18:16:42 +0530 Subject: [PATCH 272/311] Add boon validation library for Rust --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index a5229060..f1f126fa 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -321,6 +321,12 @@ last-updated: "2022-08-31" - name: Rust implementations: + - name: boon + url: https://github.com/santhosh-tekuri/boon + date-draft: [2020-12, 2019-09] + draft: [7, 6, 4] + license: Apache License 2.0 + last-updated: "2023-02-22" - name: jsonschema-rs url: https://github.com/Stranger6667/jsonschema-rs notes: Fast due to compiling schema into a validation tree; 2019-09 and 2020-12 are partially supported From d7a714909faace2ffe3c54e8a7c1a0b3cd3f8432 Mon Sep 17 00:00:00 2001 From: Benjamin Granados <40007659+benjagm@users.noreply.github.com> Date: Wed, 1 Feb 2023 18:04:08 +0100 Subject: [PATCH 273/311] Update validator-libraries-modern.yml Added a GitHub Action in a new category. --- _data/validator-libraries-modern.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index f1f126fa..9bf2dac3 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -453,3 +453,13 @@ last-updated: "2022-08-31" built-on: name: ajv +- name: Github Actions + implementations: + - name: Validate JSON Action + license: MIT + url: 'https://github.com/OrRosenblatt/validate-json-action' + date-draft: [2019-09, 2020-12] + draft: [] + built-on: + name: ajv + last-updated: "2023-02-01" From ec08a95bc8327fa53bd60cc041bd9988b61b9003 Mon Sep 17 00:00:00 2001 From: Matthew Adams Date: Tue, 14 Feb 2023 10:32:37 +0000 Subject: [PATCH 274/311] Added implementation details. --- _data/validator-libraries-modern.yml | 6 ++++++ implementations.md | 2 ++ 2 files changed, 8 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 9bf2dac3..84030d69 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -14,6 +14,12 @@ draft: [7, 6, 4, 3] license: "AGPL-3.0-only" last-updated: "2022-08-31" + - name: Corvus.JsonSchema + url: https://github.com/corvus-dotnet/corvus.jsonschema + date-draft: [2020-12, 2019-09] + draft: [7, 6] + license: Apache License, Version 2.0 + last-updated: "2023-02-14" - name: C notes: No known implementations support draft-06 or later. - name: C++ diff --git a/implementations.md b/implementations.md index e0cc8bce..37bef9a9 100644 --- a/implementations.md +++ b/implementations.md @@ -194,6 +194,8 @@ are the only keywords that changed. #### Code generation +- Dotnet + - [Corvus.JsonSchema](https://www.nuget.org/packages/Corvus.Json.JsonSchema.TypeGeneratorTool/) - generates an idiomatic dotnet type model from JSON Schema files, supporting all JSON Schema features, including property accessors, enumeration, common string `format`, and JSON document building/modification; over low-level `System.Text.Json` types. *supports Draft 6, Draft 7, Draft 2019-09 and Draft 2020-12*. - Elm - [json-schema-to-elm](https://github.com/dragonwasrobot/json-schema-to-elm) - generates Elm types, JSON decoders+encoders, and fuzz tests from one or more JSON Schema files, using [dragonwasrobot/json_schema](https://github.com/dragonwasrobot/json_schema) *supports Draft 7* - Go From 20f6094a35789aca785367882f165219062584c8 Mon Sep 17 00:00:00 2001 From: Benjamin Granados <40007659+benjagm@users.noreply.github.com> Date: Wed, 1 Feb 2023 17:44:14 +0100 Subject: [PATCH 275/311] Update implementations.md --- implementations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implementations.md b/implementations.md index 37bef9a9..3a210100 100644 --- a/implementations.md +++ b/implementations.md @@ -162,6 +162,8 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - [scala-jsonschema](https://github.com/andyglow/scala-jsonschema) (Apache 2.0) - generates schemad out of Scala case classes - Ruby - [Shale](https://github.com/kgiszczak/shale) (MIT) - generates schema from Ruby models *supports Draft 2020-12* +- Rust + - [Schemars](https://github.com/GREsau/schemars) (MIT) - generates schema from Rust code *supports Draft 7* #### From data From f627c7f0a189f03ef9b0d0a48cd7087eb98ef36a Mon Sep 17 00:00:00 2001 From: Benjamin Granados <40007659+benjagm@users.noreply.github.com> Date: Wed, 1 Feb 2023 17:50:30 +0100 Subject: [PATCH 276/311] Update implementations.md Added OpenAPI2JSON schema converter --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index 3a210100..22de12f0 100644 --- a/implementations.md +++ b/implementations.md @@ -290,6 +290,7 @@ the utility, and decided on a case-by-case basis. - OpenAPI - [JSON Schema to OpenAPI Schema](https://github.com/wework/json-schema-to-openapi-schema) _draft-04_ Draft-06 and -07 planned per README (MIT) + - [OpenAPI specification to JSON Schema](https://github.com/instrumenta/openapi2jsonschema) Draft-07 (MIT) - Orderly - [Orderly](https://github.com/lloyd/orderly) (BSD-3-Clause) - RAML From 4b70748708c463a0169f3c91ef067d3652c0d7e4 Mon Sep 17 00:00:00 2001 From: Nicolas Le Cam Date: Tue, 28 Feb 2023 11:07:53 +0100 Subject: [PATCH 277/311] Update @cfworker/json-schema info --- _data/validator-libraries-modern.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 84030d69..4b76ded6 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -194,10 +194,10 @@ anchor-name: cfworker url: https://github.com/cfworker/cfworker/blob/master/packages/json-schema/README.md notes: "Built for Cloudflare workers, browsers, and Node.js" - date-draft: [2019-09] - draft: [7, 6, 4] + date-draft: [2019-09, 2020-12] + draft: [7, 4] license: MIT - last-updated: "2022-08-31" + last-updated: "2023-02-28" - name: JSON Schema Library url: https://github.com/sagold/json-schema-library notes: "Built for Node.js and browsers. Customizable json-validator and json-schema utilities for traversal, data generation and validation" From cc0706ef3f7fcfbe9f66c09078ae1f63d62ca424 Mon Sep 17 00:00:00 2001 From: Benjamin Granados Date: Tue, 7 Mar 2023 10:45:43 +0100 Subject: [PATCH 278/311] Adding the OpenJS Foundation logo and copyright to JSON Schema site. As per OpenJS Foundation onboarding requirements we need to add the OpenJS Foundation logo and copyright to JSON Schema site. --- _includes/footer.html | 5 ++- assets/main.scss | 7 ++++ assets/openjs_foundation-logo.svg | 67 +++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 assets/openjs_foundation-logo.svg diff --git a/_includes/footer.html b/_includes/footer.html index 6f99d796..d3537f08 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -19,7 +19,10 @@ diff --git a/assets/main.scss b/assets/main.scss index 9e965232..23875e58 100644 --- a/assets/main.scss +++ b/assets/main.scss @@ -176,4 +176,11 @@ $content-width: 960px !default; .wrapper.buttons { margin-bottom: 10px; +} + +.custom-logo-link { + /* display: inline-block; */ + max-height: 40px; + padding-bottom: 0.7em; + /* width: auto; */ } \ No newline at end of file diff --git a/assets/openjs_foundation-logo.svg b/assets/openjs_foundation-logo.svg new file mode 100644 index 00000000..fa063e7c --- /dev/null +++ b/assets/openjs_foundation-logo.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 3b773016a739ff11662c92891bc6304ac0182993 Mon Sep 17 00:00:00 2001 From: Benjamin Granados Date: Tue, 7 Mar 2023 11:07:33 +0100 Subject: [PATCH 279/311] Adding the OpenJS Foundation trademarks content. Adding the OpenJS Foundation trademarks content. --- _includes/footer.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/_includes/footer.html b/_includes/footer.html index d3537f08..95b34378 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -21,11 +21,16 @@ - + From 4195b02d3243cd8ad47208ffea50a91fe58ac95a Mon Sep 17 00:00:00 2001 From: Benjamin Granados Date: Tue, 7 Mar 2023 18:45:07 +0100 Subject: [PATCH 280/311] Included @jviotti Reference docs https://www.learnjsonschema.com/ Included @jviotti Reference docs https://www.learnjsonschema.com/ --- learn/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/learn/index.md b/learn/index.md index 37c3a883..d9b9f3b4 100644 --- a/learn/index.md +++ b/learn/index.md @@ -12,4 +12,5 @@ title: Learn * [card.schema.json](./examples/card.schema.json) * [geographical-location.schema.json](./examples/geographical-location.schema.json) * [Understanding JSON Schema](/understanding-json-schema/) +* [JSON Schema reference focumentation](https://www.learnjsonschema.com/) * [JSON Schema Glossary](./glossary.md) which attempts to explain conversational terminology From 706d7fade01431b740ab7de07d6394cbe991ecfe Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Wed, 8 Mar 2023 10:47:10 +0000 Subject: [PATCH 281/311] Fix typo Co-authored-by: Jason Desrosiers --- learn/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learn/index.md b/learn/index.md index d9b9f3b4..f94aaff2 100644 --- a/learn/index.md +++ b/learn/index.md @@ -12,5 +12,5 @@ title: Learn * [card.schema.json](./examples/card.schema.json) * [geographical-location.schema.json](./examples/geographical-location.schema.json) * [Understanding JSON Schema](/understanding-json-schema/) -* [JSON Schema reference focumentation](https://www.learnjsonschema.com/) +* [JSON Schema reference documentation](https://www.learnjsonschema.com/) * [JSON Schema Glossary](./glossary.md) which attempts to explain conversational terminology From cb53c1dbcaa9fb25dc9cf010c23d7100a8e30ce9 Mon Sep 17 00:00:00 2001 From: Benjamin Granados Date: Fri, 10 Mar 2023 15:14:37 +0100 Subject: [PATCH 282/311] Removing any reference to years in the OpenJS section Removing any reference to years in the OpenJS section --- _includes/footer.html | 1 - 1 file changed, 1 deletion(-) diff --git a/_includes/footer.html b/_includes/footer.html index 95b34378..46fe6fac 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -21,7 +21,6 @@ From 6c84af2059680a65defce977a8b823d210d13fd5 Mon Sep 17 00:00:00 2001 From: Tobias Buschor Date: Thu, 23 Mar 2023 20:21:40 +0100 Subject: [PATCH 283/311] Update validator-libraries-modern.yml --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 4b76ded6..b384a1b5 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -218,6 +218,12 @@ draft: [6] license: MIT last-updated: "2022-08-31" + - name: schema.js + url: https://github.com/nuxodin/schema.js + date-draft: [2020-12] + draft: [] + license: MIT + last-updated: "2023-03-23" - name: Kotlin implementations: - name: Medeia-validator From cf211cfd1061f3624d677035ebfca9554f9e8981 Mon Sep 17 00:00:00 2001 From: Tobias Buschor Date: Tue, 28 Mar 2023 11:09:58 +0200 Subject: [PATCH 284/311] Rename the implementation schema.js to jema.js (#511) * Rename the implementation schema.js to jema.js I have decided to use a more unique name. --- _data/validator-libraries-modern.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index b384a1b5..1844bfaa 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -218,12 +218,12 @@ draft: [6] license: MIT last-updated: "2022-08-31" - - name: schema.js - url: https://github.com/nuxodin/schema.js + - name: jema.js + url: https://github.com/nuxodin/jema.js date-draft: [2020-12] draft: [] license: MIT - last-updated: "2023-03-23" + last-updated: "2023-03-28" - name: Kotlin implementations: - name: Medeia-validator From 1a696c37375b658a5187cf195d62968dac772f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kl=C3=ADmek?= Date: Tue, 28 Mar 2023 12:19:32 +0200 Subject: [PATCH 285/311] Add Dataspecer to implementations (#509) --- implementations.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/implementations.md b/implementations.md index 22de12f0..cb578e54 100644 --- a/implementations.md +++ b/implementations.md @@ -179,6 +179,10 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - [Liquid Online Tools](https://www.liquid-technologies.com/online-json-to-schema-converter) - infer JSON Schema from sample JSON data - [quicktype.io](https://app.quicktype.io/#l=schema) - infer JSON Schema from samples, and generate TypeScript, C++, go, Java, C#, Swift, etc. types from JSON Schema +#### From model + +- [Dataspecer](https://dataspecer.com) - Generates JSON Schema (and JSON-LD context) from conceptual model *supports Draft 2020-12* + Generators from schemas ----------------------- From dbe7f658b6086e39cec91ff331c7cf39244ee425 Mon Sep 17 00:00:00 2001 From: Alexander Tikhonov Date: Tue, 11 Apr 2023 14:18:47 +0300 Subject: [PATCH 286/311] Add mashumaro to implementations (#514) --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index cb578e54..5810819a 100644 --- a/implementations.md +++ b/implementations.md @@ -156,6 +156,7 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - Python - [Pydantic](https://pydantic-docs.helpmanual.io/) (MIT) - generates schemas from Python models based on Python 3.6+ type hints. - [msgspec](https://jcristharif.com/msgspec/) (BSD-3-Clause) - generates schemas from Python type annotations. + - [mashumaro](https://github.com/Fatal1ty/mashumaro) (Apache 2.0) - generates schemas from Python type annotations - Java - [jsonschema-generator](https://github.com/victools/jsonschema-generator) (Apache 2.0) - generates schemas from Java types *supports Draft 7 and Draft 2019-09* - Scala From a7ba6527cef06c605d6bae1fdd44057bf25de173 Mon Sep 17 00:00:00 2001 From: Bence Eros Date: Tue, 11 Apr 2023 13:22:04 +0200 Subject: [PATCH 287/311] adds erosb/json-sKema (#515) --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 1844bfaa..ce5a3c4e 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -151,6 +151,12 @@ docs: https://github.com/networknt/json-schema-validator/blob/master/doc/config.md instructions: "set `handleNullableField` to `false`" last-updated: "2022-08-31" + - name: erosb/json-sKema + url: https://github.com/erosb/json-sKema + notes: Successor of the everit-org/json-schema library + date-draft: [2020-12] + license: MIT + last-updated: "2023-04-10" - name: Snow url: https://github.com/ssilverman/snowy-json notes: Uses Maven for the project and Gson under the hood. From 850c0c84c942d77a0ae957fe9dd4c583b05c3c86 Mon Sep 17 00:00:00 2001 From: Isaac Yonemoto Date: Tue, 4 Apr 2023 15:23:54 -0500 Subject: [PATCH 288/311] Update validator-libraries-modern.yml --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index ce5a3c4e..79f1b4ea 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -88,6 +88,12 @@ last-updated: "2022-08-31" - name: Elixir implementations: + - name: Exonerate + url: https://hexdocs.pm/exonerate/Exonerate.html + date-draft: [2020-12, 2019-09] + draft: [7, 6, 4] + license: MIT + last-updated: "2023-04-04" - name: JsonXema url: https://github.com/hrzndhrn/json_xema date-draft: [] From d7c7f15d7d71146c190ea58450f9690696e39421 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Mon, 17 Apr 2023 12:31:59 +0100 Subject: [PATCH 289/311] Update slack invite link Previous one expired, so new slack invite link! The link doesn't have an expiery date, but sometimes expires after some number of uses... number unknown or not documented by Slack as far as I can tell. --- slack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slack.md b/slack.md index 18113d47..0f8bb1cf 100644 --- a/slack.md +++ b/slack.md @@ -1,3 +1,3 @@ --- -redirect_to: https://join.slack.com/t/json-schema/shared_invite/zt-15ylccbuu-3T2bRia8uzhE157TSW6nXg +redirect_to: https://join.slack.com/t/json-schema/shared_invite/zt-1tc77c02b-z~UiKXqpM2gHchClKbUoXw --- From 76fa30ec186a89665f91247a1d9596ca1d3129c1 Mon Sep 17 00:00:00 2001 From: Chaitanya Chandurkar Date: Thu, 13 Apr 2023 03:01:47 -0400 Subject: [PATCH 290/311] Add json-schema-to-case-class to implementations --- implementations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implementations.md b/implementations.md index 5810819a..e5979b87 100644 --- a/implementations.md +++ b/implementations.md @@ -223,6 +223,8 @@ are the only keywords that changed. - [statham](https://github.com/jacksmith15/statham-schema) (MIT) - generate type-annotated models from JSON Schema documents. - Rust - [schemafy](https://github.com/Marwes/schemafy/) - generates Rust types and serialization code from a JSON schema. *supports Draft 4* +- Scala + - [json-schema-to-case-class](https://github.com/cchandurkar/json-schema-to-case-class#readme) (MIT) - NPM Package, [Web UI](https://cchandurkar.github.io/json-schema-to-case-class) and a CLI to generate Scala case classes from JSON Schema. *Supports JSON Schema 2019-09, draft-07, -06, -04, -03* - TypeScript - [jsongenerator](https://github.com/jimblackler/jsonschematypes/tree/master/codegen) *JSON Schema 2019-09, draft-07, -06, -04, -03* (Apache-2.0) - Ruby From 2f96bcc762fce95430f6364df17196df3cbe9755 Mon Sep 17 00:00:00 2001 From: Chaitanya Chandurkar Date: Thu, 13 Apr 2023 03:05:21 -0400 Subject: [PATCH 291/311] Link to main repo --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index e5979b87..24cd8fff 100644 --- a/implementations.md +++ b/implementations.md @@ -224,7 +224,7 @@ are the only keywords that changed. - Rust - [schemafy](https://github.com/Marwes/schemafy/) - generates Rust types and serialization code from a JSON schema. *supports Draft 4* - Scala - - [json-schema-to-case-class](https://github.com/cchandurkar/json-schema-to-case-class#readme) (MIT) - NPM Package, [Web UI](https://cchandurkar.github.io/json-schema-to-case-class) and a CLI to generate Scala case classes from JSON Schema. *Supports JSON Schema 2019-09, draft-07, -06, -04, -03* + - [json-schema-to-case-class](https://github.com/cchandurkar/json-schema-to-case-class) (MIT) - NPM Package, [Web UI](https://cchandurkar.github.io/json-schema-to-case-class) and a CLI to generate Scala case classes from JSON Schema. *Supports JSON Schema 2019-09, draft-07, -06, -04, -03* - TypeScript - [jsongenerator](https://github.com/jimblackler/jsonschematypes/tree/master/codegen) *JSON Schema 2019-09, draft-07, -06, -04, -03* (Apache-2.0) - Ruby From 2f0a2f8b8304afcc263a242567dc04a2890a195e Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 26 Apr 2023 16:56:50 -0400 Subject: [PATCH 292/311] Slightly loosen the language defining dialects and vocabularies. Even though this isn't fully consistent with the current spec definitions, it matches colloquial uses, and perhaps plans for future changes to these two concepts, without sacrificing accuracy today. --- learn/glossary.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/learn/glossary.md b/learn/glossary.md index 1fd68007..325cd5a9 100644 --- a/learn/glossary.md +++ b/learn/glossary.md @@ -16,12 +16,15 @@ The entries on this page can be linked to via anchor links (e.g. `https://json-s ### dialect -A collection of [vocabularies](#vocabulary), along with an indication of whether supporting each vocabulary is required to process schemas written in the dialect. +A cohesive collection of [keywords](#keyword) available for use within a schema, often representing a use-case specific single release of the JSON Schema specification. -Dialects are identified by a URI, which [schemas](#schema) may then reference in their `$schema` [keyword](#keyword). +Dialects, particularly the 2019-09 and 2020-12 dialects, are often defined via a collection of [vocabularies](#vocabulary). + +Each dialect is identified by a URI, its *dialect identifier*, which [schemas](#schema) may then reference in their `$schema` [keyword](#keyword). Doing so identifies the schema as being written in the dialect, and thereby indicates which keywords are usable within it, along with their intended meaning. -The JSON Schema specification [defines](https://json-schema.org/specification.html#general-purpose-meta-schema) a number of dialects, each of which enable vocabularies suitable for the dialect's specific use case. +The JSON Schema specification defines a number of dialects, each of which enable vocabularies suitable for the dialect's specific use case. +These vocabularies are [described](https://json-schema.org/specification.html#general-purpose-meta-schema) in meta-schemas. ### draft @@ -82,7 +85,7 @@ In recent [drafts](#draft) of the specification, a schema is either a JSON objec ### vocabulary -A collection of related [keywords](keyword), grouped to facilitate re-use. +A tightly related collection of [keywords](keyword), grouped to facilitate re-use. A vocabulary is specified by a prose document or specification which explains the semantics of its keywords in a way suitable for implementers and users of the vocabulary. It often also includes a [meta-schema](#meta-schema) (or multiple metaschemas) which define the syntax of its keywords. @@ -90,7 +93,7 @@ It often also includes a [meta-schema](#meta-schema) (or multiple metaschemas) w Anyone can create and publish a vocabulary, and implementations generally will include facilities for extending themselves with support for additional vocabularies and their keywords. The JSON Schema specification includes a number of vocabularies which cover each of the keywords it defines. -Vocabularies are identified by a URI which may be referenced via the `$vocabulary` keyword in order to enable the vocabulary within a [dialect](#dialect). +In some [dialects](#dialect) of JSON Schema, the `$vocabulary` keyword can be used to include the keywords defined by a vocabulary into the dialect, as well as to indicate whether implementations must specifically recognize the vocabulary in order to be able to process schemas written in the dialect or not. #### See also From 7e4de361720ace9a4d2ac18fabc549dd7e9dac2b Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 27 Apr 2023 11:14:50 -0400 Subject: [PATCH 293/311] Add a glossary entry for subschema. --- learn/glossary.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/learn/glossary.md b/learn/glossary.md index 325cd5a9..15f8a9d6 100644 --- a/learn/glossary.md +++ b/learn/glossary.md @@ -83,6 +83,24 @@ Strictly speaking, according to the specification, schemas are themselves JSON d In recent [drafts](#draft) of the specification, a schema is either a JSON object or a JSON boolean value. +### subschema + +A [schema](#schema) which is itself contained within a surrounding parent schema. +Like schemas themselves, in recent [drafts](#draft) of JSON Schema, subschemas are either JSON objects or JSON boolean values. + +Within the JSON Schema specification and its [dialects](#dialect), a number of [keywords](#keyword) take subschemas as part of their values. +For example, the `not` keyword takes a subschema value and inverts its result, succeeding whenever the subschema does not succeed, such that the [instance](#instance) `12` is invalid under `{"type": "string"}` but valid under `{"not": {"type": "string"}}`, where `{"type": "string"}` is a subschema contained in the full schema. + +Some subschemas may appear in more complex nested locations within a parent schema. +The `allOf` keyword, for instance, takes an array of multiple subschemas and succeeds whenever all of the subschemas do individually. + +Whether something that otherwise *appears* to be a schema (based on its contents) actually *is* a subschema can be misleading at first glance without context or knowlege about its location within the parent schema. +Specifically, in our above example, `{"type": "string"}` was a subschema of a larger schema, but in the schema `{"const": {"type": "string"}}`, it is *not* a subschema. +Even though as a value it looks the same, the `const` keyword, which compares instances against a specific expected value, does *not* take a subschema as its value, its value is an opaque value with no particular meaning (such that in this schema, the number 12 would be invalid, but the precise instance `{"type": "string"}` is valid). +Said more plainly, whether a particular value is a subschema or not depends on its precise location within a parent schema, as interpretation of the value depends on the defined behavior of the keyword(s) it lives under. + +Subschemas may themselves contain sub-subschemas, though colloquially one generally uses the term "subschema" regardless of the level of nesting, further clarifying which larger schema is the parent schema whenever needed. + ### vocabulary A tightly related collection of [keywords](keyword), grouped to facilitate re-use. From 21276dc13d350817cc6584a9f497647f006ebc83 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 2 May 2023 13:47:45 -0400 Subject: [PATCH 294/311] Add a glossary entry for JSON. --- learn/glossary.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/learn/glossary.md b/learn/glossary.md index 15f8a9d6..08a9681a 100644 --- a/learn/glossary.md +++ b/learn/glossary.md @@ -36,6 +36,18 @@ While future drafts may introduce new behavior or changes to existing behavior, The current list of drafts can be found [here](https://json-schema.org/specification-links.html#published-drafts). +### JSON + +A pervasive data interchange format used for representing and transmitting data as human readable text. +JSON is extremely widely used, and parsers which can read and write it exist for essentially every commonly-used programming language. + +JSON Schema, distinctly, is built *on top* of JSON, in that JSON [schemas](#schema) are themselves JSON objects which describe other JSON objects. +The two are, however, entirely different pieces of the conceptual puzzle, with JSON being a concrete format for *representing* data and JSON Schema being a way to *schematize* data which is written in the JSON format. + +The JSON format is an open format, with its own [homepage](https://www.json.org/), and specifications published in the [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf) and [RFC-8259](https://datatracker.ietf.org/doc/html/rfc8259) documents from ECMA and the IETF respectively. +In particular, it is not managed or developed by the JSON Schema team, who simply make use of the format. + + ### keyword A property appearing within a [schema](#schema) object. @@ -79,14 +91,14 @@ A document, written according to the proscribed structure of the JSON Schema spe The rules constituting which schemas are conformant, as well as the rules governing their behavior when validating instances, are defined by the [JSON Schema specification](https://json-schema.org/specification.html). -Strictly speaking, according to the specification, schemas are themselves JSON documents, though it is somewhat common for them to be authored or maintained in other languages which are easily translated to JSON, such as YAML. +Strictly speaking, according to the specification, schemas are themselves [JSON documents](#JSON), though it is somewhat common for them to be authored or maintained in other languages which are easily translated to JSON, such as YAML. In recent [drafts](#draft) of the specification, a schema is either a JSON object or a JSON boolean value. ### subschema A [schema](#schema) which is itself contained within a surrounding parent schema. -Like schemas themselves, in recent [drafts](#draft) of JSON Schema, subschemas are either JSON objects or JSON boolean values. +Like schemas themselves, in recent [drafts](#draft) of JSON Schema, subschemas are either [JSON](#JSON) objects or JSON boolean values. Within the JSON Schema specification and its [dialects](#dialect), a number of [keywords](#keyword) take subschemas as part of their values. For example, the `not` keyword takes a subschema value and inverts its result, succeeding whenever the subschema does not succeed, such that the [instance](#instance) `12` is invalid under `{"type": "string"}` but valid under `{"not": {"type": "string"}}`, where `{"type": "string"}` is a subschema contained in the full schema. From c0b1495a94c2834ee7f0e2a9aa5d3b173c7ad57f Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 4 May 2023 10:31:58 -0400 Subject: [PATCH 295/311] Apply suggestions from CR Co-authored-by: Jason Desrosiers --- learn/glossary.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/learn/glossary.md b/learn/glossary.md index 08a9681a..8328a958 100644 --- a/learn/glossary.md +++ b/learn/glossary.md @@ -41,8 +41,8 @@ The current list of drafts can be found [here](https://json-schema.org/specifica A pervasive data interchange format used for representing and transmitting data as human readable text. JSON is extremely widely used, and parsers which can read and write it exist for essentially every commonly-used programming language. -JSON Schema, distinctly, is built *on top* of JSON, in that JSON [schemas](#schema) are themselves JSON objects which describe other JSON objects. -The two are, however, entirely different pieces of the conceptual puzzle, with JSON being a concrete format for *representing* data and JSON Schema being a way to *schematize* data which is written in the JSON format. +JSON Schema, distinctly, is built *on top* of JSON, in that JSON [schemas](#schema) are themselves JSON objects which describe JSON values. +The two are, however, entirely different pieces of the conceptual puzzle, with JSON being a concrete format for *representing* data, and JSON Schema being a way to *schematize* data which is written in a JSON-compatible format. The JSON format is an open format, with its own [homepage](https://www.json.org/), and specifications published in the [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf) and [RFC-8259](https://datatracker.ietf.org/doc/html/rfc8259) documents from ECMA and the IETF respectively. In particular, it is not managed or developed by the JSON Schema team, who simply make use of the format. From 805bec0239cc5c7153e1d3dba83e7506dadf559f Mon Sep 17 00:00:00 2001 From: slisaasquatch Date: Mon, 24 Apr 2023 11:41:46 -0700 Subject: [PATCH 296/311] Update saasquatch/json-schema-inferrer --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 24cd8fff..f5054ae1 100644 --- a/implementations.md +++ b/implementations.md @@ -169,7 +169,7 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e #### From data - Java - - [saasquatch/json-schema-inferrer](https://github.com/saasquatch/json-schema-inferrer) _draft-07, -06, -04_ (Apache 2.0) - Java library for inferring JSON Schemas from one or multiple JSON samples. + - [saasquatch/json-schema-inferrer](https://github.com/saasquatch/json-schema-inferrer) _2020-12, 2019-09, draft-07, draft-06, draft-04_ (Apache 2.0) - Java library for inferring JSON Schemas from one or multiple JSON samples. - Scala - [Schema Guru](https://github.com/snowplow/schema-guru) (Apache 2.0) - CLI util, Spark Job and Web UI for deriving JSON Schemas out of corpus of JSON instances; see issue [178](https://github.com/snowplow/schema-guru/issues/178) for progress towards draft-06+ support - [JSONoid](https://github.com/michaelmior/jsonoid-discovery/) (MIT) - command line tool and Spark application for inferring schemas from JSON documents, supports draft 2019-09 From 6901d61c0ff8db1568e4db1da4be4417e340e5c3 Mon Sep 17 00:00:00 2001 From: Jason Desrosiers Date: Sun, 18 Jun 2023 17:18:19 -0700 Subject: [PATCH 297/311] Remove 2019-09,2020-12 support from networknt --- _data/validator-libraries-modern.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 79f1b4ea..7327709a 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -149,7 +149,7 @@ - name: networknt/json-schema-validator url: https://github.com/networknt/json-schema-validator notes: Support OpenAPI 3.0 with Jackson parser - date-draft: [2020-12, 2019-09] + date-draft: [] draft: [7, 6, 4] license: Apache License 2.0 compliance: From 65556f7a16c9a888898ebb37a62bf19280d6f2a2 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Tue, 11 Jul 2023 11:46:13 +0100 Subject: [PATCH 298/311] Update slack link Fixes https://github.com/json-schema-org/blog/issues/34 Should not expire. Is limited to 400 uses per slack requirements. --- slack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slack.md b/slack.md index 0f8bb1cf..cc97f5ed 100644 --- a/slack.md +++ b/slack.md @@ -1,3 +1,3 @@ --- -redirect_to: https://join.slack.com/t/json-schema/shared_invite/zt-1tc77c02b-z~UiKXqpM2gHchClKbUoXw +redirect_to: https://join.slack.com/t/json-schema/shared_invite/zt-1ywpdj4yd-bXiBLjYEbKWUjzon0qiY9Q --- From a086d976948e5bc6aee326dd892ddcaa58be313c Mon Sep 17 00:00:00 2001 From: Clemens Uhlenhut Date: Fri, 30 Jun 2023 12:55:17 +0200 Subject: [PATCH 299/311] Update implementations.md Added information about JSON Schema testing tool. --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index f5054ae1..66d5ad7c 100644 --- a/implementations.md +++ b/implementations.md @@ -319,7 +319,7 @@ the utility, and decided on a case-by-case basis. - [Altova XMLSpy 2019r3](https://www.altova.com/xmlspy-xml-editor#json_schema) - *Graphical JSON Schema editor for draft-06 and draft-7, as well as validation of JSON files based on JSON Schema* - [Dashjoin JSON Schema editor](https://dashjoin.github.io/#/schema) - *Graphical online JSON Schema editor for draft-06 (minus oneOf, anyOf, allOf, not). The generated schema can be tested immediately via a form that is driven by it.* - [Hackolade Studio](https://hackolade.com/help/JSONSchemaEditor.html) - *Visual JSON Schema editor for draft-04, draft-06, draft-07, 2019-09, 2020-12, as well as data modeling tool for NoSQL databases, storage formats, REST APIs, and JSON in RDBMS. Also converts to and from: different draft specifications, DDL, XSD, Swagger, OpenAPI, YAML, Avro, Parquet, Protobuf, and most of the NoSQL script syntaxes. Includes a GUI for Entity-Relationship Diagrams and a Command-Line Interface.* -- [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator. Complete JSON Schema development environment with JSON Schema analyzer, context sensitive entry-helpers, sample data generation based on JSON Schema and JSON Schema validation debugger: Step through the validation process and set breakpoints. Support for draft-4, draft-6, draft-7, 2019-09 and 2020-12.* +- [JSONBuddy](https://www.json-buddy.com/) - *Text and grid-style JSON editor and validator. Complete JSON Schema development environment with JSON Schema analyzer, context sensitive entry-helpers, sample data generation based on JSON Schema and JSON Schema validation debugger: Step through the validation process and set breakpoints. JSON Schema testing tool including schema coverage. Support for draft-4, draft-6, draft-7, 2019-09 and 2020-12.* - [JSONEditor Online](https://jsoneditoronline.org/) - *View, edit, format, and validate JSON online* Support draft-4, draft-6, and draft-7. - [Liquid JSON Schema Editor](https://www.liquid-technologies.com/json-schema-editor) - *Graphical JSON Schema editor for draft-04, draft-06, draft-07 and 2019-09, with split source code and grphical editing. Includes validation of JSON files based on JSON Schema, JSON Sample Generator and JSON Schema Documentation Generator.* - [Oxygen JSON Schema Editor](https://www.oxygenxml.com/xml_developer/json_schema_editor.html) - *JSON Schema editor with a variety of editing features and helper views (Design/Text/Author). Support for validation and editing JSON Schema draft-4, draft-6, and draft-7, 2019-09 (partial), 2020-12 (partial). Validation and editing of JSON files based on JSON Schema.* From fb3b1e681e273738f38cb1438b0635b6d4ad5383 Mon Sep 17 00:00:00 2001 From: Harrel Date: Thu, 29 Jun 2023 22:04:21 +0200 Subject: [PATCH 300/311] add dev.harrel:json-schema implementation --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 7327709a..45401832 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -182,6 +182,12 @@ draft: [7, 6, 4] license: Apache License 2.0 last-updated: "2022-08-31" + - name: json-schema (dev.harrel) + url: https://github.com/harrel56/json-schema + notes: JSON library agnostic implementation. Supports custom keywords. + date-draft: [ 2020-12 ] + license: MIT + last-updated: "2023-06-29" - name: JavaScript implementations: - name: Hyperjump JSV From afebf6b72b471f754a89a8ab19dbc6676b7adac2 Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Wed, 2 Aug 2023 11:55:01 +0400 Subject: [PATCH 301/311] Add new json-schema-validator library to the list of implementations --- _data/validator-libraries-modern.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 45401832..6abf666e 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -261,6 +261,15 @@ draft: [7] license: MIT last-updated: "2022-08-31" + - name: json-schema-validator + url: https://github.com/OptimumCode/json-schema-validator + notes: | + Kotlin Muliplatform implementation of JSON schema to validate the JsonElement from kotlinx.serialization-json. + The library is 'work in progress' and new features/drafts will be added in the future. + date-draft: [] + draft: [7] + license: MIT + last-updated: "2023-08-01" - name: Perl implementations: - name: JSON::Schema::Modern From 9ac36093083da18743d6b2d98faa94fb9974ef29 Mon Sep 17 00:00:00 2001 From: Nikita Skovoroda Date: Tue, 29 Aug 2023 20:24:03 +0300 Subject: [PATCH 302/311] Add `@exodus/schemasafe` validation library for JavaScript --- _data/validator-libraries-modern.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 6abf666e..40122198 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -197,6 +197,20 @@ draft: [7, 6, 4] license: MIT last-updated: "2022-08-31" + - name: "@exodus/schemasafe" + url: https://github.com/ExodusMovement/schemasafe + notes: | + For Node.js and browsers, with security and speed being the main focus. Pre-compiles schemas to JS functions. + [Supports OpenAPI `discriminator`](https://github.com/ExodusMovement/schemasafe/blob/master/doc/Discriminator-support.md). + Default behavior is hardened with additional schema coherence validation. + date-draft: [2020-12, 2019-09] + draft: [7, 6, 4] + license: MIT + compliance: + config: + docs: https://github.com/ExodusMovement/schemasafe/blob/master/doc/Options.md + instructions: "disable schema coherence checks and `format` assertion by setting option `mode: 'spec'`" + last-updated: "2023-08-29" - name: ajv url: https://github.com/ajv-validator/ajv notes: "for Node.js and browsers - supports [user-defined keywords](https://github.com/ajv-validator/ajv/blob/master/docs/keywords.md) and [$data reference](https://github.com/json-schema-org/json-schema-spec/issues/51)" From 24d63efaa905e96074ddb1c01676068639a282f0 Mon Sep 17 00:00:00 2001 From: Chrusty Date: Thu, 7 Sep 2023 09:51:09 +1200 Subject: [PATCH 303/311] Adding protoc-gen-jsonschema as a code-generator --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index 66d5ad7c..ddb15002 100644 --- a/implementations.md +++ b/implementations.md @@ -207,6 +207,7 @@ are the only keywords that changed. - [json-schema-to-elm](https://github.com/dragonwasrobot/json-schema-to-elm) - generates Elm types, JSON decoders+encoders, and fuzz tests from one or more JSON Schema files, using [dragonwasrobot/json_schema](https://github.com/dragonwasrobot/json_schema) *supports Draft 7* - Go - [go-jsonschema](https://git.sr.ht/~emersion/go-jsonschema) - generates Go types and helpers from JSON schema files *supports Draft 2020-12* + - [protoc-gen-jsonschema](https://github.com/chrusty/protoc-gen-jsonschema) - Generates JSON schemas from protobuf proto v2 and v3 files. - Java - [jsonCodeGen](https://github.com/schlothauer-wauer/jsoncodegen) (MIT) - Groovy based generation tasks from JSON schema. Already includes templates/generators for Java Beans, Swagger specification files and PlantUML diagrams. - [jsonschema2pojo](https://github.com/joelittlejohn/jsonschema2pojo) (Apache 2.0) - generates Java types from JSON Schema (or example JSON) and can annotate those types for data-binding with Jackson 2.x or Gson. *draft-07* From ed82c99e2b68fd92e1e205b50b323efe87e925db Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Wed, 6 Sep 2023 14:16:27 +0200 Subject: [PATCH 304/311] Add drf-jsonschema-serializer schema generator --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index ddb15002..9c44bf9c 100644 --- a/implementations.md +++ b/implementations.md @@ -157,6 +157,7 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - [Pydantic](https://pydantic-docs.helpmanual.io/) (MIT) - generates schemas from Python models based on Python 3.6+ type hints. - [msgspec](https://jcristharif.com/msgspec/) (BSD-3-Clause) - generates schemas from Python type annotations. - [mashumaro](https://github.com/Fatal1ty/mashumaro) (Apache 2.0) - generates schemas from Python type annotations + - [drf-jsonschema-serializer](https://github.com/maykinmedia/drf-jsonschema-serializer) (BSD-3-Clause) - generates schemas from Django Rest Framework serializers - Java - [jsonschema-generator](https://github.com/victools/jsonschema-generator) (Apache 2.0) - generates schemas from Java types *supports Draft 7 and Draft 2019-09* - Scala From cdbcf6919442b218fd6d957746028d6ae1c0c8b3 Mon Sep 17 00:00:00 2001 From: David Harsha Date: Sun, 20 Aug 2023 14:54:22 -0700 Subject: [PATCH 305/311] Add 2020-12/2019-09 support to json_schemer (ruby) Just released version 2.0.0 with support for these drafts: https://github.com/davishmcclurg/json_schemer/pull/135 --- _data/validator-libraries-modern.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 40122198..9b4b6e8e 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -362,10 +362,10 @@ implementations: - name: JSONSchemer url: https://github.com/davishmcclurg/json_schemer - date-draft: [] + date-draft: [2020-12, 2019-09] draft: [7, 6, 4] license: MIT - last-updated: "2022-08-31" + last-updated: "2023-08-20" - name: JSI url: https://rubydoc.info/gems/jsi date-draft: [] From a322db4c7a9ee4f101ed7f270ff5bc9bd2723e7a Mon Sep 17 00:00:00 2001 From: David Harsha Date: Sun, 20 Aug 2023 15:49:25 -0700 Subject: [PATCH 306/311] Improve implementation draft list layout This adds a comma between `draft` and `date-draft` items and checks for `empty` arrays to prevent stray "draft-0" output. --- implementations.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/implementations.md b/implementations.md index 9c44bf9c..c2df42b0 100644 --- a/implementations.md +++ b/implementations.md @@ -50,10 +50,11 @@ Validators {{ implementation.name }}
        • Supports: - {% if implementation.date-draft %} + {% if implementation.date-draft and implementation.date-draft != empty %} {{ implementation.date-draft | sort | reverse | join: ", " }} + {%- if implementation.draft and implementation.draft != empty %}, {% endif %} {% endif %} - {% if implementation.draft %} + {% if implementation.draft and implementation.draft != empty %} draft-0{{ implementation.draft | sort | reverse | join: ", -0" }} {% endif %}
        • From 619d105f900bd078578787d13a043874460e8382 Mon Sep 17 00:00:00 2001 From: Niklas Eldberger Date: Tue, 12 Sep 2023 16:09:06 +0200 Subject: [PATCH 307/311] Add Zuunr JSON, Java validator --- _data/validator-libraries-modern.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_data/validator-libraries-modern.yml b/_data/validator-libraries-modern.yml index 9b4b6e8e..04de6723 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -188,6 +188,12 @@ date-draft: [ 2020-12 ] license: MIT last-updated: "2023-06-29" + - name: Zuunr JSON + url: https://bitbucket.org/zuunr/json + notes: Immutable JSON representation in Java + validation and filtering based on JSON Schema + date-draft: [ 2020-12 ] + license: Apache 2.0 + last-updated: 2023-09-04 - name: JavaScript implementations: - name: Hyperjump JSV From 9e2873d81a3e13eb980e08889c0f31c5ee50dd4d Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Mon, 2 Oct 2023 10:22:14 +0100 Subject: [PATCH 308/311] Delete CNAME Website is now deployed via Cloudflare from new `website` repo for this org. --- CNAME | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 CNAME diff --git a/CNAME b/CNAME deleted file mode 100644 index 0d9c62bd..00000000 --- a/CNAME +++ /dev/null @@ -1,2 +0,0 @@ -json-schema.org - From 1ded71fde5e9773132c1e85c17d3e6e1c0086af7 Mon Sep 17 00:00:00 2001 From: Benjamin Granados <40007659+benjagm@users.noreply.github.com> Date: Wed, 11 Oct 2023 15:51:28 +0200 Subject: [PATCH 309/311] Add deprecation notice Add deprecation notice --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index b1992750..75764538 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ +--- +📌 **Deprecation Notice** 📌 + +This repository is now deprecated. To contribute to JSON Schema's website please use the new repository ➡️ [https://github.com/json-schema-org/website](https://github.com/json-schema-org/website). + +--- + # JSON Schema Website [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://github.com/json-schema-org/.github/blob/main/CODE_OF_CONDUCT.md) From 15701ceb9ad63bdb72e24b826df74899796547ca Mon Sep 17 00:00:00 2001 From: Benjamin Granados <40007659+benjagm@users.noreply.github.com> Date: Mon, 23 Oct 2023 11:02:47 +0200 Subject: [PATCH 310/311] Update README.md to tidy up badges. Tidy up badges. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75764538..96dcb5ef 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This repository is now deprecated. To contribute to JSON Schema's website please # JSON Schema Website [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://github.com/json-schema-org/.github/blob/main/CODE_OF_CONDUCT.md) -[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) +[![Project Status: Moved/Deprecated to https://github.com/json-schema-org/website – The project has been moved to a new location, and the version at that location should be considered authoritative.](https://www.repostatus.org/badges/latest/moved.svg)](https://www.repostatus.org/#moved) to [https://github.com/json-schema-org/website](https://github.com/json-schema-org/websitem) [![Financial Contributors on Open Collective](https://opencollective.com/json-schema/all/badge.svg?label=financial+contributors)](https://opencollective.com/json-schema) This is the repository for the [JSON Schema website](https://json-schema.org). From 91018fefd959caec966910184ef4a5ccb6aae326 Mon Sep 17 00:00:00 2001 From: Benjamin Granados <40007659+benjagm@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:52:34 +0200 Subject: [PATCH 311/311] Update README.md to tidy up badges Update README.md to tidy up badges --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 96dcb5ef..5ee11859 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,9 @@ This repository is now deprecated. To contribute to JSON Schema's website please # JSON Schema Website -[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://github.com/json-schema-org/.github/blob/main/CODE_OF_CONDUCT.md) [![Project Status: Moved/Deprecated to https://github.com/json-schema-org/website – The project has been moved to a new location, and the version at that location should be considered authoritative.](https://www.repostatus.org/badges/latest/moved.svg)](https://www.repostatus.org/#moved) to [https://github.com/json-schema-org/website](https://github.com/json-schema-org/websitem) + +[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://github.com/json-schema-org/.github/blob/main/CODE_OF_CONDUCT.md) [![Financial Contributors on Open Collective](https://opencollective.com/json-schema/all/badge.svg?label=financial+contributors)](https://opencollective.com/json-schema) This is the repository for the [JSON Schema website](https://json-schema.org).