From ebb3e1b6505a1abad4b507868d572b0b0a5f855e Mon Sep 17 00:00:00 2001 From: "Erik P. Hansen" Date: Sat, 18 Aug 2018 10:06:23 -0700 Subject: [PATCH 001/395] Fix formatting of the full fstab schema --- learn/file-system.md | 83 ++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/learn/file-system.md b/learn/file-system.md index 24b77fda..65048d03 100644 --- a/learn/file-system.md +++ b/learn/file-system.md @@ -346,54 +346,53 @@ The resulting schema is quite large: }, "required": [ "type", "device" ], "additionalProperties": false - } - }, - "diskUUID": { - "properties": { - "type": { - "enum": [ "disk" ] - }, - "label": { - "type": "string", - "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - } }, - "required": [ "type", "label" ], - "additionalProperties": false - }, - "nfs": { - "properties": { - "type": { "enum": [ "nfs" ] }, - "remotePath": { - "type": "string", - "pattern": "^(/[^/]+)+$" + "diskUUID": { + "properties": { + "type": { + "enum": [ "disk" ] + }, + "label": { + "type": "string", + "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + } }, - "server": { - "type": "string", - "oneOf": [ - { "format": "hostname" }, - { "format": "ipv4" }, - { "format": "ipv6" } - ] - } + "required": [ "type", "label" ], + "additionalProperties": false }, - "required": [ "type", "server", "remotePath" ], - "additionalProperties": false - }, - "tmpfs": { - "properties": { - "type": { "enum": [ "tmpfs" ] }, - "sizeInMB": { - "type": "integer", - "minimum": 16, - "maximum": 512 - } + "nfs": { + "properties": { + "type": { "enum": [ "nfs" ] }, + "remotePath": { + "type": "string", + "pattern": "^(/[^/]+)+$" + }, + "server": { + "type": "string", + "oneOf": [ + { "format": "hostname" }, + { "format": "ipv4" }, + { "format": "ipv6" } + ] + } + }, + "required": [ "type", "server", "remotePath" ], + "additionalProperties": false }, - "required": [ "type", "sizeInMB" ], - "additionalProperties": false + "tmpfs": { + "properties": { + "type": { "enum": [ "tmpfs" ] }, + "sizeInMB": { + "type": "integer", + "minimum": 16, + "maximum": 512 + } + }, + "required": [ "type", "sizeInMB" ], + "additionalProperties": false + } } } -} ``` ## Referencing the `entry` schema in the `fstab` schema From bd54022939ebe8b7756f85e15fed2ff0828256ec Mon Sep 17 00:00:00 2001 From: Andrew Podkovyrin Date: Fri, 31 Aug 2018 00:42:59 +0300 Subject: [PATCH 002/395] Update validator-libraries-modern.yml --- _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 ecb80991..d347439d 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -88,6 +88,13 @@ notes: draft: [7, 6, 4] license: MIT +- name: Objective-C + implementations: + - name: DSJSONSchemaValidation + url: https://github.com/dashevo/JSONSchemaValidation + notes: + draft: [7, 6, 4] + license: MIT - name: Web (Online) implementations: - name: JSON Schema Validator From ec14bf644f3760ae7496537cd282c1ba5fb98ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirit=20S=C3=A6lensminde?= Date: Mon, 3 Sep 2018 20:16:35 +0700 Subject: [PATCH 003/395] Add f5-json-schema to the implementations list --- _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 d347439d..c0e9cc81 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -16,6 +16,12 @@ 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 + url: https://github.com/KayEss/json-schema + draft: [7] + license: Boost Software License 1.0 - name: Elixir implementations: - name: Elixir JSON Schema validator From f91360753ff09284cc8f0b6e7aadd0f05b1d2865 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Sun, 9 Sep 2018 14:13:09 -0700 Subject: [PATCH 004/395] Add a status update and more about getting to RFC Particularly since two of the four drafts are expired right now, and at the current rate we probably won't quite manage to publish another round before the other two expire, it seems like a good idea to make it very clear that the project is active. That should soon be apparent from PRs, but it's been a bit slow over the summer. --- index.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/index.md b/index.md index bdc2ade0..9583e1cc 100644 --- a/index.md +++ b/index.md @@ -37,7 +37,19 @@ permalink: / ## Project Status -The JSON Schema project intends to shepherd the Core, Validation, and Hyper-Schema specifications 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. +### Update as of 9 September 2018 + +We expect to publish a new round of drafts (Core, Validation, Hyper-Schema, Relative JSON Pointer) before the end of the year. While Hyper-Schema and Relative JSON Pointer are currently expired, they are just as much under active development as Core and Validation (which expire in October). + +There are several major PRs that still need to be written for Core and Hyper-Schema. Major changes generally require a minimum two-week review period. Once all major changes are in-place, there is a four-week final review period before publication. For these reasons, the earliest likely date for the next round of drafts is **November 2018**. + +Progress on the next set of Internet-Drafts can be tracked on GitHub. The [draft-08](https://github.com/json-schema-org/json-schema-spec/milestone/6) milestone will track the evolving scope of the draft (although see [issue #612](https://github.com/json-schema-org/json-schema-spec/issues/612) for a discussion of whether "draft-08" is the right name for this milestone). + +### 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. + +If you have experience with such things and would like to help, please 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/) @@ -49,8 +61,6 @@ Internet-Drafts expire after six months, so our goal is to publish often enough 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. -Progress on the next set of Internet-Drafts can be tracked on GitHub. The [draft-08](https://github.com/json-schema-org/json-schema-spec/milestone/6) milestone will track the evolving scope of the draft - ## Quickstart The JSON document being validated or described we call the *instance*, and the document containing the description is called the *schema*. From 1d9a3afe34525c3b792c0f1366abf914ea2e242a Mon Sep 17 00:00:00 2001 From: Adam Quaile Date: Wed, 26 Sep 2018 10:19:37 +0100 Subject: [PATCH 005/395] Use HTTPS for schema links --- specification.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification.md b/specification.md index 1e1568ab..6f97a600 100644 --- a/specification.md +++ b/specification.md @@ -39,8 +39,8 @@ The meta-schemas are schemas against which other schemas can be validated. They The latest meta-schema is **draft-07**. |--------------------------------------------------------------|------------------------------------------------------------| -| [Core/Validation meta-schema](http://json-schema.org/draft-07/schema) | Used for schemas written for pure validation. | -| [Hyper meta-schema](http://json-schema.org/draft-07/hyper-schema) | Used for schemas written for validation and hyper-linking. | +| [Core/Validation meta-schema](https://json-schema.org/draft-07/schema) | Used for schemas written for pure validation. | +| [Hyper meta-schema](https://json-schema.org/draft-07/hyper-schema) | Used for schemas written for validation and hyper-linking. | _If you are accessing the above meta-schema links **from a web browser**, you will need to **save the file** then open it as a JSON document._ From 03a284a8078140f430da90a2a7f242d8219c28b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Miernik?= Date: Thu, 25 Oct 2018 20:26:54 +0200 Subject: [PATCH 006/395] Added uniforms. --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index 7a1e19dc..f5348508 100644 --- a/implementations.md +++ b/implementations.md @@ -197,6 +197,7 @@ Various levels of support for UI generation primarily from the validation vocabu - [pure-form webcomponent](https://github.com/john-doherty/pure-form) (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) + - [uniforms (Vazco)](https://github.com/vazco/uniforms) (MIT) #### Data from schemas From 673f97b7c93e3029c7f0cc1b3d1dc146d2de6fa5 Mon Sep 17 00:00:00 2001 From: Brendan Quinn Date: Fri, 2 Nov 2018 12:07:38 +0200 Subject: [PATCH 007/395] Update Python jsonschema version support The linked repo says "Full support for Draft 7, Draft 6, Draft 4 and Draft 3" --- _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 c0e9cc81..525bdf31 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -84,8 +84,8 @@ implementations: - name: jsonschema url: https://github.com/Julian/jsonschema - notes: "Draft-06+ progress: issues [337](https://github.com/Julian/jsonschema/issues/337), [400](https://github.com/Julian/jsonschema/issues/400); branches [draft6](https://github.com/Julian/jsonschema/tree/draft6), [draft7](https://github.com/Julian/jsonschema/tree/draft7)" - draft: [4, 3] + notes: + draft: [7, 6, 4, 3] license: "MIT" - name: Ruby implementations: From ee0421b6b8cc6d07b2acea6ab1d1b328b1d7f9b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Jaenisch?= Date: Sun, 4 Nov 2018 22:07:19 +0100 Subject: [PATCH 008/395] Fixed typo While working on my own project (where I want to use JSON-Schema) I stumbled upon this small typo :-) --- learn/getting-started-step-by-step.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learn/getting-started-step-by-step.md b/learn/getting-started-step-by-step.md index 9ef0cf44..94b3a27a 100644 --- a/learn/getting-started-step-by-step.md +++ b/learn/getting-started-step-by-step.md @@ -50,7 +50,7 @@ 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 the a specific draft of the standard and used for a variety of reasons, primarily version control. +* 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. From 2b63e94566c274b5a5f90ca31386bb2793780443 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Mon, 5 Nov 2018 18:08:42 -0800 Subject: [PATCH 009/395] Update on schedules --- index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.md b/index.md index 9583e1cc..387d2262 100644 --- a/index.md +++ b/index.md @@ -37,11 +37,11 @@ permalink: / ## Project Status -### Update as of 9 September 2018 +### Update as of 5 November 2018 -We expect to publish a new round of drafts (Core, Validation, Hyper-Schema, Relative JSON Pointer) before the end of the year. While Hyper-Schema and Relative JSON Pointer are currently expired, they are just as much under active development as Core and Validation (which expire in October). +We expect to publish a new round of drafts (Core, Validation, Hyper-Schema, Relative JSON Pointer) before the end of the year, and are actively working on the last few PRs. While the drafts are currently expired, they are still under active development. This project is staffed by volunteers, and life occasionally disregards IETF expiration schedules. -There are several major PRs that still need to be written for Core and Hyper-Schema. Major changes generally require a minimum two-week review period. Once all major changes are in-place, there is a four-week final review period before publication. For these reasons, the earliest likely date for the next round of drafts is **November 2018**. +Once the major PRs have been written, there will be a four-week final review period before publication. Therefore, the likely publication date will be in **December 2018**. Although the holiday season may delay this until January depending on how much feedback arrives during final review. Progress on the next set of Internet-Drafts can be tracked on GitHub. The [draft-08](https://github.com/json-schema-org/json-schema-spec/milestone/6) milestone will track the evolving scope of the draft (although see [issue #612](https://github.com/json-schema-org/json-schema-spec/issues/612) for a discussion of whether "draft-08" is the right name for this milestone). From 31948a41afcad922d908ff1b62af2215c113ff66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Schweigh=C3=B6fer?= Date: Wed, 21 Nov 2018 10:06:18 +0100 Subject: [PATCH 010/395] Use $id consistently in examples --- learn/examples/geographical-location.schema.json | 2 +- learn/miscellaneous-examples.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/learn/examples/geographical-location.schema.json b/learn/examples/geographical-location.schema.json index 86656397..1e0fc9cf 100644 --- a/learn/examples/geographical-location.schema.json +++ b/learn/examples/geographical-location.schema.json @@ -1,5 +1,5 @@ { - "id": "https://example.com/geographical-location.schema.json", + "$id": "https://example.com/geographical-location.schema.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "Longitude and Latitude Values", "description": "A geographical coordinate.", diff --git a/learn/miscellaneous-examples.md b/learn/miscellaneous-examples.md index 37b0dee4..29bb7747 100644 --- a/learn/miscellaneous-examples.md +++ b/learn/miscellaneous-examples.md @@ -61,7 +61,7 @@ This example introduces: ```json { - "id": "https://example.com/geographical-location.schema.json", + "$id": "https://example.com/geographical-location.schema.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "Longitude and Latitude Values", "description": "A geographical coordinate.", @@ -105,7 +105,7 @@ We also introduce the following with this example: ```json { - "id": "https://example.com/arrays.schema.json", + "$id": "https://example.com/arrays.schema.json", "$schema": "http://json-schema.org/draft-07/schema#", "description": "A representation of a person, company, organization, or place", "type": "object", From 81b8e6753ee16264d76e98587f88b491d70cdb86 Mon Sep 17 00:00:00 2001 From: Jacob Ward Date: Tue, 27 Nov 2018 12:28:42 +0000 Subject: [PATCH 011/395] Fix spelling mistake Resolves #238 --- draft-07/json-schema-release-notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/draft-07/json-schema-release-notes.md b/draft-07/json-schema-release-notes.md index 648341d7..183d42b2 100644 --- a/draft-07/json-schema-release-notes.md +++ b/draft-07/json-schema-release-notes.md @@ -57,7 +57,7 @@ compatibility. ### Classification of Keywords While it does not have a direct impact on the validation process, this set -of drafts classifies kewyords by their behavior. The names of these +of drafts classifies keywords by their behavior. The names of these classifications are used throughout the documents, so they are useful to know: From 9c1f0948af61d3b39e7f5efb20d565f9573a0ed6 Mon Sep 17 00:00:00 2001 From: leadpony Date: Sun, 9 Dec 2018 18:04:51 +0900 Subject: [PATCH 012/395] Add Justify to the validator list --- _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 525bdf31..5a192973 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -52,6 +52,11 @@ notes: draft: [7, 6, 4] license: Apache License 2.0 + - name: Justify + url: https://github.com/leadpony/justify + notes: + draft: [7] + license: Apache License 2.0 - name: JavaScript implementations: - name: ajv From 6df2a636d2a2780daaacf764b08ee2b7c58c0def Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Sun, 16 Dec 2018 15:08:05 -0800 Subject: [PATCH 013/395] Update schedule estimates --- index.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.md b/index.md index 387d2262..f8099799 100644 --- a/index.md +++ b/index.md @@ -37,11 +37,13 @@ permalink: / ## Project Status -### Update as of 5 November 2018 +### Update as of 16 December 2018 -We expect to publish a new round of drafts (Core, Validation, Hyper-Schema, Relative JSON Pointer) before the end of the year, and are actively working on the last few PRs. While the drafts are currently expired, they are still under active development. This project is staffed by volunteers, and life occasionally disregards IETF expiration schedules. +We expect to publish a new round of drafts (Core, Validation, Hyper-Schema, Relative JSON Pointer) in early 2019, and are actively working on the last few PRs. While the drafts are currently expired, they are still under active development. This project is staffed by volunteers, and life occasionally disregards IETF expiration schedules. -Once the major PRs have been written, there will be a four-week final review period before publication. Therefore, the likely publication date will be in **December 2018**. Although the holiday season may delay this until January depending on how much feedback arrives during final review. +The last two major PRs (for modular vocabularies and a standardized output format) are under review and have gotten several rounds of feedback. Once those are complete, there will be a four-week final review period during which we will take feedback on the overall flow and content before publication. Therefore, the likely publication date will be in **January or Feburary 2018**. We had hoped for December but the holiday season and other life events have prevented that. + +This draft has taken more time than expected because it tackles deep, long-term issues that have long been a challenge for JSON Schema. This includes building in a formal extensibility mechanism so that we can more easily draw a line to finalize the contents of the Core and Validation specifications. Progress on the next set of Internet-Drafts can be tracked on GitHub. The [draft-08](https://github.com/json-schema-org/json-schema-spec/milestone/6) milestone will track the evolving scope of the draft (although see [issue #612](https://github.com/json-schema-org/json-schema-spec/issues/612) for a discussion of whether "draft-08" is the right name for this milestone). From 0c18461d2485257babd5a544ef452ee5d5f33ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sat, 22 Dec 2018 19:30:24 +0400 Subject: [PATCH 014/395] Add FastAPI and Pydantic to JSON Schema implementations --- implementations.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/implementations.md b/implementations.md index f5348508..be79af3c 100644 --- a/implementations.md +++ b/implementations.md @@ -116,6 +116,9 @@ 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) +- Python + - [FastAPI](https://github.com/tiangolo/fastapi) is an API framework based on Python 3.6+ types that generates **OpenAPI 3** schemas, including **JSON Schemas** for all the models declared. + #### Link Description Object utilities - JavaScript @@ -144,6 +147,8 @@ For example, the only incompatibilities between draft-04 and draft-06 involve `e - [Liform](https://github.com/Limenius/liform) (MIT) - generates schemas from Symfony forms - TypeScript - [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. #### From data From fd83d5395e15ed597986936d23df425f3d0d8da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sat, 22 Dec 2018 19:32:44 +0400 Subject: [PATCH 015/395] Add license note to FastAPI --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index be79af3c..0984e27b 100644 --- a/implementations.md +++ b/implementations.md @@ -117,7 +117,7 @@ Hyper-Schema - [@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) - Python - - [FastAPI](https://github.com/tiangolo/fastapi) is an API framework based on Python 3.6+ types that generates **OpenAPI 3** schemas, including **JSON Schemas** for all the models declared. + - [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. #### Link Description Object utilities From d825e3a09103e4e65f5ed1f22589c24e6a42de99 Mon Sep 17 00:00:00 2001 From: Patrick Boettcher Date: Thu, 27 Dec 2018 18:31:34 +0100 Subject: [PATCH 016/395] Add JSON schema validator for JSON for Modern C++ --- _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 5a192973..ba088c26 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -22,6 +22,10 @@ url: https://github.com/KayEss/json-schema 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 + draft: [7] + license: MIT - name: Elixir implementations: - name: Elixir JSON Schema validator From e63a2408195fa4e5ba00c817273b717b452dcc4b Mon Sep 17 00:00:00 2001 From: Illia Grybkov Date: Sat, 29 Dec 2018 12:58:17 +0200 Subject: [PATCH 017/395] Fix year typo on the index page --- index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.md b/index.md index f8099799..fe928df4 100644 --- a/index.md +++ b/index.md @@ -41,7 +41,7 @@ permalink: / We expect to publish a new round of drafts (Core, Validation, Hyper-Schema, Relative JSON Pointer) in early 2019, and are actively working on the last few PRs. While the drafts are currently expired, they are still under active development. This project is staffed by volunteers, and life occasionally disregards IETF expiration schedules. -The last two major PRs (for modular vocabularies and a standardized output format) are under review and have gotten several rounds of feedback. Once those are complete, there will be a four-week final review period during which we will take feedback on the overall flow and content before publication. Therefore, the likely publication date will be in **January or Feburary 2018**. We had hoped for December but the holiday season and other life events have prevented that. +The last two major PRs (for modular vocabularies and a standardized output format) are under review and have gotten several rounds of feedback. Once those are complete, there will be a four-week final review period during which we will take feedback on the overall flow and content before publication. Therefore, the likely publication date will be in **January or Feburary 2019**. We had hoped for December but the holiday season and other life events have prevented that. This draft has taken more time than expected because it tackles deep, long-term issues that have long been a challenge for JSON Schema. This includes building in a formal extensibility mechanism so that we can more easily draw a line to finalize the contents of the Core and Validation specifications. From 9a7870340b386b8a2c0209c783b29d33db47ed90 Mon Sep 17 00:00:00 2001 From: Andreas Ulmer Date: Mon, 7 Jan 2019 17:51:06 +0100 Subject: [PATCH 018/395] Fixes `comment` url to link to rfc section 9 --- draft-07/json-schema-release-notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/draft-07/json-schema-release-notes.md b/draft-07/json-schema-release-notes.md index 183d42b2..99cee747 100644 --- a/draft-07/json-schema-release-notes.md +++ b/draft-07/json-schema-release-notes.md @@ -23,7 +23,7 @@ more clearly than before. keyword | change | notes ---- | ---- | ---- -[`"$comment"`](json-schema-core.html#rfc.section.10) | added to Core | Intended for notes to schema maintainers, as opposed to [`"description"`](json-schema-validation.html#rfc.section.10.1) which is suitable for display to end users +[`"$comment"`](json-schema-core.html#rfc.section.9) | added to Core | Intended for notes to schema maintainers, as opposed to [`"description"`](json-schema-validation.html#rfc.section.10.1) which is suitable for display to end users [`"if"`, `"then"`, `"else"`](json-schema-validation.html#rfc.section.6.6) | added to Validation | explicit conditional schema evaluation [`"readOnly"`](json-schema-validation.html#rfc.section.10.3) | moved from Hyper-Schema to Validation | not limited to hypermedia environments [`"writeOnly"`](json-schema-validation.html#rfc.section.10.3) | added to Validation | general write-only fields, including but not limited to passwords From e12c9139c040838f9fb096d7977abd97bf782538 Mon Sep 17 00:00:00 2001 From: rider85 Date: Fri, 18 Jan 2019 01:28:25 +0300 Subject: [PATCH 019/395] Added link to JSON Schema editor. --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index 0984e27b..b018a8ba 100644 --- a/implementations.md +++ b/implementations.md @@ -264,6 +264,7 @@ _TODO: Sort by draft support._ - [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 files using JSON Schema* +- [JsonDraft](https://jsondraft.com/) - *Tree view JSON and JSON Schema editor online. Create and Save reusable components, Share JSON.* Schema Repositories From ffce7a341a6787ffd6337dcbab875f587ff389e8 Mon Sep 17 00:00:00 2001 From: Henrik Mohr Date: Mon, 18 Feb 2019 13:13:59 +0100 Subject: [PATCH 020/395] 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 5a192973..1b2b36ad 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -22,6 +22,12 @@ url: https://github.com/KayEss/json-schema draft: [7] license: Boost Software License 1.0 +- name: Clojure + implementations: + - name: json-schema + url: https://github.com/luposlip/json-schema + draft: [7] + license: Eclipse Public License 2.0 - name: Elixir implementations: - name: Elixir JSON Schema validator From 03f1a230b4248bc6c75f57090aa3302749606010 Mon Sep 17 00:00:00 2001 From: Austin Wright Date: Thu, 28 Feb 2019 19:44:53 -0700 Subject: [PATCH 021/395] Add link to Understanding JSON Schema (#233) --- index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/index.md b/index.md index fe928df4..bb24fd53 100644 --- a/index.md +++ b/index.md @@ -85,6 +85,7 @@ JSON Schema is hypermedia ready, and ideal for annotating your existing JSON-bas 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) From c26b96d153b6ce54041bec40bc9fce5cef884af7 Mon Sep 17 00:00:00 2001 From: Erwin Bolwidt Date: Fri, 15 Mar 2019 08:42:36 +1100 Subject: [PATCH 022/395] Added Medeia-validator validation implementation --- _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 5a192973..0539fe06 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -57,6 +57,13 @@ notes: draft: [7] license: Apache License 2.0 +- name: Kotlin + implementations: + - name: Medeia-validator + url: https://github.com/worldturner/medeia-validator + notes: streaming validator for Kotlin and Java clients; works with Jackson and Gson + draft: [7, 6, 4] + license: Apache License 2.0 - name: JavaScript implementations: - name: ajv From d45200ad3a97843e2da05dce04dc8ff8b8f6f5dc Mon Sep 17 00:00:00 2001 From: Eugene Pirogov <207112+gmile@users.noreply.github.com> Date: Fri, 15 Mar 2019 11:58:21 +0200 Subject: [PATCH 023/395] Add JsonXema, JSON schema implementation in Elixir --- _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 96ff4b56..0ee70f00 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -35,6 +35,10 @@ 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 + draft: [7, 6, 4] + license: MIT - name: Go implementations: - name: gojsonschema From 61046fc45c9623ce5013194576990dabc8947b97 Mon Sep 17 00:00:00 2001 From: Clemens Uhlenhut Date: Wed, 20 Mar 2019 14:57:44 +0100 Subject: [PATCH 024/395] Update implementations.md Added support for draft 7 to JSONBuddy editor. --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index b018a8ba..92cf72d6 100644 --- a/implementations.md +++ b/implementations.md @@ -256,7 +256,7 @@ _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](https://www.visualstudio.com/) - *Auto-completion and tooltips based on JSON schema draft 3 and draft 4* -- [JSONBuddy](http://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 and draft 6.* +- [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* - [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* From ea3945ea29ab70c40b75a4d90565fd38f7e5bcd7 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Mon, 1 Apr 2019 09:18:46 -0700 Subject: [PATCH 025/395] Update front page for yet another delay. --- index.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/index.md b/index.md index bb24fd53..2213803a 100644 --- a/index.md +++ b/index.md @@ -37,13 +37,19 @@ permalink: / ## Project Status -### Update as of 16 December 2018 +### Update as of 31 March 2019 -We expect to publish a new round of drafts (Core, Validation, Hyper-Schema, Relative JSON Pointer) in early 2019, and are actively working on the last few PRs. While the drafts are currently expired, they are still under active development. This project is staffed by volunteers, and life occasionally disregards IETF expiration schedules. +**You may be wondering _what in the world is going on with this draft?_ The short version is: we are entering the home stretch. There are some ideas for simplifying `$id` that we are considering, and then there will be a final review period for feedback on overall flow and clarity.** -The last two major PRs (for modular vocabularies and a standardized output format) are under review and have gotten several rounds of feedback. Once those are complete, there will be a four-week final review period during which we will take feedback on the overall flow and content before publication. Therefore, the likely publication date will be in **January or Feburary 2019**. We had hoped for December but the holiday season and other life events have prevented that. +As for the long version: The original intent was to publish by the time the previous draft by or at least soon after the current Core and Validation drafts expired on 20 September, 2018. The project is a volunteer project, and one editor was driving most of the large changes in this draft. -This draft has taken more time than expected because it tackles deep, long-term issues that have long been a challenge for JSON Schema. This includes building in a formal extensibility mechanism so that we can more easily draw a line to finalize the contents of the Core and Validation specifications. +Unfortunately, that editor had a lot of Real Life Stuff(tm) to deal with this past year, including changing jobs (which put things on hold from about May through August or so) and then a run of minor health issues (which put things on hold from November through February). Other contributors made progress during those times, + +As of March, everyone is back to working towards the publication of the draft as schedules permit. + +We expect to publish a new round of drafts (Core, Validation, Hyper-Schema, Relative JSON Pointer) in the next month or two, and are actively working on the last few PRs. While the drafts are currently expired, they are still under active development. This project is staffed by volunteers, and life occasionally disregards IETF expiration schedules. + +This draft has also taken more time than expected because it tackles deep, long-term issues that have long been a challenge for JSON Schema. This includes building in a formal extensibility mechanism so that we can more easily draw a line to finalize the contents of the Core and Validation specifications. Progress on the next set of Internet-Drafts can be tracked on GitHub. The [draft-08](https://github.com/json-schema-org/json-schema-spec/milestone/6) milestone will track the evolving scope of the draft (although see [issue #612](https://github.com/json-schema-org/json-schema-spec/issues/612) for a discussion of whether "draft-08" is the right name for this milestone). From dc6175fd13c3410a5c59aeac75f622eea6d6ab60 Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Wed, 3 Apr 2019 15:20:13 +1100 Subject: [PATCH 026/395] Update implementations.md --- implementations.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 92cf72d6..f72a9a5a 100644 --- a/implementations.md +++ b/implementations.md @@ -231,7 +231,8 @@ the utility, and decided on a case-by-case basis. #### Schema draft migration -_None currently support draft-06 or later._ +- 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. #### Format converters @@ -248,6 +249,7 @@ _None currently support draft-06 or later._ #### 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 #### Editors From 2ce61c8cc735c6798a8dd99a988d19c3e9712cc9 Mon Sep 17 00:00:00 2001 From: Tobias Munk Date: Wed, 3 Apr 2019 15:45:01 +0200 Subject: [PATCH 027/395] updated URL of json-editor The original project from jdorn is deprecated https://github.com/jdorn/json-editor#deprecation-notice --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 92cf72d6..058ca74c 100644 --- a/implementations.md +++ b/implementations.md @@ -192,7 +192,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) - - [JSON Editor](https://github.com/jdorn/json-editor) (MIT) + - [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) - [JSONForms (jsonforms.io)](https://jsonforms.io/) (EclipseSource) (MIT) From 1bdb6f9039452586b90faa02788490190948f04f Mon Sep 17 00:00:00 2001 From: Jess Lee Yarbrough Date: Sat, 13 Apr 2019 10:21:16 -0400 Subject: [PATCH 028/395] Update implementations.md with Go validator benchmarks --- implementations.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/implementations.md b/implementations.md index b518a154..7e2785d3 100644 --- a/implementations.md +++ b/implementations.md @@ -64,6 +64,9 @@ Validators Benchmarks that compare at least two implementations supporting draft-06+ may be listed here. +- Go + - [validator-benchmarks](https://github.com/TheWildBlue/validator-benchmarks) - benchmark of Go JSON Schema validators based on official test suite + - 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) From 454968f5e78b6680e702a687d428f12f5b32b83a Mon Sep 17 00:00:00 2001 From: Peter Urbak Date: Fri, 19 Apr 2019 11:49:17 +0200 Subject: [PATCH 029/395] Adds link to json-schema-to-elm --- implementations.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index b518a154..2dc2ee8a 100644 --- a/implementations.md +++ b/implementations.md @@ -180,6 +180,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* +- 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) #### Web UI generation @@ -251,7 +253,7 @@ the utility, and decided on a case-by-case basis. - 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 - + #### Editors _TODO: Sort by draft support._ From d76fe783d7827da6a711230b2e52fada60499a0b Mon Sep 17 00:00:00 2001 From: ldexterldesign Date: Sat, 20 Apr 2019 16:36:08 +0200 Subject: [PATCH 030/395] Add https://github.com/json-schema-faker to generator (i.e. data) from schema --- obsolete-implementations.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/obsolete-implementations.md b/obsolete-implementations.md index 27918389..fcb22a07 100644 --- a/obsolete-implementations.md +++ b/obsolete-implementations.md @@ -129,7 +129,7 @@ Hyper-Schema {% endfor %} -Schema generation +Schema generators ----------------- - Python @@ -143,6 +143,14 @@ Schema generation - Sparx Enterprise Architect - [API-Add-In](https://github.com/bayeslife/api-add-in) - Sparx EA extension for exporting JSON Schema from UML models +Generators from schemas +----------------------- + +#### Data from schemas + +- JavaScript + - [json-schema-generator](https://github.com/json-schema-faker) (MIT) - JSON-Schema + fake data generators + Data parsing and code generation -------------------------------- From ee4f29823604f02186721aa05d99b0897c7669a7 Mon Sep 17 00:00:00 2001 From: leadpony Date: Sun, 21 Apr 2019 22:39:06 +0900 Subject: [PATCH 031/395] Update the supported drafts for Justify --- _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 20a8f728..2fc9aad5 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -69,7 +69,7 @@ - name: Justify url: https://github.com/leadpony/justify notes: - draft: [7] + draft: [7, 6, 4] license: Apache License 2.0 - name: Kotlin implementations: From 7d638dd97866881f11b4c6682725a5db63811413 Mon Sep 17 00:00:00 2001 From: Alexander Falk Date: Mon, 6 May 2019 16:44:18 -0400 Subject: [PATCH 032/395] Added Altova XMLSpy 2019r3 to list of Editors Added Altova XMLSpy 2019r3 to list of Editors, since it now supports draft-06 and draft-07 of JSON Schema --- implementations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/implementations.md b/implementations.md index b518a154..851def3f 100644 --- a/implementations.md +++ b/implementations.md @@ -256,6 +256,7 @@ the utility, and decided on a case-by-case basis. _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.* From fc471177d357a9ed7f82a4856234508d715bc413 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Thu, 9 May 2019 18:28:28 +0530 Subject: [PATCH 033/395] Add linter link --- implementations.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/implementations.md b/implementations.md index b518a154..7b4d11a5 100644 --- a/implementations.md +++ b/implementations.md @@ -273,3 +273,9 @@ Schema Repositories ------------------- - [SchemaStore.org](http://schemastore.org/json/) - validate against common JSON Schemas + + +Schema Linter/Parser +-------------------- + +- [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 From 316eb8fe8da3796cdad0922679aae75392f43c44 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Thu, 9 May 2019 16:26:04 +0100 Subject: [PATCH 034/395] Just for linters, and added draft support --- implementations.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/implementations.md b/implementations.md index 7b4d11a5..f2dc1df9 100644 --- a/implementations.md +++ b/implementations.md @@ -275,7 +275,7 @@ Schema Repositories - [SchemaStore.org](http://schemastore.org/json/) - validate against common JSON Schemas -Schema Linter/Parser --------------------- +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 +- [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. From f97f722ec00f80e882ee7d505103552b5c337c92 Mon Sep 17 00:00:00 2001 From: Henrik Mohr Date: Fri, 10 May 2019 23:18:44 +0200 Subject: [PATCH 035/395] Update of license for Clojure library --- _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 20a8f728..711f1038 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -31,7 +31,7 @@ - name: json-schema url: https://github.com/luposlip/json-schema draft: [7] - license: Eclipse Public License 2.0 + license: Apache License, Version 2.0 - name: Elixir implementations: - name: Elixir JSON Schema validator From 1224440592cf6041dafd43da5465489ec92f3c42 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Sat, 25 May 2019 14:39:59 -0700 Subject: [PATCH 036/395] Update work-in-progress index for "draft-08" and also link to it from the front page. No documents in this commit, they will be in the next one. --- index.md | 17 ++---- work-in-progress/index.md | 115 +++++++++++++++++++++++++++++++++++++- 2 files changed, 118 insertions(+), 14 deletions(-) diff --git a/index.md b/index.md index 2213803a..9d843cbd 100644 --- a/index.md +++ b/index.md @@ -7,6 +7,9 @@ permalink: / ***The current version is [draft-07](specification.html)!*** {: style="color:gray; font-size: 150%; text-align: center;"} +***The next draft work-in-progres is [in final review](work-in-progress/)!*** +{: style="color:red; font-size: 150%; text-align: center;"} + **JSON Schema** is a vocabulary that allows you to **annotate** and **validate** JSON documents. @@ -37,21 +40,13 @@ permalink: / ## Project Status -### Update as of 31 March 2019 - -**You may be wondering _what in the world is going on with this draft?_ The short version is: we are entering the home stretch. There are some ideas for simplifying `$id` that we are considering, and then there will be a final review period for feedback on overall flow and clarity.** - -As for the long version: The original intent was to publish by the time the previous draft by or at least soon after the current Core and Validation drafts expired on 20 September, 2018. The project is a volunteer project, and one editor was driving most of the large changes in this draft. - -Unfortunately, that editor had a lot of Real Life Stuff(tm) to deal with this past year, including changing jobs (which put things on hold from about May through August or so) and then a run of minor health issues (which put things on hold from November through February). Other contributors made progress during those times, - -As of March, everyone is back to working towards the publication of the draft as schedules permit. +### Update as of 27 May 2019 -We expect to publish a new round of drafts (Core, Validation, Hyper-Schema, Relative JSON Pointer) in the next month or two, and are actively working on the last few PRs. While the drafts are currently expired, they are still under active development. This project is staffed by volunteers, and life occasionally disregards IETF expiration schedules. +**The forthcoming draft is in [final review](work-in-progress/).** This draft has also taken more time than expected because it tackles deep, long-term issues that have long been a challenge for JSON Schema. This includes building in a formal extensibility mechanism so that we can more easily draw a line to finalize the contents of the Core and Validation specifications. -Progress on the next set of Internet-Drafts can be tracked on GitHub. The [draft-08](https://github.com/json-schema-org/json-schema-spec/milestone/6) milestone will track the evolving scope of the draft (although see [issue #612](https://github.com/json-schema-org/json-schema-spec/issues/612) for a discussion of whether "draft-08" is the right name for this milestone). +Additionally, numerous life issues reduced the availability of key contributors during the process. ### The Path to Standardization diff --git a/work-in-progress/index.md b/work-in-progress/index.md index 523cb2f0..c16ac946 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -7,7 +7,116 @@ permalink: /work-in-progress * TOC {:toc} -**draft-07** (a.k.a. **draft-handrews-\*-00**) has been released! -Please see the [specification](../documentation.md) page for details. +## The Next Draft (by whatever name) Is Ready for Final Pre-Publication Review! + +The forthcoming draft is now feature-frozen and entering the final four-week feedback +period before publication. This final review will last from May 27th to June 24th, 2019. + +The timeline may be compressed if, after at least two weeks, there is a clear consensus that +the drafts are solid and it would be best to publish sooner rather than later. + +The following sorts of feedback are particularly desired: + +* Clarity, readability, and accessibility to new readers +* Contradictions, inconsistencies and other bugs +* Anything so egregious that implementation would be infeasible or impossible + +New features or major changes to existing features will be deferred to a future draft, +and work on the next draft will begin immediately after this one is published. + +## What Is This Draft Called, Anyway? + +We have typically referred to this as `draft-08`, following our own convention of just +incrementing the draft number for meta-schemas regardless of the IETF identifier. + +However, this is frowned upon by the IETF and has in fact been a source of confusion. +It worked well up to and including `draft-04`, as even after the split into multiple +documents, `draft-zyp-json-schema-04` (the core spec) at least ended in `-04`! +Unfortnately, after that point, the numbers stopped matching in any way. + +Assuming this new draft gets published more or less as presented in this WIP, +and by the end of June, it will be: + +* IETF identifiers: `draft-handrews-*-02` +* Meta-schema identifiers: `draft/2019-06` + +Meta-schemas will now be identified with dates, which can be correlated with the publication +and expiration dates of the IETF documents. This will make it more clear when a bugfix +meta-schema is produced, and also make it more obvious that the IETF and meta-schema identifiers +are not expected to match exactly. + +## Pre-Built Review Documents + +To encourage as many reviewers as possible, pre-built documents are available. These may +slightly lag those in the GitHub repository, although all efforts will be made to keep them +in sync during the review period. After the review period, these will be removed. In particular, +using "WORK IN PROGRESS" meta-schemas **is not allowed** and **will break** as soon as the files +are moved to their permanent homes. + +### Specifications: + +As always, these are the actual normative documents: + +_**NOTE:** Links to meta-schemas and among the drafts will not work correctly in these review copies._ + +* [WIP: JSON Schema (core)](/work-in-progress/WIP-jsonschema-core.html) +* [WIP: JSON Schema Validation](/work-in-progress/WIP-jsonschema-validation.html) +* [WIP: JSON Schema Hyper-Schema](/work-in-progress/WIP-jsonschema-hyperschema.html) +* [WIP: Relative JSON Pointer](/work-in-progress/WIP-relative-json-pointer.html) + +### General use meta-schemas: + +These are the traditional non-normative meta-schemas, which serve the same purpose as +in previous drafts, although their internal structure is different. + +_**NOTE:** when published, the `.json` will be removed from the final URI_ + +* [WIP: schema.json](/work-in-progress/WIP-schema.json) (core and validation) +* [WIP: links.json](/work-in-progress/WIP-links.json) (individual link description object) +* [WIP: hyper-schema.json](/work-in-progress/WIP-hyper-schema.json) (hyper-schema, references schema and links) + +### Single-vocabulary meta-schemas: + +The new draft introduces the concept of modular vocabularies. Most schema authors will not directly +reference these meta-schemas. Instead, they are combined in useful ways by the general use meta-schemas. +However, those wishing to build custom meta-schemas may find it useful to choose different subsets of +the standard keywords depending on the custom meta-schema's intended purpose. + +_**NOTE:** when published, the `.json` will be removed from the final URI_ + +* [WIP: meta/core.json](/work-in-progress/meta/WIP-core.json) (core keywords, from the core spec) +* [WIP: meta/applicator.json](/work-in-progress/meta/WIP-applicator.json) (applicator keywords, from the core spec) +* [WIP: meta/validation.json](/work-in-progress/meta/WIP-validation.json) (validation assertions, from the validation spec) +* [WIP: meta/meta-data.json](/work-in-progress/meta/WIP-meta-data.json) (meta-data annotations, from the validation spec) +* [WIP: meta/format.json](/work-in-progress/meta/WIP-format.json) (the format keyword, from the validation spec) +* [WIP: meta/content.json](/work-in-progress/meta/WIP-content.json) (content keywords, from the validation spec) +* [WIP: meta/hyper-schema.json](/work-in-progress/meta/WIP-hyper-schema.json) (hyper-schema keywords, from the hyper-shema spec) + +### Output schema: + +The new draft also introduces recommended output formats for reporting errors and annotations. + +_**NOTE:** when published, the `.json` will be removed from the final URI_ + +* [WIP: schema.json](/work-in-progress/output/WIP-schema.json) (schema for recommended output formats) +* [WIP: verbose-example.json](/work-in-progress/output/WIP-verbose-example.json) (example of the most verbose output format) +* [WIP: hyper-schema.json](/work-in-progress/output/WIP-hyper-schema.json) (format used by the proposed hyper-schema test suite, and used in examples in the specification) + +## Providing Feedback and Tracking Progress in GitHub + +We are **particularly interested** in feedback on whether the wording and concepts is an +improvement in terms of how easy it is to understand and learn the specifications. + +Note that _all drafts have Changelog appendicies_, for a concise list of notable changes. + +* The active sources are on the +["master" branch of json-schema-org/json-schema-spec](https://github.com/json-schema-org/json-schema-spec) +* The [draft-08 milestone](https://github.com/json-schema-org/json-schema-spec/milestone/6) + tracks all issues and PRs for this draft + _(yes, it's still called draft-08 here because GitHub doesn't handle milestone renames well)_ +* Check the [open PRs](https://github.com/json-schema-org/json-schema-spec/pulls) + to see what is already being changed from other feedback +* [file an issue](https://github.com/json-schema-org/json-schema-spec/issues/new?milestone=draft-08) + or [join us on Slack](https://join.slack.com/t/json-schema/shared_invite/enQtMjk1NDcyNDI2NTAwLTcyYmYwMjdmMmUxNzZjYzIxNGU2YjdkNzdlOGZiNjIwNDI2M2Y3NmRkYjA4YmMwODMwYjgyOTFlNWZjZjAyNjg) to submit feedback + _(technically there is also a [mailing list](https://groups.google.com/forum/#!forum/json-schema) but it gets very little traffic and is not closely monitored)_ -This page will remain empty until draft-08 enters the final pre-publication review period. From 065e118f94905ea72d257bb85ae111f696372fcf Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Sat, 25 May 2019 21:27:31 -0700 Subject: [PATCH 037/395] Copy over built docs directly, no changes --- work-in-progress/WIP-hyper-schema.json | 26 + work-in-progress/WIP-jsonschema-core.html | 2280 ++++++++++ work-in-progress/WIP-jsonschema-core.txt | 3752 +++++++++++++++++ .../WIP-jsonschema-hyperschema.html | 2009 +++++++++ .../WIP-jsonschema-hyperschema.txt | 3248 ++++++++++++++ .../WIP-jsonschema-validation.html | 1380 ++++++ .../WIP-jsonschema-validation.txt | 1512 +++++++ work-in-progress/WIP-links.json | 91 + .../WIP-relative-json-pointer.html | 692 +++ .../WIP-relative-json-pointer.txt | 392 ++ work-in-progress/WIP-schema.json | 42 + work-in-progress/meta/WIP-applicator.json | 60 + work-in-progress/meta/WIP-content.json | 17 + work-in-progress/meta/WIP-core.json | 52 + work-in-progress/meta/WIP-format.json | 14 + work-in-progress/meta/WIP-hyper-schema.json | 29 + work-in-progress/meta/WIP-meta-data.json | 37 + work-in-progress/meta/WIP-validation.json | 98 + work-in-progress/output/WIP-hyper-schema.json | 62 + work-in-progress/output/WIP-schema.json | 86 + .../output/WIP-verbose-example.json | 130 + 21 files changed, 16009 insertions(+) create mode 100644 work-in-progress/WIP-hyper-schema.json create mode 100644 work-in-progress/WIP-jsonschema-core.html create mode 100644 work-in-progress/WIP-jsonschema-core.txt create mode 100644 work-in-progress/WIP-jsonschema-hyperschema.html create mode 100644 work-in-progress/WIP-jsonschema-hyperschema.txt create mode 100644 work-in-progress/WIP-jsonschema-validation.html create mode 100644 work-in-progress/WIP-jsonschema-validation.txt create mode 100644 work-in-progress/WIP-links.json create mode 100644 work-in-progress/WIP-relative-json-pointer.html create mode 100644 work-in-progress/WIP-relative-json-pointer.txt create mode 100644 work-in-progress/WIP-schema.json create mode 100644 work-in-progress/meta/WIP-applicator.json create mode 100644 work-in-progress/meta/WIP-content.json create mode 100644 work-in-progress/meta/WIP-core.json create mode 100644 work-in-progress/meta/WIP-format.json create mode 100644 work-in-progress/meta/WIP-hyper-schema.json create mode 100644 work-in-progress/meta/WIP-meta-data.json create mode 100644 work-in-progress/meta/WIP-validation.json create mode 100644 work-in-progress/output/WIP-hyper-schema.json create mode 100644 work-in-progress/output/WIP-schema.json create mode 100644 work-in-progress/output/WIP-verbose-example.json diff --git a/work-in-progress/WIP-hyper-schema.json b/work-in-progress/WIP-hyper-schema.json new file mode 100644 index 00000000..07d331dd --- /dev/null +++ b/work-in-progress/WIP-hyper-schema.json @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#", + "$id": "http://json-schema.org/draft/2019-04/hyper-schema", + "$vocabulary": { + "https://json-schema.org/draft/2019-04/vocab/core": true, + "https://json-schema.org/draft/2019-04/vocab/applicator": true, + "https://json-schema.org/draft/2019-04/vocab/validation": true, + "https://json-schema.org/draft/2019-04/vocab/meta-data": true, + "https://json-schema.org/draft/2019-04/vocab/format": true, + "https://json-schema.org/draft/2019-04/vocab/content": true, + "https://json-schema.org/draft/2019-04/vocab/hyper-schema": true + }, + "$recursiveAnchor": true, + + "title": "JSON Hyper-Schema", + "allOf": [ + {"$ref": "http://json-schema.org/draft/2019-04/schema"}, + {"$ref": "http://json-schema.org/draft/2019-04/meta/hyper-schema"} + ], + "links": [ + { + "rel": "self", + "href": "{+%24id}" + } + ] +} diff --git a/work-in-progress/WIP-jsonschema-core.html b/work-in-progress/WIP-jsonschema-core.html new file mode 100644 index 00000000..74e31829 --- /dev/null +++ b/work-in-progress/WIP-jsonschema-core.html @@ -0,0 +1,2280 @@ + + + + + + + JSON Schema: A Media Type for Describing JSON Documents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Internet Engineering Task ForceA. Wright, Ed.
Internet-Draft
Intended status: InformationalH. Andrews, Ed.
Expires: November 26, 2019Riverbed Technology
B. Hutton, Ed.
Wellcome Sanger Institute
G. Dennis
May 25, 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 <http://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 November 26, 2019.

+

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.

+

+3.1. 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.

+

+3.1.1. 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.

+

+3.1.2. 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.

+

+3.1.3. 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.

+

+3.1.4. 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.

+

+3.1.4.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.

+

+3.1.5. 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.

+

The default behavior is simply to collect all values in a list in indeterminate order. Given the extensibility of keywords, including applicators, it is not possible to define a universally predictable order of processing.

+

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.

+

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.

+

+3.2. Schema Vocabularies +

+

A JSON Schema vocabulary is a set of keywords defined for a particular purpose. The vocabulary specifies the meaning of its keywords as assertions, annotations, and/or any vocabulary-defined keyword category.

+

Several vocabularies are provided as standards in this and closely related documents. These vocabularies are used with the core keywords defined as fundamental to the "application/schema+json" media type.

+

Schema authors are encouraged to define their own vocabularies for domain-specific concepts. A vocabulary need not be a standard to be re-usable, although users of extension vocabularies MUST NOT assume that any JSON Schema implementation can support the vocabulary unless it specifically documents such support.

+

+3.2.1. Subschema Application

+

This vocabulary provides keywords for applying subschemas to the instance in various ways. It is defined in this document, and it is RECOMMENDED that all JSON Schema implementations support it. All other vocabularies in this section are designed to be used alongside the subschema application vocabulary.

+

Without this vocabulary or an equivalent one, JSON Schema can only be applied to a JSON document as a whole. In most cases, schema keywords need to be applied to specific object properties or array items.

+

+3.2.2. Validation

+

This vocabulary describes the structure of a JSON document (for instance, required properties and length limitations). Applications can use this information to validate instances (check that constraints are met), or inform interfaces to collect user input such that the constraints are satisfied.

+

Validation behaviour and keywords are specified in a separate document.

+

+3.2.3. Basic Meta-Data

+

A small set of annotation keywords are defined in the validation specification to allow associating common kinds of meta-data with an instance.

+

+3.2.4. Hypermedia and Linking

+

JSON Hyper-Schema produces hyperlinks as annotations available for use with a JSON document. It supports resolving URI Templates and describing the resource and data submission formats required to use an API.

+

Hyper-schema behaviour and keywords are specified in a separate document.

+

+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 is itself 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 three categories:

+ +
+
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
+
+ +

+

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. Root Schema and Subschemas +

+

The root schema is the schema that comprises the entire JSON document in question.

+

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.

+

+4.3.4. 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 the document'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 jumps 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", "$recursiveAnchor", and should be considered an advanced feature and used with caution when defining additional keywords.

+

+4.3.5. Referenced and Referencing Schemas +

+

As noted in Section 3.1.3, 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.

+

+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 "$id" 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 ECMA 262 regular expression dialect.

+

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.

+

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.

+

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

+

Authors of extensions to JSON Schema are encouraged to write their own meta-schemas, which extend the existing meta-schemas using "allOf". This extended meta-schema SHOULD be referenced using the "$schema" keyword, to allow tools to follow the correct behaviour.

+

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

+

+7. Meta-Schemas and Vocabularies

+

Two concepts, meta-schemas and vocabularies, are used to inform an implementation how to interpret a schema. A schema S declares its meta-schema M with the "$schema" keyword, and meta-schemas declare vocabularies with the "$vocabulary" keyword. The vocabularies declared in M are those that are expected to be used in S. The meta-schema M may itself use a different set of vocabularies, which are declared in its own meta-schema, M'.

+

The role of the meta-schema is to constrain the structure of conforming schemas, as well as simplify the process of composing multiple vocabularies into a usable feature set. Schema authoring is expected to be a common activity, so schema authors need only understand how to reference a single meta-schema.

+

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

+

The role of a vocabulary is to declare which keywords (including sub-keywords such as those in JSON Hyper-Schema's Link Description Object) are in use, and with which semantics. The semantics are indicated by the document that publicizes the vocabulary URI. At this time, there is no machine-readable description of keywords other than validation rules, which appear in the meta-schema.

+

Meta-schemas are separate from vocabularies to allow for the same sets of 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.

+

+7.1. The "$schema" Keyword

+

The "$schema" keyword is both used as a JSON Schema feature set identifier and the location of a resource which is itself a JSON Schema, which describes any schema 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 root schema. It MUST NOT appear in subschemas.

+

[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.

+

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

+

+7.2. The "$vocabulary" Keyword

+

The "$vocabulary" keyword, which appears in a meta-schema, identifies what sets of keywords are expected to be used in schemas described by that meta-schema, and with what semantics. This is conceptually analogous to how most other keywords used in meta-schemas describe the syntax of keywords used in schemas described by that meta-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 resources is currently undefined, and reserved for future use. Vocabulary authors SHOULD NOT serve a document at that URL. A server MAY respond with the relevant protocol's successful "no content" message, such as an HTTP 204 status. [CREF3]Vocabulary documents may be added shortly, or in the next draft. For now, identifying the keyword set is deemed sufficient as that, along with meta-schema validation, is how the current "vocabularies" work today.

+

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 MAY choose to proceed with processing such schemas.

+

When processing a schema that uses unrecognized vocabularies, keywords declared by those vocabularies are treated like any other unrecognized keyword, and ignored.

+

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.

+

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.

+

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. If the meta-schema, as referenced by the schema, is not recognized, then implementations MUST assume the use of the core vocabulary, and SHOULD assume the use of all vocabularies in this specification and the companion Validation specification.

+

+7.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 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.

+

+7.4. Best Practices for Vocabulary and Meta-Schema Authors

+

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. Such meta-schemas SHOULD NOT forbid additional keywords, and MUST NOT forbid the "$id", "$schema", or "$vocabulary" keywords in the root schema.

+

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.

+

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.

+

+7.5. The JSON Schema Core Vocabulary

+

Keywords declared in in this specification that 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 "$vocabulary" 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.

+

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-04/vocab/core>.

+

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

+

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.

+

+7.6. Example Meta-Schema With Vocabulary Declarations +

+

This meta-schema explicitly declares both the Core and Applicator vocabularies, and combines their meta-schemas with an "allOf". It additionally restricts the usage of the Applicator vocabulary by forbidding the keyword prefixed with "unevaluated". It also describes a keyword, "localKeyword", that is not part of either vocabulary. Note that it is its own meta-schema, as it relies on both the Core vocabulary (as all schemas do) and the Applicator vocabulary (for "allOf").

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

As shown above, even though each of the referenced standard meta-schemas declares its corresponding vocabulary, this new meta-schema must re-declare them for itself. It would be valid to leave the core vocabulary out of the "$vocabulary" keyword, but it needs to be referenced through the "allOf" keyword in order for its terms to be validated. There is no special case for validation of core keywords.

+

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.

+

+8. Base URI 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.

+

+8.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 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.

+

+8.2. The "$id" Keyword +

+

The "$id" keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. A subschema's "$id" is resolved against the base URI of its parent schema. If no parent sets an explicit base with "$id", the base URI is that of the entire document, as determined per RFC 3986 section 5.

+

If present, the value for this keyword MUST be a string, and MUST represent a valid URI-reference. This value SHOULD be normalized, and SHOULD NOT be an empty fragment <#> or an empty string <>.

+

+8.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), or this absolute URI but with an empty fragment.

+

+8.2.2. Changing the base URI within a schema file

+

When an "$id" sets the base URI, the object containing that "$id" and all of its subschemas can be identified by using a JSON Pointer fragment starting from that location. This is true even of subschemas that further change the base URI. Therefore, a single subschema may be accessible by multiple URIs, each consisting of base URI declared in the subschema or a parent, along with a JSON Pointer fragment identifying the path from the schema object that declares the base to the subschema being identified. Examples of this are shown in section 8.2.4.

+

+8.2.3. 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.

+

To specify such a subschema identifier, the "$id" keyword is set to a URI reference with a plain name fragment (not a JSON Pointer fragment). This value MUST begin with the number sign that specifies a fragment ("#"), then a letter ([A-Za-z]), followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), or periods (".").

+

The effect of using a fragment in "$id" that isn't blank or doesn't follow the plain name syntax is undefined. [CREF4]How should an "$id" URI reference containing a fragment with other components be interpreted? There are two cases: when the other components match the current base URI and when they change the base URI.

+

+8.2.4. Schema identification examples +

+

Consider the following schema, which shows "$id" being used to identify the root schema, change the base URI for subschemas, and assign plain name fragments to subschemas:

+
+
+{
+    "$id": "http://example.com/root.json",
+    "$defs": {
+        "A": { "$id": "#foo" },
+        "B": {
+            "$id": "other.json",
+            "$defs": {
+                "X": { "$id": "#bar" },
+                "Y": { "$id": "t/inner.json" }
+            }
+        },
+        "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 Section 5 above:

+

+ +
+
# (document root)
+
+
+
+
http://example.com/root.json
+
+
http://example.com/root.json#
+
+

+
+
#/$defs/A
+
+
+
+
http://example.com/root.json#foo
+
+
http://example.com/root.json#/$defs/A
+
+

+
+
#/$defs/B
+
+
+
+
http://example.com/other.json
+
+
http://example.com/other.json#
+
+
http://example.com/root.json#/$defs/B
+
+

+
+
#/$defs/B/$defs/X
+
+
+
+
http://example.com/other.json#bar
+
+
http://example.com/other.json#/$defs/X
+
+
http://example.com/root.json#/$defs/B/$defs/X
+
+

+
+
#/$defs/B/$defs/Y
+
+
+
+
http://example.com/t/inner.json
+
+
http://example.com/t/inner.json#
+
+
http://example.com/other.json#/$defs/Y
+
+
http://example.com/root.json#/$defs/B/$defs/Y
+
+

+
+
#/$defs/C
+
+
+
+
urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f
+
+
urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f#
+
+
http://example.com/root.json#/$defs/C
+
+

+
+
+ +

+

+8.3. 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 a helper keyword that controls how the referenced schema of "$recursiveRef" is determined.

+

As the value 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.3.1. Direct References with "$ref" +

+

The "$ref" keyword is used to reference a statically identified schema.

+

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

+

+8.3.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 ("#").

+

Extending a recursive schema with "$ref" alone involves redefining all recursive references in the source schema to point to the root of the extension. This produces the correct recursive behavior in the extension, which is that all recursion should reference the root of the extension.

+

Consider the following two schemas. The first schema, identified as "original" as it is the schema to be extended, describes an object with one string property and one recursive reference property, "r". The second schema, identified as "extension", references the first, and describes an additional things" property, which is an array of recursive references. It also repeats the description of "r" from the original schema.

+
+
+{
+    "$schema": "http://json-schema.org/draft/2019-04/schema#",
+    "$id": "https://example.com/original",
+
+    "properties": {
+        "name": {
+            "type": "string"
+        },
+        "r": {
+            "$ref": "#"
+        }
+    }
+}
+
+{
+    "$schema": "http://json-schema.org/draft/2019-04/schema#",
+    "$id": "https://example.com/extension",
+
+    "$ref": "original",
+    "properties": {
+        "r": {
+            "$ref": "#"
+        },
+        "things": {
+            "type": "array"
+            "items": {
+                "$ref": "#"
+            }
+        }
+    }
+}
+
+                        
+

This apparent duplication is important because it resolves to "https://example.com/extension#", meaning that for instance validated against the extension schema, the value of "r" must be valid according to the extension, and not just the original schema as "r" was described there.

+

This approach is fine for a single recursive field, but the more complicated the original schema, the more redefinitions are necessary in the extension. This leads to a verbose and error-prone extension, which must be kept synchronized with the original schema if the original changes its recursive fields. This approach can be seen in the meta-schema for JSON Hyper-Schema in all prior drafts.

+

+8.3.2.1. Enabling Recursion with "$recursiveAnchor"

+

The desired behavior is for the recursive reference, "r", in the original schema to resolve to the original schema when that is the only schema being used, but to resolve to the extension schema when using the extension. Then there would be no need to redefine the "r" property, or others like it, in the extension.

+

In order to create a recursive reference, we must do three things:

+ +
    +
  • In our original schema, indicate that the schema author intends for it to be extensible recursively.
  • +
  • In our extension schema, indicate that it is intended to be a recursive extension.
  • +
  • Use a reference keyword that explicitly activates the recursive behavior at the point of reference.
  • +
+ +

These three things together ensure that all schema authors are intentionally constructing a recursive extension, which in turn gives all uses of the regular "$ref" keyword confidence that it only behaves as it appears to, using lexical scoping.

+

The "$recursiveAnchor" keyword is how schema authors indicate that a schema can be extended recursively, and be a recursive schema. This keyword MAY appear in the root schema of a schema document, and MUST NOT appear in any subschema.

+

The value of "$recursiveAnchor" MUST be of type boolean, and MUST be true. The value false is reserved for possible future use.

+

+8.3.2.2. Dynamically recursive references with "$recursiveRef"

+

The "$recursiveRef" keyword behaves identically to "$ref", except that if the referenced schema has "$recursiveAnchor" set to true, then the implementation MUST examine the dynamic scope for the outermost (first seen) schema document with "$recursiveAnchor" set to true. If such a schema document exists, then the target of the "$recursiveRef" MUST be set to that document's URI, in place of the URI produced by the rules for "$ref".

+

Note that if the schema referenced by "$recursiveRef" does not contain "$recursiveAnchor" set to true, or if there are no other "$recursiveAnchor" keywords set to true anywhere further back in the dynamic scope, then "$recursiveRef"'s behavior is identical to that of "$ref".

+

With this in mind, we can rewrite the previous example:

+
+
+{
+    "$schema": "http://json-schema.org/draft/2019-04/schema#",
+    "$id": "https://example.com/original",
+    "$recursiveAnchor": true,
+
+    "properties": {
+        "name": {
+            "type": "string"
+        },
+        "r": {
+            "$recursiveRef": "#"
+        }
+    }
+}
+
+{
+    "$schema": "http://json-schema.org/draft/2019-04/schema#",
+    "$id": "https://example.com/extension",
+    "$recursiveAnchor": true,
+
+    "$ref": "original",
+    "properties": {
+        "things": {
+            "type": "array"
+            "items": {
+                "$recursiveRef": "#"
+            }
+        }
+    }
+}
+
+                            
+

Note that the "r" property no longer appears in the extension schema. Instead, all "$ref"s have been changed to "$recursiveRef"s, and both schemas have "$recursiveAnchor" set to true in their root schema.

+

When using the original schema on its own, there is no change in behavior. The "$recursiveRef" does lead to a schema where "$recursiveAnchor" is set to true, but since the original schema is the only schema document in the dynamics scope (it references itself, and does not reference any other schema documents), the behavior is effectively the same as "$ref".

+

When using the extension schema, the "$recursiveRef" within that schema (for the array items within "things") also effectively behaves like "$ref". The extension schema is the outermost dynamic scope, so the reference target is not changed.

+

In contrast, when using the extension schema, the "$recursiveRef" for "r" in the original schema now behaves differently. Its initial target is the root schema of the original schema document, which has "$recursiveAnchor" set to true. In this case, the outermost dynamic scope that also has "$recursiveAnchor" set to true is the extension schema. So when using the extensions schema, "r"'s reference in the original schema will resolve to "https://example.com/extension#", not "https://example.com/original#".

+

+8.3.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.3.4. References to Possible Non-Schemas

+

Subschema objects (or booleans) are recognized by their use with known applicator keywords. These keywords may be 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. [CREF5]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.3.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 section 8.2.4.

+

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.3.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": "http://example.net/root.json",
+    "items": {
+        "type": "array",
+        "items": { "$ref": "#item" }
+    },
+    "$defs": {
+        "single": {
+            "$id": "#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 <http://example.net/root.json#item>.

+

When an implementation then looks inside the <#/items> schema, it encounters the <#item> reference, and resolves this to <http://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 <http://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. [CREF6]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.4. Schema Re-Use With "$defs"

+

The "$defs" keyword provides a standardized 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":

+

+9. Comments With "$comment"

+

This keyword is reserved 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.

+

+10. 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.

+

+10.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.

+

+10.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.

+

+10.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.

+

+11. 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-04/vocab/applicator>.

+

The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-04/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.

+

+11.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
  • +
+ +

+

+11.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.

+

+11.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.

+

+11.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.

+

+11.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.

+

+11.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.

+

+11.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.

+

+11.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.

+

+11.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".

+

+11.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.

+

+11.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.

+

+11.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.

+

+11.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.

+

+11.3.1. Keywords for Applying Subschemas to Arrays

+

+11.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.

+

+11.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.

+

+11.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.

+

+11.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. This keyword does not produce annotation results. [CREF7]Should it produce a set of the indices for which the array element is valid against the subschema? "contains" does not affect "additionalItems" or any other current or proposed keyword, but the information could be useful, and implementation that collect annotations need to apply "contains" to every element anyway.

+

+11.3.2. Keywords for Applying Subschemas to Objects

+

+11.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.

+

+11.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.

+

+11.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.

+

+11.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.

+

+11.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.

+

+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 "$recursiveRef".

+
+
+#/properties/minLength/$ref/minimum
+
+                        
+

Note that this pointer may not be resolvable due to the inclusion of these 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 an absolute URI, and it MUST NOT include by-reference applicators such as "$ref" or "$recursiveRef".

+
+
+http://json-schema.org/draft/2019-04/schema#/$defs/nonNegativeInteger/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.

+

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".

+

+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": "http://example.com/polygon#",
+  "$schema": "http://json-schema.org/draft/2019-04/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 neither the error message property nor its wording as depicted in these examples is not a requirement of this specification. Implementations SHOULD craft error messages tailored for their audience.

+

+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":
+        "http://example.com/polygon#/definitions/point",
+      "instanceLocation": "#/1",
+      "error": "A subschema had errors."
+    },
+    {
+      "keywordLocation": "#/items/$ref/required",
+      "absoluteKeywordLocation":
+        "http://example.com/polygon#/definitions/point/required",
+      "instanceLocation": "#/1",
+      "error": "Required property 'y' not found."
+    },
+    {
+      "keywordLocation": "#/items/$ref/additionalProperties",
+      "absoluteKeywordLocation":
+        "http://example.com/polygon#/definitions/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 correllation 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":
+        "http://example.com/polygon#/definitions/point",
+      "instanceLocation": "#/1",
+      "errors": [
+        {
+          "valid": false,
+          "keywordLocation": "#/items/$ref/required",
+          "absoluteKeywordLocation":
+            "http://example.com/polygon#/definitions/point/required",
+          "instanceLocation": "#/1",
+          "error": "Required property 'y' not found."
+        },
+        {
+          "valid": false,
+          "keywordLocation": "#/items/$ref/additionalProperties",
+          "absoluteKeywordLocation":
+            "http://example.com/polygon#/definitions/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/2019-04/output/verbose-example>.

+
+
+// schema
+{
+  "$id": "http://example.com/polygon#",
+  "$schema": "http://json-schema.org/draft/2019-04/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/2019-04/output/schema>.

+

+13. 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.

+

+13.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: <http://example.com/my-hyper-schema#>; rel="describedby"
+
+                    
+

+13.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="http://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="http://example.com/alice http://example.com/bob"
+
+                    
+

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

+
+
+Accept: application/json;
+          schema="http://example.com/qiang http://example.com/li",
+        application/json;
+          schema="http://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.

+

[CREF8]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"
+
+                    
+

+13.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.

+

+14. 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.

+

+15. IANA Considerations

+

+15.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 14 above.
  • +
  • Interoperability considerations: See Sections 6.2, 6.3, and 6.4 above.
  • +
  • Fragment identifier considerations: See Section 5
  • +
+ +

+

+15.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 14 above.
  • +
  • Interoperability considerations: See Sections 6.2, 6.3, and 6.4 above.
  • +
  • Fragment identifier considerations: See Section 5
  • +
+ +

+

+16. References

+

+16.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.
+

+16.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.
[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. 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 B. ChangeLog

+

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

+

+ +
+
draft-handrews-json-schema-02
+
+
    +
  • Update to RFC 8359 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
  • +
+

+
+
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) + + + Riverbed Technology + + 680 Folsom St. + + + San Francisco, + CA + + + USA + + EMail: handrews@riverbed.com + +
+
+
+ + Ben Hutton (editor) + + + Wellcome Sanger Institute + + + + + + + + + + EMail: bh7@sanger.ac.uk + +
+
+
+ + Greg Dennis + + + + + + + Auckland, + + + + NZ + + EMail: gregsdennis@yahoo.com + +
+
+ + + diff --git a/work-in-progress/WIP-jsonschema-core.txt b/work-in-progress/WIP-jsonschema-core.txt new file mode 100644 index 00000000..19156592 --- /dev/null +++ b/work-in-progress/WIP-jsonschema-core.txt @@ -0,0 +1,3752 @@ + + + + +Internet Engineering Task Force A. Wright, Ed. +Internet-Draft +Intended status: Informational H. Andrews, Ed. +Expires: November 26, 2019 Riverbed Technology + B. Hutton, Ed. + Wellcome Sanger Institute + G. Dennis + May 25, 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 . + + For additional information, see . + + 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." + + + + +Wright, et al. Expires November 26, 2019 [Page 1] + +Internet-Draft JSON Schema May 2019 + + + This Internet-Draft will expire on November 26, 2019. + +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 . . . . . . . . . . . . . . . . . . . . . . . . 4 + 2. Conventions and Terminology . . . . . . . . . . . . . . . . . 4 + 3. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 5 + 3.1. Keyword Behaviors . . . . . . . . . . . . . . . . . . . . 5 + 3.1.1. Keyword Interactions . . . . . . . . . . . . . . . . 5 + 3.1.2. Default Behaviors . . . . . . . . . . . . . . . . . . 6 + 3.1.3. Applicators . . . . . . . . . . . . . . . . . . . . . 6 + 3.1.4. Assertions . . . . . . . . . . . . . . . . . . . . . 7 + 3.1.5. Annotations . . . . . . . . . . . . . . . . . . . . . 7 + 3.2. Schema Vocabularies . . . . . . . . . . . . . . . . . . . 8 + 3.2.1. Subschema Application . . . . . . . . . . . . . . . . 8 + 3.2.2. Validation . . . . . . . . . . . . . . . . . . . . . 8 + 3.2.3. Basic Meta-Data . . . . . . . . . . . . . . . . . . . 9 + 3.2.4. Hypermedia and Linking . . . . . . . . . . . . . . . 9 + 4. Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 9 + 4.1. JSON Document . . . . . . . . . . . . . . . . . . . . . . 9 + 4.2. Instance . . . . . . . . . . . . . . . . . . . . . . . . 9 + 4.2.1. Instance Data Model . . . . . . . . . . . . . . . . . 9 + 4.2.2. Instance Media Types . . . . . . . . . . . . . . . . 10 + 4.2.3. Instance Equality . . . . . . . . . . . . . . . . . . 11 + 4.3. JSON Schema Documents . . . . . . . . . . . . . . . . . . 11 + 4.3.1. JSON Schema Objects and Keywords . . . . . . . . . . 12 + 4.3.2. Boolean JSON Schemas . . . . . . . . . . . . . . . . 12 + 4.3.3. Root Schema and Subschemas . . . . . . . . . . . . . 13 + 4.3.4. Lexical Scope and Dynamic Scope . . . . . . . . . . . 13 + 4.3.5. Referenced and Referencing Schemas . . . . . . . . . 14 + 5. Fragment Identifiers . . . . . . . . . . . . . . . . . . . . 15 + 6. General Considerations . . . . . . . . . . . . . . . . . . . 15 + 6.1. Range of JSON Values . . . . . . . . . . . . . . . . . . 15 + + + +Wright, et al. Expires November 26, 2019 [Page 2] + +Internet-Draft JSON Schema May 2019 + + + 6.2. Programming Language Independence . . . . . . . . . . . . 15 + 6.3. Mathematical Integers . . . . . . . . . . . . . . . . . . 16 + 6.4. Regular Expressions . . . . . . . . . . . . . . . . . . . 16 + 6.5. Extending JSON Schema . . . . . . . . . . . . . . . . . . 16 + 7. Meta-Schemas and Vocabularies . . . . . . . . . . . . . . . . 17 + 7.1. The "$schema" Keyword . . . . . . . . . . . . . . . . . . 18 + 7.2. The "$vocabulary" Keyword . . . . . . . . . . . . . . . . 18 + 7.3. Detecting a Meta-Schema . . . . . . . . . . . . . . . . . 20 + 7.4. Best Practices for Vocabulary and Meta-Schema Authors . . 20 + 7.5. The JSON Schema Core Vocabulary . . . . . . . . . . . . . 21 + 7.6. Example Meta-Schema With Vocabulary Declarations . . . . 22 + 8. Base URI and Dereferencing . . . . . . . . . . . . . . . . . 23 + 8.1. Initial Base URI . . . . . . . . . . . . . . . . . . . . 23 + 8.2. The "$id" Keyword . . . . . . . . . . . . . . . . . . . . 23 + 8.2.1. Identifying the root schema . . . . . . . . . . . . . 23 + 8.2.2. Changing the base URI within a schema file . . . . . 24 + 8.2.3. Location-independent identifiers . . . . . . . . . . 24 + 8.2.4. Schema identification examples . . . . . . . . . . . 24 + 8.3. Schema References . . . . . . . . . . . . . . . . . . . . 26 + 8.3.1. Direct References with "$ref" . . . . . . . . . . . . 26 + 8.3.2. Recursive References with "$recursiveRef" and + "$recursiveAnchor" . . . . . . . . . . . . . . . . . 27 + 8.3.3. Guarding Against Infinite Recursion . . . . . . . . . 31 + 8.3.4. References to Possible Non-Schemas . . . . . . . . . 31 + 8.3.5. Loading a referenced schema . . . . . . . . . . . . . 32 + 8.3.6. Dereferencing . . . . . . . . . . . . . . . . . . . . 32 + 8.4. Schema Re-Use With "$defs" . . . . . . . . . . . . . . . 33 + 9. Comments With "$comment" . . . . . . . . . . . . . . . . . . 34 + 10. Collecting Annotations . . . . . . . . . . . . . . . . . . . 34 + 10.1. Distinguishing Among Multiple Values . . . . . . . . . . 35 + 10.2. Annotations and Assertions . . . . . . . . . . . . . . . 37 + 10.3. Annotations and Applicators . . . . . . . . . . . . . . 38 + 11. A Vocabulary for Applying Subschemas . . . . . . . . . . . . 38 + 11.1. Keyword Independence . . . . . . . . . . . . . . . . . . 39 + 11.2. Keywords for Applying Subschemas in Place . . . . . . . 39 + 11.2.1. Keywords for Applying Subschemas With Boolean Logic 39 + 11.2.2. Keywords for Applying Subschemas Conditionally . . . 40 + 11.3. Keywords for Applying Subschemas to Child Instances . . 42 + 11.3.1. Keywords for Applying Subschemas to Arrays . . . . . 42 + 11.3.2. Keywords for Applying Subschemas to Objects . . . . 44 + 12. Output Formatting . . . . . . . . . . . . . . . . . . . . . . 47 + 12.1. Format . . . . . . . . . . . . . . . . . . . . . . . . . 47 + 12.2. Output Formats . . . . . . . . . . . . . . . . . . . . . 47 + 12.3. Minimum Information . . . . . . . . . . . . . . . . . . 47 + 12.3.1. Keyword Relative Location . . . . . . . . . . . . . 48 + 12.3.2. Keyword Absolute Location . . . . . . . . . . . . . 48 + 12.3.3. Instance Location . . . . . . . . . . . . . . . . . 48 + 12.3.4. Error or Annotation . . . . . . . . . . . . . . . . 49 + + + +Wright, et al. Expires November 26, 2019 [Page 3] + +Internet-Draft JSON Schema May 2019 + + + 12.3.5. Nested Results . . . . . . . . . . . . . . . . . . . 49 + 12.4. Output Structure . . . . . . . . . . . . . . . . . . . . 49 + 12.4.1. Flag . . . . . . . . . . . . . . . . . . . . . . . . 51 + 12.4.2. Basic . . . . . . . . . . . . . . . . . . . . . . . 51 + 12.4.3. Detailed . . . . . . . . . . . . . . . . . . . . . . 52 + 12.4.4. Verbose . . . . . . . . . . . . . . . . . . . . . . 54 + 12.4.5. Output validation schemas . . . . . . . . . . . . . 56 + 13. Usage for Hypermedia . . . . . . . . . . . . . . . . . . . . 56 + 13.1. Linking to a Schema . . . . . . . . . . . . . . . . . . 56 + 13.2. Identifying a Schema via a Media Type Parameter . . . . 56 + 13.3. Usage Over HTTP . . . . . . . . . . . . . . . . . . . . 58 + 14. Security Considerations . . . . . . . . . . . . . . . . . . . 58 + 15. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 59 + 15.1. application/schema+json . . . . . . . . . . . . . . . . 59 + 15.2. application/schema-instance+json . . . . . . . . . . . . 60 + 16. References . . . . . . . . . . . . . . . . . . . . . . . . . 60 + 16.1. Normative References . . . . . . . . . . . . . . . . . . 60 + 16.2. Informative References . . . . . . . . . . . . . . . . . 61 + Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . 63 + Appendix B. ChangeLog . . . . . . . . . . . . . . . . . . . . . 63 + Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 66 + +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 [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]. + + + + + +Wright, et al. Expires November 26, 2019 [Page 4] + +Internet-Draft JSON Schema May 2019 + + +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. + +3.1. 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. + +3.1.1. Keyword Interactions + + Keyword behavior MAY be defined in terms of the annotation results of + subschemas (Section 4.3.3) 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 (Section 4.3). + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 5] + +Internet-Draft JSON Schema May 2019 + + +3.1.2. 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. + +3.1.3. 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.3) 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 3.1.4) 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. + + + +Wright, et al. Expires November 26, 2019 [Page 6] + +Internet-Draft JSON Schema May 2019 + + + Annotation (Section 3.1.5) results are combined according to the + rules specified by each annotation keyword. + +3.1.4. 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. + +3.1.4.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. + +3.1.5. 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. + + The default behavior is simply to collect all values in a list in + indeterminate order. Given the extensibility of keywords, including + applicators, it is not possible to define a universally predictable + order of processing. + + 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. + + + +Wright, et al. Expires November 26, 2019 [Page 7] + +Internet-Draft JSON Schema May 2019 + + + 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. + +3.2. Schema Vocabularies + + A JSON Schema vocabulary is a set of keywords defined for a + particular purpose. The vocabulary specifies the meaning of its + keywords as assertions, annotations, and/or any vocabulary-defined + keyword category. + + Several vocabularies are provided as standards in this and closely + related documents. These vocabularies are used with the core + keywords defined as fundamental to the "application/schema+json" + media type. + + Schema authors are encouraged to define their own vocabularies for + domain-specific concepts. A vocabulary need not be a standard to be + re-usable, although users of extension vocabularies MUST NOT assume + that any JSON Schema implementation can support the vocabulary unless + it specifically documents such support. + +3.2.1. Subschema Application + + This vocabulary provides keywords for applying subschemas to the + instance in various ways. It is defined in this document, and it is + RECOMMENDED that all JSON Schema implementations support it. All + other vocabularies in this section are designed to be used alongside + the subschema application vocabulary. + + Without this vocabulary or an equivalent one, JSON Schema can only be + applied to a JSON document as a whole. In most cases, schema + keywords need to be applied to specific object properties or array + items. + +3.2.2. Validation + + This vocabulary describes the structure of a JSON document (for + instance, required properties and length limitations). Applications + can use this information to validate instances (check that + constraints are met), or inform interfaces to collect user input such + that the constraints are satisfied. + + Validation behaviour and keywords are specified in a separate + document [json-schema-validation]. + + + + + +Wright, et al. Expires November 26, 2019 [Page 8] + +Internet-Draft JSON Schema May 2019 + + +3.2.3. Basic Meta-Data + + A small set of annotation keywords are defined in the validation + specification [json-schema-validation] to allow associating common + kinds of meta-data with an instance. + +3.2.4. Hypermedia and Linking + + JSON Hyper-Schema produces hyperlinks as annotations available for + use with a JSON document. It supports resolving URI Templates and + describing the resource and data submission formats required to use + an API. + + Hyper-schema behaviour and keywords are specified in a separate + document [json-hyper-schema]. + +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". + +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 + + + + + +Wright, et al. Expires November 26, 2019 [Page 9] + +Internet-Draft JSON Schema May 2019 + + + 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 + (Section 3.2) 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. + + + + + + +Wright, et al. Expires November 26, 2019 [Page 10] + +Internet-Draft JSON Schema May 2019 + + + 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 is itself 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. + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 11] + +Internet-Draft JSON Schema May 2019 + + +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 three categories: + + 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 + + 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. + + + + + + +Wright, et al. Expires November 26, 2019 [Page 12] + +Internet-Draft JSON Schema May 2019 + + +4.3.3. Root Schema and Subschemas + + The root schema is the schema that comprises the entire JSON document + in question. + + 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. + +4.3.4. 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 the document's root schema. + + + + + +Wright, et al. Expires November 26, 2019 [Page 13] + +Internet-Draft JSON Schema May 2019 + + + 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 jumps 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", + "$recursiveAnchor", and should be considered an advanced feature and + used with caution when defining additional keywords. + +4.3.5. Referenced and Referencing Schemas + + As noted in Section 3.1.3, 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.3.1), + 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. + + + + + + +Wright, et al. Expires November 26, 2019 [Page 14] + +Internet-Draft JSON Schema May 2019 + + +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 [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 "$id" keyword + (Section 8.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. + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 15] + +Internet-Draft JSON Schema May 2019 + + +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 ECMA 262 + [ecma262] regular expression dialect. + + 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 ignore keywords they do not support. + + + +Wright, et al. Expires November 26, 2019 [Page 16] + +Internet-Draft JSON Schema May 2019 + + + 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. + + A schema that itself describes a schema is called a meta-schema. + Meta-schemas are used to validate JSON Schemas and specify which + vocabulary they are using. + + Authors of extensions to JSON Schema are encouraged to write their + own meta-schemas, which extend the existing meta-schemas using + "allOf". This extended meta-schema SHOULD be referenced using the + "$schema" keyword, to allow tools to follow the correct behaviour. + + The recursive nature of meta-schemas makes the "$recursiveAnchor" and + "$recursiveRef" keywords particularly useful for such extensions, as + can be seen in the JSON Hyper-Schema meta-schema. + +7. Meta-Schemas and Vocabularies + + Two concepts, meta-schemas and vocabularies, are used to inform an + implementation how to interpret a schema. A schema S declares its + meta-schema M with the "$schema" keyword, and meta-schemas declare + vocabularies with the "$vocabulary" keyword. The vocabularies + declared in M are those that are expected to be used in S. The meta- + schema M may itself use a different set of vocabularies, which are + declared in its own meta-schema, M'. + + The role of the meta-schema is to constrain the structure of + conforming schemas, as well as simplify the process of composing + multiple vocabularies into a usable feature set. Schema authoring is + expected to be a common activity, so schema authors need only + understand how to reference a single meta-schema. + + Meta-schema authoring is an advanced usage of JSON Schema, so the + design of meta-schema features emphasizes flexibility over + simplicity. + + + + +Wright, et al. Expires November 26, 2019 [Page 17] + +Internet-Draft JSON Schema May 2019 + + + The role of a vocabulary is to declare which keywords (including sub- + keywords such as those in JSON Hyper-Schema's Link Description + Object) are in use, and with which semantics. The semantics are + indicated by the document that publicizes the vocabulary URI. At + this time, there is no machine-readable description of keywords other + than validation rules, which appear in the meta-schema. + + Meta-schemas are separate from vocabularies to allow for the same + sets of 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. + +7.1. The "$schema" Keyword + + The "$schema" keyword is both used as a JSON Schema feature set + identifier and the location of a resource which is itself a JSON + Schema, which describes any schema written for this particular + feature set. + + 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 a root schema. It MUST NOT + appear in subschemas. + + [[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. + ]] + + Values for this property are defined elsewhere in this and other + documents, and by other parties. + +7.2. The "$vocabulary" Keyword + + The "$vocabulary" keyword, which appears in a meta-schema, identifies + what sets of keywords are expected to be used in schemas described by + that meta-schema, and with what semantics. This is conceptually + + + + +Wright, et al. Expires November 26, 2019 [Page 18] + +Internet-Draft JSON Schema May 2019 + + + analogous to how most other keywords used in meta-schemas describe + the syntax of keywords used in schemas described by that meta-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 resources is + currently undefined, and reserved for future use. Vocabulary authors + SHOULD NOT serve a document at that URL. A server MAY respond with + the relevant protocol's successful "no content" message, such as an + HTTP 204 status. [[CREF3: Vocabulary documents may be added shortly, + or in the next draft. For now, identifying the keyword set is deemed + sufficient as that, along with meta-schema validation, is how the + current "vocabularies" work today. ]] + + 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 MAY choose to proceed with processing such + schemas. + + When processing a schema that uses unrecognized vocabularies, + keywords declared by those vocabularies are treated like any other + unrecognized keyword, and ignored. + + 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. + + 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 + (Section 7.6). + + 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. If the meta-schema, as + + + +Wright, et al. Expires November 26, 2019 [Page 19] + +Internet-Draft JSON Schema May 2019 + + + referenced by the schema, is not recognized, then implementations + MUST assume the use of the core vocabulary, and SHOULD assume the use + of all vocabularies in this specification and the companion + Validation specification. + +7.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 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. + +7.4. Best Practices for Vocabulary and Meta-Schema Authors + + 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. Such meta-schemas + SHOULD NOT forbid additional keywords, and MUST NOT forbid the "$id", + "$schema", or "$vocabulary" keywords in the root schema. + + It is RECOMMENDED that meta-schema authors reference each + vocabulary's meta-schema using the "allOf" (Section 11.2.1.1) + keyword, although other mechanisms for constructing the meta-schema + may be appropriate for certain use cases. + + 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 + + + +Wright, et al. Expires November 26, 2019 [Page 20] + +Internet-Draft JSON Schema May 2019 + + + 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. + +7.5. The JSON Schema Core Vocabulary + + Keywords declared in in this specification that 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 "$vocabulary" 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. + + 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: . + + The current URI for the corresponding meta-schema is: . + + 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. + + + + + +Wright, et al. Expires November 26, 2019 [Page 21] + +Internet-Draft JSON Schema May 2019 + + +7.6. Example Meta-Schema With Vocabulary Declarations + + This meta-schema explicitly declares both the Core and Applicator + vocabularies, and combines their meta-schemas with an "allOf". It + additionally restricts the usage of the Applicator vocabulary by + forbidding the keyword prefixed with "unevaluated". It also + describes a keyword, "localKeyword", that is not part of either + vocabulary. Note that it is its own meta-schema, as it relies on + both the Core vocabulary (as all schemas do) and the Applicator + vocabulary (for "allOf"). + + + { + "$schema": "https://json-schema.org/draft/2019-04/core-app-example#", + "$id": "https://json-schema.org/draft/2019-04/core-app-example", + "$recursiveAnchor": true, + "$vocabulary": { + "https://json-schema.org/draft/2019-04/vocab/core": true, + "https://json-schema.org/draft/2019-04/vocab/applicator": true + }, + "allOf": [ + {"$ref": "https://json-schema.org/draft/2019-04/meta/core"}, + {"$ref": "https://json-schema.org/draft/2019-04/meta/applicator"} + ], + "patternProperties": { + "^unevaluated.*$": false + }, + "properties": { + "$comment": "Not in vocabulary, but validated if used", + "localKeyword": { + "type": "string" + } + } + } + + + As shown above, even though each of the referenced standard meta- + schemas declares its corresponding vocabulary, this new meta-schema + must re-declare them for itself. It would be valid to leave the core + vocabulary out of the "$vocabulary" keyword, but it needs to be + referenced through the "allOf" keyword in order for its terms to be + validated. There is no special case for validation of core keywords. + + 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. + + + + +Wright, et al. Expires November 26, 2019 [Page 22] + +Internet-Draft JSON Schema May 2019 + + + These URIs for these meta-schemas may be found in the Validation and + Hyper-Schema specifications, respectively. + +8. Base URI 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. + +8.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 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. + +8.2. The "$id" Keyword + + The "$id" keyword defines a URI for the schema, and the base URI that + other URI references within the schema are resolved against. A + subschema's "$id" is resolved against the base URI of its parent + schema. If no parent sets an explicit base with "$id", the base URI + is that of the entire document, as determined per RFC 3986 section 5 + [RFC3986]. + + If present, the value for this keyword MUST be a string, and MUST + represent a valid URI-reference [RFC3986]. This value SHOULD be + normalized, and SHOULD NOT be an empty fragment <#> or an empty + string <>. + +8.2.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), or this absolute URI but with an empty fragment. + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 23] + +Internet-Draft JSON Schema May 2019 + + +8.2.2. Changing the base URI within a schema file + + When an "$id" sets the base URI, the object containing that "$id" and + all of its subschemas can be identified by using a JSON Pointer + fragment starting from that location. This is true even of + subschemas that further change the base URI. Therefore, a single + subschema may be accessible by multiple URIs, each consisting of base + URI declared in the subschema or a parent, along with a JSON Pointer + fragment identifying the path from the schema object that declares + the base to the subschema being identified. Examples of this are + shown in section 8.2.4. + +8.2.3. 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. + + To specify such a subschema identifier, the "$id" keyword is set to a + URI reference with a plain name fragment (not a JSON Pointer + fragment). This value MUST begin with the number sign that specifies + a fragment ("#"), then a letter ([A-Za-z]), followed by any number of + letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons + (":"), or periods ("."). + + The effect of using a fragment in "$id" that isn't blank or doesn't + follow the plain name syntax is undefined. [[CREF4: How should an + "$id" URI reference containing a fragment with other components be + interpreted? There are two cases: when the other components match + the current base URI and when they change the base URI. ]] + +8.2.4. Schema identification examples + + + + + + + + + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 24] + +Internet-Draft JSON Schema May 2019 + + + Consider the following schema, which shows "$id" being used to + identify the root schema, change the base URI for subschemas, and + assign plain name fragments to subschemas: + + + { + "$id": "http://example.com/root.json", + "$defs": { + "A": { "$id": "#foo" }, + "B": { + "$id": "other.json", + "$defs": { + "X": { "$id": "#bar" }, + "Y": { "$id": "t/inner.json" } + } + }, + "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 Section 5 above: + + # (document root) + + http://example.com/root.json + + http://example.com/root.json# + + #/$defs/A + + http://example.com/root.json#foo + + http://example.com/root.json#/$defs/A + + #/$defs/B + + http://example.com/other.json + + http://example.com/other.json# + + http://example.com/root.json#/$defs/B + + #/$defs/B/$defs/X + + + +Wright, et al. Expires November 26, 2019 [Page 25] + +Internet-Draft JSON Schema May 2019 + + + http://example.com/other.json#bar + + http://example.com/other.json#/$defs/X + + http://example.com/root.json#/$defs/B/$defs/X + + #/$defs/B/$defs/Y + + http://example.com/t/inner.json + + http://example.com/t/inner.json# + + http://example.com/other.json#/$defs/Y + + http://example.com/root.json#/$defs/B/$defs/Y + + #/$defs/C + + urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f + + urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f# + + http://example.com/root.json#/$defs/C + +8.3. 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 a helper keyword that controls how + the referenced schema of "$recursiveRef" is determined. + + As the value 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.3.1. Direct References with "$ref" + + The "$ref" keyword is used to reference a statically identified + schema. + + + + +Wright, et al. Expires November 26, 2019 [Page 26] + +Internet-Draft JSON Schema May 2019 + + + The value of the "$ref" property MUST be a string which is a URI + Reference. Resolved against the current URI base, it identifies the + URI of a schema to use. + +8.3.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 ("#"). + + Extending a recursive schema with "$ref" alone involves redefining + all recursive references in the source schema to point to the root of + the extension. This produces the correct recursive behavior in the + extension, which is that all recursion should reference the root of + the extension. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 27] + +Internet-Draft JSON Schema May 2019 + + + Consider the following two schemas. The first schema, identified as + "original" as it is the schema to be extended, describes an object + with one string property and one recursive reference property, "r". + The second schema, identified as "extension", references the first, + and describes an additional things" property, which is an array of + recursive references. It also repeats the description of "r" from + the original schema. + + + { + "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "https://example.com/original", + + "properties": { + "name": { + "type": "string" + }, + "r": { + "$ref": "#" + } + } + } + + { + "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "https://example.com/extension", + + "$ref": "original", + "properties": { + "r": { + "$ref": "#" + }, + "things": { + "type": "array" + "items": { + "$ref": "#" + } + } + } + } + + + This apparent duplication is important because it resolves to + "https://example.com/extension#", meaning that for instance validated + against the extension schema, the value of "r" must be valid + according to the extension, and not just the original schema as "r" + was described there. + + + + +Wright, et al. Expires November 26, 2019 [Page 28] + +Internet-Draft JSON Schema May 2019 + + + This approach is fine for a single recursive field, but the more + complicated the original schema, the more redefinitions are necessary + in the extension. This leads to a verbose and error-prone extension, + which must be kept synchronized with the original schema if the + original changes its recursive fields. This approach can be seen in + the meta-schema for JSON Hyper-Schema in all prior drafts. + +8.3.2.1. Enabling Recursion with "$recursiveAnchor" + + The desired behavior is for the recursive reference, "r", in the + original schema to resolve to the original schema when that is the + only schema being used, but to resolve to the extension schema when + using the extension. Then there would be no need to redefine the "r" + property, or others like it, in the extension. + + In order to create a recursive reference, we must do three things: + + In our original schema, indicate that the schema author intends + for it to be extensible recursively. + + In our extension schema, indicate that it is intended to be a + recursive extension. + + Use a reference keyword that explicitly activates the recursive + behavior at the point of reference. + + These three things together ensure that all schema authors are + intentionally constructing a recursive extension, which in turn gives + all uses of the regular "$ref" keyword confidence that it only + behaves as it appears to, using lexical scoping. + + The "$recursiveAnchor" keyword is how schema authors indicate that a + schema can be extended recursively, and be a recursive schema. This + keyword MAY appear in the root schema of a schema document, and MUST + NOT appear in any subschema. + + The value of "$recursiveAnchor" MUST be of type boolean, and MUST be + true. The value false is reserved for possible future use. + +8.3.2.2. Dynamically recursive references with "$recursiveRef" + + The "$recursiveRef" keyword behaves identically to "$ref", except + that if the referenced schema has "$recursiveAnchor" set to true, + then the implementation MUST examine the dynamic scope for the + outermost (first seen) schema document with "$recursiveAnchor" set to + true. If such a schema document exists, then the target of the + "$recursiveRef" MUST be set to that document's URI, in place of the + URI produced by the rules for "$ref". + + + +Wright, et al. Expires November 26, 2019 [Page 29] + +Internet-Draft JSON Schema May 2019 + + + Note that if the schema referenced by "$recursiveRef" does not + contain "$recursiveAnchor" set to true, or if there are no other + "$recursiveAnchor" keywords set to true anywhere further back in the + dynamic scope, then "$recursiveRef"'s behavior is identical to that + of "$ref". + + With this in mind, we can rewrite the previous example: + + + { + "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "https://example.com/original", + "$recursiveAnchor": true, + + "properties": { + "name": { + "type": "string" + }, + "r": { + "$recursiveRef": "#" + } + } + } + + { + "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "https://example.com/extension", + "$recursiveAnchor": true, + + "$ref": "original", + "properties": { + "things": { + "type": "array" + "items": { + "$recursiveRef": "#" + } + } + } + } + + + Note that the "r" property no longer appears in the extension schema. + Instead, all "$ref"s have been changed to "$recursiveRef"s, and both + schemas have "$recursiveAnchor" set to true in their root schema. + + When using the original schema on its own, there is no change in + behavior. The "$recursiveRef" does lead to a schema where + "$recursiveAnchor" is set to true, but since the original schema is + + + +Wright, et al. Expires November 26, 2019 [Page 30] + +Internet-Draft JSON Schema May 2019 + + + the only schema document in the dynamics scope (it references itself, + and does not reference any other schema documents), the behavior is + effectively the same as "$ref". + + When using the extension schema, the "$recursiveRef" within that + schema (for the array items within "things") also effectively behaves + like "$ref". The extension schema is the outermost dynamic scope, so + the reference target is not changed. + + In contrast, when using the extension schema, the "$recursiveRef" for + "r" in the original schema now behaves differently. Its initial + target is the root schema of the original schema document, which has + "$recursiveAnchor" set to true. In this case, the outermost dynamic + scope that also has "$recursiveAnchor" set to true is the extension + schema. So when using the extensions schema, "r"'s reference in the + original schema will resolve to "https://example.com/extension#", not + "https://example.com/original#". + +8.3.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.3.4. References to Possible Non-Schemas + + Subschema objects (or booleans) are recognized by their use with + known applicator keywords. These keywords may be 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. [[CREF5: 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. ]] + + + +Wright, et al. Expires November 26, 2019 [Page 31] + +Internet-Draft JSON Schema May 2019 + + + 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.3.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 (Section 13). + + 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 + section 8.2.4. + + 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.3.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 [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: + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 32] + +Internet-Draft JSON Schema May 2019 + + + { + "$id": "http://example.net/root.json", + "items": { + "type": "array", + "items": { "$ref": "#item" } + }, + "$defs": { + "single": { + "$id": "#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 + . + + When an implementation then looks inside the <#/items> schema, it + encounters the <#item> reference, and resolves this to + , 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 , 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. [[CREF6: 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.4. Schema Re-Use With "$defs" + + The "$defs" keyword provides a standardized 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. + + + + + + +Wright, et al. Expires November 26, 2019 [Page 33] + +Internet-Draft JSON Schema May 2019 + + + 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 + } + } + } + + +9. Comments With "$comment" + + This keyword is reserved 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. + +10. 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. + + + +Wright, et al. Expires November 26, 2019 [Page 34] + +Internet-Draft JSON Schema May 2019 + + + 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. + +10.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]: + + + + + + + + + + + + + + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 35] + +Internet-Draft JSON Schema May 2019 + + + 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" + + + + +Wright, et al. Expires November 26, 2019 [Page 36] + +Internet-Draft JSON Schema May 2019 + + + 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. + +10.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: + + + + + + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 37] + +Internet-Draft JSON Schema May 2019 + + + { + "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. + +10.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. + +11. 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: . + + The current URI for the corresponding meta-schema is: . + + 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. + + + +Wright, et al. Expires November 26, 2019 [Page 38] + +Internet-Draft JSON Schema May 2019 + + +11.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 + +11.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. + +11.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. + +11.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. + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 39] + +Internet-Draft JSON Schema May 2019 + + +11.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. + +11.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. + +11.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. + +11.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. + +11.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. + + + +Wright, et al. Expires November 26, 2019 [Page 40] + +Internet-Draft JSON Schema May 2019 + + + 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 3.1.5) 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". + +11.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. + +11.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. + +11.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. + + + + + +Wright, et al. Expires November 26, 2019 [Page 41] + +Internet-Draft JSON Schema May 2019 + + + 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. + +11.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. + +11.3.1. Keywords for Applying Subschemas to Arrays + +11.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. + +11.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". + + + +Wright, et al. Expires November 26, 2019 [Page 42] + +Internet-Draft JSON Schema May 2019 + + + 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. + +11.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 (Section 11.2) 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. + + + +Wright, et al. Expires November 26, 2019 [Page 43] + +Internet-Draft JSON Schema May 2019 + + + 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. + +11.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. This keyword does not + produce annotation results. [[CREF7: Should it produce a set of the + indices for which the array element is valid against the subschema? + "contains" does not affect "additionalItems" or any other current or + proposed keyword, but the information could be useful, and + implementation that collect annotations need to apply "contains" to + every element anyway. ]] + +11.3.2. Keywords for Applying Subschemas to Objects + +11.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. + + + + + + +Wright, et al. Expires November 26, 2019 [Page 44] + +Internet-Draft JSON Schema May 2019 + + +11.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. + +11.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. + + + + +Wright, et al. Expires November 26, 2019 [Page 45] + +Internet-Draft JSON Schema May 2019 + + +11.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 (Section 11.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 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. + +11.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. + + + +Wright, et al. Expires November 26, 2019 [Page 46] + +Internet-Draft JSON Schema May 2019 + + + Omitting this keyword has the same 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. + + + + + +Wright, et al. Expires November 26, 2019 [Page 47] + +Internet-Draft JSON Schema May 2019 + + + 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 + "$recursiveRef". + + + #/properties/minLength/$ref/minimum + + + Note that this pointer may not be resolvable due to the inclusion of + these 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 an absolute URI, and it MUST NOT include + by-reference applicators such as "$ref" or "$recursiveRef". + + +http://json-schema.org/draft/2019-04/schema#/$defs/nonNegativeInteger/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". + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 48] + +Internet-Draft JSON Schema May 2019 + + +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. + + 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". + +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. + + + + + + + + + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 49] + +Internet-Draft JSON Schema May 2019 + + + { + "$id": "http://example.com/polygon#", + "$schema": "http://json-schema.org/draft/2019-04/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 neither the error message property nor its wording as + depicted in these examples is not a requirement of this + + + + +Wright, et al. Expires November 26, 2019 [Page 50] + +Internet-Draft JSON Schema May 2019 + + + specification. Implementations SHOULD craft error messages tailored + for their audience. + +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. + + + + + + + + + + + + + + + + + + + + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 51] + +Internet-Draft JSON Schema May 2019 + + +{ + "valid": false, + "errors": [ + { + "keywordLocation": "#", + "instanceLocation": "#", + "error": "A subschema had errors." + }, + { + "keywordLocation": "#/items/$ref", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point", + "instanceLocation": "#/1", + "error": "A subschema had errors." + }, + { + "keywordLocation": "#/items/$ref/required", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point/required", + "instanceLocation": "#/1", + "error": "Required property 'y' not found." + }, + { + "keywordLocation": "#/items/$ref/additionalProperties", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/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 correllation is more easily identified. + + + + +Wright, et al. Expires November 26, 2019 [Page 52] + +Internet-Draft JSON Schema May 2019 + + + 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. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 53] + +Internet-Draft JSON Schema May 2019 + + +{ + "valid": false, + "keywordLocation": "#", + "instanceLocation": "#", + "errors": [ + { + "valid": false, + "keywordLocation": "#/items/$ref", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point", + "instanceLocation": "#/1", + "errors": [ + { + "valid": false, + "keywordLocation": "#/items/$ref/required", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point/required", + "instanceLocation": "#/1", + "error": "Required property 'y' not found." + }, + { + "valid": false, + "keywordLocation": "#/items/$ref/additionalProperties", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/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 + + + +Wright, et al. Expires November 26, 2019 [Page 54] + +Internet-Draft JSON Schema May 2019 + + + 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: . + + +// schema +{ + "$id": "http://example.com/polygon#", + "$schema": "http://json-schema.org/draft/2019-04/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": "#", + + + +Wright, et al. Expires November 26, 2019 [Page 55] + +Internet-Draft JSON Schema May 2019 + + + "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: . + +13. 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]. + +13.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: ; rel="describedby" + + +13.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). + + + + + +Wright, et al. Expires November 26, 2019 [Page 56] + +Internet-Draft JSON Schema May 2019 + + + 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="http://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="http://example.com/alice http://example.com/bob" + + + Media type parameters are also used in HTTP's Accept request header: + + + Accept: application/json; + schema="http://example.com/qiang http://example.com/li", + application/json; + schema="http://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. + + + + +Wright, et al. Expires November 26, 2019 [Page 57] + +Internet-Draft JSON Schema May 2019 + + + 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. + + [[CREF8: 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: ;rel="schema", ;rel="schema" + + +13.3. 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. + +14. Security Considerations + + Both schemas and instances are JSON values. As such, all security + considerations defined in RFC 8259 [RFC8259] apply. + + + + +Wright, et al. Expires November 26, 2019 [Page 58] + +Internet-Draft JSON Schema May 2019 + + + 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. + +15. IANA Considerations + +15.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 + [RFC8259]. + + + + +Wright, et al. Expires November 26, 2019 [Page 59] + +Internet-Draft JSON Schema May 2019 + + + Security considerations: See Section 14 above. + + Interoperability considerations: See Sections 6.2, 6.3, and 6.4 + above. + + Fragment identifier considerations: See Section 5 + +15.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 + [RFC8259]. + + Security considerations: See Section 14 above. + + Interoperability considerations: See Sections 6.2, 6.3, and 6.4 + above. + + Fragment identifier considerations: See Section 5 + +16. References + +16.1. Normative References + + [ecma262] "ECMA 262 specification", . + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 60] + +Internet-Draft JSON Schema May 2019 + + + [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., Ed., Zyp, K., and M. Nottingham, Ed., + "JavaScript Object Notation (JSON) Pointer", RFC 6901, + DOI 10.17487/RFC6901, April 2013, + . + + [RFC8259] Bray, T., Ed., "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, + . + +16.2. Informative References + + [json-hyper-schema] + Andrews, H. and A. Wright, "JSON Hyper-Schema: A + Vocabulary for Hypermedia Annotation of JSON", draft- + handrews-json-schema-hyperschema-02 (work in progress), + November 2017. + + [json-schema-validation] + Wright, A., Andrews, H., and G. Luff, "JSON Schema + Validation: A Vocabulary for Structural Validation of + JSON", draft-handrews-json-schema-validation-02 (work in + progress), November 2017. + + [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object + Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, + October 2013, . + + + +Wright, et al. Expires November 26, 2019 [Page 61] + +Internet-Draft JSON Schema May 2019 + + + [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "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, + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 62] + +Internet-Draft JSON Schema May 2019 + + +Appendix A. 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 B. ChangeLog + + [[CREF9: This section to be removed before leaving Internet-Draft + status.]] + + draft-handrews-json-schema-02 + + * Update to RFC 8359 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 + + + +Wright, et al. Expires November 26, 2019 [Page 63] + +Internet-Draft JSON Schema May 2019 + + + * 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 + + 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 + + + +Wright, et al. Expires November 26, 2019 [Page 64] + +Internet-Draft JSON Schema May 2019 + + + * 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" + + + + +Wright, et al. Expires November 26, 2019 [Page 65] + +Internet-Draft JSON Schema May 2019 + + + * 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) + Riverbed Technology + 680 Folsom St. + San Francisco, CA + USA + + EMail: handrews@riverbed.com + + + Ben Hutton (editor) + Wellcome Sanger Institute + + EMail: bh7@sanger.ac.uk + + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 66] + +Internet-Draft JSON Schema May 2019 + + + Greg Dennis + Auckland + NZ + + EMail: gregsdennis@yahoo.com + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 67] diff --git a/work-in-progress/WIP-jsonschema-hyperschema.html b/work-in-progress/WIP-jsonschema-hyperschema.html new file mode 100644 index 00000000..76a9f113 --- /dev/null +++ b/work-in-progress/WIP-jsonschema-hyperschema.html @@ -0,0 +1,2009 @@ + + + + + + + JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Internet Engineering Task ForceH. Andrews, Ed.
Internet-DraftRiverbed Technology
Intended status: InformationalA. Wright, Ed.
Expires: November 26, 2019May 25, 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 <http://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 November 26, 2019.

+

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 <http://json-schema.org/draft/2019-04/hyper-schema#>.

+

The current URI for this vocabulary, known as the Hyper-Schema vocabulary, is: <https://json-schema.org/draft/2019-04/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-04/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: <http://json-schema.org/draft/2019-04/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 <http://json-schema.org/draft/2019-04/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:
+        temlateData[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": "http://json-schema.org/draft/2019-04/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": "http://json-schema.org/draft/2019-04/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": "http://json-schema.org/draft/2019-04/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": "http://json-schema.org/draft/2019-04/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": "http://json-schema.org/draft/2019-04/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": "http://json-schema.org/draft/2019-04/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) + + + Riverbed Technology + + 680 Folsom St. + + + San Francisco, + CA + + + USA + + EMail: handrews@riverbed.com + +
+
+
+ + Austin Wright (editor) + + + + + + + + + + + + + EMail: aaa@bzfx.net + +
+
+ + + diff --git a/work-in-progress/WIP-jsonschema-hyperschema.txt b/work-in-progress/WIP-jsonschema-hyperschema.txt new file mode 100644 index 00000000..aa1c5f7a --- /dev/null +++ b/work-in-progress/WIP-jsonschema-hyperschema.txt @@ -0,0 +1,3248 @@ + + + + +Internet Engineering Task Force H. Andrews, Ed. +Internet-Draft Riverbed Technology +Intended status: Informational A. Wright, Ed. +Expires: November 26, 2019 May 25, 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 . + + For additional information, see . + + 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 November 26, 2019. + + + + + +Andrews & Wright Expires November 26, 2019 [Page 1] + +Internet-Draft JSON Hyper-Schema May 2019 + + +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 . . . . . . . . . . . . . . . . . . . . . . . . 3 + 2. Notational Conventions . . . . . . . . . . . . . . . . . . . 4 + 3. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 4 + 3.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 5 + 3.2. Functionality . . . . . . . . . . . . . . . . . . . . . . 6 + 4. Meta-Schemas and Output Schema . . . . . . . . . . . . . . . 7 + 5. Schema Keywords . . . . . . . . . . . . . . . . . . . . . . . 8 + 5.1. base . . . . . . . . . . . . . . . . . . . . . . . . . . 8 + 5.2. links . . . . . . . . . . . . . . . . . . . . . . . . . . 8 + 6. Link Description Object . . . . . . . . . . . . . . . . . . . 8 + 6.1. Link Context . . . . . . . . . . . . . . . . . . . . . . 9 + 6.1.1. anchor . . . . . . . . . . . . . . . . . . . . . . . 10 + 6.1.2. anchorPointer . . . . . . . . . . . . . . . . . . . . 10 + 6.2. Link Relation Type . . . . . . . . . . . . . . . . . . . 10 + 6.2.1. rel . . . . . . . . . . . . . . . . . . . . . . . . . 11 + 6.2.2. "self" Links . . . . . . . . . . . . . . . . . . . . 11 + 6.2.3. "collection" and "item" Links . . . . . . . . . . . . 11 + 6.2.4. Using Extension Relation Types . . . . . . . . . . . 12 + 6.3. Link Target . . . . . . . . . . . . . . . . . . . . . . . 12 + 6.3.1. href . . . . . . . . . . . . . . . . . . . . . . . . 12 + 6.4. Adjusting URI Template Resolution . . . . . . . . . . . . 12 + 6.4.1. templatePointers . . . . . . . . . . . . . . . . . . 13 + 6.4.2. templateRequired . . . . . . . . . . . . . . . . . . 13 + 6.5. Link Target Attributes . . . . . . . . . . . . . . . . . 13 + 6.5.1. title . . . . . . . . . . . . . . . . . . . . . . . . 13 + 6.5.2. description . . . . . . . . . . . . . . . . . . . . . 13 + 6.5.3. targetMediaType . . . . . . . . . . . . . . . . . . . 14 + 6.5.4. targetSchema . . . . . . . . . . . . . . . . . . . . 14 + 6.5.5. targetHints . . . . . . . . . . . . . . . . . . . . . 14 + 6.6. Link Input . . . . . . . . . . . . . . . . . . . . . . . 15 + 6.6.1. hrefSchema . . . . . . . . . . . . . . . . . . . . . 15 + + + +Andrews & Wright Expires November 26, 2019 [Page 2] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 6.6.2. headerSchema . . . . . . . . . . . . . . . . . . . . 16 + 6.6.3. Manipulating the Target Resource Representation . . . 17 + 6.6.4. Submitting Data for Processing . . . . . . . . . . . 17 + 7. Implementation Requirements . . . . . . . . . . . . . . . . . 18 + 7.1. Link Discovery and Look-Up . . . . . . . . . . . . . . . 19 + 7.2. URI Templating . . . . . . . . . . . . . . . . . . . . . 20 + 7.2.1. Populating Template Data From the Instance . . . . . 21 + 7.2.2. Accepting Input for Template Data . . . . . . . . . . 22 + 7.2.3. Encoding Data as Strings . . . . . . . . . . . . . . 23 + 7.3. Providing Access to LDO Keywords . . . . . . . . . . . . 24 + 7.4. Requests . . . . . . . . . . . . . . . . . . . . . . . . 24 + 7.5. Responses . . . . . . . . . . . . . . . . . . . . . . . . 25 + 7.6. Streaming Parsers . . . . . . . . . . . . . . . . . . . . 26 + 8. JSON Hyper-Schema and HTTP . . . . . . . . . . . . . . . . . 26 + 8.1. One Link Per Target and Relation Type . . . . . . . . . . 27 + 8.2. "targetSchema" and HTTP . . . . . . . . . . . . . . . . . 27 + 8.3. HTTP POST and the "submission*" keywords . . . . . . . . 28 + 8.4. Optimizing HTTP Discoverability With "targetHints" . . . 28 + 8.5. Advertising HTTP Features With "headerSchema" . . . . . . 29 + 8.6. Creating Resources Through Collections . . . . . . . . . 30 + 8.7. Content Negotiation and Schema Evolution . . . . . . . . 30 + 9. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 31 + 9.1. Entry Point Links, No Templates . . . . . . . . . . . . . 31 + 9.2. Individually Identified Resources . . . . . . . . . . . . 33 + 9.3. Submitting a Payload and Accepting URI Input . . . . . . 34 + 9.4. "anchor", "base" and URI Template Resolution . . . . . . 37 + 9.5. Collections . . . . . . . . . . . . . . . . . . . . . . . 40 + 9.5.1. Pagination . . . . . . . . . . . . . . . . . . . . . 45 + 9.5.2. Creating the First Item . . . . . . . . . . . . . . . 48 + 10. Security Considerations . . . . . . . . . . . . . . . . . . . 49 + 10.1. Target Attributes . . . . . . . . . . . . . . . . . . . 49 + 10.2. "self" Links . . . . . . . . . . . . . . . . . . . . . . 50 + 11. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 51 + 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 51 + 12.1. Normative References . . . . . . . . . . . . . . . . . . 51 + 12.2. Informative References . . . . . . . . . . . . . . . . . 52 + Appendix A. Using JSON Hyper-Schema in APIs . . . . . . . . . . 54 + A.1. Resource Evolution With Hyper-Schema . . . . . . . . . . 54 + A.2. Responses and Errors . . . . . . . . . . . . . . . . . . 54 + A.3. Static Analysis of an API's Hyper-Schemas . . . . . . . . 55 + Appendix B. ChangeLog . . . . . . . . . . . . . . . . . . . . . 55 + Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 58 + +1. Introduction + + JSON Hyper-Schema is a JSON Schema vocabulary for annotating JSON + documents with hyperlinks and instructions for processing and + + + + +Andrews & Wright Expires November 26, 2019 [Page 3] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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 [RFC8288]. + + This specification will use the concepts, syntax, and terminology + defined by the JSON Schema core [json-schema] and JSON Schema + validation [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 [RFC2119]. + +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 + + + +Andrews & Wright Expires November 26, 2019 [Page 4] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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 [RFC3986], 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 + [json-schema]. + + The terms "applicable" and "attached" are to be interpreted as + defined in Section 3.1 of the JSON Schema core specification + [json-schema]. + + 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 [RFC8288]. + + The term "user agent" is to be interpreted as defined in Section 2.1 + of RFC 7230 [RFC7230], 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: + + + +Andrews & Wright Expires November 26, 2019 [Page 5] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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 [RFC8288], a + link consists of a context, a typed relation, a target, and + optionally additional target attributes. + + + + +Andrews & Wright Expires November 26, 2019 [Page 6] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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 + . + + The current URI for this vocabulary, known as the Hyper-Schema + vocabulary, is: . + + 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: . + + The link description format (Section 6) 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: . + + 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" (Section 7), and to show the output + generated by examples (Section 9). 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 . + + + + + +Andrews & Wright Expires November 26, 2019 [Page 7] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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 [json-schema], 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 + (Section 7.2), 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 [RFC8288]. 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 + + + +Andrews & Wright Expires November 26, 2019 [Page 8] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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" + (Section 6.3.1) and "rel" (Section 6.2.1) 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 [json-schema]). 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 [RFC6901] in place of + a URI fragment. The process for constructing a URI based on a URI + template is given in the URI Templating (Section 7.2) section. + + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 9] + +Internet-Draft JSON Hyper-Schema May 2019 + + +6.1.1. anchor + + This property sets the context URI of the link. The value of the + property is a URI Template [RFC6570], and the resulting URI-reference + [RFC3986] 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" (Section 6.3.1) property, with the + exception that "hrefSchema" (Section 6.6.1) 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 [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" (Section 6.1.1) 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. + + + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 10] + +Internet-Draft JSON Hyper-Schema May 2019 + + +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 + [RFC4287], 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 [RFC6573] 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. + + + +Andrews & Wright Expires November 26, 2019 [Page 11] + +Internet-Draft JSON Hyper-Schema May 2019 + + + As such a method would correspond to JSON Hyper-Schema's data + submission concept, the "submissionSchema" (Section 6.6.4.2) 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 [RFC8288]. 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 [RFC4151]. + + 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" (Section 6.6.1), 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 7.2) 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 [RFC3986] + 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 7.2) 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 + + + + +Andrews & Wright Expires November 26, 2019 [Page 12] + +Internet-Draft JSON Hyper-Schema May 2019 + + + "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 [RFC6901], or a valid Relative JSON Pointer + [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. + + + + +Andrews & Wright Expires November 26, 2019 [Page 13] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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 + [RFC2046], 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 [RFC7231]. + + 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" (Section 10) 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" (Section 6.6.2). 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 8) 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 + + + +Andrews & Wright Expires November 26, 2019 [Page 14] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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" (Section 8) 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 + + + + +Andrews & Wright Expires November 26, 2019 [Page 15] + +Internet-Draft JSON Hyper-Schema May 2019 + + + other user agent data for filling out the URI Template in "href" + (Section 6.3.1). + + 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 + + + +Andrews & Wright Expires November 26, 2019 [Page 16] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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 8) 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" (Section 6.5.4) 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" (Section 8) for detailed examples. + +6.6.4. Submitting Data for Processing + + The "submissionSchema" (Section 6.6.4.2) and "submissionMediaType" + (Section 6.6.4.1) 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. + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 17] + +Internet-Draft JSON Hyper-Schema May 2019 + + +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" (Section 6.6.4.2). + + 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" (Section 6.5.4) + 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 6.2) 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: + + + + + +Andrews & Wright Expires November 26, 2019 [Page 18] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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" + (Section 5.1) values necessary to resolve each LDO's URI Templates + + + +Andrews & Wright Expires November 26, 2019 [Page 19] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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 [RFC6570]: "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: + + o "ldo.templatePointers" is an empty object if the keyword was not + present and "ldo.templateRequired" is likewise an empty array. + + o "attachmentPointer" is the absolute JSON Pointer for the + attachment location of the LDO. + + o "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: + + + +Andrews & Wright Expires November 26, 2019 [Page 20] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 1. Populate template variable data from the instance + + 2. If input is desired, accept input + + 3. Check that all required variables have a value + + 4. Encode values into strings and fill out the template + + 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. Otherwise, look for a property name matching the variable in the + instance location to which the link is attached + + 3. In either case, if there is a value at the location, put it in + the template resolution data set + + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 21] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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. Pre-populate the input data set if the template resolution data + set has a value + + 3. Accept input (present a web form, make a callback, etc.) + + 4. Validate the input data set, (not the template resolution data + set) + + 5. Put the input in the template resolution data set, overriding any + existing values + + + + + + + + + + + + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 22] + +Internet-Draft JSON Hyper-Schema May 2019 + + + "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. + + + + + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 23] + +Internet-Draft JSON Hyper-Schema May 2019 + + + for varname in templateData: + value = templateData[varname] + if value is true: + templateData[varname] = "true" + else if value is false: + temlateData[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. + + + + + +Andrews & Wright Expires November 26, 2019 [Page 24] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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 + + + +Andrews & Wright Expires November 26, 2019 [Page 25] + +Internet-Draft JSON Hyper-Schema May 2019 + + + schemas and use appropriate media types (e.g. "application/ + problem+json" [RFC7807] 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 [json-schema] + 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 + + + + +Andrews & Wright Expires November 26, 2019 [Page 26] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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 + (Section 6.2.1) 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" [RFC7231]. + + + + +Andrews & Wright Expires November 26, 2019 [Page 27] + +Internet-Draft JSON Hyper-Schema May 2019 + + + Per RFC 5789 [RFC5789], 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" [I-D.reschke-http-jfv]. 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 + + + +Andrews & Wright Expires November 26, 2019 [Page 28] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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: + + o Method allowance + + o Method-specific request media types + + o 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" [I-D.reschke-http-jfv] 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: + + o Content negotiation + + o Authentication and authorization + + + +Andrews & Wright Expires November 26, 2019 [Page 29] + +Internet-Draft JSON Hyper-Schema May 2019 + + + o Range requests + + o 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. + + + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 30] + +Internet-Draft JSON Hyper-Schema May 2019 + + +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 (Section 8). + +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: ; 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": "http://json-schema.org/draft/2019-04/hyper-schema#", + "base": "https://example.com/api/", + "links": [ + { + "rel": "self", + "href": "../api", + }, { + "rel": "about", + "href": "docs" + } + ] + } + + + +Andrews & Wright Expires November 26, 2019 [Page 31] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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. + + + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 32] + +Internet-Draft JSON Hyper-Schema May 2019 + + +9.2. Individually Identified Resources + + Let's add "things" to our system, starting with an individual thing: + + { + "$id": "https://schema.example.com/thing", + "$schema": "http://json-schema.org/draft/2019-04/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, + + + + +Andrews & Wright Expires November 26, 2019 [Page 33] + +Internet-Draft JSON Hyper-Schema May 2019 + + + so an extension relationship is defined using the "tag:" URI scheme + [RFC4151]: + + { + "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 + (Section 8). + + In this case, we use a "mailto:" URI, which, per RFC 6068, Section 3" + [RFC6068], 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". + + + + + +Andrews & Wright Expires November 26, 2019 [Page 34] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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": "http://json-schema.org/draft/2019-04/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" + }, + + + +Andrews & Wright Expires November 26, 2019 [Page 35] + +Internet-Draft JSON Hyper-Schema May 2019 + + + "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": + + + + +Andrews & Wright Expires November 26, 2019 [Page 36] + +Internet-Draft JSON Hyper-Schema May 2019 + + + { + "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=y + our%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. + + + + + +Andrews & Wright Expires November 26, 2019 [Page 37] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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: ; rel="self" + Link: ; rel="up"; + anchor="https://example.com/api/trees/1/nodes/456" + Link: ; 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. + + + + + + + + + + + + + + + + + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 38] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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": "http://json-schema.org/draft/2019-04/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. + + + + +Andrews & Wright Expires November 26, 2019 [Page 39] + +Internet-Draft JSON Hyper-Schema May 2019 + + +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. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 40] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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": "http://json-schema.org/draft/2019-04/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. + + + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 41] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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": "http://json-schema.org/draft/2019-04/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"} + } + ] + } + + + + + + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 42] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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" + }, + + + +Andrews & Wright Expires November 26, 2019 [Page 43] + +Internet-Draft JSON Hyper-Schema May 2019 + + + { + "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. + + + + +Andrews & Wright Expires November 26, 2019 [Page 44] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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": "#"} + + + +Andrews & Wright Expires November 26, 2019 [Page 45] + +Internet-Draft JSON Hyper-Schema May 2019 + + + }, { + "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. + + + + + + + + + + + + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 46] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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. + + + + + +Andrews & Wright Expires November 26, 2019 [Page 47] + +Internet-Draft JSON Hyper-Schema May 2019 + + + [[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. + + + + +Andrews & Wright Expires November 26, 2019 [Page 48] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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 [RFC8288] 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 + + + + +Andrews & Wright Expires November 26, 2019 [Page 49] + +Internet-Draft JSON Hyper-Schema May 2019 + + + 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. + ]] + + + + + +Andrews & Wright Expires November 26, 2019 [Page 50] + +Internet-Draft JSON Hyper-Schema May 2019 + + +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", draft-handrews-json-schema-02 + (work in progress), November 2017. + + [json-schema-validation] + Wright, A., Andrews, H., and G. Luff, "JSON Schema + Validation: A Vocabulary for Structural Validation of + JSON", draft-handrews-json-schema-validation-02 (work in + progress), November 2017. + + [relative-json-pointer] + Luff, G. and H. Andrews, "Relative JSON Pointers", draft- + handrews-relative-json-pointer-02 (work in progress), + 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., Ed. and R. Sayre, Ed., "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, + . + + + +Andrews & Wright Expires November 26, 2019 [Page 51] + +Internet-Draft JSON Hyper-Schema May 2019 + + + [RFC6573] Amundsen, M., "The Item and Collection Link Relations", + RFC 6573, DOI 10.17487/RFC6573, April 2012, + . + + [RFC6901] Bryan, P., Ed., Zyp, K., and M. Nottingham, Ed., + "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", draft-reschke-http-jfv-06 (work in progress), + 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., Ed. and J. Reschke, Ed., "Hypertext Transfer + Protocol (HTTP/1.1): Message Syntax and Routing", + RFC 7230, DOI 10.17487/RFC7230, June 2014, + . + + [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer + Protocol (HTTP/1.1): Semantics and Content", RFC 7231, + DOI 10.17487/RFC7231, June 2014, + . + + + + + +Andrews & Wright Expires November 26, 2019 [Page 52] + +Internet-Draft JSON Hyper-Schema May 2019 + + + [RFC7807] Nottingham, M. and E. Wilde, "Problem Details for HTTP + APIs", RFC 7807, DOI 10.17487/RFC7807, March 2016, + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 53] + +Internet-Draft JSON Hyper-Schema May 2019 + + +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" + + + +Andrews & Wright Expires November 26, 2019 [Page 54] + +Internet-Draft JSON Hyper-Schema May 2019 + + + [RFC7807], 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) + + + + + +Andrews & Wright Expires November 26, 2019 [Page 55] + +Internet-Draft JSON Hyper-Schema May 2019 + + + * 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" + + + +Andrews & Wright Expires November 26, 2019 [Page 56] + +Internet-Draft JSON Hyper-Schema May 2019 + + + * 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 + + + +Andrews & Wright Expires November 26, 2019 [Page 57] + +Internet-Draft JSON Hyper-Schema May 2019 + + + * 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) + Riverbed Technology + 680 Folsom St. + San Francisco, CA + USA + + EMail: handrews@riverbed.com + + + Austin Wright (editor) + + EMail: aaa@bzfx.net + + + + + + + + + + + + + + + + + + + + + + + + +Andrews & Wright Expires November 26, 2019 [Page 58] diff --git a/work-in-progress/WIP-jsonschema-validation.html b/work-in-progress/WIP-jsonschema-validation.html new file mode 100644 index 00000000..64f417fd --- /dev/null +++ b/work-in-progress/WIP-jsonschema-validation.html @@ -0,0 +1,1380 @@ + + + + + + + JSON Schema Validation: A Vocabulary for Structural Validation of JSON + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Internet Engineering Task ForceA. Wright, Ed.
Internet-Draft
Intended status: InformationalH. Andrews, Ed.
Expires: November 26, 2019Riverbed Technology
B. Hutton, Ed.
Wellcome Sanger Institute
G. Luff
May 25, 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 <http://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 November 26, 2019.

+

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 and Section 8 keywords are also useful as annotations as well as being optional assertions, as they convey additional usage guidance for the instance data.

+

+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 JSON Schema Validation meta-schema is <http://json-schema.org/draft/2019-04/schenma#>. For schema author convenience, this meta-schema describes all vocabularies defined in this specification and the JSON Schema Core specification. Individual vocabulary and vocabulary meta-schema URIs are given for each section below.

+

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-04/vocab/validation>.

+

The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-04/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 Validation With "format" +

+

+7.1. Foreword

+

Structural validation alone may be insufficient to validate that an instance meets all the requirements of an application. The "format" keyword is defined to allow interoperable semantic validation 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.

+

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, although 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-04/vocab/format>.

+

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

+

+7.2. Implementation Requirements

+

The "format" keyword functions as both an annotation and as an assertion. While no special effort is required to implement it as an annotation conveying semantic meaning, implementing validation is non-trivial.

+

Implementations MAY support the "format" keyword as a validation assertion. Should they choose to do so:

+ +
    +
  • they SHOULD implement validation for attributes defined below;
  • +
  • they SHOULD offer an option to disable validation for this keyword.
  • +
+ +

+

Implementations MAY add custom format attributes. Save for agreement between parties, schema authors SHALL NOT expect a peer implementation to support this keyword and/or custom format attributes.

+

+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. [CREF1]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

+

Properties defined in this section indicate that an instance contains non-JSON data encoded in a JSON string. They describe the type of content and how it is encoded.

+

These properties provide additional information required to interpret JSON data as rich multimedia documents.

+

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, although see the Implementation Requirements below for details.

+

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

+

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

+

+8.2. Implementation Requirements

+

The content keywords function as both annotations and as assertions. While no special effort is required to implement them as annotations conveying how applications can interpret the data in the string, implementing validation of conformance to the media type and encoding is non-trivial.

+

Implementations MAY support the "contentMediaType" and "contentEncoding" keywords as validation assertions. Should they choose to do so, they SHOULD offer an option to disable validation for 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.

+

The value of this property SHOULD be ignored if the instance described is not a string.

+

+8.4. contentMediaType

+

If the instance is a string, this property defines 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.

+

The value of this property SHOULD be ignored if the instance described is not a string.

+

+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 the instance described is not a string, or 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 should 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 should 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-04/vocab/meta-data>.

+

The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-04/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, the resulting value MUST be true if any occurrence specifies a true value, and MUST be false otherwise.

+

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 the entire root schema MAY be removed in the future.

+

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 value MUST be true if any occurrence specifies a true value, and MUST be false 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.
+
"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. 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

+

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

+

+ +
+
draft-handrews-json-schema-validation-02
+
+
    +
  • 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
  • +
  • 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) + + + Riverbed Technology + + 680 Folsom St. + + + San Francisco, + CA + + + USA + + EMail: handrews@riverbed.com + +
+
+
+ + Ben Hutton (editor) + + + Wellcome Sanger Institute + + + + + + + + + + EMail: bh7@sanger.ac.uk + +
+
+
+ + Geraint Luff + + + + + + + Cambridge, + + + + UK + + EMail: luffgd@gmail.com + +
+
+ + + diff --git a/work-in-progress/WIP-jsonschema-validation.txt b/work-in-progress/WIP-jsonschema-validation.txt new file mode 100644 index 00000000..5d9d78b7 --- /dev/null +++ b/work-in-progress/WIP-jsonschema-validation.txt @@ -0,0 +1,1512 @@ + + + + +Internet Engineering Task Force A. Wright, Ed. +Internet-Draft +Intended status: Informational H. Andrews, Ed. +Expires: November 26, 2019 Riverbed Technology + B. Hutton, Ed. + Wellcome Sanger Institute + G. Luff + May 25, 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 . + + For additional information, see . + + 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 November 26, 2019. + + + + +Wright, et al. Expires November 26, 2019 [Page 1] + +Internet-Draft JSON Schema Validation May 2019 + + +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 . . . . . . . . . . . . . . . . . . . . . . . . 3 + 2. Conventions and Terminology . . . . . . . . . . . . . . . . . 4 + 3. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 4 + 4. Interoperability Considerations . . . . . . . . . . . . . . . 4 + 4.1. Validation of String Instances . . . . . . . . . . . . . 4 + 4.2. Validation of Numeric Instances . . . . . . . . . . . . . 5 + 4.3. Regular Expressions . . . . . . . . . . . . . . . . . . . 5 + 5. Meta-Schema . . . . . . . . . . . . . . . . . . . . . . . . . 5 + 6. A Vocabulary for Structural Validation . . . . . . . . . . . 5 + 6.1. Validation Keywords for Any Instance Type . . . . . . . . 6 + 6.1.1. type . . . . . . . . . . . . . . . . . . . . . . . . 6 + 6.1.2. enum . . . . . . . . . . . . . . . . . . . . . . . . 6 + 6.1.3. const . . . . . . . . . . . . . . . . . . . . . . . . 6 + 6.2. Validation Keywords for Numeric Instances (number and + integer) . . . . . . . . . . . . . . . . . . . . . . . . 6 + 6.2.1. multipleOf . . . . . . . . . . . . . . . . . . . . . 6 + 6.2.2. maximum . . . . . . . . . . . . . . . . . . . . . . . 7 + 6.2.3. exclusiveMaximum . . . . . . . . . . . . . . . . . . 7 + 6.2.4. minimum . . . . . . . . . . . . . . . . . . . . . . . 7 + 6.2.5. exclusiveMinimum . . . . . . . . . . . . . . . . . . 7 + 6.3. Validation Keywords for Strings . . . . . . . . . . . . . 7 + 6.3.1. maxLength . . . . . . . . . . . . . . . . . . . . . . 7 + 6.3.2. minLength . . . . . . . . . . . . . . . . . . . . . . 8 + 6.3.3. pattern . . . . . . . . . . . . . . . . . . . . . . . 8 + 6.4. Validation Keywords for Arrays . . . . . . . . . . . . . 8 + 6.4.1. maxItems . . . . . . . . . . . . . . . . . . . . . . 8 + 6.4.2. minItems . . . . . . . . . . . . . . . . . . . . . . 8 + 6.4.3. uniqueItems . . . . . . . . . . . . . . . . . . . . . 8 + 6.4.4. maxContains . . . . . . . . . . . . . . . . . . . . . 9 + 6.4.5. minContains . . . . . . . . . . . . . . . . . . . . . 9 + 6.5. Validation Keywords for Objects . . . . . . . . . . . . . 9 + + + +Wright, et al. Expires November 26, 2019 [Page 2] + +Internet-Draft JSON Schema Validation May 2019 + + + 6.5.1. maxProperties . . . . . . . . . . . . . . . . . . . . 9 + 6.5.2. minProperties . . . . . . . . . . . . . . . . . . . . 9 + 6.5.3. required . . . . . . . . . . . . . . . . . . . . . . 10 + 6.5.4. dependentRequired . . . . . . . . . . . . . . . . . . 10 + 7. A Vocabulary for Semantic Validation With "format" . . . . . 10 + 7.1. Foreword . . . . . . . . . . . . . . . . . . . . . . . . 10 + 7.2. Implementation Requirements . . . . . . . . . . . . . . . 11 + 7.3. Defined Formats . . . . . . . . . . . . . . . . . . . . . 11 + 7.3.1. Dates, Times, and Duration . . . . . . . . . . . . . 11 + 7.3.2. Email Addresses . . . . . . . . . . . . . . . . . . . 12 + 7.3.3. Hostnames . . . . . . . . . . . . . . . . . . . . . . 12 + 7.3.4. IP Addresses . . . . . . . . . . . . . . . . . . . . 13 + 7.3.5. Resource Identifiers . . . . . . . . . . . . . . . . 13 + 7.3.6. uri-template . . . . . . . . . . . . . . . . . . . . 13 + 7.3.7. JSON Pointers . . . . . . . . . . . . . . . . . . . . 14 + 7.3.8. regex . . . . . . . . . . . . . . . . . . . . . . . . 14 + 8. A Vocabulary for the Contents of String-Encoded Data . . . . 14 + 8.1. Foreword . . . . . . . . . . . . . . . . . . . . . . . . 14 + 8.2. Implementation Requirements . . . . . . . . . . . . . . . 15 + 8.3. contentEncoding . . . . . . . . . . . . . . . . . . . . . 15 + 8.4. contentMediaType . . . . . . . . . . . . . . . . . . . . 15 + 8.5. contentSchema . . . . . . . . . . . . . . . . . . . . . . 16 + 8.6. Example . . . . . . . . . . . . . . . . . . . . . . . . . 16 + 9. A Vocabulary for Basic Meta-Data Annotations . . . . . . . . 17 + 9.1. "title" and "description" . . . . . . . . . . . . . . . . 18 + 9.2. "default" . . . . . . . . . . . . . . . . . . . . . . . . 18 + 9.3. "deprecated" . . . . . . . . . . . . . . . . . . . . . . 18 + 9.4. "readOnly" and "writeOnly" . . . . . . . . . . . . . . . 18 + 9.5. "examples" . . . . . . . . . . . . . . . . . . . . . . . 19 + 10. Security Considerations . . . . . . . . . . . . . . . . . . . 20 + 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 20 + 11.1. Normative References . . . . . . . . . . . . . . . . . . 20 + 11.2. Informative References . . . . . . . . . . . . . . . . . 22 + Appendix A. Keywords Moved from Validation to Core . . . . . . . 23 + Appendix B. Acknowledgments . . . . . . . . . . . . . . . . . . 23 + Appendix C. ChangeLog . . . . . . . . . . . . . . . . . . . . . 24 + Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 27 + +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. + + + +Wright, et al. Expires November 26, 2019 [Page 3] + +Internet-Draft JSON Schema Validation May 2019 + + +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 and + Section 8 keywords are also useful as annotations as well as being + optional assertions, as they convey additional usage guidance for the + instance data. + +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. + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 4] + +Internet-Draft JSON Schema Validation May 2019 + + +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 JSON Schema Validation meta-schema is + . For schema author + convenience, this meta-schema describes all vocabularies defined in + this specification and the JSON Schema Core specification. + Individual vocabulary and vocabulary meta-schema URIs are given for + each section below. + + 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: . + + The current URI for the corresponding meta-schema is: . + + + + + +Wright, et al. Expires November 26, 2019 [Page 5] + +Internet-Draft JSON Schema Validation May 2019 + + +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" + (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. + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 6] + +Internet-Draft JSON Schema Validation May 2019 + + +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 [RFC8259]. + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 7] + +Internet-Draft JSON Schema Validation May 2019 + + +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. + + + + +Wright, et al. Expires November 26, 2019 [Page 8] + +Internet-Draft JSON Schema Validation May 2019 + + + 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" + [json-schema] 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" + [json-schema] 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. + + + +Wright, et al. Expires November 26, 2019 [Page 9] + +Internet-Draft JSON Schema Validation May 2019 + + +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 Validation With "format" + +7.1. Foreword + + Structural validation alone may be insufficient to validate that an + instance meets all the requirements of an application. The "format" + keyword is defined to allow interoperable semantic validation 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. + + 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, although see the Implementation Requirements below for details. + + + + + +Wright, et al. Expires November 26, 2019 [Page 10] + +Internet-Draft JSON Schema Validation May 2019 + + + The current URI for this vocabulary, known as the Format vocabulary, + is: . + + The current URI for the corresponding meta-schema is: . + +7.2. Implementation Requirements + + The "format" keyword functions as both an annotation and as an + assertion. While no special effort is required to implement it as an + annotation conveying semantic meaning, implementing validation is + non-trivial. + + Implementations MAY support the "format" keyword as a validation + assertion. Should they choose to do so: + + they SHOULD implement validation for attributes defined below; + + they SHOULD offer an option to disable validation for this + keyword. + + Implementations MAY add custom format attributes. Save for agreement + between parties, schema authors SHALL NOT expect a peer + implementation to support this keyword and/or custom format + attributes. + +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" 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. + + + + +Wright, et al. Expires November 26, 2019 [Page 11] + +Internet-Draft JSON Schema Validation May 2019 + + + 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. [[CREF1: 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 [RFC5322]. + + idn-email: As defined by RFC 6531 [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. + + + +Wright, et al. Expires November 26, 2019 [Page 12] + +Internet-Draft JSON Schema Validation May 2019 + + +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]. + + + +Wright, et al. Expires November 26, 2019 [Page 13] + +Internet-Draft JSON Schema Validation May 2019 + + + 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 + + Properties defined in this section indicate that an instance contains + non-JSON data encoded in a JSON string. They describe the type of + content and how it is encoded. + + These properties provide additional information required to interpret + JSON data as rich multimedia documents. + + 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, although see the Implementation Requirements below for details. + + The current URI for this vocabulary, known as the Content vocabulary, + is: . + + + + +Wright, et al. Expires November 26, 2019 [Page 14] + +Internet-Draft JSON Schema Validation May 2019 + + + The current URI for the corresponding meta-schema is: . + +8.2. Implementation Requirements + + The content keywords function as both annotations and as assertions. + While no special effort is required to implement them as annotations + conveying how applications can interpret the data in the string, + implementing validation of conformance to the media type and encoding + is non-trivial. + + Implementations MAY support the "contentMediaType" and + "contentEncoding" keywords as validation assertions. Should they + choose to do so, they SHOULD offer an option to disable validation + for 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 + [RFC2045] and RFC 4648 [RFC4648]. 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" (Section 6.3.3) 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. + + The value of this property SHOULD be ignored if the instance + described is not a string. + +8.4. contentMediaType + + If the instance is a string, this property defines 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]. + + + + + +Wright, et al. Expires November 26, 2019 [Page 15] + +Internet-Draft JSON Schema Validation May 2019 + + + The value of this property SHOULD be ignored if the instance + described is not a string. + +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 the instance + described is not a string, or 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 should 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 should 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. + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 16] + +Internet-Draft JSON Schema Validation May 2019 + + + 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. + + + +Wright, et al. Expires November 26, 2019 [Page 17] + +Internet-Draft JSON Schema Validation May 2019 + + + The current URI for this vocabulary, known as the Meta-Data + vocabulary, is: . + + The current URI for the corresponding meta-schema is: . + +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, + the resulting value MUST be true if any occurrence specifies a true + value, and MUST be false otherwise. + + 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 + the entire root schema MAY be removed in the future. + + 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- + + + + +Wright, et al. Expires November 26, 2019 [Page 18] + +Internet-Draft JSON Schema Validation May 2019 + + + instance, the resulting value MUST be true if any occurrence + specifies a true value, and MUST be false 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. + + + + + +Wright, et al. Expires November 26, 2019 [Page 19] + +Internet-Draft JSON Schema Validation May 2019 + + + 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 + + [ecma262] "ECMA 262 specification", . + + [json-schema] + Wright, A. and H. Andrews, "JSON Schema: A Media Type for + Describing JSON Documents", draft-handrews-json-schema-02 + (work in progress), November 2017. + + [relative-json-pointer] + Luff, G. and H. Andrews, "Relative JSON Pointers", draft- + handrews-relative-json-pointer-01 (work in progress), + November 2017. + + + +Wright, et al. Expires November 26, 2019 [Page 20] + +Internet-Draft JSON Schema Validation May 2019 + + + [RFC1123] Braden, R., Ed., "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, . + + + + + + +Wright, et al. Expires November 26, 2019 [Page 21] + +Internet-Draft JSON Schema Validation May 2019 + + + [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data + Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, + . + + [RFC5322] Resnick, P., Ed., "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., Ed., Zyp, K., and M. Nottingham, Ed., + "JavaScript Object Notation (JSON) Pointer", RFC 6901, + DOI 10.17487/RFC6901, April 2013, + . + + [RFC8259] Bray, T., Ed., "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, + . + + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 22] + +Internet-Draft JSON Schema Validation May 2019 + + +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. + + "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. 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. + + + + + + +Wright, et al. Expires November 26, 2019 [Page 23] + +Internet-Draft JSON Schema Validation May 2019 + + +Appendix C. ChangeLog + + [[CREF2: This section to be removed before leaving Internet-Draft + status.]] + + draft-handrews-json-schema-validation-02 + + * 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 + + * 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 + + + +Wright, et al. Expires November 26, 2019 [Page 24] + +Internet-Draft JSON Schema Validation May 2019 + + + * 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 + + + + +Wright, et al. Expires November 26, 2019 [Page 25] + +Internet-Draft JSON Schema Validation May 2019 + + + * 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. + + + + + +Wright, et al. Expires November 26, 2019 [Page 26] + +Internet-Draft JSON Schema Validation May 2019 + + +Authors' Addresses + + Austin Wright (editor) + + EMail: aaa@bzfx.net + + + Henry Andrews (editor) + Riverbed Technology + 680 Folsom St. + San Francisco, CA + USA + + EMail: handrews@riverbed.com + + + Ben Hutton (editor) + Wellcome Sanger Institute + + EMail: bh7@sanger.ac.uk + + + Geraint Luff + Cambridge + UK + + EMail: luffgd@gmail.com + + + + + + + + + + + + + + + + + + + + + + + + +Wright, et al. Expires November 26, 2019 [Page 27] diff --git a/work-in-progress/WIP-links.json b/work-in-progress/WIP-links.json new file mode 100644 index 00000000..a5d5469c --- /dev/null +++ b/work-in-progress/WIP-links.json @@ -0,0 +1,91 @@ +{ + "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#", + "$id": "http://json-schema.org/draft/2019-04/links", + "title": "Link Description Object", + "allOf": [ + { "required": [ "rel", "href" ] }, + { "$ref": "#/$defs/noRequiredFields" } + ], + "$defs": { + "noRequiredFields": { + "type": "object", + "properties": { + "anchor": { + "type": "string", + "format": "uri-template" + }, + "anchorPointer": { + "type": "string", + "anyOf": [ + { "format": "json-pointer" }, + { "format": "relative-json-pointer" } + ] + }, + "rel": { + "anyOf": [ + { "type": "string" }, + { + "type": "array", + "items": { "type": "string" }, + "minItems": 1 + } + ] + }, + "href": { + "type": "string", + "format": "uri-template" + }, + "hrefSchema": { + "$recursiveRef": "http://json-schema.org/draft/2019-04/hyper-schema", + "default": false + }, + "templatePointers": { + "type": "object", + "additionalProperties": { + "type": "string", + "anyOf": [ + { "format": "json-pointer" }, + { "format": "relative-json-pointer" } + ] + } + }, + "templateRequired": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "targetSchema": { + "$recursiveRef": "http://json-schema.org/draft/2019-04/hyper-schema", + "default": true + }, + "targetMediaType": { + "type": "string" + }, + "targetHints": { }, + "headerSchema": { + "$recursiveRef": "http://json-schema.org/draft/2019-04/hyper-schema", + "default": true + }, + "submissionMediaType": { + "type": "string", + "default": "application/json" + }, + "submissionSchema": { + "$recursiveRef": "http://json-schema.org/draft/2019-04/hyper-schema", + "default": true + }, + "$comment": { + "type": "string" + } + } + } + } +} diff --git a/work-in-progress/WIP-relative-json-pointer.html b/work-in-progress/WIP-relative-json-pointer.html new file mode 100644 index 00000000..c9784f06 --- /dev/null +++ b/work-in-progress/WIP-relative-json-pointer.html @@ -0,0 +1,692 @@ + + + + + + + Relative JSON Pointers + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Internet Engineering Task ForceG. Luff
Internet-Draft
Intended status: InformationalH. Andrews, Ed.
Expires: November 26, 2019Riverbed Technology
May 25, 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 November 26, 2019.

+

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) + + + Riverbed Technology + + 680 Folsom St. + + + San Francisco, + CA + + + USA + + EMail: handrews@riverbed.com + +
+
+ + + diff --git a/work-in-progress/WIP-relative-json-pointer.txt b/work-in-progress/WIP-relative-json-pointer.txt new file mode 100644 index 00000000..eba2d3c2 --- /dev/null +++ b/work-in-progress/WIP-relative-json-pointer.txt @@ -0,0 +1,392 @@ + + + + +Internet Engineering Task Force G. Luff +Internet-Draft +Intended status: Informational H. Andrews, Ed. +Expires: November 26, 2019 Riverbed Technology + May 25, 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 November 26, 2019. + +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. + + + +Luff & Andrews Expires November 26, 2019 [Page 1] + +Internet-Draft Relative JSON Pointers May 2019 + + +Table of Contents + + 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 + 2. Conventions and Terminology . . . . . . . . . . . . . . . . . 2 + 3. Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 + 4. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . 3 + 5. JSON String Representation . . . . . . . . . . . . . . . . . 4 + 5.1. Examples . . . . . . . . . . . . . . . . . . . . . . . . 4 + 6. Non-use in URI Fragment Identifiers . . . . . . . . . . . . . 5 + 7. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 5 + 8. Relationship to JSON Pointer . . . . . . . . . . . . . . . . 5 + 9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 5 + 10. Security Considerations . . . . . . . . . . . . . . . . . . . 5 + 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 6 + 11.1. Normative References . . . . . . . . . . . . . . . . . . 6 + 11.2. Informative References . . . . . . . . . . . . . . . . . 6 + Appendix A. ChangeLog . . . . . . . . . . . . . . . . . . . . . 7 + Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 7 + +1. Introduction + + JSON Pointer (RFC 6901 [RFC6901]) 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 [RFC2119]. + +3. Syntax + + A Relative JSON Pointer is a Unicode string in UTF-8 encoding (see + RFC 8259, Section 8 [RFC8259]), comprising a non-negative integer, + followed by either a '#' (%x23) character or a JSON Pointer (RFC 6901 + [RFC6901]). + + 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 '#'. + + + + + + + + +Luff & Andrews Expires November 26, 2019 [Page 2] + +Internet-Draft Relative JSON Pointers May 2019 + + + 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 follows the production defined in RFC 6901, + Section 3 [RFC6901] ("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 remainder of the Relative JSON Pointer is a JSON Pointer, then + evaluation proceeds as per RFC 6901, Section 4 [RFC6901] + ("Evaluation"), 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. + + + +Luff & Andrews Expires November 26, 2019 [Page 3] + +Internet-Draft Relative JSON Pointers May 2019 + + + 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 + [RFC6901]. + +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" + + + + + + +Luff & Andrews Expires November 26, 2019 [Page 4] + +Internet-Draft Relative JSON Pointers May 2019 + + +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. + + + +Luff & Andrews Expires November 26, 2019 [Page 5] + +Internet-Draft Relative JSON Pointers May 2019 + + +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., Ed., Zyp, K., and M. Nottingham, Ed., + "JavaScript Object Notation (JSON) Pointer", RFC 6901, + DOI 10.17487/RFC6901, April 2013, + . + +11.2. Informative References + + [RFC8259] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data + Interchange Format", STD 90, RFC 8259, + DOI 10.17487/RFC8259, December 2017, + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Luff & Andrews Expires November 26, 2019 [Page 6] + +Internet-Draft Relative JSON Pointers May 2019 + + +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) + Riverbed Technology + 680 Folsom St. + San Francisco, CA + USA + + EMail: handrews@riverbed.com + + + + + + + + + + + + +Luff & Andrews Expires November 26, 2019 [Page 7] diff --git a/work-in-progress/WIP-schema.json b/work-in-progress/WIP-schema.json new file mode 100644 index 00000000..74215b30 --- /dev/null +++ b/work-in-progress/WIP-schema.json @@ -0,0 +1,42 @@ +{ + "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "http://json-schema.org/draft/2019-04/schema#", + "$vocabulary": { + "https://json-schema.org/draft/2019-04/vocab/core": true, + "https://json-schema.org/draft/2019-04/vocab/applicator": true, + "https://json-schema.org/draft/2019-04/vocab/validation": true, + "https://json-schema.org/draft/2019-04/vocab/meta-data": true, + "https://json-schema.org/draft/2019-04/vocab/format": true, + "https://json-schema.org/draft/2019-04/vocab/content": true + }, + "$recursiveAnchor": true, + + "title": "Core and Validation specifications meta-schema", + "allOf": [ + {"$ref": "meta/core"}, + {"$ref": "meta/applicator"}, + {"$ref": "meta/validation"}, + {"$ref": "meta/meta-data"}, + {"$ref": "meta/format"}, + {"$ref": "meta/content"} + ], + "type": ["object", "boolean"], + "properties": { + "definitions": { + "$comment": "While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.", + "type": "object", + "additionalProperties": { "$recursiveRef": "#" }, + "default": {} + }, + "dependencies": { + "$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"", + "type": "object", + "additionalProperties": { + "anyOf": [ + { "$recursiveRef": "#" }, + { "$ref": "meta/validation#/$defs/stringArray" } + ] + } + } + } +} diff --git a/work-in-progress/meta/WIP-applicator.json b/work-in-progress/meta/WIP-applicator.json new file mode 100644 index 00000000..43b104ef --- /dev/null +++ b/work-in-progress/meta/WIP-applicator.json @@ -0,0 +1,60 @@ +{ + "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "https://json-schema.org/draft/2019-04/meta/applicator", + "$vocabulary": { + "https://json-schema.org/draft/2019-04/vocab/applicator": true + }, + "$recursiveAnchor": true, + + "title": "Applicator vocabulary meta-schema", + "properties": { + "additionalItems": { "$recursiveRef": "#" }, + "unevaluatedItems": { "$recursiveRef": "#" }, + "items": { + "anyOf": [ + { "$recursiveRef": "#" }, + { "$ref": "#/$defs/schemaArray" } + ] + }, + "contains": { "$recursiveRef": "#" }, + "additionalProperties": { "$recursiveRef": "#" }, + "unevaluatedProperties": { + "type": "object", + "additionalProperties": { + "$recursiveRef": "#" + } + }, + "properties": { + "type": "object", + "additionalProperties": { "$recursiveRef": "#" }, + "default": {} + }, + "patternProperties": { + "type": "object", + "additionalProperties": { "$recursiveRef": "#" }, + "propertyNames": { "format": "regex" }, + "default": {} + }, + "dependentSchemas": { + "type": "object", + "additionalProperties": { + "$recursiveRef": "#" + } + }, + "propertyNames": { "$recursiveRef": "#" }, + "if": { "$recursiveRef": "#" }, + "then": { "$recursiveRef": "#" }, + "else": { "$recursiveRef": "#" }, + "allOf": { "$ref": "#/$defs/schemaArray" }, + "anyOf": { "$ref": "#/$defs/schemaArray" }, + "oneOf": { "$ref": "#/$defs/schemaArray" }, + "not": { "$recursiveRef": "#" } + }, + "$defs": { + "schemaArray": { + "type": "array", + "minItems": 1, + "items": { "$recursiveRef": "#" } + } + } +} diff --git a/work-in-progress/meta/WIP-content.json b/work-in-progress/meta/WIP-content.json new file mode 100644 index 00000000..2262099a --- /dev/null +++ b/work-in-progress/meta/WIP-content.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "http://json-schema.org/draft/2019-04/meta/content", + "$vocabulary": { + "https://json-schema.org/draft/2019-04/vocab/content": true + }, + "$recursiveAnchor": true, + + "title": "Content vocabulary meta-schema", + + "type": ["object", "boolean"], + "properties": { + "contentMediaType": { "type": "string" }, + "contentEncoding": { "type": "string" }, + "contentSchema": { "$recursiveRef": "#" } + } +} diff --git a/work-in-progress/meta/WIP-core.json b/work-in-progress/meta/WIP-core.json new file mode 100644 index 00000000..6ba4329e --- /dev/null +++ b/work-in-progress/meta/WIP-core.json @@ -0,0 +1,52 @@ +{ + "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "https://json-schema.org/draft/2019-04/meta/core", + "$vocabulary": { + "https://json-schema.org/draft/2019-04/vocab/core": true + }, + "$recursiveAnchor": true, + + "title": "Core vocabulary meta-schema", + "type": ["object", "boolean"], + "properties": { + "$id": { + "type": "string", + "format": "uri-reference" + }, + "$schema": { + "type": "string", + "format": "uri" + }, + "$ref": { + "type": "string", + "format": "uri-reference" + }, + "$recursiveRef": { + "type": "string", + "format": "uri-reference" + }, + "$recursiveAnchor": { + "type": "boolean", + "const": true, + "default": false + }, + "$vocabulary": { + "type": "object", + "propertyNames": { + "type": "string", + "format": "uri" + }, + "additionalProperties": { + "type": "boolean" + } + }, + "$comment": { + "type": "string" + }, + "$defs": { + "type": "object", + "additionalProperties": { "$recursiveRef": "#" }, + "default": {} + } + } +} diff --git a/work-in-progress/meta/WIP-format.json b/work-in-progress/meta/WIP-format.json new file mode 100644 index 00000000..02970f37 --- /dev/null +++ b/work-in-progress/meta/WIP-format.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "http://json-schema.org/draft/2019-04/meta/format", + "$vocabulary": { + "https://json-schema.org/draft/2019-04/vocab/format": true + }, + "$recursiveAnchor": true, + + "title": "Format vocabulary meta-schema", + "type": ["object", "boolean"], + "properties": { + "format": { "type": "string" } + } +} diff --git a/work-in-progress/meta/WIP-hyper-schema.json b/work-in-progress/meta/WIP-hyper-schema.json new file mode 100644 index 00000000..8f427d4b --- /dev/null +++ b/work-in-progress/meta/WIP-hyper-schema.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#", + "$id": "http://json-schema.org/draft/2019-04/meta/hyper-schema", + "$vocabulary": { + "https://json-schema.org/draft/2019-04/vocab/hyper-schema": true + }, + "$recursiveAnchor": true, + + "title": "JSON Hyper-Schema Vocabulary Schema", + "type": ["object", "boolean"], + "properties": { + "base": { + "type": "string", + "format": "uri-template" + }, + "links": { + "type": "array", + "items": { + "$ref": "http://json-schema.org/draft/2019-04/links" + } + } + }, + "links": [ + { + "rel": "self", + "href": "{+%24id}" + } + ] +} diff --git a/work-in-progress/meta/WIP-meta-data.json b/work-in-progress/meta/WIP-meta-data.json new file mode 100644 index 00000000..1accce67 --- /dev/null +++ b/work-in-progress/meta/WIP-meta-data.json @@ -0,0 +1,37 @@ +{ + "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "http://json-schema.org/draft/2019-04/meta/meta-data", + "$vocabulary": { + "https://json-schema.org/draft/2019-04/vocab/meta-data": true + }, + "$recursiveAnchor": true, + + "title": "Meta-data vocabulary meta-schema", + + "type": ["object", "boolean"], + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "default": true, + "deprecated": { + "type": "boolean", + "default": false + }, + "readOnly": { + "type": "boolean", + "default": false + }, + "writeOnly": { + "type": "boolean", + "default": false + }, + "examples": { + "type": "array", + "items": true + } + } +} diff --git a/work-in-progress/meta/WIP-validation.json b/work-in-progress/meta/WIP-validation.json new file mode 100644 index 00000000..51db8864 --- /dev/null +++ b/work-in-progress/meta/WIP-validation.json @@ -0,0 +1,98 @@ +{ + "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "http://json-schema.org/draft/2019-04/meta/validation", + "$vocabulary": { + "https://json-schema.org/draft/2019-04/vocab/validation": true + }, + "$recursiveAnchor": true, + + "title": "Validation vocabulary meta-schema", + "type": ["object", "boolean"], + "properties": { + "multipleOf": { + "type": "number", + "exclusiveMinimum": 0 + }, + "maximum": { + "type": "number" + }, + "exclusiveMaximum": { + "type": "number" + }, + "minimum": { + "type": "number" + }, + "exclusiveMinimum": { + "type": "number" + }, + "maxLength": { "$ref": "#/$defs/nonNegativeInteger" }, + "minLength": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, + "pattern": { + "type": "string", + "format": "regex" + }, + "maxItems": { "$ref": "#/$defs/nonNegativeInteger" }, + "minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, + "uniqueItems": { + "type": "boolean", + "default": false + }, + "maxContains": { "$ref": "#/$defs/nonNegativeInteger" }, + "minContains": { + "$ref": "#/$defs/nonNegativeInteger", + "default": 1 + }, + "maxProperties": { "$ref": "#/$defs/nonNegativeInteger" }, + "minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, + "required": { "$ref": "#/$defs/stringArray" }, + "dependentRequired": { + "type": "object", + "additionalProperties": { + "$ref": "#/$defs/stringArray" + } + }, + "const": true, + "enum": { + "type": "array", + "items": true + }, + "type": { + "anyOf": [ + { "$ref": "#/$defs/simpleTypes" }, + { + "type": "array", + "items": { "$ref": "#/$defs/simpleTypes" }, + "minItems": 1, + "uniqueItems": true + } + ] + } + }, + "$defs": { + "nonNegativeInteger": { + "type": "integer", + "minimum": 0 + }, + "nonNegativeIntegerDefault0": { + "$ref": "#/$defs/nonNegativeInteger", + "default": 0 + }, + "simpleTypes": { + "enum": [ + "array", + "boolean", + "integer", + "null", + "number", + "object", + "string" + ] + }, + "stringArray": { + "type": "array", + "items": { "type": "string" }, + "uniqueItems": true, + "default": [] + } + } +} diff --git a/work-in-progress/output/WIP-hyper-schema.json b/work-in-progress/output/WIP-hyper-schema.json new file mode 100644 index 00000000..04e6e05a --- /dev/null +++ b/work-in-progress/output/WIP-hyper-schema.json @@ -0,0 +1,62 @@ +{ + "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "http://json-schema.org/draft/2019-04/output/hyper-schema", + "title": "JSON Hyper-Schema Output", + "type": "array", + "items": { + "allOf": [ + {"$ref": "http://json-schema.org/draft/2019-04/links#/$defs/noRequiredFields" } + ], + "type": "object", + "required": [ + "contextUri", + "contextPointer", + "rel", + "attachmentPointer" + ], + "if": { "required": [ "hrefSchema" ] }, + "then": { "required": [ "hrefInputTemplates", "hrefPrepopulatedInput" ] }, + "else": { "required": [ "targetUri" ] }, + "properties": { + "contextUri": { + "$comment": "The fully resolved URI of the link context, including a fragment if it is possible to construct one for the given media type and instance", + "type": "string", + "format": "uri" + }, + "contextPointer": { + "$comment": "The absolute JSON Pointer to the location in the instance that is the context of the link. If the context resource supports JSON Pointer fragments, this will the string form of the identical JSON Pointer", + "type": "string", + "format": "json-pointer" + }, + "rel": { + "type": "string" + }, + "targetUri": { + "$comment": "The fully resolved target URI", + "type": "string", + "format": "uri" + }, + "hrefInputTemplates": { + "$comment": "The list of partially resolved URI Templates, starting with \"href\", followed by applicable \"base\" values from nearest to furthest.", + "type": "array", + "items": { + "type": "string", + "format": "uri-template" + } + }, + "hrefPrepopulatedInput": { + "$comment": "The initial data set to be presented with the input form when URI Tempalte input is accepted.", + "type": "object", + "propertyNames": { + "$comment": "These are all URI Template variable names, specifically the 'varname' production from RFC 6570, Section 2.3", + "pattern": "^(?:\\w|(?:%[a-f\\d]{2}))+(?:\\.(?:\\w|(?:%[a-f\\d]{2})))*$" + } + }, + "attachmentPointer": { + "$comment": "The absolute JSON Pointer, in string form, of the position to which this resolved link applies", + "type": "string", + "format": "json-pointer" + } + } + } +} diff --git a/work-in-progress/output/WIP-schema.json b/work-in-progress/output/WIP-schema.json new file mode 100644 index 00000000..d9ab2cd1 --- /dev/null +++ b/work-in-progress/output/WIP-schema.json @@ -0,0 +1,86 @@ +{ + "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "http://json-schema.org/draft/2019-04/output/schema", + "description": "A schema that validates the minimum requirements for validation output", + + "oneOf": [ + { "$ref": "#/$defs/flag" }, + { "$ref": "#/$defs/basic" }, + { "$ref": "#/$defs/detailed" }, + { "$ref": "#/$defs/verbose" } + ], + "$defs": { + "outputUnit":{ + "properties": { + "valid": { "type": "boolean" }, + "keywordLocation": { + "type": "string", + "format": "uri-reference" + }, + "absoluteKeywordLocation": { + "type": "string", + "format": "uri" + }, + "instanceLocation": { + "type": "string", + "format": "uri-reference" + }, + "errors": { + "$ref": "#/$defs/outputUnitArray" + }, + "annotations": { + "$ref": "#/$defs/outputUnitArray" + } + }, + "required": [ "valid", "keywordLocation", "instanceLocation" ], + "allOf": [ + { + "if": { + "properties": { + "valid": { "const": false } + } + }, + "then": { + "required": [ "errors" ] + } + }, + { + "if": { + "oneOf": [ + { + "properties": { + "keywordLocation": { + "pattern": ".*/$ref/.*" + } + } + }, + { + "properties": { + "keywordLocation": { + "pattern": ".*/$recursiveRef/.*" + } + } + } + ] + }, + "then": { + "required": [ "absoluteKeywordLocation" ] + } + } + ] + }, + "outputUnitArray": { + "type": "array", + "items": { "$ref": "#/$defs/outputUnit" } + }, + "flag": { + "properties": { + "valid": { "type": "boolean" } + }, + "required": [ "valid" ] + }, + "basic": { "$ref": "#/outputUnit" }, + "detailed": { "$ref": "#/outputUnit" }, + "verbose": { "$ref": "#/outputUnit" } + } +} diff --git a/work-in-progress/output/WIP-verbose-example.json b/work-in-progress/output/WIP-verbose-example.json new file mode 100644 index 00000000..ef50444f --- /dev/null +++ b/work-in-progress/output/WIP-verbose-example.json @@ -0,0 +1,130 @@ +{ + "valid": false, + "keywordLocation": "#", + "instanceLocation": "#", + "errors": [ + { + "valid": true, + "keywordLocation": "#/definitions", + "instanceLocation": "#" + }, + { + "valid": true, + "keywordLocation": "#/type", + "instanceLocation": "#" + }, + { + "valid": false, + "keywordLocation": "#/items", + "instanceLocation": "#", + "errors": [ + { + "valid": true, + "keywordLocation": "#/items/$ref", + "absoluteKeywordLocation": + "http://example.com/polygon#/items/$ref", + "instanceLocation": "#/0", + "annotations": [ + { + "valid": true, + "keywordLocation": "#/items/$ref", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point", + "instanceLocation": "#/0", + "annotations": [ + { + "valid": true, + "keywordLocation": "#/items/$ref/type", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point/type", + "instanceLocation": "#/0" + }, + { + "valid": true, + "keywordLocation": "#/items/$ref/properties", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point/properties", + "instanceLocation": "#/0" + }, + { + "valid": true, + "keywordLocation": "#/items/$ref/required", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point/required", + "instanceLocation": "#/0" + }, + { + "valid": true, + "keywordLocation": "#/items/$ref/additionalProperties", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point/additionalProperties", + "instanceLocation": "#/0" + } + ] + } + ] + }, + { + "valid": false, + "keywordLocation": "#/items/$ref", + "absoluteKeywordLocation": + "http://example.com/polygon#/items/$ref", + "instanceLocation": "#/1", + "errors": [ + { + "valid": false, + "keywordLocation": "#/items/$ref", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point", + "instanceLocation": "#/1", + "errors": [ + { + "valid": true, + "keywordLocation": "#/items/$ref/type", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point/type", + "instanceLocation": "#/1" + }, + { + "valid": true, + "keywordLocation": "#/items/$ref/properties", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point/properties", + "instanceLocation": "#/1" + }, + { + "valid": false, + "keywordLocation": "#/items/$ref/required", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point/required", + "instanceLocation": "#/1" + }, + { + "valid": false, + "keywordLocation": "#/items/$ref/additionalProperties", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point/additionalProperties", + "instanceLocation": "#/1", + "errors": [ + { + "valid": false, + "keywordLocation": "#/items/$ref/additionalProperties", + "absoluteKeywordLocation": + "http://example.com/polygon#/definitions/point/additionalProperties", + "instanceLocation": "#/1/z" + } + ] + } + ] + } + ] + } + ] + }, + { + "valid": false, + "keywordLocation": "#/minItems", + "instanceLocation": "#" + } + ] +} From 06b996060e12f7368b46c7deb334bec546b0796d Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Sun, 26 May 2019 09:19:51 -0700 Subject: [PATCH 038/395] Mark JSON files as works in progress --- work-in-progress/WIP-hyper-schema.json | 22 +++++++++---------- work-in-progress/WIP-links.json | 12 +++++----- work-in-progress/WIP-schema.json | 16 +++++++------- work-in-progress/meta/WIP-applicator.json | 6 ++--- work-in-progress/meta/WIP-content.json | 6 ++--- work-in-progress/meta/WIP-core.json | 6 ++--- work-in-progress/meta/WIP-format.json | 6 ++--- work-in-progress/meta/WIP-hyper-schema.json | 8 +++---- work-in-progress/meta/WIP-meta-data.json | 6 ++--- work-in-progress/meta/WIP-validation.json | 6 ++--- work-in-progress/output/WIP-hyper-schema.json | 6 ++--- work-in-progress/output/WIP-schema.json | 4 ++-- 12 files changed, 52 insertions(+), 52 deletions(-) diff --git a/work-in-progress/WIP-hyper-schema.json b/work-in-progress/WIP-hyper-schema.json index 07d331dd..406455d3 100644 --- a/work-in-progress/WIP-hyper-schema.json +++ b/work-in-progress/WIP-hyper-schema.json @@ -1,21 +1,21 @@ { - "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#", - "$id": "http://json-schema.org/draft/2019-04/hyper-schema", + "$schema": "http://json-schema.org/draft/2019-WIP/hyper-schema#", + "$id": "http://json-schema.org/draft/2019-WIP/hyper-schema", "$vocabulary": { - "https://json-schema.org/draft/2019-04/vocab/core": true, - "https://json-schema.org/draft/2019-04/vocab/applicator": true, - "https://json-schema.org/draft/2019-04/vocab/validation": true, - "https://json-schema.org/draft/2019-04/vocab/meta-data": true, - "https://json-schema.org/draft/2019-04/vocab/format": true, - "https://json-schema.org/draft/2019-04/vocab/content": true, - "https://json-schema.org/draft/2019-04/vocab/hyper-schema": true + "https://json-schema.org/draft/2019-WIP/vocab/core": true, + "https://json-schema.org/draft/2019-WIP/vocab/applicator": true, + "https://json-schema.org/draft/2019-WIP/vocab/validation": true, + "https://json-schema.org/draft/2019-WIP/vocab/meta-data": true, + "https://json-schema.org/draft/2019-WIP/vocab/format": true, + "https://json-schema.org/draft/2019-WIP/vocab/content": true, + "https://json-schema.org/draft/2019-WIP/vocab/hyper-schema": true }, "$recursiveAnchor": true, "title": "JSON Hyper-Schema", "allOf": [ - {"$ref": "http://json-schema.org/draft/2019-04/schema"}, - {"$ref": "http://json-schema.org/draft/2019-04/meta/hyper-schema"} + {"$ref": "http://json-schema.org/draft/2019-WIP/schema"}, + {"$ref": "http://json-schema.org/draft/2019-WIP/meta/hyper-schema"} ], "links": [ { diff --git a/work-in-progress/WIP-links.json b/work-in-progress/WIP-links.json index a5d5469c..c5b3a20c 100644 --- a/work-in-progress/WIP-links.json +++ b/work-in-progress/WIP-links.json @@ -1,6 +1,6 @@ { - "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#", - "$id": "http://json-schema.org/draft/2019-04/links", + "$schema": "http://json-schema.org/draft/2019-WIP/hyper-schema#", + "$id": "http://json-schema.org/draft/2019-WIP/links", "title": "Link Description Object", "allOf": [ { "required": [ "rel", "href" ] }, @@ -36,7 +36,7 @@ "format": "uri-template" }, "hrefSchema": { - "$recursiveRef": "http://json-schema.org/draft/2019-04/hyper-schema", + "$recursiveRef": "http://json-schema.org/draft/2019-WIP/hyper-schema", "default": false }, "templatePointers": { @@ -63,7 +63,7 @@ "type": "string" }, "targetSchema": { - "$recursiveRef": "http://json-schema.org/draft/2019-04/hyper-schema", + "$recursiveRef": "http://json-schema.org/draft/2019-WIP/hyper-schema", "default": true }, "targetMediaType": { @@ -71,7 +71,7 @@ }, "targetHints": { }, "headerSchema": { - "$recursiveRef": "http://json-schema.org/draft/2019-04/hyper-schema", + "$recursiveRef": "http://json-schema.org/draft/2019-WIP/hyper-schema", "default": true }, "submissionMediaType": { @@ -79,7 +79,7 @@ "default": "application/json" }, "submissionSchema": { - "$recursiveRef": "http://json-schema.org/draft/2019-04/hyper-schema", + "$recursiveRef": "http://json-schema.org/draft/2019-WIP/hyper-schema", "default": true }, "$comment": { diff --git a/work-in-progress/WIP-schema.json b/work-in-progress/WIP-schema.json index 74215b30..6855b335 100644 --- a/work-in-progress/WIP-schema.json +++ b/work-in-progress/WIP-schema.json @@ -1,13 +1,13 @@ { - "$schema": "http://json-schema.org/draft/2019-04/schema#", - "$id": "http://json-schema.org/draft/2019-04/schema#", + "$schema": "http://json-schema.org/draft/2019-WIP/schema#", + "$id": "http://json-schema.org/draft/2019-WIP/schema#", "$vocabulary": { - "https://json-schema.org/draft/2019-04/vocab/core": true, - "https://json-schema.org/draft/2019-04/vocab/applicator": true, - "https://json-schema.org/draft/2019-04/vocab/validation": true, - "https://json-schema.org/draft/2019-04/vocab/meta-data": true, - "https://json-schema.org/draft/2019-04/vocab/format": true, - "https://json-schema.org/draft/2019-04/vocab/content": true + "https://json-schema.org/draft/2019-WIP/vocab/core": true, + "https://json-schema.org/draft/2019-WIP/vocab/applicator": true, + "https://json-schema.org/draft/2019-WIP/vocab/validation": true, + "https://json-schema.org/draft/2019-WIP/vocab/meta-data": true, + "https://json-schema.org/draft/2019-WIP/vocab/format": true, + "https://json-schema.org/draft/2019-WIP/vocab/content": true }, "$recursiveAnchor": true, diff --git a/work-in-progress/meta/WIP-applicator.json b/work-in-progress/meta/WIP-applicator.json index 43b104ef..73788361 100644 --- a/work-in-progress/meta/WIP-applicator.json +++ b/work-in-progress/meta/WIP-applicator.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft/2019-04/schema#", - "$id": "https://json-schema.org/draft/2019-04/meta/applicator", + "$schema": "http://json-schema.org/draft/2019-WIP/schema#", + "$id": "https://json-schema.org/draft/2019-WIP/meta/applicator", "$vocabulary": { - "https://json-schema.org/draft/2019-04/vocab/applicator": true + "https://json-schema.org/draft/2019-WIP/vocab/applicator": true }, "$recursiveAnchor": true, diff --git a/work-in-progress/meta/WIP-content.json b/work-in-progress/meta/WIP-content.json index 2262099a..79882081 100644 --- a/work-in-progress/meta/WIP-content.json +++ b/work-in-progress/meta/WIP-content.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft/2019-04/schema#", - "$id": "http://json-schema.org/draft/2019-04/meta/content", + "$schema": "http://json-schema.org/draft/2019-WIP/schema#", + "$id": "http://json-schema.org/draft/2019-WIP/meta/content", "$vocabulary": { - "https://json-schema.org/draft/2019-04/vocab/content": true + "https://json-schema.org/draft/2019-WIP/vocab/content": true }, "$recursiveAnchor": true, diff --git a/work-in-progress/meta/WIP-core.json b/work-in-progress/meta/WIP-core.json index 6ba4329e..82ad7e25 100644 --- a/work-in-progress/meta/WIP-core.json +++ b/work-in-progress/meta/WIP-core.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft/2019-04/schema#", - "$id": "https://json-schema.org/draft/2019-04/meta/core", + "$schema": "http://json-schema.org/draft/2019-WIP/schema#", + "$id": "https://json-schema.org/draft/2019-WIP/meta/core", "$vocabulary": { - "https://json-schema.org/draft/2019-04/vocab/core": true + "https://json-schema.org/draft/2019-WIP/vocab/core": true }, "$recursiveAnchor": true, diff --git a/work-in-progress/meta/WIP-format.json b/work-in-progress/meta/WIP-format.json index 02970f37..7a2bd28f 100644 --- a/work-in-progress/meta/WIP-format.json +++ b/work-in-progress/meta/WIP-format.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft/2019-04/schema#", - "$id": "http://json-schema.org/draft/2019-04/meta/format", + "$schema": "http://json-schema.org/draft/2019-WIP/schema#", + "$id": "http://json-schema.org/draft/2019-WIP/meta/format", "$vocabulary": { - "https://json-schema.org/draft/2019-04/vocab/format": true + "https://json-schema.org/draft/2019-WIP/vocab/format": true }, "$recursiveAnchor": true, diff --git a/work-in-progress/meta/WIP-hyper-schema.json b/work-in-progress/meta/WIP-hyper-schema.json index 8f427d4b..357747c6 100644 --- a/work-in-progress/meta/WIP-hyper-schema.json +++ b/work-in-progress/meta/WIP-hyper-schema.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#", - "$id": "http://json-schema.org/draft/2019-04/meta/hyper-schema", + "$schema": "http://json-schema.org/draft/2019-WIP/hyper-schema#", + "$id": "http://json-schema.org/draft/2019-WIP/meta/hyper-schema", "$vocabulary": { - "https://json-schema.org/draft/2019-04/vocab/hyper-schema": true + "https://json-schema.org/draft/2019-WIP/vocab/hyper-schema": true }, "$recursiveAnchor": true, @@ -16,7 +16,7 @@ "links": { "type": "array", "items": { - "$ref": "http://json-schema.org/draft/2019-04/links" + "$ref": "http://json-schema.org/draft/2019-WIP/links" } } }, diff --git a/work-in-progress/meta/WIP-meta-data.json b/work-in-progress/meta/WIP-meta-data.json index 1accce67..0bbbdeaf 100644 --- a/work-in-progress/meta/WIP-meta-data.json +++ b/work-in-progress/meta/WIP-meta-data.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft/2019-04/schema#", - "$id": "http://json-schema.org/draft/2019-04/meta/meta-data", + "$schema": "http://json-schema.org/draft/2019-WIP/schema#", + "$id": "http://json-schema.org/draft/2019-WIP/meta/meta-data", "$vocabulary": { - "https://json-schema.org/draft/2019-04/vocab/meta-data": true + "https://json-schema.org/draft/2019-WIP/vocab/meta-data": true }, "$recursiveAnchor": true, diff --git a/work-in-progress/meta/WIP-validation.json b/work-in-progress/meta/WIP-validation.json index 51db8864..4d5fcc96 100644 --- a/work-in-progress/meta/WIP-validation.json +++ b/work-in-progress/meta/WIP-validation.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft/2019-04/schema#", - "$id": "http://json-schema.org/draft/2019-04/meta/validation", + "$schema": "http://json-schema.org/draft/2019-WIP/schema#", + "$id": "http://json-schema.org/draft/2019-WIP/meta/validation", "$vocabulary": { - "https://json-schema.org/draft/2019-04/vocab/validation": true + "https://json-schema.org/draft/2019-WIP/vocab/validation": true }, "$recursiveAnchor": true, diff --git a/work-in-progress/output/WIP-hyper-schema.json b/work-in-progress/output/WIP-hyper-schema.json index 04e6e05a..ebb53d46 100644 --- a/work-in-progress/output/WIP-hyper-schema.json +++ b/work-in-progress/output/WIP-hyper-schema.json @@ -1,11 +1,11 @@ { - "$schema": "http://json-schema.org/draft/2019-04/schema#", - "$id": "http://json-schema.org/draft/2019-04/output/hyper-schema", + "$schema": "http://json-schema.org/draft/2019-WIP/schema#", + "$id": "http://json-schema.org/draft/2019-WIP/output/hyper-schema", "title": "JSON Hyper-Schema Output", "type": "array", "items": { "allOf": [ - {"$ref": "http://json-schema.org/draft/2019-04/links#/$defs/noRequiredFields" } + {"$ref": "http://json-schema.org/draft/2019-WIP/links#/$defs/noRequiredFields" } ], "type": "object", "required": [ diff --git a/work-in-progress/output/WIP-schema.json b/work-in-progress/output/WIP-schema.json index d9ab2cd1..45187ee0 100644 --- a/work-in-progress/output/WIP-schema.json +++ b/work-in-progress/output/WIP-schema.json @@ -1,6 +1,6 @@ { - "$schema": "http://json-schema.org/draft/2019-04/schema#", - "$id": "http://json-schema.org/draft/2019-04/output/schema", + "$schema": "http://json-schema.org/draft/2019-WIP/schema#", + "$id": "http://json-schema.org/draft/2019-WIP/output/schema", "description": "A schema that validates the minimum requirements for validation output", "oneOf": [ From 61586998d2c1d4569cd46ac3d8fef1cd6aa0dfd5 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Sun, 26 May 2019 09:17:58 -0700 Subject: [PATCH 039/395] Mark IETF draft docs as works in progress --- work-in-progress/WIP-jsonschema-core.html | 10 +++++----- work-in-progress/WIP-jsonschema-core.txt | 6 +++--- work-in-progress/WIP-jsonschema-hyperschema.html | 10 +++++----- work-in-progress/WIP-jsonschema-hyperschema.txt | 8 ++++---- work-in-progress/WIP-jsonschema-validation.html | 8 ++++---- work-in-progress/WIP-jsonschema-validation.txt | 6 +++--- work-in-progress/WIP-relative-json-pointer.html | 6 +++--- work-in-progress/WIP-relative-json-pointer.txt | 4 ++-- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/work-in-progress/WIP-jsonschema-core.html b/work-in-progress/WIP-jsonschema-core.html index 74e31829..3535420a 100644 --- a/work-in-progress/WIP-jsonschema-core.html +++ b/work-in-progress/WIP-jsonschema-core.html @@ -477,7 +477,7 @@ - + @@ -527,7 +527,7 @@

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

+ draft-handrews-json-schema-WIP

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.

@@ -2047,12 +2047,12 @@

[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. +Andrews, H. and A. Wright, "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON", Internet-Draft draft-handrews-json-schema-hyperschema-WIP, 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. +Wright, A., Andrews, H. and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of JSON", Internet-Draft draft-handrews-json-schema-validation-WIP, November 2017. [RFC7049] @@ -2085,7 +2085,7 @@

-
draft-handrews-json-schema-02
+
draft-handrews-json-schema-WIP
  • Update to RFC 8359 for JSON specification
  • diff --git a/work-in-progress/WIP-jsonschema-core.txt b/work-in-progress/WIP-jsonschema-core.txt index 19156592..fd1d3a6b 100644 --- a/work-in-progress/WIP-jsonschema-core.txt +++ b/work-in-progress/WIP-jsonschema-core.txt @@ -13,7 +13,7 @@ Expires: November 26, 2019 Riverbed Technology JSON Schema: A Media Type for Describing JSON Documents - draft-handrews-json-schema-02 + draft-handrews-json-schema-WIP Abstract @@ -3404,7 +3404,7 @@ Internet-Draft JSON Schema May 2019 [json-schema-validation] Wright, A., Andrews, H., and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of - JSON", draft-handrews-json-schema-validation-02 (work in + JSON", draft-handrews-json-schema-validation-WIP (work in progress), November 2017. [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object @@ -3488,7 +3488,7 @@ Appendix B. ChangeLog [[CREF9: This section to be removed before leaving Internet-Draft status.]] - draft-handrews-json-schema-02 + draft-handrews-json-schema-WIP * Update to RFC 8359 for JSON specification diff --git a/work-in-progress/WIP-jsonschema-hyperschema.html b/work-in-progress/WIP-jsonschema-hyperschema.html index 76a9f113..39a06000 100644 --- a/work-in-progress/WIP-jsonschema-hyperschema.html +++ b/work-in-progress/WIP-jsonschema-hyperschema.html @@ -453,7 +453,7 @@ - + @@ -487,7 +487,7 @@

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

    + draft-handrews-json-schema-hyperschema-WIP

    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.

    @@ -1751,12 +1751,12 @@

    [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. +Wright, A. and H. Andrews, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-handrews-json-schema-WIP, 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. +Wright, A., Andrews, H. and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of JSON", Internet-Draft draft-handrews-json-schema-validation-WIP, November 2017. [relative-json-pointer] @@ -1868,7 +1868,7 @@

    -
    draft-handrews-json-schema-hyperschema-02
    +
    draft-handrews-json-schema-hyperschema-WIP
    • Allow multiple values for "rel"
    • diff --git a/work-in-progress/WIP-jsonschema-hyperschema.txt b/work-in-progress/WIP-jsonschema-hyperschema.txt index aa1c5f7a..4bddd66e 100644 --- a/work-in-progress/WIP-jsonschema-hyperschema.txt +++ b/work-in-progress/WIP-jsonschema-hyperschema.txt @@ -9,7 +9,7 @@ Expires: November 26, 2019 May 25, 2019 JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON - draft-handrews-json-schema-hyperschema-02 + draft-handrews-json-schema-hyperschema-WIP Abstract @@ -2818,13 +2818,13 @@ Internet-Draft JSON Hyper-Schema May 2019 [json-schema] Wright, A. and H. Andrews, "JSON Schema: A Media Type for - Describing JSON Documents", draft-handrews-json-schema-02 + Describing JSON Documents", draft-handrews-json-schema-WIP (work in progress), November 2017. [json-schema-validation] Wright, A., Andrews, H., and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of - JSON", draft-handrews-json-schema-validation-02 (work in + JSON", draft-handrews-json-schema-validation-WIP (work in progress), November 2017. [relative-json-pointer] @@ -3052,7 +3052,7 @@ Appendix B. ChangeLog [[CREF13: This section to be removed before leaving Internet-Draft status.]] - draft-handrews-json-schema-hyperschema-02 + draft-handrews-json-schema-hyperschema-WIP * Allow multiple values for "rel" diff --git a/work-in-progress/WIP-jsonschema-validation.html b/work-in-progress/WIP-jsonschema-validation.html index 64f417fd..badf6984 100644 --- a/work-in-progress/WIP-jsonschema-validation.html +++ b/work-in-progress/WIP-jsonschema-validation.html @@ -447,7 +447,7 @@ - + @@ -497,7 +497,7 @@

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

      + draft-handrews-json-schema-validation-WIP

      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.

      @@ -1066,7 +1066,7 @@

      [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. +Wright, A. and H. Andrews, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-handrews-json-schema-WIP, November 2017. [relative-json-pointer] @@ -1195,7 +1195,7 @@

      -
      draft-handrews-json-schema-validation-02
      +
      draft-handrews-json-schema-validation-WIP
      • Moved "definitions" to the core spec as "$defs"
      • diff --git a/work-in-progress/WIP-jsonschema-validation.txt b/work-in-progress/WIP-jsonschema-validation.txt index 5d9d78b7..e1537e27 100644 --- a/work-in-progress/WIP-jsonschema-validation.txt +++ b/work-in-progress/WIP-jsonschema-validation.txt @@ -13,7 +13,7 @@ Expires: November 26, 2019 Riverbed Technology JSON Schema Validation: A Vocabulary for Structural Validation of JSON - draft-handrews-json-schema-validation-02 + draft-handrews-json-schema-validation-WIP Abstract @@ -1107,7 +1107,7 @@ Internet-Draft JSON Schema Validation May 2019 [json-schema] Wright, A. and H. Andrews, "JSON Schema: A Media Type for - Describing JSON Documents", draft-handrews-json-schema-02 + Describing JSON Documents", draft-handrews-json-schema-WIP (work in progress), November 2017. [relative-json-pointer] @@ -1295,7 +1295,7 @@ Appendix C. ChangeLog [[CREF2: This section to be removed before leaving Internet-Draft status.]] - draft-handrews-json-schema-validation-02 + draft-handrews-json-schema-validation-WIP * Moved "definitions" to the core spec as "$defs" diff --git a/work-in-progress/WIP-relative-json-pointer.html b/work-in-progress/WIP-relative-json-pointer.html index c9784f06..18880b17 100644 --- a/work-in-progress/WIP-relative-json-pointer.html +++ b/work-in-progress/WIP-relative-json-pointer.html @@ -396,7 +396,7 @@ - + @@ -434,7 +434,7 @@

        Relative JSON Pointers
        - draft-handrews-relative-json-pointer-02

        + draft-handrews-relative-json-pointer-WIP

        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.

        @@ -616,7 +616,7 @@

        -
        draft-handrews-relative-json-pointer-02
        +
        draft-handrews-relative-json-pointer-WIP
        • Update to the latest JSON RFC

        diff --git a/work-in-progress/WIP-relative-json-pointer.txt b/work-in-progress/WIP-relative-json-pointer.txt index eba2d3c2..2f2ae7c5 100644 --- a/work-in-progress/WIP-relative-json-pointer.txt +++ b/work-in-progress/WIP-relative-json-pointer.txt @@ -10,7 +10,7 @@ Expires: November 26, 2019 Riverbed Technology Relative JSON Pointers - draft-handrews-relative-json-pointer-02 + draft-handrews-relative-json-pointer-WIP Abstract @@ -343,7 +343,7 @@ Appendix A. ChangeLog [[CREF1: This section to be removed before leaving Internet-Draft status.]] - draft-handrews-relative-json-pointer-02 + draft-handrews-relative-json-pointer-WIP * Update to the latest JSON RFC From b87e01c0702dadb9267ea3c5f5a1914eddde42a1 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Mon, 27 May 2019 17:34:04 -0700 Subject: [PATCH 040/395] Local and production differ w.r.t. trailing / Of course. It would be too easy if the recommended way of running a local github pages env actually behavied like github. Trailing slashes are apparently bad. --- index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.md b/index.md index 9d843cbd..f024ceff 100644 --- a/index.md +++ b/index.md @@ -7,7 +7,7 @@ permalink: / ***The current version is [draft-07](specification.html)!*** {: style="color:gray; font-size: 150%; text-align: center;"} -***The next draft work-in-progres is [in final review](work-in-progress/)!*** +***The next draft work-in-progres is [in final review](work-in-progress)!*** {: style="color:red; font-size: 150%; text-align: center;"} **JSON Schema** is a vocabulary that allows you to **annotate** and **validate** JSON documents. @@ -42,7 +42,7 @@ permalink: / ### Update as of 27 May 2019 -**The forthcoming draft is in [final review](work-in-progress/).** +**The forthcoming draft is in [final review](work-in-progress).** This draft has also taken more time than expected because it tackles deep, long-term issues that have long been a challenge for JSON Schema. This includes building in a formal extensibility mechanism so that we can more easily draw a line to finalize the contents of the Core and Validation specifications. From 1dd92ac9be1c292a424e828083cc51f39631652d Mon Sep 17 00:00:00 2001 From: Sander Hahn Date: Tue, 28 May 2019 22:28:30 +0200 Subject: [PATCH 041/395] example $id update --- learn/examples/calendar.schema.json | 2 +- learn/examples/card.schema.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/learn/examples/calendar.schema.json b/learn/examples/calendar.schema.json index bb98ca30..7eab280b 100644 --- a/learn/examples/calendar.schema.json +++ b/learn/examples/calendar.schema.json @@ -1,5 +1,5 @@ { - "$id": "https://example.com/address.schema.json", + "$id": "https://example.com/calendar.schema.json", "$schema": "http://json-schema.org/draft-07/schema#", "description": "A representation of an event", "type": "object", diff --git a/learn/examples/card.schema.json b/learn/examples/card.schema.json index 7740a8b9..a19439a6 100644 --- a/learn/examples/card.schema.json +++ b/learn/examples/card.schema.json @@ -1,5 +1,5 @@ { - "$id": "https://example.com/address.schema.json", + "$id": "https://example.com/card.schema.json", "$schema": "http://json-schema.org/draft-07/schema#", "description": "A representation of a person, company, organization, or place", "type": "object", From 3e6d2485d34d405212247119a91ab169c22ba35d Mon Sep 17 00:00:00 2001 From: Johan Dorland Date: Tue, 4 Jun 2019 15:41:45 +0200 Subject: [PATCH 042/395] Fix a spelling error on the WIP page --- 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 c16ac946..461abc0d 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -32,7 +32,7 @@ incrementing the draft number for meta-schemas regardless of the IETF identifier However, this is frowned upon by the IETF and has in fact been a source of confusion. It worked well up to and including `draft-04`, as even after the split into multiple documents, `draft-zyp-json-schema-04` (the core spec) at least ended in `-04`! -Unfortnately, after that point, the numbers stopped matching in any way. +Unfortunately, after that point, the numbers stopped matching in any way. Assuming this new draft gets published more or less as presented in this WIP, and by the end of June, it will be: From 3aeb9ffc46eb3f9060b87e06d86cb84aca0a453c Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Tue, 4 Jun 2019 15:03:09 +0100 Subject: [PATCH 043/395] Fix issue badges! Sorry! --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 30a832a4..d15bb072 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ For the current status of issues and pull requests, please see the following bad [![Issues](https://img.shields.io/github/issues-raw/json-schema-org/json-schema-org.github.io.svg)](https://github.com/json-schema-org/json-schema-org.github.io/issues) -[![Available](https://img.shields.io/waffle/label/json-schema-org/json-schema-org.github.io/Status:%20Available.svg?style=flat)](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/waffle/label/json-schema-org/json-schema-org.github.io/Status:%20In%20Progress.svg?style=flat)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Status:%20In%20Progress) [![Review Needed](https://img.shields.io/waffle/label/json-schema-org/json-schema-org.github.io/Status:%20Review%20Needed.svg?style=flat)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Status%3A%20Review%20Needed) +[![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/waffle/label/json-schema-org/json-schema-org.github.io/Priority:%20Critical.svg?style=flat -)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Priority%3A%20Critical) [![High](https://img.shields.io/waffle/label/json-schema-org/json-schema-org.github.io/Priority:%20High.svg?style=flat)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Priority%3A%20High) [![Medium](https://img.shields.io/waffle/label/json-schema-org/json-schema-org.github.io/Priority:%20Medium.svg?style=flat)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Priority%3A%20Medium) [![Low](https://img.shields.io/waffle/label/json-schema-org/json-schema-org.github.io/Priority:%20Low.svg?style=flat)](https://github.com/json-schema-org/json-schema-org.github.io/labels/Priority%3A%20Low) +[![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) Labels are assigned based on [Sensible Github Labels](https://github.com/Relequestual/sensible-github-labels). From 88ddacd7448f43198226036a2a7813c4e8c834d7 Mon Sep 17 00:00:00 2001 From: Carsten Wickner <11309681+CarstenWickner@users.noreply.github.com> Date: Sun, 16 Jun 2019 11:25:48 +0200 Subject: [PATCH 044/395] Include Java-from-Code schema generator example --- implementations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implementations.md b/implementations.md index f2dc1df9..a886bc20 100644 --- a/implementations.md +++ b/implementations.md @@ -149,6 +149,8 @@ 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. +- Java + - [jsonschema-generator](https://github.com/victools/jsonschema-generator) (Apache 2.0) - generates schemas from Java types #### From data From ac82756864d044ac210f52b07d1ee129982d9aca Mon Sep 17 00:00:00 2001 From: Relequestual Date: Thu, 20 Jun 2019 20:08:41 +0100 Subject: [PATCH 045/395] Update WIP docs --- work-in-progress/WIP-jsonschema-core.html | 33 ++++++++++--------- .../WIP-jsonschema-hyperschema.html | 10 +++--- .../WIP-jsonschema-validation.html | 14 ++++---- .../WIP-relative-json-pointer.html | 10 +++--- 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/work-in-progress/WIP-jsonschema-core.html b/work-in-progress/WIP-jsonschema-core.html index 3535420a..76e26d3b 100644 --- a/work-in-progress/WIP-jsonschema-core.html +++ b/work-in-progress/WIP-jsonschema-core.html @@ -473,12 +473,12 @@ - + - + @@ -502,7 +502,7 @@ H. Andrews, Ed. -Expires: November 26, 2019 +Expires: December 20, 2019 Riverbed Technology @@ -519,7 +519,7 @@ -May 25, 2019 +June 18, 2019 @@ -539,7 +539,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 November 26, 2019.

        +

        This Internet-Draft will expire on December 20, 2019.

        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.

        @@ -1078,11 +1078,12 @@

        8.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 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 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.

        8.2. The "$id" Keyword

        -

        The "$id" keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. A subschema's "$id" is resolved against the base URI of its parent schema. If no parent sets an explicit base with "$id", the base URI is that of the entire document, as determined per RFC 3986 section 5.

        +

        The "$id" keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. A subschema's "$id" is resolved against the base URI of its parent schema. If no parent schema defines an explicit base URI with "$id", the base URI is that of the entire document, as determined per RFC 3986 section 5.

        If present, the value for this keyword MUST be a string, and MUST represent a valid URI-reference. This value SHOULD be normalized, and SHOULD NOT be an empty fragment <#> or an empty string <>.

        8.2.1. Identifying the root schema

        @@ -1718,7 +1719,7 @@

      • There are only two vertices, but three are required.
      -

      Note that neither the error message property nor its wording as depicted in these examples is not a requirement of this specification. Implementations SHOULD craft error messages tailored for their audience.

      +

      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.

      @@ -1746,21 +1747,21 @@

      { "keywordLocation": "#/items/$ref", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point", + "http://example.com/polygon#/$defs/point", "instanceLocation": "#/1", "error": "A subschema had errors." }, { "keywordLocation": "#/items/$ref/required", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/required", + "http://example.com/polygon#/$defs/point/required", "instanceLocation": "#/1", "error": "Required property 'y' not found." }, { "keywordLocation": "#/items/$ref/additionalProperties", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/additionalProperties", + "http://example.com/polygon#/$defs/point/additionalProperties", "instanceLocation": "#/1/z", "error": "Additional property 'z' found but was invalid." }, @@ -1796,14 +1797,14 @@

      "valid": false, "keywordLocation": "#/items/$ref", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point", + "http://example.com/polygon#/$defs/point", "instanceLocation": "#/1", "errors": [ { "valid": false, "keywordLocation": "#/items/$ref/required", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/required", + "http://example.com/polygon#/$defs/point/required", "instanceLocation": "#/1", "error": "Required property 'y' not found." }, @@ -1811,7 +1812,7 @@

      "valid": false, "keywordLocation": "#/items/$ref/additionalProperties", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/additionalProperties", + "http://example.com/polygon#/$defs/point/additionalProperties", "instanceLocation": "#/1/z", "error": "Additional property 'z' found but was invalid." } @@ -2088,7 +2089,7 @@

      draft-handrews-json-schema-WIP
        -
      • Update to RFC 8359 for JSON specification
      • +
      • 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"
      • @@ -2252,6 +2253,8 @@

        Authors' Addresses

        EMail: bh7@sanger.ac.uk +URI: https://jsonschema.dev +
        diff --git a/work-in-progress/WIP-jsonschema-hyperschema.html b/work-in-progress/WIP-jsonschema-hyperschema.html index 39a06000..0e052baf 100644 --- a/work-in-progress/WIP-jsonschema-hyperschema.html +++ b/work-in-progress/WIP-jsonschema-hyperschema.html @@ -449,12 +449,12 @@ - + - + @@ -478,8 +478,8 @@ A. Wright, Ed. -Expires: November 26, 2019 -May 25, 2019 +Expires: December 20, 2019 +June 18, 2019 @@ -499,7 +499,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 November 26, 2019.

        +

        This Internet-Draft will expire on December 20, 2019.

        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.

        diff --git a/work-in-progress/WIP-jsonschema-validation.html b/work-in-progress/WIP-jsonschema-validation.html index badf6984..73f660f6 100644 --- a/work-in-progress/WIP-jsonschema-validation.html +++ b/work-in-progress/WIP-jsonschema-validation.html @@ -443,12 +443,12 @@ - + - + @@ -472,7 +472,7 @@ H. Andrews, Ed. -Expires: November 26, 2019 +Expires: December 20, 2019 Riverbed Technology @@ -489,7 +489,7 @@ -May 25, 2019 +June 18, 2019 @@ -509,7 +509,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 November 26, 2019.

        +

        This Internet-Draft will expire on December 20, 2019.

        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.

        @@ -1066,7 +1066,7 @@

        [json-schema] -Wright, A. and H. Andrews, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-handrews-json-schema-WIP, November 2017. +Wright, A. and H. Andrews, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-handrews-json-schema-WIP, November 2017. [relative-json-pointer] @@ -1352,6 +1352,8 @@

        Authors' Addresses

        EMail: bh7@sanger.ac.uk +URI: https://jsonschema.dev +
        diff --git a/work-in-progress/WIP-relative-json-pointer.html b/work-in-progress/WIP-relative-json-pointer.html index 18880b17..31f3eb8f 100644 --- a/work-in-progress/WIP-relative-json-pointer.html +++ b/work-in-progress/WIP-relative-json-pointer.html @@ -392,12 +392,12 @@ - + - + @@ -421,12 +421,12 @@ H. Andrews, Ed. -Expires: November 26, 2019 +Expires: December 20, 2019 Riverbed Technology -May 25, 2019 +June 18, 2019 @@ -442,7 +442,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 November 26, 2019.

        +

        This Internet-Draft will expire on December 20, 2019.

        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.

        From 38a663fb5fc4f505aed42da90684a68d4b2a671a Mon Sep 17 00:00:00 2001 From: Drew Miller Date: Sun, 23 Jun 2019 07:09:01 +0900 Subject: [PATCH 046/395] Remove projects with dead links --- implementations.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/implementations.md b/implementations.md index f2dc1df9..ac4d51c0 100644 --- a/implementations.md +++ b/implementations.md @@ -196,10 +196,7 @@ Various levels of support for UI generation primarily from the validation vocabu - [JSON Form (joshfire)](https://github.com/joshfire/jsonform) (joshfire) (MIT) - [Json Forms (brutusin)](https://github.com/brutusin/json-forms) (brutusin) (MIT) - [JSONForms (jsonforms.io)](https://jsonforms.io/) (EclipseSource) (MIT) - - [Jsonary](https://github.com/jsonary-js/) (MIT) - [Liform-react](https://github.com/Limenius/liform-react) (MIT) - - [Metawidget](https://metawidget.org/) (LGPL) - - [pure-form webcomponent](https://github.com/john-doherty/pure-form) (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) - [uniforms (Vazco)](https://github.com/vazco/uniforms) (MIT) From a0ebcf59e39f1f38fd0885f419a73fb2f3bf76bf Mon Sep 17 00:00:00 2001 From: Thomas Schulz Date: Tue, 25 Jun 2019 09:56:42 +0200 Subject: [PATCH 047/395] Add info about YAML support in IntelliJ based IDEs --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index ac4d51c0..185d42bb 100644 --- a/implementations.md +++ b/implementations.md @@ -262,7 +262,7 @@ _TODO: Sort by draft support._ - [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 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* - [JsonDraft](https://jsondraft.com/) - *Tree view JSON and JSON Schema editor online. Create and Save reusable components, Share JSON.* From 1412d61c8b479abf857699749117d2d9fe33c4a7 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Wed, 3 Jul 2019 12:40:48 -0700 Subject: [PATCH 048/395] Update on draft review timeline. --- work-in-progress/index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/work-in-progress/index.md b/work-in-progress/index.md index 461abc0d..9b0ca834 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -15,6 +15,10 @@ period before publication. This final review will last from May 27th to June 24 The timeline may be compressed if, after at least two weeks, there is a clear consensus that the drafts are solid and it would be best to publish sooner rather than later. +***UPDATE:** As of July 2nd, We are incorporating feedback from the review period. +There will be an update, followed by a brief period to review the update, and then +hopefully publication.*** + The following sorts of feedback are particularly desired: * Clarity, readability, and accessibility to new readers From 98c3e1fdfd8ad2f6dd706333f7c2f9fd36ad05e3 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Wed, 3 Jul 2019 12:53:52 -0700 Subject: [PATCH 049/395] Fix formatting of last commit. --- work-in-progress/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/work-in-progress/index.md b/work-in-progress/index.md index 9b0ca834..ef01fb2e 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -15,9 +15,9 @@ period before publication. This final review will last from May 27th to June 24 The timeline may be compressed if, after at least two weeks, there is a clear consensus that the drafts are solid and it would be best to publish sooner rather than later. -***UPDATE:** As of July 2nd, We are incorporating feedback from the review period. -There will be an update, followed by a brief period to review the update, and then -hopefully publication.*** +_**UPDATE:** As of July 2nd, We are incorporating feedback from the review period._ +_There will be an update, followed by a brief period to review the update, and then_ +_hopefully publication._ The following sorts of feedback are particularly desired: From 0f9dbf752f71e24929e38bf9fe944542aab93e1f Mon Sep 17 00:00:00 2001 From: cyril <38669260+cyrilbois@users.noreply.github.com> Date: Thu, 4 Jul 2019 22:18:46 +0200 Subject: [PATCH 050/395] Added ExtendsClass to list of Validators Adds ExtendsClass's JSON Schema Validator to list of Online Validators. And adds draft-07 for JSON Schema Lint. --- _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 2fc9aad5..34ebd4e3 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -134,7 +134,10 @@ draft: [7, 6, 4, 3] - name: JSON Schema Lint url: http://jsonschemalint.com/ - draft: [6, 4, 3, 2, 1] + draft: [7, 6, 4, 3, 2, 1] + - name: ExtendsClass's JSON Schema Validator + url: https://extendsclass.com/json-schema-validator.html + draft: [7] - name: Command Line implementations: - name: ajv-cli From 429b3754ade284d27eca7418e62e5f43987883b1 Mon Sep 17 00:00:00 2001 From: Ben Hutton Date: Fri, 5 Jul 2019 14:50:59 +0100 Subject: [PATCH 051/395] Change slack invite link. This one should never expire! --- _includes/header.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/header.html b/_includes/header.html index e4913e54..295d14bc 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -25,7 +25,7 @@ {{ my_page.title | escape }} {%- endif -%} {% endfor -%} - + Discussion
        From 5a59a160b83f150defd701ec4c0e6629e8f1d908 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Thu, 11 Jul 2019 10:49:50 -0700 Subject: [PATCH 052/395] Change slack link in the other two places ...maybe we should make that easier? Although this link is not supposed to expire so it's probably fine as is. --- _includes/footer.html | 2 +- index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_includes/footer.html b/_includes/footer.html index ae60b3fb..beb53386 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/index.md b/index.md index f024ceff..dad1963a 100644 --- a/index.md +++ b/index.md @@ -97,4 +97,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/enQtMjk1NDcyNDI2NTAwLTcyYmYwMjdmMmUxNzZjYzIxNGU2YjdkNzdlOGZiNjIwNDI2M2Y3NmRkYjA4YmMwODMwYjgyOTFlNWZjZjAyNjg) +* [Slack](https://join.slack.com/t/json-schema/shared_invite/enQtNjc5NTk0MzkzODg5LTVlZGIxNmVhMGY2MWFlYTdiNDQ5NWFiZGUwOThhNmYxZDE0YzA5YjRiOTA5MGY4ZTZlZGZhZDFmYTY4NWM2N2Y) From 505c68a0173d2cff736404b3eee6388b2dab9467 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Sat, 13 Jul 2019 18:22:55 -0700 Subject: [PATCH 053/395] Update WIP core spec with new overview --- work-in-progress/WIP-jsonschema-core.html | 1199 ++++++++-------- work-in-progress/WIP-jsonschema-core.txt | 1514 ++++++++++----------- 2 files changed, 1344 insertions(+), 1369 deletions(-) diff --git a/work-in-progress/WIP-jsonschema-core.html b/work-in-progress/WIP-jsonschema-core.html index 76e26d3b..106c32d8 100644 --- a/work-in-progress/WIP-jsonschema-core.html +++ b/work-in-progress/WIP-jsonschema-core.html @@ -377,17 +377,6 @@ - - - - - - - - - - - @@ -407,78 +396,85 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -502,7 +498,7 @@ H. Andrews, Ed. -Expires: December 20, 2019 +Expires: January 14, 2020 Riverbed Technology @@ -519,7 +515,7 @@ -June 18, 2019 +July 13, 2019 @@ -539,7 +535,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 December 20, 2019.

      +

      This Internet-Draft will expire on January 14, 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.

      @@ -555,29 +551,7 @@

      Table of Contents

    • 3. Overview
    • -
    • 4. Definitions +
    • 4. Definitions
    • 7. Meta-Schemas and Vocabularies +
  • 7. Keyword Behaviors +
  • +
  • 11. A Vocabulary for Applying Subschemas +
  • 14. Security Considerations +
  • 16. References +
  • 16. IANA Considerations
  • -
    • 16.1. Normative References +
    • 17. References +
    • +
    • Appendix A. Acknowledgments
    • @@ -759,66 +747,12 @@

      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.

      -

      -3.1. 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.

      -

      -3.1.1. 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.

      -

      -3.1.2. 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.

      -

      -3.1.3. 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.

      -

      -3.1.4. 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.

      -

      -3.1.4.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.

      -

      -3.1.5. 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.

      -

      The default behavior is simply to collect all values in a list in indeterminate order. Given the extensibility of keywords, including applicators, it is not possible to define a universally predictable order of processing.

      -

      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.

      -

      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.

      -

      -3.2. Schema Vocabularies -

      -

      A JSON Schema vocabulary is a set of keywords defined for a particular purpose. The vocabulary specifies the meaning of its keywords as assertions, annotations, and/or any vocabulary-defined keyword category.

      -

      Several vocabularies are provided as standards in this and closely related documents. These vocabularies are used with the core keywords defined as fundamental to the "application/schema+json" media type.

      -

      Schema authors are encouraged to define their own vocabularies for domain-specific concepts. A vocabulary need not be a standard to be re-usable, although users of extension vocabularies MUST NOT assume that any JSON Schema implementation can support the vocabulary unless it specifically documents such support.

      -

      -3.2.1. Subschema Application

      -

      This vocabulary provides keywords for applying subschemas to the instance in various ways. It is defined in this document, and it is RECOMMENDED that all JSON Schema implementations support it. All other vocabularies in this section are designed to be used alongside the subschema application vocabulary.

      -

      Without this vocabulary or an equivalent one, JSON Schema can only be applied to a JSON document as a whole. In most cases, schema keywords need to be applied to specific object properties or array items.

      -

      -3.2.2. Validation

      -

      This vocabulary describes the structure of a JSON document (for instance, required properties and length limitations). Applications can use this information to validate instances (check that constraints are met), or inform interfaces to collect user input such that the constraints are satisfied.

      -

      Validation behaviour and keywords are specified in a separate document.

      -

      -3.2.3. Basic Meta-Data

      -

      A small set of annotation keywords are defined in the validation specification to allow associating common kinds of meta-data with an instance.

      -

      -3.2.4. Hypermedia and Linking

      -

      JSON Hyper-Schema produces hyperlinks as annotations available for use with a JSON document. It supports resolving URI Templates and describing the resource and data submission formats required to use an API.

      -

      Hyper-schema behaviour and keywords are specified in a separate document.

      +

      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

      @@ -939,7 +873,7 @@

      4.3.5. Referenced and Referencing Schemas

      -

      As noted in Section 3.1.3, 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.

      +

      As noted in Section 7.3, 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.

      @@ -992,55 +926,96 @@

      Authors of extensions to JSON Schema are encouraged to write their own meta-schemas, which extend the existing meta-schemas using "allOf". This extended meta-schema SHOULD be referenced using the "$schema" keyword, to allow tools to follow the correct behaviour.

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

      -7. Meta-Schemas and Vocabularies

      -

      Two concepts, meta-schemas and vocabularies, are used to inform an implementation how to interpret a schema. A schema S declares its meta-schema M with the "$schema" keyword, and meta-schemas declare vocabularies with the "$vocabulary" keyword. The vocabularies declared in M are those that are expected to be used in S. The meta-schema M may itself use a different set of vocabularies, which are declared in its own meta-schema, M'.

      -

      The role of the meta-schema is to constrain the structure of conforming schemas, as well as simplify the process of composing multiple vocabularies into a usable feature set. Schema authoring is expected to be a common activity, so schema authors need only understand how to reference a single meta-schema.

      -

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

      -

      The role of a vocabulary is to declare which keywords (including sub-keywords such as those in JSON Hyper-Schema's Link Description Object) are in use, and with which semantics. The semantics are indicated by the document that publicizes the vocabulary URI. At this time, there is no machine-readable description of keywords other than validation rules, which appear in the meta-schema.

      -

      Meta-schemas are separate from vocabularies to allow for the same sets of 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.

      +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.

    -7.1. The "$schema" Keyword

    -

    The "$schema" keyword is both used as a JSON Schema feature set identifier and the location of a resource which is itself a JSON Schema, which describes any schema 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 root schema. It MUST NOT appear in subschemas.

    -

    [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.

    -

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

    +7.1. 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.2. The "$vocabulary" Keyword

-

The "$vocabulary" keyword, which appears in a meta-schema, identifies what sets of keywords are expected to be used in schemas described by that meta-schema, and with what semantics. This is conceptually analogous to how most other keywords used in meta-schemas describe the syntax of keywords used in schemas described by that meta-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 resources is currently undefined, and reserved for future use. Vocabulary authors SHOULD NOT serve a document at that URL. A server MAY respond with the relevant protocol's successful "no content" message, such as an HTTP 204 status. [CREF3]Vocabulary documents may be added shortly, or in the next draft. For now, identifying the keyword set is deemed sufficient as that, along with meta-schema validation, is how the current "vocabularies" work today.

-

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 MAY choose to proceed with processing such schemas.

-

When processing a schema that uses unrecognized vocabularies, keywords declared by those vocabularies are treated like any other unrecognized keyword, and ignored.

-

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.

-

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.

-

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. If the meta-schema, as referenced by the schema, is not recognized, then implementations MUST assume the use of the core vocabulary, and SHOULD assume the use of all vocabularies in this specification and the companion Validation specification.

+7.2. 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.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 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.

+7.3. 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.4. Best Practices for Vocabulary and Meta-Schema Authors

-

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. Such meta-schemas SHOULD NOT forbid additional keywords, and MUST NOT forbid the "$id", "$schema", or "$vocabulary" keywords in the root schema.

-

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.

-

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.

+7.4. 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.4.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.

-7.5. The JSON Schema Core Vocabulary

-

Keywords declared in in this specification that 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 "$vocabulary" 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.

-

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-04/vocab/core>.

-

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

-

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.

-

-7.6. Example Meta-Schema With Vocabulary Declarations +7.5. 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.

+

The default behavior is simply to collect all values in a list in indeterminate order. Given the extensibility of keywords, including applicators, it is not possible to define a universally predictable order of processing.

+

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.

+

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.

+

+8. Meta-Schemas and Vocabularies +

+

Two concepts, meta-schemas and vocabularies, are used to inform an implementation how to interpret a schema. A schema S declares its meta-schema M with the "$schema" keyword, and meta-schemas declare vocabularies with the "$vocabulary" keyword. The vocabularies declared in M are those that are expected to be used in S. The meta-schema M may itself use a different set of vocabularies, which are declared in its own meta-schema, M'.

+

The role of the meta-schema is to constrain the structure of conforming schemas, as well as simplify the process of composing multiple vocabularies into a usable feature set. Schema authoring is expected to be a common activity, so schema authors need only understand how to reference a single meta-schema.

+

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

+

A JSON Schema vocabulary is a set of keywords defined for a particular purpose. The vocabulary specifies the meaning of its keywords as assertions, annotations, and/or any vocabulary-defined keyword category.

+

The role of a vocabulary is to declare which keywords (including sub-keywords such as those in JSON Hyper-Schema's Link Description Object) are in use, and with which semantics. The semantics are indicated by the document that publicizes the vocabulary URI. At this time, there is no machine-readable description of keywords other than validation rules, which appear in the meta-schema.

+

Meta-schemas are separate from vocabularies to allow for the same sets of 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.

+

+8.1. The "$schema" Keyword

+

The "$schema" keyword is both used as a JSON Schema feature set identifier and the location of a resource which is itself a JSON Schema, which describes any schema 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 root schema. It MUST NOT appear in subschemas.

+

[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.

+

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

+

+8.2. The "$vocabulary" Keyword

+

The "$vocabulary" keyword, which appears in a meta-schema, identifies what sets of keywords are expected to be used in schemas described by that meta-schema, and with what semantics. This is conceptually analogous to how most other keywords used in meta-schemas describe the syntax of keywords used in schemas described by that meta-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 resources is currently undefined, and reserved for future use. Vocabulary authors SHOULD NOT serve a document at that URL. A server MAY respond with the relevant protocol's successful "no content" message, such as an HTTP 204 status. [CREF3]Vocabulary documents may be added shortly, or in the next draft. For now, identifying the keyword set is deemed sufficient as that, along with meta-schema validation, is how the current "vocabularies" work today.

+

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 MAY choose to proceed with processing such schemas.

+

When processing a schema that uses unrecognized vocabularies, keywords declared by those vocabularies are treated like any other unrecognized keyword, and ignored.

+

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.

+

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.

+

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. If the meta-schema, as referenced by the schema, is not recognized, then implementations MUST assume the use of the core vocabulary, and SHOULD assume the use of all vocabularies in this specification and the companion Validation specification.

+

+8.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 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.4. Best Practices for Vocabulary and Meta-Schema Authors

+

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. Such meta-schemas SHOULD NOT forbid additional keywords, and MUST NOT forbid the "$id", "$schema", or "$vocabulary" keywords in the root schema.

+

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.

+

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.

+

+8.5. The JSON Schema Core Vocabulary

+

Keywords declared in in this specification that 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 "$vocabulary" 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.

+

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-04/vocab/core>.

+

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

+

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.6. Example Meta-Schema With Vocabulary Declarations

This meta-schema explicitly declares both the Core and Applicator vocabularies, and combines their meta-schemas with an "allOf". It additionally restricts the usage of the Applicator vocabulary by forbidding the keyword prefixed with "unevaluated". It also describes a keyword, "localKeyword", that is not part of either vocabulary. Note that it is its own meta-schema, as it relies on both the Core vocabulary (as all schemas do) and the Applicator vocabulary (for "allOf").

@@ -1070,34 +1045,34 @@ 

As shown above, even though each of the referenced standard meta-schemas declares its corresponding vocabulary, this new meta-schema must re-declare them for itself. It would be valid to leave the core vocabulary out of the "$vocabulary" keyword, but it needs to be referenced through the "allOf" keyword in order for its terms to be validated. There is no special case for validation of core keywords.

-

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.

-

-8. Base URI 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.

-

-8.1. Initial Base URI

+

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.

+

+9. Base URI 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.

+

+9.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.

-

-8.2. The "$id" Keyword +

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.

+

+9.2. The "$id" Keyword

-

The "$id" keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. A subschema's "$id" is resolved against the base URI of its parent schema. If no parent schema defines an explicit base URI with "$id", the base URI is that of the entire document, as determined per RFC 3986 section 5.

-

If present, the value for this keyword MUST be a string, and MUST represent a valid URI-reference. This value SHOULD be normalized, and SHOULD NOT be an empty fragment <#> or an empty string <>.

-

-8.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), or this absolute URI but with an empty fragment.

-

-8.2.2. Changing the base URI within a schema file

-

When an "$id" sets the base URI, the object containing that "$id" and all of its subschemas can be identified by using a JSON Pointer fragment starting from that location. This is true even of subschemas that further change the base URI. Therefore, a single subschema may be accessible by multiple URIs, each consisting of base URI declared in the subschema or a parent, along with a JSON Pointer fragment identifying the path from the schema object that declares the base to the subschema being identified. Examples of this are shown in section 8.2.4.

-

-8.2.3. 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.

-

To specify such a subschema identifier, the "$id" keyword is set to a URI reference with a plain name fragment (not a JSON Pointer fragment). This value MUST begin with the number sign that specifies a fragment ("#"), then a letter ([A-Za-z]), followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), or periods (".").

-

The effect of using a fragment in "$id" that isn't blank or doesn't follow the plain name syntax is undefined. [CREF4]How should an "$id" URI reference containing a fragment with other components be interpreted? There are two cases: when the other components match the current base URI and when they change the base URI.

-

-8.2.4. Schema identification examples +

The "$id" keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. A subschema's "$id" is resolved against the base URI of its parent schema. If no parent schema defines an explicit base URI with "$id", the base URI is that of the entire document, as determined per RFC 3986 section 5.

+

If present, the value for this keyword MUST be a string, and MUST represent a valid URI-reference. This value SHOULD be normalized, and SHOULD NOT be an empty fragment <#> or an empty string <>.

+

+9.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), or this absolute URI but with an empty fragment.

+

+9.2.2. Changing the base URI within a schema file

+

When an "$id" sets the base URI, the object containing that "$id" and all of its subschemas can be identified by using a JSON Pointer fragment starting from that location. This is true even of subschemas that further change the base URI. Therefore, a single subschema may be accessible by multiple URIs, each consisting of base URI declared in the subschema or a parent, along with a JSON Pointer fragment identifying the path from the schema object that declares the base to the subschema being identified. Examples of this are shown in section 9.2.4.

+

+9.2.3. 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.

+

To specify such a subschema identifier, the "$id" keyword is set to a URI reference with a plain name fragment (not a JSON Pointer fragment). This value MUST begin with the number sign that specifies a fragment ("#"), then a letter ([A-Za-z]), followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), or periods (".").

+

The effect of using a fragment in "$id" that isn't blank or doesn't follow the plain name syntax is undefined. [CREF4]How should an "$id" URI reference containing a fragment with other components be interpreted? There are two cases: when the other components match the current base URI and when they change the base URI.

+

+9.2.4. Schema identification examples

Consider the following schema, which shows "$id" being used to identify the root schema, change the base URI for subschemas, and assign plain name fragments to subschemas:

@@ -1120,7 +1095,7 @@ 

}

-

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 Section 5 above:

+

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 Section 5 above:

@@ -1197,20 +1172,20 @@

-

-8.3. 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 a helper keyword that controls how the referenced schema of "$recursiveRef" is determined.

-

As the value 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.3.1. Direct References with "$ref" +

+9.3. 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 a helper keyword that controls how the referenced schema of "$recursiveRef" is determined.

+

As the value 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.

+

+9.3.1. Direct References with "$ref"

-

The "$ref" keyword is used to reference a statically identified schema.

-

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

-

-8.3.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 ("#").

-

Extending a recursive schema with "$ref" alone involves redefining all recursive references in the source schema to point to the root of the extension. This produces the correct recursive behavior in the extension, which is that all recursion should reference the root of the extension.

+

The "$ref" keyword is used to reference a statically identified schema.

+

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

+

+9.3.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 ("#").

+

Extending a recursive schema with "$ref" alone involves redefining all recursive references in the source schema to point to the root of the extension. This produces the correct recursive behavior in the extension, which is that all recursion should reference the root of the extension.

Consider the following two schemas. The first schema, identified as "original" as it is the schema to be extended, describes an object with one string property and one recursive reference property, "r". The second schema, identified as "extension", references the first, and describes an additional things" property, which is an array of recursive references. It also repeats the description of "r" from the original schema.

 
@@ -1248,11 +1223,11 @@ 

This apparent duplication is important because it resolves to "https://example.com/extension#", meaning that for instance validated against the extension schema, the value of "r" must be valid according to the extension, and not just the original schema as "r" was described there.

-

This approach is fine for a single recursive field, but the more complicated the original schema, the more redefinitions are necessary in the extension. This leads to a verbose and error-prone extension, which must be kept synchronized with the original schema if the original changes its recursive fields. This approach can be seen in the meta-schema for JSON Hyper-Schema in all prior drafts.

-

-8.3.2.1. Enabling Recursion with "$recursiveAnchor"

-

The desired behavior is for the recursive reference, "r", in the original schema to resolve to the original schema when that is the only schema being used, but to resolve to the extension schema when using the extension. Then there would be no need to redefine the "r" property, or others like it, in the extension.

-

In order to create a recursive reference, we must do three things:

+

This approach is fine for a single recursive field, but the more complicated the original schema, the more redefinitions are necessary in the extension. This leads to a verbose and error-prone extension, which must be kept synchronized with the original schema if the original changes its recursive fields. This approach can be seen in the meta-schema for JSON Hyper-Schema in all prior drafts.

+

+9.3.2.1. Enabling Recursion with "$recursiveAnchor"

+

The desired behavior is for the recursive reference, "r", in the original schema to resolve to the original schema when that is the only schema being used, but to resolve to the extension schema when using the extension. Then there would be no need to redefine the "r" property, or others like it, in the extension.

+

In order to create a recursive reference, we must do three things:

  • In our original schema, indicate that the schema author intends for it to be extensible recursively.
  • @@ -1261,12 +1236,12 @@

These three things together ensure that all schema authors are intentionally constructing a recursive extension, which in turn gives all uses of the regular "$ref" keyword confidence that it only behaves as it appears to, using lexical scoping.

-

The "$recursiveAnchor" keyword is how schema authors indicate that a schema can be extended recursively, and be a recursive schema. This keyword MAY appear in the root schema of a schema document, and MUST NOT appear in any subschema.

-

The value of "$recursiveAnchor" MUST be of type boolean, and MUST be true. The value false is reserved for possible future use.

-

-8.3.2.2. Dynamically recursive references with "$recursiveRef"

-

The "$recursiveRef" keyword behaves identically to "$ref", except that if the referenced schema has "$recursiveAnchor" set to true, then the implementation MUST examine the dynamic scope for the outermost (first seen) schema document with "$recursiveAnchor" set to true. If such a schema document exists, then the target of the "$recursiveRef" MUST be set to that document's URI, in place of the URI produced by the rules for "$ref".

-

Note that if the schema referenced by "$recursiveRef" does not contain "$recursiveAnchor" set to true, or if there are no other "$recursiveAnchor" keywords set to true anywhere further back in the dynamic scope, then "$recursiveRef"'s behavior is identical to that of "$ref".

+

The "$recursiveAnchor" keyword is how schema authors indicate that a schema can be extended recursively, and be a recursive schema. This keyword MAY appear in the root schema of a schema document, and MUST NOT appear in any subschema.

+

The value of "$recursiveAnchor" MUST be of type boolean, and MUST be true. The value false is reserved for possible future use.

+

+9.3.2.2. Dynamically recursive references with "$recursiveRef"

+

The "$recursiveRef" keyword behaves identically to "$ref", except that if the referenced schema has "$recursiveAnchor" set to true, then the implementation MUST examine the dynamic scope for the outermost (first seen) schema document with "$recursiveAnchor" set to true. If such a schema document exists, then the target of the "$recursiveRef" MUST be set to that document's URI, in place of the URI produced by the rules for "$ref".

+

Note that if the schema referenced by "$recursiveRef" does not contain "$recursiveAnchor" set to true, or if there are no other "$recursiveAnchor" keywords set to true anywhere further back in the dynamic scope, then "$recursiveRef"'s behavior is identical to that of "$ref".

With this in mind, we can rewrite the previous example:

 
@@ -1303,28 +1278,28 @@ 

Note that the "r" property no longer appears in the extension schema. Instead, all "$ref"s have been changed to "$recursiveRef"s, and both schemas have "$recursiveAnchor" set to true in their root schema.

-

When using the original schema on its own, there is no change in behavior. The "$recursiveRef" does lead to a schema where "$recursiveAnchor" is set to true, but since the original schema is the only schema document in the dynamics scope (it references itself, and does not reference any other schema documents), the behavior is effectively the same as "$ref".

-

When using the extension schema, the "$recursiveRef" within that schema (for the array items within "things") also effectively behaves like "$ref". The extension schema is the outermost dynamic scope, so the reference target is not changed.

-

In contrast, when using the extension schema, the "$recursiveRef" for "r" in the original schema now behaves differently. Its initial target is the root schema of the original schema document, which has "$recursiveAnchor" set to true. In this case, the outermost dynamic scope that also has "$recursiveAnchor" set to true is the extension schema. So when using the extensions schema, "r"'s reference in the original schema will resolve to "https://example.com/extension#", not "https://example.com/original#".

-

-8.3.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.3.4. References to Possible Non-Schemas

-

Subschema objects (or booleans) are recognized by their use with known applicator keywords. These keywords may be 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. [CREF5]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.3.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 section 8.2.4.

-

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.3.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:

+

When using the original schema on its own, there is no change in behavior. The "$recursiveRef" does lead to a schema where "$recursiveAnchor" is set to true, but since the original schema is the only schema document in the dynamics scope (it references itself, and does not reference any other schema documents), the behavior is effectively the same as "$ref".

+

When using the extension schema, the "$recursiveRef" within that schema (for the array items within "things") also effectively behaves like "$ref". The extension schema is the outermost dynamic scope, so the reference target is not changed.

+

In contrast, when using the extension schema, the "$recursiveRef" for "r" in the original schema now behaves differently. Its initial target is the root schema of the original schema document, which has "$recursiveAnchor" set to true. In this case, the outermost dynamic scope that also has "$recursiveAnchor" set to true is the extension schema. So when using the extensions schema, "r"'s reference in the original schema will resolve to "https://example.com/extension#", not "https://example.com/original#".

+

+9.3.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.

+

+9.3.4. References to Possible Non-Schemas

+

Subschema objects (or booleans) are recognized by their use with known applicator keywords. These keywords may be 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. [CREF5]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.3.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 section 9.2.4.

+

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.3.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:

 
 {
@@ -1343,13 +1318,13 @@ 

}

-

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

-

When an implementation then looks inside the <#/items> schema, it encounters the <#item> reference, and resolves this to <http://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 <http://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. [CREF6]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.4. Schema Re-Use With "$defs"

-

The "$defs" keyword provides a standardized 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.

+

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

+

When an implementation then looks inside the <#/items> schema, it encounters the <#item> reference, and resolves this to <http://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 <http://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. [CREF6]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.4. Schema Re-Use With "$defs"

+

The "$defs" keyword provides a standardized 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.

 
 {
@@ -1364,14 +1339,14 @@ 

}

-

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

-

-9. Comments With "$comment"

-

This keyword is reserved 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.

+

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

-10. 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:

+10. Comments With "$comment" +

This keyword is reserved 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.

+

+11. 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
  • @@ -1382,11 +1357,11 @@

-

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.

-

-10.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:

+

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.

+

+11.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.

 
@@ -1429,15 +1404,15 @@ 

}

-

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.

-

-10.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:

+

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.

+

+11.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:

 
 {
@@ -1454,21 +1429,21 @@ 

}

-

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.

-

-10.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.

-

-11. 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-04/vocab/applicator>.

-

The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-04/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.

-

-11.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:

+

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.

+

+11.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.

+

+12. 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-04/vocab/applicator>.

+

The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-04/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.

+

+12.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"
  • @@ -1478,147 +1453,147 @@

-

-11.2. Keywords for Applying Subschemas in Place +

+12.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.

-

-11.2.1. Keywords for Applying Subschemas With Boolean Logic +

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.

+

+12.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.

-

-11.2.1.1. allOf +

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.

+

+12.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.

-

-11.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.

-

-11.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.

-

-11.2.1.4. not +

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.

+

+12.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.

+

+12.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.

+

+12.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.

-

-11.2.2. Keywords for Applying Subschemas Conditionally +

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.

+

+12.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.

-

-11.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".

-

-11.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.

-

-11.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.

-

-11.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.

-

-11.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.

-

-11.3.1. Keywords for Applying Subschemas to Arrays

-

-11.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.

-

-11.3.1.2. additionalItems +

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.

+

+12.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".

+

+12.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.

+

+12.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.

+

+12.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.

+

+12.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.

+

+12.3.1. Keywords for Applying Subschemas to Arrays

+

+12.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.

+

+12.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.

-

-11.3.1.3. unevaluatedItems +

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.

+

+12.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.

-

-11.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. This keyword does not produce annotation results. [CREF7]Should it produce a set of the indices for which the array element is valid against the subschema? "contains" does not affect "additionalItems" or any other current or proposed keyword, but the information could be useful, and implementation that collect annotations need to apply "contains" to every element anyway.

-

-11.3.2. Keywords for Applying Subschemas to Objects

-

-11.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.

-

-11.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.

-

-11.3.2.3. additionalProperties +

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.

+

+12.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. This keyword does not produce annotation results. [CREF7]Should it produce a set of the indices for which the array element is valid against the subschema? "contains" does not affect "additionalItems" or any other current or proposed keyword, but the information could be useful, and implementation that collect annotations need to apply "contains" to every element anyway.

+

+12.3.2. Keywords for Applying Subschemas to Objects

+

+12.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.

+

+12.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.

+

+12.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.

-

-11.3.2.4. unevaluatedProperties +

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.

+

+12.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.

-

-11.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.

-

-12. Output Formatting +

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.

+

+12.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.

+

+13. 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.

+

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.

+

+13.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.

+

+13.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.
  • @@ -1628,47 +1603,47 @@

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 "$recursiveRef".

+

+13.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.

+

+13.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/minLength/$ref/minimum
 
                         
-

Note that this pointer may not be resolvable due to the inclusion of these 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 an absolute URI, and it MUST NOT include by-reference applicators such as "$ref" or "$recursiveRef".

+

Note that this pointer may not be resolvable due to the inclusion of these applicator keywords.

+

The JSON key for this information is "keywordLocation".

+

+13.3.2. Keyword Absolute Location

+

The absolute, dereferenced location of the validating keyword. The value MUST be expressed as an absolute URI, and it MUST NOT include by-reference applicators such as "$ref" or "$recursiveRef".

 
 http://json-schema.org/draft/2019-04/schema#/$defs/nonNegativeInteger/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.

-

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".

-

-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.

+

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".

+

+13.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".

+

+13.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.

+

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

+

+13.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".

+

+13.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
  • @@ -1710,8 +1685,8 @@

    ] -

    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:

    +

    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.
    • @@ -1720,9 +1695,9 @@

    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.

    +

    +13.4.1. Flag

    +

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

     
     {
    @@ -1730,10 +1705,10 @@ 

    }

    -

    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.

    +

    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.

    +

    +13.4.2. Basic

    +

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

     
     {
    @@ -1774,10 +1749,10 @@ 

    }

    -

    -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 correllation is more easily identified.

    -

    The following rules govern the construction of the results object:

    +

    +13.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 correllation 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.
    • @@ -1828,11 +1803,11 @@

      } -

      -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/2019-04/output/verbose-example>.

      +

      +13.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-04/output/verbose-example>.

       
       // schema
      @@ -1885,44 +1860,44 @@ 

      }

      -

      -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/2019-04/output/schema>.

      -

      -13. Usage for Hypermedia +

      +13.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-04/output/schema>.

      +

      +14. 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.

      -

      -13.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:

      +

      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.

      +

      +14.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: <http://example.com/my-hyper-schema#>; rel="describedby"
       
                           
      -

      -13.2. Identifying a Schema via a Media Type Parameter +

      +14.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:

      +

      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="http://example.com/my-hyper-schema#"
       
                           
      -

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

      +

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

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

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

      +

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

       
       Accept: application/json;
      @@ -1931,39 +1906,39 @@ 

      schema="http://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.

      +

      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.

      [CREF8]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"
       
                           
      -

      -13.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.

      +

      +14.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.

      -

      -14. 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.

      +

      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.

      -15. IANA Considerations

      -

      -15.1. application/schema+json

      -

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

      +15. 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.

      +

      +16. IANA Considerations

      +

      +16.1. application/schema+json

      +

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

      • Type name: application
      • @@ -1976,15 +1951,15 @@

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

      -

      -15.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:

      +

      +16.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
      • @@ -1996,16 +1971,16 @@

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

      -16. References

      +17. References

      -16.1. Normative References

      +17.1. Normative References @@ -2043,17 +2018,17 @@

      [ecma262]

      -16.2. Informative References

      +17.2. Informative References +Andrews, H. and A. Wright, "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON", Internet-Draft draft-handrews-json-schema-hyperschema-WIP, November 2017. +Wright, A., Andrews, H. and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of JSON", Internet-Draft draft-handrews-json-schema-validation-WIP, November 2017. diff --git a/work-in-progress/WIP-jsonschema-core.txt b/work-in-progress/WIP-jsonschema-core.txt index fd1d3a6b..19706a55 100644 --- a/work-in-progress/WIP-jsonschema-core.txt +++ b/work-in-progress/WIP-jsonschema-core.txt @@ -5,11 +5,11 @@ Internet Engineering Task Force A. Wright, Ed. Internet-Draft Intended status: Informational H. Andrews, Ed. -Expires: November 26, 2019 Riverbed Technology +Expires: January 14, 2020 Riverbed Technology B. Hutton, Ed. Wellcome Sanger Institute G. Dennis - May 25, 2019 + July 13, 2019 JSON Schema: A Media Type for Describing JSON Documents @@ -53,12 +53,12 @@ Status of This Memo -Wright, et al. Expires November 26, 2019 [Page 1] +Wright, et al. Expires January 14, 2020 [Page 1] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 - This Internet-Draft will expire on November 26, 2019. + This Internet-Draft will expire on January 14, 2020. Copyright Notice @@ -79,115 +79,111 @@ Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 2. Conventions and Terminology . . . . . . . . . . . . . . . . . 4 - 3. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 5 - 3.1. Keyword Behaviors . . . . . . . . . . . . . . . . . . . . 5 - 3.1.1. Keyword Interactions . . . . . . . . . . . . . . . . 5 - 3.1.2. Default Behaviors . . . . . . . . . . . . . . . . . . 6 - 3.1.3. Applicators . . . . . . . . . . . . . . . . . . . . . 6 - 3.1.4. Assertions . . . . . . . . . . . . . . . . . . . . . 7 - 3.1.5. Annotations . . . . . . . . . . . . . . . . . . . . . 7 - 3.2. Schema Vocabularies . . . . . . . . . . . . . . . . . . . 8 - 3.2.1. Subschema Application . . . . . . . . . . . . . . . . 8 - 3.2.2. Validation . . . . . . . . . . . . . . . . . . . . . 8 - 3.2.3. Basic Meta-Data . . . . . . . . . . . . . . . . . . . 9 - 3.2.4. Hypermedia and Linking . . . . . . . . . . . . . . . 9 - 4. Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 9 - 4.1. JSON Document . . . . . . . . . . . . . . . . . . . . . . 9 - 4.2. Instance . . . . . . . . . . . . . . . . . . . . . . . . 9 - 4.2.1. Instance Data Model . . . . . . . . . . . . . . . . . 9 - 4.2.2. Instance Media Types . . . . . . . . . . . . . . . . 10 - 4.2.3. Instance Equality . . . . . . . . . . . . . . . . . . 11 - 4.3. JSON Schema Documents . . . . . . . . . . . . . . . . . . 11 - 4.3.1. JSON Schema Objects and Keywords . . . . . . . . . . 12 - 4.3.2. Boolean JSON Schemas . . . . . . . . . . . . . . . . 12 - 4.3.3. Root Schema and Subschemas . . . . . . . . . . . . . 13 - 4.3.4. Lexical Scope and Dynamic Scope . . . . . . . . . . . 13 - 4.3.5. Referenced and Referencing Schemas . . . . . . . . . 14 - 5. Fragment Identifiers . . . . . . . . . . . . . . . . . . . . 15 - 6. General Considerations . . . . . . . . . . . . . . . . . . . 15 - 6.1. Range of JSON Values . . . . . . . . . . . . . . . . . . 15 - - - -Wright, et al. Expires November 26, 2019 [Page 2] - -Internet-Draft JSON Schema May 2019 - - - 6.2. Programming Language Independence . . . . . . . . . . . . 15 - 6.3. Mathematical Integers . . . . . . . . . . . . . . . . . . 16 - 6.4. Regular Expressions . . . . . . . . . . . . . . . . . . . 16 - 6.5. Extending JSON Schema . . . . . . . . . . . . . . . . . . 16 - 7. Meta-Schemas and Vocabularies . . . . . . . . . . . . . . . . 17 - 7.1. The "$schema" Keyword . . . . . . . . . . . . . . . . . . 18 - 7.2. The "$vocabulary" Keyword . . . . . . . . . . . . . . . . 18 - 7.3. Detecting a Meta-Schema . . . . . . . . . . . . . . . . . 20 - 7.4. Best Practices for Vocabulary and Meta-Schema Authors . . 20 - 7.5. The JSON Schema Core Vocabulary . . . . . . . . . . . . . 21 - 7.6. Example Meta-Schema With Vocabulary Declarations . . . . 22 - 8. Base URI and Dereferencing . . . . . . . . . . . . . . . . . 23 - 8.1. Initial Base URI . . . . . . . . . . . . . . . . . . . . 23 - 8.2. The "$id" Keyword . . . . . . . . . . . . . . . . . . . . 23 - 8.2.1. Identifying the root schema . . . . . . . . . . . . . 23 - 8.2.2. Changing the base URI within a schema file . . . . . 24 - 8.2.3. Location-independent identifiers . . . . . . . . . . 24 - 8.2.4. Schema identification examples . . . . . . . . . . . 24 - 8.3. Schema References . . . . . . . . . . . . . . . . . . . . 26 - 8.3.1. Direct References with "$ref" . . . . . . . . . . . . 26 - 8.3.2. Recursive References with "$recursiveRef" and + 3. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 4 + 4. Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 5 + 4.1. JSON Document . . . . . . . . . . . . . . . . . . . . . . 5 + 4.2. Instance . . . . . . . . . . . . . . . . . . . . . . . . 6 + 4.2.1. Instance Data Model . . . . . . . . . . . . . . . . . 6 + 4.2.2. Instance Media Types . . . . . . . . . . . . . . . . 7 + 4.2.3. Instance Equality . . . . . . . . . . . . . . . . . . 7 + 4.3. JSON Schema Documents . . . . . . . . . . . . . . . . . . 8 + 4.3.1. JSON Schema Objects and Keywords . . . . . . . . . . 8 + 4.3.2. Boolean JSON Schemas . . . . . . . . . . . . . . . . 9 + 4.3.3. Root Schema and Subschemas . . . . . . . . . . . . . 9 + 4.3.4. Lexical Scope and Dynamic Scope . . . . . . . . . . . 9 + 4.3.5. Referenced and Referencing Schemas . . . . . . . . . 10 + 5. Fragment Identifiers . . . . . . . . . . . . . . . . . . . . 11 + 6. General Considerations . . . . . . . . . . . . . . . . . . . 12 + 6.1. Range of JSON Values . . . . . . . . . . . . . . . . . . 12 + 6.2. Programming Language Independence . . . . . . . . . . . . 12 + 6.3. Mathematical Integers . . . . . . . . . . . . . . . . . . 12 + 6.4. Regular Expressions . . . . . . . . . . . . . . . . . . . 12 + 6.5. Extending JSON Schema . . . . . . . . . . . . . . . . . . 13 + 7. Keyword Behaviors . . . . . . . . . . . . . . . . . . . . . . 14 + 7.1. Keyword Interactions . . . . . . . . . . . . . . . . . . 14 + 7.2. Default Behaviors . . . . . . . . . . . . . . . . . . . . 14 + 7.3. Applicators . . . . . . . . . . . . . . . . . . . . . . . 15 + 7.4. Assertions . . . . . . . . . . . . . . . . . . . . . . . 15 + 7.4.1. Assertions and Instance Primitive Types . . . . . . . 16 + 7.5. Annotations . . . . . . . . . . . . . . . . . . . . . . . 16 + + + +Wright, et al. Expires January 14, 2020 [Page 2] + +Internet-Draft JSON Schema July 2019 + + + 8. Meta-Schemas and Vocabularies . . . . . . . . . . . . . . . . 17 + 8.1. The "$schema" Keyword . . . . . . . . . . . . . . . . . . 17 + 8.2. The "$vocabulary" Keyword . . . . . . . . . . . . . . . . 18 + 8.3. Detecting a Meta-Schema . . . . . . . . . . . . . . . . . 19 + 8.4. Best Practices for Vocabulary and Meta-Schema Authors . . 20 + 8.5. The JSON Schema Core Vocabulary . . . . . . . . . . . . . 20 + 8.6. Example Meta-Schema With Vocabulary Declarations . . . . 21 + 9. Base URI and Dereferencing . . . . . . . . . . . . . . . . . 23 + 9.1. Initial Base URI . . . . . . . . . . . . . . . . . . . . 23 + 9.2. The "$id" Keyword . . . . . . . . . . . . . . . . . . . . 23 + 9.2.1. Identifying the root schema . . . . . . . . . . . . . 23 + 9.2.2. Changing the base URI within a schema file . . . . . 24 + 9.2.3. Location-independent identifiers . . . . . . . . . . 24 + 9.2.4. Schema identification examples . . . . . . . . . . . 24 + 9.3. Schema References . . . . . . . . . . . . . . . . . . . . 26 + 9.3.1. Direct References with "$ref" . . . . . . . . . . . . 26 + 9.3.2. Recursive References with "$recursiveRef" and "$recursiveAnchor" . . . . . . . . . . . . . . . . . 27 - 8.3.3. Guarding Against Infinite Recursion . . . . . . . . . 31 - 8.3.4. References to Possible Non-Schemas . . . . . . . . . 31 - 8.3.5. Loading a referenced schema . . . . . . . . . . . . . 32 - 8.3.6. Dereferencing . . . . . . . . . . . . . . . . . . . . 32 - 8.4. Schema Re-Use With "$defs" . . . . . . . . . . . . . . . 33 - 9. Comments With "$comment" . . . . . . . . . . . . . . . . . . 34 - 10. Collecting Annotations . . . . . . . . . . . . . . . . . . . 34 - 10.1. Distinguishing Among Multiple Values . . . . . . . . . . 35 - 10.2. Annotations and Assertions . . . . . . . . . . . . . . . 37 - 10.3. Annotations and Applicators . . . . . . . . . . . . . . 38 - 11. A Vocabulary for Applying Subschemas . . . . . . . . . . . . 38 - 11.1. Keyword Independence . . . . . . . . . . . . . . . . . . 39 - 11.2. Keywords for Applying Subschemas in Place . . . . . . . 39 - 11.2.1. Keywords for Applying Subschemas With Boolean Logic 39 - 11.2.2. Keywords for Applying Subschemas Conditionally . . . 40 - 11.3. Keywords for Applying Subschemas to Child Instances . . 42 - 11.3.1. Keywords for Applying Subschemas to Arrays . . . . . 42 - 11.3.2. Keywords for Applying Subschemas to Objects . . . . 44 - 12. Output Formatting . . . . . . . . . . . . . . . . . . . . . . 47 - 12.1. Format . . . . . . . . . . . . . . . . . . . . . . . . . 47 - 12.2. Output Formats . . . . . . . . . . . . . . . . . . . . . 47 - 12.3. Minimum Information . . . . . . . . . . . . . . . . . . 47 - 12.3.1. Keyword Relative Location . . . . . . . . . . . . . 48 - 12.3.2. Keyword Absolute Location . . . . . . . . . . . . . 48 - 12.3.3. Instance Location . . . . . . . . . . . . . . . . . 48 - 12.3.4. Error or Annotation . . . . . . . . . . . . . . . . 49 - - - -Wright, et al. Expires November 26, 2019 [Page 3] - -Internet-Draft JSON Schema May 2019 - - - 12.3.5. Nested Results . . . . . . . . . . . . . . . . . . . 49 - 12.4. Output Structure . . . . . . . . . . . . . . . . . . . . 49 - 12.4.1. Flag . . . . . . . . . . . . . . . . . . . . . . . . 51 - 12.4.2. Basic . . . . . . . . . . . . . . . . . . . . . . . 51 - 12.4.3. Detailed . . . . . . . . . . . . . . . . . . . . . . 52 - 12.4.4. Verbose . . . . . . . . . . . . . . . . . . . . . . 54 - 12.4.5. Output validation schemas . . . . . . . . . . . . . 56 - 13. Usage for Hypermedia . . . . . . . . . . . . . . . . . . . . 56 - 13.1. Linking to a Schema . . . . . . . . . . . . . . . . . . 56 - 13.2. Identifying a Schema via a Media Type Parameter . . . . 56 - 13.3. Usage Over HTTP . . . . . . . . . . . . . . . . . . . . 58 - 14. Security Considerations . . . . . . . . . . . . . . . . . . . 58 - 15. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 59 - 15.1. application/schema+json . . . . . . . . . . . . . . . . 59 - 15.2. application/schema-instance+json . . . . . . . . . . . . 60 - 16. References . . . . . . . . . . . . . . . . . . . . . . . . . 60 - 16.1. Normative References . . . . . . . . . . . . . . . . . . 60 - 16.2. Informative References . . . . . . . . . . . . . . . . . 61 + 9.3.3. Guarding Against Infinite Recursion . . . . . . . . . 31 + 9.3.4. References to Possible Non-Schemas . . . . . . . . . 31 + 9.3.5. Loading a referenced schema . . . . . . . . . . . . . 32 + 9.3.6. Dereferencing . . . . . . . . . . . . . . . . . . . . 32 + 9.4. Schema Re-Use With "$defs" . . . . . . . . . . . . . . . 33 + 10. Comments With "$comment" . . . . . . . . . . . . . . . . . . 34 + 11. Collecting Annotations . . . . . . . . . . . . . . . . . . . 34 + 11.1. Distinguishing Among Multiple Values . . . . . . . . . . 35 + 11.2. Annotations and Assertions . . . . . . . . . . . . . . . 37 + 11.3. Annotations and Applicators . . . . . . . . . . . . . . 38 + 12. A Vocabulary for Applying Subschemas . . . . . . . . . . . . 38 + 12.1. Keyword Independence . . . . . . . . . . . . . . . . . . 39 + 12.2. Keywords for Applying Subschemas in Place . . . . . . . 39 + 12.2.1. Keywords for Applying Subschemas With Boolean Logic 39 + 12.2.2. Keywords for Applying Subschemas Conditionally . . . 40 + 12.3. Keywords for Applying Subschemas to Child Instances . . 42 + 12.3.1. Keywords for Applying Subschemas to Arrays . . . . . 42 + 12.3.2. Keywords for Applying Subschemas to Objects . . . . 44 + 13. Output Formatting . . . . . . . . . . . . . . . . . . . . . . 47 + 13.1. Format . . . . . . . . . . . . . . . . . . . . . . . . . 47 + 13.2. Output Formats . . . . . . . . . . . . . . . . . . . . . 47 + 13.3. Minimum Information . . . . . . . . . . . . . . . . . . 47 + 13.3.1. Keyword Relative Location . . . . . . . . . . . . . 48 + 13.3.2. Keyword Absolute Location . . . . . . . . . . . . . 48 + 13.3.3. Instance Location . . . . . . . . . . . . . . . . . 48 + 13.3.4. Error or Annotation . . . . . . . . . . . . . . . . 49 + 13.3.5. Nested Results . . . . . . . . . . . . . . . . . . . 49 + 13.4. Output Structure . . . . . . . . . . . . . . . . . . . . 49 + 13.4.1. Flag . . . . . . . . . . . . . . . . . . . . . . . . 51 + 13.4.2. Basic . . . . . . . . . . . . . . . . . . . . . . . 51 + + + +Wright, et al. Expires January 14, 2020 [Page 3] + +Internet-Draft JSON Schema July 2019 + + + 13.4.3. Detailed . . . . . . . . . . . . . . . . . . . . . . 52 + 13.4.4. Verbose . . . . . . . . . . . . . . . . . . . . . . 54 + 13.4.5. Output validation schemas . . . . . . . . . . . . . 56 + 14. Usage for Hypermedia . . . . . . . . . . . . . . . . . . . . 56 + 14.1. Linking to a Schema . . . . . . . . . . . . . . . . . . 56 + 14.2. Identifying a Schema via a Media Type Parameter . . . . 56 + 14.3. Usage Over HTTP . . . . . . . . . . . . . . . . . . . . 58 + 15. Security Considerations . . . . . . . . . . . . . . . . . . . 58 + 16. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 59 + 16.1. application/schema+json . . . . . . . . . . . . . . . . 59 + 16.2. application/schema-instance+json . . . . . . . . . . . . 60 + 17. References . . . . . . . . . . . . . . . . . . . . . . . . . 60 + 17.1. Normative References . . . . . . . . . . . . . . . . . . 60 + 17.2. Informative References . . . . . . . . . . . . . . . . . 61 Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . 63 Appendix B. ChangeLog . . . . . . . . . . . . . . . . . . . . . 63 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 66 @@ -217,261 +213,74 @@ Internet-Draft JSON Schema May 2019 and "null" in this document are to be interpreted as defined in RFC 8259 [RFC8259]. - - - - -Wright, et al. Expires November 26, 2019 [Page 4] - -Internet-Draft JSON Schema May 2019 - - 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. - -3.1. 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. - -3.1.1. Keyword Interactions - - Keyword behavior MAY be defined in terms of the annotation results of - subschemas (Section 4.3.3) 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 (Section 4.3). - - - - - - - -Wright, et al. Expires November 26, 2019 [Page 5] - -Internet-Draft JSON Schema May 2019 - - -3.1.2. 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. - -3.1.3. 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.3) 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 3.1.4) 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. - - - -Wright, et al. Expires November 26, 2019 [Page 6] - -Internet-Draft JSON Schema May 2019 - - - Annotation (Section 3.1.5) results are combined according to the - rules specified by each annotation keyword. - -3.1.4. 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. - -3.1.4.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. -3.1.5. 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. - - The default behavior is simply to collect all values in a list in - indeterminate order. Given the extensibility of keywords, including - applicators, it is not possible to define a universally predictable - order of processing. - - 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. - - - -Wright, et al. Expires November 26, 2019 [Page 7] +Wright, et al. Expires January 14, 2020 [Page 4] -Internet-Draft JSON Schema May 2019 - - - 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. +Internet-Draft JSON Schema July 2019 -3.2. Schema Vocabularies - A JSON Schema vocabulary is a set of keywords defined for a - particular purpose. The vocabulary specifies the meaning of its - keywords as assertions, annotations, and/or any vocabulary-defined - keyword category. - - Several vocabularies are provided as standards in this and closely - related documents. These vocabularies are used with the core - keywords defined as fundamental to the "application/schema+json" - media type. - - Schema authors are encouraged to define their own vocabularies for - domain-specific concepts. A vocabulary need not be a standard to be - re-usable, although users of extension vocabularies MUST NOT assume - that any JSON Schema implementation can support the vocabulary unless - it specifically documents such support. - -3.2.1. Subschema Application - - This vocabulary provides keywords for applying subschemas to the - instance in various ways. It is defined in this document, and it is - RECOMMENDED that all JSON Schema implementations support it. All - other vocabularies in this section are designed to be used alongside - the subschema application vocabulary. + 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. - Without this vocabulary or an equivalent one, JSON Schema can only be - applied to a JSON document as a whole. In most cases, schema - keywords need to be applied to specific object properties or array - items. + 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. -3.2.2. Validation +4. Definitions - This vocabulary describes the structure of a JSON document (for - instance, required properties and length limitations). Applications - can use this information to validate instances (check that - constraints are met), or inform interfaces to collect user input such - that the constraints are satisfied. +4.1. JSON Document - Validation behaviour and keywords are specified in a separate - document [json-schema-validation]. + A JSON document is an information resource (series of octets) + described by the application/json media type. -Wright, et al. Expires November 26, 2019 [Page 8] +Wright, et al. Expires January 14, 2020 [Page 5] -Internet-Draft JSON Schema May 2019 - +Internet-Draft JSON Schema July 2019 -3.2.3. Basic Meta-Data - - A small set of annotation keywords are defined in the validation - specification [json-schema-validation] to allow associating common - kinds of meta-data with an instance. - -3.2.4. Hypermedia and Linking - - JSON Hyper-Schema produces hyperlinks as annotations available for - use with a JSON document. It supports resolving URI Templates and - describing the resource and data submission formats required to use - an API. - - Hyper-schema behaviour and keywords are specified in a separate - document [json-hyper-schema]. - -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. @@ -497,15 +306,6 @@ Internet-Draft JSON Schema May 2019 null: A JSON "null" production - - - - -Wright, et al. Expires November 26, 2019 [Page 9] - -Internet-Draft JSON Schema May 2019 - - boolean: A "true" or "false" value, from the JSON "true" or "false" productions @@ -524,11 +324,20 @@ Internet-Draft JSON Schema May 2019 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 3.2) that wish to work with such differences in lexical + (Section 8) 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. + + + + +Wright, et al. Expires January 14, 2020 [Page 6] + +Internet-Draft JSON Schema July 2019 + + 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 @@ -552,16 +361,6 @@ Internet-Draft JSON Schema May 2019 content negotiation and in calculating URIs for specific locations within an instance, respectively. - - - - - -Wright, et al. Expires November 26, 2019 [Page 10] - -Internet-Draft JSON Schema May 2019 - - 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. @@ -588,6 +387,13 @@ Internet-Draft JSON Schema May 2019 property with a key equal to the other's, and that other property has an equal value. + + +Wright, et al. Expires January 14, 2020 [Page 7] + +Internet-Draft JSON Schema July 2019 + + 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 @@ -606,18 +412,6 @@ Internet-Draft JSON Schema May 2019 A JSON Schema MUST be an object or a boolean. - - - - - - - -Wright, et al. Expires November 26, 2019 [Page 11] - -Internet-Draft JSON Schema May 2019 - - 4.3.1. JSON Schema Objects and Keywords Object properties that are applied to the instance are called @@ -645,6 +439,17 @@ Internet-Draft JSON Schema May 2019 An empty schema is a JSON Schema with no properties, or only unknown properties. + + + + + + +Wright, et al. Expires January 14, 2020 [Page 8] + +Internet-Draft JSON Schema July 2019 + + 4.3.2. Boolean JSON Schemas The boolean schema values "true" and "false" are trivial schemas that @@ -664,16 +469,6 @@ Internet-Draft JSON Schema May 2019 equivalents to the "false" schema. Using the boolean values ensures that the intent is clear to both human readers and implementations. - - - - - -Wright, et al. Expires November 26, 2019 [Page 12] - -Internet-Draft JSON Schema May 2019 - - 4.3.3. Root Schema and Subschemas The root schema is the schema that comprises the entire JSON document @@ -703,6 +498,14 @@ Internet-Draft JSON Schema May 2019 most need to take into account the values or results of adjacent keywords in the same schema object, a few have more complex behavior. + + + +Wright, et al. Expires January 14, 2020 [Page 9] + +Internet-Draft JSON Schema July 2019 + + 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 @@ -721,15 +524,6 @@ Internet-Draft JSON Schema May 2019 scope of the entire schema document, and therefore MUST only appear in the document's root schema. - - - - -Wright, et al. Expires November 26, 2019 [Page 13] - -Internet-Draft JSON Schema May 2019 - - 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 @@ -757,9 +551,17 @@ Internet-Draft JSON Schema May 2019 4.3.5. Referenced and Referencing Schemas - As noted in Section 3.1.3, an applicator keyword may refer to a - schema to be applied, rather than including it as a subschema in the + As noted in Section 7.3, 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 + + + +Wright, et al. Expires January 14, 2020 [Page 10] + +Internet-Draft JSON Schema July 2019 + + known as the referenced schema, while the schema containing the applicator keyword is the referencing schema. @@ -769,23 +571,13 @@ Internet-Draft JSON Schema May 2019 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.3.1), + For some by-reference applicators, such as "$ref" (Section 9.3.1), 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. - - - - - -Wright, et al. Expires November 26, 2019 [Page 14] - -Internet-Draft JSON Schema May 2019 - - 5. Fragment Identifiers In accordance with section 3.1 of [RFC6839], the syntax and semantics @@ -812,121 +604,301 @@ Internet-Draft JSON Schema May 2019 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 "$id" keyword - (Section 8.2) section. + Defining and referencing a plain name fragment identifier within an + "application/schema+json" document are specified in the "$id" keyword + (Section 9.2) section. + + + + + + +Wright, et al. Expires January 14, 2020 [Page 11] + +Internet-Draft JSON Schema July 2019 + + +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 ECMA 262 + [ecma262] regular expression dialect. + + 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; + + + + +Wright, et al. Expires January 14, 2020 [Page 12] + +Internet-Draft JSON Schema July 2019 + + + 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. + + 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. + + A schema that itself describes a schema is called a meta-schema. + Meta-schemas are used to validate JSON Schemas and specify which + vocabulary they are using. + + Authors of extensions to JSON Schema are encouraged to write their + own meta-schemas, which extend the existing meta-schemas using + "allOf". This extended meta-schema SHOULD be referenced using the + "$schema" keyword, to allow tools to follow the correct behaviour. + + The recursive nature of meta-schemas makes the "$recursiveAnchor" and + "$recursiveRef" keywords particularly useful for such extensions, as + can be seen in the JSON Hyper-Schema meta-schema. + + + + + + + + +Wright, et al. Expires January 14, 2020 [Page 13] + +Internet-Draft JSON Schema July 2019 + + +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. + +7.1. Keyword Interactions + + Keyword behavior MAY be defined in terms of the annotation results of + subschemas (Section 4.3.3) 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 (Section 4.3). + +7.2. 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 + -6. General Considerations -6.1. Range of JSON Values +Wright, et al. Expires January 14, 2020 [Page 14] + +Internet-Draft JSON Schema July 2019 - 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 + the value which produces the default behavior would produce + annotation results if present, the default behavior still MUST NOT + result in annotations. - 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. + 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.3. 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.3) 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.4) 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.5) results are combined according to the rules + specified by each annotation keyword. +7.4. Assertions -Wright, et al. Expires November 26, 2019 [Page 15] - -Internet-Draft JSON Schema May 2019 + 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. -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 +Wright, et al. Expires January 14, 2020 [Page 15] + +Internet-Draft JSON Schema July 2019 - 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 ECMA 262 - [ecma262] regular expression dialect. - Furthermore, given the high disparity in regular expression - constructs support, schema authors SHOULD limit themselves to the - following regular expression tokens: + JSON Schema implementations produce a single boolean result when + evaluating an instance against schema assertions. - individual Unicode characters, as defined by the JSON - specification [RFC8259]; + An instance can only fail an assertion that is present in the schema. - simple character classes ([abc]), range character classes ([a-z]); +7.4.1. Assertions and Instance Primitive Types - complemented character classes ([^abc], [^a-z]); + 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. - simple quantifiers: "+" (one or more), "*" (zero or more), "?" - (zero or one), and their lazy versions ("+?", "*?", "??"); + 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. - range quantifiers: "{x}" (exactly x occurrences), "{x,y}" (at - least x, at most y, occurrences), {x,} (x occurrences or more), - and their lazy versions; +7.5. Annotations - the beginning-of-input ("^") and end-of-input ("$") anchors; + 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. - simple grouping ("(...)") and alternation ("|"). + 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. - 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". + The default behavior is simply to collect all values in a list in + indeterminate order. Given the extensibility of keywords, including + applicators, it is not possible to define a universally predictable + order of processing. -6.5. Extending JSON Schema + 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. - 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. + 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. -Wright, et al. Expires November 26, 2019 [Page 16] - -Internet-Draft JSON Schema May 2019 - 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. - A schema that itself describes a schema is called a meta-schema. - Meta-schemas are used to validate JSON Schemas and specify which - vocabulary they are using. - Authors of extensions to JSON Schema are encouraged to write their - own meta-schemas, which extend the existing meta-schemas using - "allOf". This extended meta-schema SHOULD be referenced using the - "$schema" keyword, to allow tools to follow the correct behaviour. +Wright, et al. Expires January 14, 2020 [Page 16] + +Internet-Draft JSON Schema July 2019 - The recursive nature of meta-schemas makes the "$recursiveAnchor" and - "$recursiveRef" keywords particularly useful for such extensions, as - can be seen in the JSON Hyper-Schema meta-schema. -7. Meta-Schemas and Vocabularies +8. Meta-Schemas and Vocabularies Two concepts, meta-schemas and vocabularies, are used to inform an implementation how to interpret a schema. A schema S declares its @@ -946,13 +918,10 @@ Internet-Draft JSON Schema May 2019 design of meta-schema features emphasizes flexibility over simplicity. - - - -Wright, et al. Expires November 26, 2019 [Page 17] - -Internet-Draft JSON Schema May 2019 - + A JSON Schema vocabulary is a set of keywords defined for a + particular purpose. The vocabulary specifies the meaning of its + keywords as assertions, annotations, and/or any vocabulary-defined + keyword category. The role of a vocabulary is to declare which keywords (including sub- keywords such as those in JSON Hyper-Schema's Link Description @@ -967,7 +936,7 @@ Internet-Draft JSON Schema May 2019 certain keywords, or performing unusually strict syntactical validation, as might be done during a development and testing cycle. -7.1. The "$schema" Keyword +8.1. The "$schema" Keyword The "$schema" keyword is both used as a JSON Schema feature set identifier and the location of a resource which is itself a JSON @@ -978,6 +947,13 @@ Internet-Draft JSON Schema May 2019 scheme) and this URI MUST be normalized. The current schema MUST be valid against the meta-schema identified by this URI. + + +Wright, et al. Expires January 14, 2020 [Page 17] + +Internet-Draft JSON Schema July 2019 + + If this URI identifies a retrievable resource, that resource SHOULD be of media type "application/schema+json". @@ -996,20 +972,11 @@ Internet-Draft JSON Schema May 2019 Values for this property are defined elsewhere in this and other documents, and by other parties. -7.2. The "$vocabulary" Keyword +8.2. The "$vocabulary" Keyword The "$vocabulary" keyword, which appears in a meta-schema, identifies what sets of keywords are expected to be used in schemas described by that meta-schema, and with what semantics. This is conceptually - - - - -Wright, et al. Expires November 26, 2019 [Page 18] - -Internet-Draft JSON Schema May 2019 - - analogous to how most other keywords used in meta-schemas describe the syntax of keywords used in schemas described by that meta-schema. @@ -1034,6 +1001,15 @@ Internet-Draft JSON Schema May 2019 recognize the vocabulary MAY choose to proceed with processing such schemas. + + + + +Wright, et al. Expires January 14, 2020 [Page 18] + +Internet-Draft JSON Schema July 2019 + + When processing a schema that uses unrecognized vocabularies, keywords declared by those vocabularies are treated like any other unrecognized keyword, and ignored. @@ -1053,25 +1029,17 @@ Internet-Draft JSON Schema May 2019 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 - (Section 7.6). + (Section 8.6). 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. If the meta-schema, as - - - -Wright, et al. Expires November 26, 2019 [Page 19] - -Internet-Draft JSON Schema May 2019 - - referenced by the schema, is not recognized, then implementations MUST assume the use of the core vocabulary, and SHOULD assume the use of all vocabularies in this specification and the companion Validation specification. -7.3. Detecting a Meta-Schema +8.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 @@ -1089,10 +1057,19 @@ Internet-Draft JSON Schema May 2019 Implementations MAY allow a schema to be 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 + + + + +Wright, et al. Expires January 14, 2020 [Page 19] + +Internet-Draft JSON Schema July 2019 + + front. Meta-schema authors MUST NOT expect such features to be interoperable across implementations. -7.4. Best Practices for Vocabulary and Meta-Schema Authors +8.4. Best Practices for Vocabulary and Meta-Schema Authors Meta-schema authors SHOULD NOT use "$vocabulary" to combine multiple vocabularies that define conflicting syntax or semantics for the same @@ -1107,21 +1084,13 @@ Internet-Draft JSON Schema May 2019 "$schema", or "$vocabulary" keywords in the root schema. It is RECOMMENDED that meta-schema authors reference each - vocabulary's meta-schema using the "allOf" (Section 11.2.1.1) + vocabulary's meta-schema using the "allOf" (Section 12.2.1.1) keyword, although other mechanisms for constructing the meta-schema may be appropriate for certain use cases. 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 - - - -Wright, et al. Expires November 26, 2019 [Page 20] - -Internet-Draft JSON Schema May 2019 - - restricting usage to a subset of a vocabulary, and for validating locally defined keywords not intended for re-use. @@ -1133,7 +1102,7 @@ Internet-Draft JSON Schema May 2019 vocabulary support in arbitrary implementations, can safely omit "$vocabulary" entirely. -7.5. The JSON Schema Core Vocabulary +8.5. The JSON Schema Core Vocabulary Keywords declared in in this specification that begin with "$" make up the JSON Schema Core vocabulary. These keywords are either @@ -1144,6 +1113,15 @@ Internet-Draft JSON Schema May 2019 The Core vocabulary MUST be considered mandatory at all times, in order to bootstrap the processing of further vocabularies. Meta- schemas that use "$vocabulary" MUST explicitly list the Core + + + + +Wright, et al. Expires January 14, 2020 [Page 20] + +Internet-Draft JSON Schema July 2019 + + vocabulary, which MUST have a value of true indicating that it is required. @@ -1169,16 +1147,36 @@ Internet-Draft JSON Schema May 2019 the next to indicate the same syntax and semantics as those listed here. +8.6. Example Meta-Schema With Vocabulary Declarations + + + + -Wright, et al. Expires November 26, 2019 [Page 21] - -Internet-Draft JSON Schema May 2019 -7.6. Example Meta-Schema With Vocabulary Declarations + + + + + + + + + + + + + + + +Wright, et al. Expires January 14, 2020 [Page 21] + +Internet-Draft JSON Schema July 2019 + This meta-schema explicitly declares both the Core and Applicator vocabularies, and combines their meta-schemas with an "allOf". It @@ -1225,25 +1223,24 @@ Internet-Draft JSON Schema May 2019 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. -Wright, et al. Expires November 26, 2019 [Page 22] +Wright, et al. Expires January 14, 2020 [Page 22] -Internet-Draft JSON Schema May 2019 - +Internet-Draft JSON Schema July 2019 - These URIs for these meta-schemas may be found in the Validation and - Hyper-Schema specifications, respectively. -8. Base URI and Dereferencing +9. Base URI 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. -8.1. Initial Base URI +9.1. Initial Base URI RFC3986 Section 5.1 [RFC3986] defines how to determine the default base URI of a document. @@ -1253,26 +1250,30 @@ Internet-Draft JSON Schema May 2019 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. -8.2. The "$id" Keyword +9.2. The "$id" Keyword The "$id" keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. A subschema's "$id" is resolved against the base URI of its parent - schema. If no parent sets an explicit base with "$id", the base URI - is that of the entire document, as determined per RFC 3986 section 5 - [RFC3986]. + schema. If no parent schema defines an explicit base URI with "$id", + the base URI is that of the entire document, as determined per RFC + 3986 section 5 [RFC3986]. If present, the value for this keyword MUST be a string, and MUST represent a valid URI-reference [RFC3986]. This value SHOULD be normalized, and SHOULD NOT be an empty fragment <#> or an empty string <>. -8.2.1. Identifying the root schema +9.2.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 @@ -1284,13 +1285,12 @@ Internet-Draft JSON Schema May 2019 - -Wright, et al. Expires November 26, 2019 [Page 23] +Wright, et al. Expires January 14, 2020 [Page 23] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 -8.2.2. Changing the base URI within a schema file +9.2.2. Changing the base URI within a schema file When an "$id" sets the base URI, the object containing that "$id" and all of its subschemas can be identified by using a JSON Pointer @@ -1300,9 +1300,9 @@ Internet-Draft JSON Schema May 2019 URI declared in the subschema or a parent, along with a JSON Pointer fragment identifying the path from the schema object that declares the base to the subschema being identified. Examples of this are - shown in section 8.2.4. + shown in section 9.2.4. -8.2.3. Location-independent identifiers +9.2.3. Location-independent identifiers Using JSON Pointer fragments requires knowledge of the structure of the schema. When writing schema documents with the intention to @@ -1324,7 +1324,7 @@ Internet-Draft JSON Schema May 2019 interpreted? There are two cases: when the other components match the current base URI and when they change the base URI. ]] -8.2.4. Schema identification examples +9.2.4. Schema identification examples @@ -1341,9 +1341,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 24] +Wright, et al. Expires January 14, 2020 [Page 24] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 Consider the following schema, which shows "$id" being used to @@ -1397,9 +1397,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 25] +Wright, et al. Expires January 14, 2020 [Page 25] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 http://example.com/other.json#bar @@ -1426,7 +1426,7 @@ Internet-Draft JSON Schema May 2019 http://example.com/root.json#/$defs/C -8.3. Schema References +9.3. Schema References Several keywords can be used to reference a schema which is to be applied to the current instance location. "$ref" and "$recursiveRef" @@ -1445,7 +1445,7 @@ Internet-Draft JSON Schema May 2019 implementations SHOULD NOT assume they should perform a network operation when they encounter a network-addressable URI. -8.3.1. Direct References with "$ref" +9.3.1. Direct References with "$ref" The "$ref" keyword is used to reference a statically identified schema. @@ -1453,16 +1453,16 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 26] +Wright, et al. Expires January 14, 2020 [Page 26] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 The value of the "$ref" property MUST be a string which is a URI Reference. Resolved against the current URI base, it identifies the URI of a schema to use. -8.3.2. Recursive References with "$recursiveRef" and "$recursiveAnchor" +9.3.2. Recursive References with "$recursiveRef" and "$recursiveAnchor" The "$recursiveRef" and "$recursiveAnchor" keywords are used to construct extensible recursive schemas. A recursive schema is one @@ -1509,9 +1509,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 27] +Wright, et al. Expires January 14, 2020 [Page 27] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 Consider the following two schemas. The first schema, identified as @@ -1565,9 +1565,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 28] +Wright, et al. Expires January 14, 2020 [Page 28] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 This approach is fine for a single recursive field, but the more @@ -1577,7 +1577,7 @@ Internet-Draft JSON Schema May 2019 original changes its recursive fields. This approach can be seen in the meta-schema for JSON Hyper-Schema in all prior drafts. -8.3.2.1. Enabling Recursion with "$recursiveAnchor" +9.3.2.1. Enabling Recursion with "$recursiveAnchor" The desired behavior is for the recursive reference, "r", in the original schema to resolve to the original schema when that is the @@ -1609,7 +1609,7 @@ Internet-Draft JSON Schema May 2019 The value of "$recursiveAnchor" MUST be of type boolean, and MUST be true. The value false is reserved for possible future use. -8.3.2.2. Dynamically recursive references with "$recursiveRef" +9.3.2.2. Dynamically recursive references with "$recursiveRef" The "$recursiveRef" keyword behaves identically to "$ref", except that if the referenced schema has "$recursiveAnchor" set to true, @@ -1621,9 +1621,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 29] +Wright, et al. Expires January 14, 2020 [Page 29] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 Note that if the schema referenced by "$recursiveRef" does not @@ -1677,9 +1677,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 30] +Wright, et al. Expires January 14, 2020 [Page 30] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 the only schema document in the dynamics scope (it references itself, @@ -1700,7 +1700,7 @@ Internet-Draft JSON Schema May 2019 original schema will resolve to "https://example.com/extension#", not "https://example.com/original#". -8.3.3. Guarding Against Infinite Recursion +9.3.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" @@ -1709,7 +1709,7 @@ Internet-Draft JSON Schema May 2019 Schemas SHOULD NOT make use of infinite recursive nesting like this; the behavior is undefined. -8.3.4. References to Possible Non-Schemas +9.3.4. References to Possible Non-Schemas Subschema objects (or booleans) are recognized by their use with known applicator keywords. These keywords may be the standard @@ -1733,9 +1733,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 31] +Wright, et al. Expires January 14, 2020 [Page 31] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 Note that single-level custom keywords with identical syntax and @@ -1745,7 +1745,7 @@ Internet-Draft JSON Schema May 2019 behavior is implementation-specific and MUST NOT be relied upon for interoperability. -8.3.5. Loading a referenced schema +9.3.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 @@ -1754,7 +1754,7 @@ Internet-Draft JSON Schema May 2019 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 (Section 13). + Hypermedia (Section 14). Implementations SHOULD be able to associate arbitrary URIs with an arbitrary schema and/or automatically associate a schema's "$id"- @@ -1762,14 +1762,14 @@ Internet-Draft JSON Schema May 2019 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 - section 8.2.4. + section 9.2.4. 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.3.6. Dereferencing +9.3.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 @@ -1789,9 +1789,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 32] +Wright, et al. Expires January 14, 2020 [Page 32] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 { @@ -1831,7 +1831,7 @@ Internet-Draft JSON Schema May 2019 system dynamically, so placing an absolute requirement of pre-loading schema documents is not feasible. ]] -8.4. Schema Re-Use With "$defs" +9.4. Schema Re-Use With "$defs" The "$defs" keyword provides a standardized location for schema authors to inline re-usable JSON Schemas into a more general schema. @@ -1845,9 +1845,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 33] +Wright, et al. Expires January 14, 2020 [Page 33] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 As an example, here is a schema describing an array of positive @@ -1867,7 +1867,7 @@ Internet-Draft JSON Schema May 2019 } -9. Comments With "$comment" +10. Comments With "$comment" This keyword is reserved for comments from schema authors to readers or maintainers of the schema. The value of this keyword MUST be a @@ -1893,7 +1893,7 @@ Internet-Draft JSON Schema May 2019 "$comment" properties. In particular, the value of "$comment" MUST NOT be collected as an annotation result. -10. Collecting Annotations +11. Collecting Annotations Annotations are collected by keywords that explicitly define annotation-collecting behavior. Note that boolean schemas cannot @@ -1901,9 +1901,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 34] +Wright, et al. Expires January 14, 2020 [Page 34] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 A collected annotation MUST include the following information: @@ -1926,7 +1926,7 @@ Internet-Draft JSON Schema May 2019 combining such values, then the combined value MUST also be associated with the instance location. -10.1. Distinguishing Among Multiple Values +11.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 @@ -1957,9 +1957,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 35] +Wright, et al. Expires January 14, 2020 [Page 35] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 Note that some lines are wrapped for clarity. @@ -2013,9 +2013,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 36] +Wright, et al. Expires January 14, 2020 [Page 36] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 value for Feature A, and the additional "description" value for @@ -2048,7 +2048,7 @@ Internet-Draft JSON Schema May 2019 presence of two different values for "default" to be an error, regardless of their schema locations. -10.2. Annotations and Assertions +11.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 @@ -2069,9 +2069,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 37] +Wright, et al. Expires January 14, 2020 [Page 37] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 { @@ -2093,7 +2093,7 @@ Internet-Draft JSON Schema May 2019 fails. The title annotation "String Value" is kept, as the instance passes the string type assertions. -10.3. Annotations and Applicators +11.3. Annotations and Applicators In addition to possibly defining annotation results of their own, applicator keywords aggregate the annotations collected in their @@ -2101,7 +2101,7 @@ Internet-Draft JSON Schema May 2019 annotation values are defined by each annotation keyword, and are not directly affected by the logic used for combining assertion results. -11. A Vocabulary for Applying Subschemas +12. A Vocabulary for Applying Subschemas This section defines a vocabulary of applicator keywords that are RECOMMENDED for use as the basis of other vocabularies. @@ -2125,12 +2125,12 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 38] +Wright, et al. Expires January 14, 2020 [Page 38] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 -11.1. Keyword Independence +12.1. Keyword Independence Schema keywords typically operate independently, without affecting each other's outcomes. @@ -2150,13 +2150,13 @@ Internet-Draft JSON Schema May 2019 "unevaluatedItems", whose behavior is defined in terms of annotations from "items", "additionalItems" and itself -11.2. Keywords for Applying Subschemas in Place +12.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. -11.2.1. Keywords for Applying Subschemas With Boolean Logic +12.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 @@ -2165,7 +2165,7 @@ Internet-Draft JSON Schema May 2019 different values. Annotation keywords define their own rules for combining such values. -11.2.1.1. allOf +12.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. @@ -2181,12 +2181,12 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 39] +Wright, et al. Expires January 14, 2020 [Page 39] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 -11.2.1.2. anyOf +12.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. @@ -2195,7 +2195,7 @@ Internet-Draft JSON Schema May 2019 validates successfully against at least one schema defined by this keyword's value. -11.2.1.3. oneOf +12.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. @@ -2204,14 +2204,14 @@ Internet-Draft JSON Schema May 2019 validates successfully against exactly one schema defined by this keyword's value. -11.2.1.4. not +12.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. -11.2.2. Keywords for Applying Subschemas Conditionally +12.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. @@ -2227,7 +2227,7 @@ Internet-Draft JSON Schema May 2019 present with an empty schema, and when "if" is not present, both "then" and "else" MUST be entirely ignored. -11.2.2.1. if +12.2.2.1. if This keyword's value MUST be a valid JSON Schema. @@ -2237,9 +2237,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 40] +Wright, et al. Expires January 14, 2020 [Page 40] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 Instances that successfully validate against this keyword's subschema @@ -2250,11 +2250,11 @@ Internet-Draft JSON Schema May 2019 also be valid against the subschema value of the "else" keyword, if present. - If annotations (Section 3.1.5) 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". + If annotations (Section 7.5) 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". -11.2.2.2. then +12.2.2.2. then This keyword's value MUST be a valid JSON Schema. @@ -2268,7 +2268,7 @@ Internet-Draft JSON Schema May 2019 evaluate the instance against this keyword, for either validation or annotation collection purposes, in such cases. -11.2.2.3. else +12.2.2.3. else This keyword's value MUST be a valid JSON Schema. @@ -2281,7 +2281,7 @@ Internet-Draft JSON Schema May 2019 NOT evaluate the instance against this keyword, for either validation or annotation collection purposes, in such cases. -11.2.2.4. dependentSchemas +12.2.2.4. dependentSchemas This keyword specifies subschemas that are evaluated if the instance is an object and contains a certain property. @@ -2293,9 +2293,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 41] +Wright, et al. Expires January 14, 2020 [Page 41] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 If the object key is a property in the instance, the entire instance @@ -2304,15 +2304,15 @@ Internet-Draft JSON Schema May 2019 Omitting this keyword has the same behavior as an empty object. -11.3. Keywords for Applying Subschemas to Child Instances +12.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. -11.3.1. Keywords for Applying Subschemas to Arrays +12.3.1. Keywords for Applying Subschemas to Arrays -11.3.1.1. items +12.3.1.1. items The value of "items" MUST be either a valid JSON Schema or an array of valid JSON Schemas. @@ -2337,7 +2337,7 @@ Internet-Draft JSON Schema May 2019 Omitting this keyword has the same assertion behavior as an empty schema. -11.3.1.2. additionalItems +12.3.1.2. additionalItems The value of "additionalItems" MUST be a valid JSON Schema. @@ -2349,9 +2349,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 42] +Wright, et al. Expires January 14, 2020 [Page 42] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 Otherwise, if "items" is absent or its annotation result is the @@ -2372,7 +2372,7 @@ Internet-Draft JSON Schema May 2019 checking for the presence and size of an "items" array. Implementations that do not support annotation collection MUST do so. -11.3.1.3. unevaluatedItems +12.3.1.3. unevaluatedItems The value of "unevaluatedItems" MUST be a valid JSON Schema. @@ -2382,7 +2382,7 @@ Internet-Draft JSON Schema May 2019 "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 (Section 11.2) keywords. This includes + adjacent in-place applicator (Section 12.2) keywords. This includes but is not limited to the in-place applicators defined in this document. @@ -2405,9 +2405,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 43] +Wright, et al. Expires January 14, 2020 [Page 43] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 If the "unevaluatedItems" subschema is applied to any positions @@ -2423,7 +2423,7 @@ Internet-Draft JSON Schema May 2019 Implementations that do not collect annotations MUST raise an error upon encountering this keyword. -11.3.1.4. contains +12.3.1.4. contains The value of this keyword MUST be a valid JSON Schema. @@ -2436,9 +2436,9 @@ Internet-Draft JSON Schema May 2019 implementation that collect annotations need to apply "contains" to every element anyway. ]] -11.3.2. Keywords for Applying Subschemas to Objects +12.3.2. Keywords for Applying Subschemas to Objects -11.3.2.1. properties +12.3.2.1. properties The value of "properties" MUST be an object. Each value of this object MUST be a valid JSON Schema. @@ -2461,12 +2461,12 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 44] +Wright, et al. Expires January 14, 2020 [Page 44] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 -11.3.2.2. patternProperties +12.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 @@ -2487,7 +2487,7 @@ Internet-Draft JSON Schema May 2019 Omitting this keyword has the same assertion behavior as an empty object. -11.3.2.3. additionalProperties +12.3.2.3. additionalProperties The value of "additionalProperties" MUST be a valid JSON Schema. @@ -2517,12 +2517,12 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 45] +Wright, et al. Expires January 14, 2020 [Page 45] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 -11.3.2.4. unevaluatedProperties +12.3.2.4. unevaluatedProperties The value of "unevaluatedProperties" MUST be a valid JSON Schema. @@ -2533,7 +2533,7 @@ Internet-Draft JSON Schema May 2019 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 11.2) keywords. This includes but is + in-place applicator (Section 12.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 @@ -2562,7 +2562,7 @@ Internet-Draft JSON Schema May 2019 Implementations that do not collect annotations MUST raise an error upon encountering this keyword. -11.3.2.5. propertyNames +12.3.2.5. propertyNames The value of "propertyNames" MUST be a valid JSON Schema. @@ -2573,14 +2573,14 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 46] +Wright, et al. Expires January 14, 2020 [Page 46] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 Omitting this keyword has the same behavior as an empty schema. -12. Output Formatting +13. Output Formatting JSON Schema is defined to be platform-independent. As such, to increase compatibility across platforms, implementations SHOULD @@ -2588,7 +2588,7 @@ Internet-Draft JSON Schema May 2019 describes the minimum requirements that consumers will need to properly interpret validation results. -12.1. Format +13.1. Format JSON Schema output is defined using the JSON Schema data instance model as described in section 4.2.1. Implementations MAY deviate @@ -2596,7 +2596,7 @@ Internet-Draft JSON Schema May 2019 however it is RECOMMENDED that the output be convertible to the JSON format defined herein via serialization or other means. -12.2. Output Formats +13.2. Output Formats This specification defines four output formats. See the "Output Structure" section for the requirements of each format. @@ -2619,7 +2619,7 @@ Internet-Draft JSON Schema May 2019 "flag" format. Implementations SHOULD specify in their documentation which formats they support. -12.3. Minimum Information +13.3. Minimum Information Beyond the simplistic "flag" output, additional information is useful to aid in debugging a schema or instance. Each sub-result SHOULD @@ -2629,9 +2629,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 47] +Wright, et al. Expires January 14, 2020 [Page 47] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 A single object that contains all of these components is considered @@ -2639,7 +2639,7 @@ Internet-Draft JSON Schema May 2019 Implementations MAY elect to provide additional information. -12.3.1. Keyword Relative Location +13.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 @@ -2655,7 +2655,7 @@ Internet-Draft JSON Schema May 2019 The JSON key for this information is "keywordLocation". -12.3.2. Keyword Absolute Location +13.3.2. Keyword Absolute Location The absolute, dereferenced location of the validating keyword. The value MUST be expressed as an absolute URI, and it MUST NOT include @@ -2671,7 +2671,7 @@ http://json-schema.org/draft/2019-04/schema#/$defs/nonNegativeInteger/minimum The JSON key for this information is "absoluteKeywordLocation". -12.3.3. Instance Location +13.3.3. Instance Location The location of the JSON value within the instance being validated. The value MUST be expressed as a JSON Pointer. @@ -2685,12 +2685,12 @@ http://json-schema.org/draft/2019-04/schema#/$defs/nonNegativeInteger/minimum -Wright, et al. Expires November 26, 2019 [Page 48] +Wright, et al. Expires January 14, 2020 [Page 48] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 -12.3.4. Error or Annotation +13.3.4. Error or Annotation The error or annotation that is produced by the validation. @@ -2700,7 +2700,7 @@ Internet-Draft JSON Schema May 2019 The JSON key for failed validations is "error"; for successful validations it is "annotation". -12.3.5. Nested Results +13.3.5. Nested Results For the two hierarchical structures, this property will hold nested errors and annotations. @@ -2708,7 +2708,7 @@ Internet-Draft JSON Schema May 2019 The JSON key for nested results in failed validations is "errors"; for successful validations it is "annotations". -12.4. Output Structure +13.4. Output Structure The output MUST be an object containing a boolean property named "valid". When additional information about the result is required, @@ -2741,9 +2741,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 49] +Wright, et al. Expires January 14, 2020 [Page 49] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 { @@ -2791,21 +2791,21 @@ Internet-Draft JSON Schema May 2019 There are only two vertices, but three are required. - Note that neither the error message property nor its wording as - depicted in these examples is not a requirement of this + 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 - -Wright, et al. Expires November 26, 2019 [Page 50] +Wright, et al. Expires January 14, 2020 [Page 50] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 - specification. Implementations SHOULD craft error messages tailored - for their audience. + templating mechanism that allows their users to craft their own + messages. -12.4.1. Flag +13.4.1. Flag In the simplest case, merely the boolean result for the "valid" valid property needs to be fulfilled. @@ -2823,7 +2823,7 @@ Internet-Draft JSON Schema May 2019 second one passes, there is no need to check the other three. The logic can simply return with success. -12.4.2. Basic +13.4.2. Basic The "Basic" structure is a flat list of output units. @@ -2853,50 +2853,50 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 51] +Wright, et al. Expires January 14, 2020 [Page 51] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 -{ - "valid": false, - "errors": [ - { - "keywordLocation": "#", - "instanceLocation": "#", - "error": "A subschema had errors." - }, - { - "keywordLocation": "#/items/$ref", - "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point", - "instanceLocation": "#/1", - "error": "A subschema had errors." - }, - { - "keywordLocation": "#/items/$ref/required", - "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/required", - "instanceLocation": "#/1", - "error": "Required property 'y' not found." - }, - { - "keywordLocation": "#/items/$ref/additionalProperties", - "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/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" - } - ] -} + { + "valid": false, + "errors": [ + { + "keywordLocation": "#", + "instanceLocation": "#", + "error": "A subschema had errors." + }, + { + "keywordLocation": "#/items/$ref", + "absoluteKeywordLocation": + "http://example.com/polygon#/$defs/point", + "instanceLocation": "#/1", + "error": "A subschema had errors." + }, + { + "keywordLocation": "#/items/$ref/required", + "absoluteKeywordLocation": + "http://example.com/polygon#/$defs/point/required", + "instanceLocation": "#/1", + "error": "Required property 'y' not found." + }, + { + "keywordLocation": "#/items/$ref/additionalProperties", + "absoluteKeywordLocation": + "http://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 +13.4.3. Detailed The "Detailed" structure is based on the schema and can be more readable for both humans and machines. Having the structure @@ -2909,9 +2909,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 52] +Wright, et al. Expires January 14, 2020 [Page 52] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 The following rules govern the construction of the results object: @@ -2965,9 +2965,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 53] +Wright, et al. Expires January 14, 2020 [Page 53] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 { @@ -2979,14 +2979,14 @@ Internet-Draft JSON Schema May 2019 "valid": false, "keywordLocation": "#/items/$ref", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point", + "http://example.com/polygon#/$defs/point", "instanceLocation": "#/1", "errors": [ { "valid": false, "keywordLocation": "#/items/$ref/required", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/required", + "http://example.com/polygon#/$defs/point/required", "instanceLocation": "#/1", "error": "Required property 'y' not found." }, @@ -2994,7 +2994,7 @@ Internet-Draft JSON Schema May 2019 "valid": false, "keywordLocation": "#/items/$ref/additionalProperties", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/additionalProperties", + "http://example.com/polygon#/$defs/point/additionalProperties", "instanceLocation": "#/1/z", "error": "Additional property 'z' found but was invalid." } @@ -3010,7 +3010,7 @@ Internet-Draft JSON Schema May 2019 } -12.4.4. Verbose +13.4.4. Verbose The "Verbose" structure is a fully realized hierarchy that exactly matches that of the schema. This structure has applications in form @@ -3021,9 +3021,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 54] +Wright, et al. Expires January 14, 2020 [Page 54] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 results that would otherwise be removed (e.g. annotations for failed @@ -3077,9 +3077,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 55] +Wright, et al. Expires January 14, 2020 [Page 55] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 "errors": [ @@ -3095,20 +3095,20 @@ Internet-Draft JSON Schema May 2019 } -12.4.5. Output validation schemas +13.4.5. Output validation schemas For convenience, JSON Schema has been provided to validate output generated by implementations. Its URI is: . -13. Usage for Hypermedia +14. 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]. -13.1. Linking to a Schema +14.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", @@ -3122,7 +3122,7 @@ Internet-Draft JSON Schema May 2019 Link: ; rel="describedby" -13.2. Identifying a Schema via a Media Type Parameter +14.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 @@ -3133,9 +3133,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 56] +Wright, et al. Expires January 14, 2020 [Page 56] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 When using the media type application/schema-instance+json, the @@ -3189,9 +3189,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 57] +Wright, et al. Expires January 14, 2020 [Page 57] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 Unlike Content-Type, Accept can contain multiple values to indicate @@ -3210,7 +3210,7 @@ Internet-Draft JSON Schema May 2019 Link: ;rel="schema", ;rel="schema" -13.3. Usage Over HTTP +14.3. Usage Over HTTP When used for hypermedia systems over a network, HTTP [RFC7231] is frequently the protocol of choice for distributing schemas. @@ -3237,7 +3237,7 @@ Internet-Draft JSON Schema May 2019 server operators can contact the owner of a potentially misbehaving script. -14. Security Considerations +15. Security Considerations Both schemas and instances are JSON values. As such, all security considerations defined in RFC 8259 [RFC8259] apply. @@ -3245,9 +3245,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 58] +Wright, et al. Expires January 14, 2020 [Page 58] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 Instances and schemas are both frequently written by untrusted third @@ -3272,9 +3272,9 @@ Internet-Draft JSON Schema May 2019 dangerous material within a "$comment". Implementations MUST NOT parse or otherwise take action based on "$comment" contents. -15. IANA Considerations +16. IANA Considerations -15.1. application/schema+json +16.1. application/schema+json The proposed MIME media type for JSON Schema is defined as follows: @@ -3301,19 +3301,19 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 59] +Wright, et al. Expires January 14, 2020 [Page 59] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 - Security considerations: See Section 14 above. + Security considerations: See Section 15 above. Interoperability considerations: See Sections 6.2, 6.3, and 6.4 above. Fragment identifier considerations: See Section 5 -15.2. application/schema-instance+json +16.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: @@ -3336,16 +3336,16 @@ Internet-Draft JSON Schema May 2019 those specified for the "application/json" media type. See JSON [RFC8259]. - Security considerations: See Section 14 above. + Security considerations: See Section 15 above. Interoperability considerations: See Sections 6.2, 6.3, and 6.4 above. Fragment identifier considerations: See Section 5 -16. References +17. References -16.1. Normative References +17.1. Normative References [ecma262] "ECMA 262 specification", . -16.2. Informative References +17.2. Informative References [json-hyper-schema] Andrews, H. and A. Wright, "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON", draft- - handrews-json-schema-hyperschema-02 (work in progress), + handrews-json-schema-hyperschema-WIP (work in progress), November 2017. [json-schema-validation] @@ -3413,9 +3413,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 61] +Wright, et al. Expires January 14, 2020 [Page 61] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer @@ -3469,9 +3469,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 62] +Wright, et al. Expires January 14, 2020 [Page 62] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 Appendix A. Acknowledgments @@ -3490,7 +3490,7 @@ Appendix B. ChangeLog draft-handrews-json-schema-WIP - * Update to RFC 8359 for JSON specification + * Update to RFC 8259 for JSON specification * Moved "definitions" from the Validation specification here as "$defs" @@ -3525,9 +3525,9 @@ Appendix B. ChangeLog -Wright, et al. Expires November 26, 2019 [Page 63] +Wright, et al. Expires January 14, 2020 [Page 63] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 * Additional guidance on initial base URIs beyond network @@ -3581,9 +3581,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 64] +Wright, et al. Expires January 14, 2020 [Page 64] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 * Add "application/schema-instance+json" media type @@ -3637,9 +3637,9 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 65] +Wright, et al. Expires January 14, 2020 [Page 65] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 * Fixed numerous invalid examples @@ -3684,6 +3684,7 @@ Authors' Addresses Wellcome Sanger Institute EMail: bh7@sanger.ac.uk + URI: https://jsonschema.dev @@ -3692,10 +3693,9 @@ Authors' Addresses - -Wright, et al. Expires November 26, 2019 [Page 66] +Wright, et al. Expires January 14, 2020 [Page 66] -Internet-Draft JSON Schema May 2019 +Internet-Draft JSON Schema July 2019 Greg Dennis @@ -3749,4 +3749,4 @@ Internet-Draft JSON Schema May 2019 -Wright, et al. Expires November 26, 2019 [Page 67] +Wright, et al. Expires January 14, 2020 [Page 67] From 06500b24ad4b25912f32f5af510e5a164f9dbba3 Mon Sep 17 00:00:00 2001 From: Alejandra Gonzalez-Beltran Date: Tue, 23 Jul 2019 09:23:04 +0100 Subject: [PATCH 054/395] Minor typo --- index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.md b/index.md index dad1963a..b32c29d4 100644 --- a/index.md +++ b/index.md @@ -7,7 +7,7 @@ permalink: / ***The current version is [draft-07](specification.html)!*** {: style="color:gray; font-size: 150%; text-align: center;"} -***The next draft work-in-progres is [in final review](work-in-progress)!*** +***The next draft work-in-progress is [in final review](work-in-progress)!*** {: style="color:red; font-size: 150%; text-align: center;"} **JSON Schema** is a vocabulary that allows you to **annotate** and **validate** JSON documents. From dd14d3fd57a3544299b6da641e7483799907bc80 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Sun, 28 Jul 2019 18:16:49 -0700 Subject: [PATCH 055/395] Update with draft publication progress. --- work-in-progress/index.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/work-in-progress/index.md b/work-in-progress/index.md index ef01fb2e..e9de7c52 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -9,15 +9,9 @@ permalink: /work-in-progress ## The Next Draft (by whatever name) Is Ready for Final Pre-Publication Review! -The forthcoming draft is now feature-frozen and entering the final four-week feedback -period before publication. This final review will last from May 27th to June 24th, 2019. +The forthcoming draft is now feature-frozen and has gone through the initial four-week pre-publication review period. -The timeline may be compressed if, after at least two weeks, there is a clear consensus that -the drafts are solid and it would be best to publish sooner rather than later. - -_**UPDATE:** As of July 2nd, We are incorporating feedback from the review period._ -_There will be an update, followed by a brief period to review the update, and then_ -_hopefully publication._ +_**UPDATE: July 28th, 2019** We continue to incorporate feedback and clarify sections of the new draft. We expect to finally publish the draft during August._ The following sorts of feedback are particularly desired: @@ -42,7 +36,7 @@ Assuming this new draft gets published more or less as presented in this WIP, and by the end of June, it will be: * IETF identifiers: `draft-handrews-*-02` -* Meta-schema identifiers: `draft/2019-06` +* Meta-schema identifiers: `draft/2019-08` Meta-schemas will now be identified with dates, which can be correlated with the publication and expiration dates of the IETF documents. This will make it more clear when a bugfix From 5608a74fe872b4df05c0ba91f25fdfbe4a17bc7d Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Sat, 10 Aug 2019 12:26:01 -0700 Subject: [PATCH 056/395] Direct copy of new revisions, no WIP fix --- work-in-progress/WIP-jsonschema-core.html | 1158 +++++----- work-in-progress/WIP-jsonschema-core.txt | 1960 ++++++++--------- .../WIP-jsonschema-hyperschema.html | 59 +- .../WIP-jsonschema-hyperschema.txt | 282 +-- .../WIP-jsonschema-validation.html | 176 +- .../WIP-jsonschema-validation.txt | 632 ++++-- .../WIP-relative-json-pointer.html | 33 +- .../WIP-relative-json-pointer.txt | 46 +- 8 files changed, 2244 insertions(+), 2102 deletions(-) diff --git a/work-in-progress/WIP-jsonschema-core.html b/work-in-progress/WIP-jsonschema-core.html index 106c32d8..92e7b9c3 100644 --- a/work-in-progress/WIP-jsonschema-core.html +++ b/work-in-progress/WIP-jsonschema-core.html @@ -386,9 +386,9 @@ - - - + + + @@ -397,15 +397,20 @@ - - - - - - + + + + + + + + + + + @@ -426,44 +431,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -473,8 +474,8 @@ - - + + @@ -498,8 +499,8 @@ - - + + @@ -515,7 +516,7 @@ - + @@ -523,19 +524,19 @@
      [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-WIP, 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-WIP, November 2017.
      [RFC7049]H. Andrews, Ed.
      Expires: January 14, 2020Riverbed TechnologyExpires: February 11, 2020
      July 13, 2019August 10, 2019

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

      + 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 <http://json-schema.org/>.

      +

      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 January 14, 2020.

      +

      This Internet-Draft will expire on February 11, 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.

      @@ -569,11 +570,11 @@

      Table of Contents

    • 4.3.2. Boolean JSON Schemas
    • -
    • 4.3.3. Root Schema and Subschemas +
    • 4.3.3. Schema Vocabularies
    • -
    • 4.3.4. Lexical Scope and Dynamic Scope +
    • 4.3.4. Meta-Schemas
    • -
    • 4.3.5. Referenced and Referencing Schemas +
    • 4.3.5. Root Schema and Subschemas
  • 5. Fragment Identifiers
  • @@ -591,25 +592,35 @@

    Table of Contents

  • 7. Keyword Behaviors
  • -
  • 8. Meta-Schemas and Vocabularies
  • 10. Comments With "$comment"
  • -
  • 11. Collecting Annotations -
  • -
  • 16. References
  • -
    • 16.1. application/schema+json +
    • 17. References -
    • -
    • Appendix A. Acknowledgments
    • @@ -811,7 +814,7 @@

      4.3. JSON Schema Documents

      -

      A JSON Schema document, or simply a schema, is a JSON document used to describe an instance. A schema is itself 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 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

      @@ -840,15 +843,23 @@

      true:
      Always passes validation, as if the empty schema {}
      false:
      -
      Always fails validation, as if the schema { "not":{} }
      +
      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. Root Schema and Subschemas +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 unkonw 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

      -

      The root schema is the schema that comprises the entire JSON document in question.

      -

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

      +

      The root schema is the schema that comprises the entire JSON document in question.

      +

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

       
       {
      @@ -859,23 +870,8 @@ 

      }

      -

      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.

      -

      -4.3.4. 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 the document'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 jumps 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", "$recursiveAnchor", and should be considered an advanced feature and used with caution when defining additional keywords.

      -

      -4.3.5. Referenced and Referencing Schemas -

      -

      As noted in Section 7.3, 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.

      +

      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.

      5. Fragment Identifiers

      @@ -920,99 +916,216 @@

      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.

      -

      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.

      -

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

      -

      Authors of extensions to JSON Schema are encouraged to write their own meta-schemas, which extend the existing meta-schemas using "allOf". This extended meta-schema SHOULD be referenced using the "$schema" keyword, to allow tools to follow the correct behaviour.

      -

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

      +

      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.

      +

      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. 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.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 the document'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. 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.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. 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.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. Assertions +7.4. Applicators

      -

      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.

      +

      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.4.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.

      +7.4.1. Referenced and Referencing Schemas + +

      As noted in Section 7.4, 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.5. Annotations +7.5. Assertions

      -

      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.

      -

      The default behavior is simply to collect all values in a list in indeterminate order. Given the extensibility of keywords, including applicators, it is not possible to define a universally predictable order of processing.

      -

      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.

      -

      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.

      +

      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.5.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.

      +

      +7.6. 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.

      +

      The default behavior is simply to collect all values in a list in indeterminate order. Given the extensibility of keywords, including applicators, it is not possible to define a universally predictable order of processing.

      +

      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.

      +

      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.

      +

      +7.6.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.

      +

      +7.6.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.6.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.6.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.

      8. Meta-Schemas and Vocabularies

      -

      Two concepts, meta-schemas and vocabularies, are used to inform an implementation how to interpret a schema. A schema S declares its meta-schema M with the "$schema" keyword, and meta-schemas declare vocabularies with the "$vocabulary" keyword. The vocabularies declared in M are those that are expected to be used in S. The meta-schema M may itself use a different set of vocabularies, which are declared in its own meta-schema, M'.

      -

      The role of the meta-schema is to constrain the structure of conforming schemas, as well as simplify the process of composing multiple vocabularies into a usable feature set. Schema authoring is expected to be a common activity, so schema authors need only understand how to reference a single meta-schema.

      -

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

      -

      A JSON Schema vocabulary is a set of keywords defined for a particular purpose. The vocabulary specifies the meaning of its keywords as assertions, annotations, and/or any vocabulary-defined keyword category.

      -

      The role of a vocabulary is to declare which keywords (including sub-keywords such as those in JSON Hyper-Schema's Link Description Object) are in use, and with which semantics. The semantics are indicated by the document that publicizes the vocabulary URI. At this time, there is no machine-readable description of keywords other than validation rules, which appear in the meta-schema.

      -

      Meta-schemas are separate from vocabularies to allow for the same sets of 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.

      +

      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. The "$schema" Keyword

      -

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

      +

      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 root schema. It MUST NOT appear in subschemas.

      +

      The "$schema" keyword SHOULD be used in a root schema. It MUST NOT appear in subschemas. If absent from the root schema, the resulting behavior 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.

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

      8.2. The "$vocabulary" Keyword

      -

      The "$vocabulary" keyword, which appears in a meta-schema, identifies what sets of keywords are expected to be used in schemas described by that meta-schema, and with what semantics. This is conceptually analogous to how most other keywords used in meta-schemas describe the syntax of keywords used in schemas described by that meta-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.

      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 resources is currently undefined, and reserved for future use. Vocabulary authors SHOULD NOT serve a document at that URL. A server MAY respond with the relevant protocol's successful "no content" message, such as an HTTP 204 status. [CREF3]Vocabulary documents may be added shortly, or in the next draft. For now, identifying the keyword set is deemed sufficient as that, along with meta-schema validation, is how the current "vocabularies" work today.

      +

      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. [CREF3]Vocabulary documents may be added shortly, or in the next draft. 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 MAY choose to proceed with processing such schemas.

      When processing a schema that uses unrecognized vocabularies, keywords declared by those vocabularies are treated like any other unrecognized keyword, and ignored.

      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.

      -

      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.

      -

      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. If the meta-schema, as referenced by the schema, is not recognized, then implementations MUST assume the use of the core vocabulary, and SHOULD assume the use of all vocabularies in this specification and the companion Validation specification.

      +

      +8.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.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.

      8.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 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.

      +

      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.4. Best Practices for Vocabulary and Meta-Schema Authors

      -

      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. Such meta-schemas SHOULD NOT forbid additional keywords, and MUST NOT forbid the "$id", "$schema", or "$vocabulary" keywords in the root schema.

      -

      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.

      -

      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.

      +

      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.

      8.5. The JSON Schema Core Vocabulary

      Keywords declared in in this specification that 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 "$vocabulary" 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.

      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-04/vocab/core>.

      -

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

      +

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

      +

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

      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.6. Example Meta-Schema With Vocabulary Declarations @@ -1021,16 +1134,16 @@

       
       {
      -  "$schema": "https://json-schema.org/draft/2019-04/core-app-example#",
      -  "$id": "https://json-schema.org/draft/2019-04/core-app-example",
      +  "$schema": "https://json-schema.org/draft/2019-08/core-app-example#",
      +  "$id": "https://json-schema.org/draft/2019-08/core-app-example",
         "$recursiveAnchor": true,
         "$vocabulary": {
      -    "https://json-schema.org/draft/2019-04/vocab/core": true,
      -    "https://json-schema.org/draft/2019-04/vocab/applicator": true
      +    "https://json-schema.org/draft/2019-08/vocab/core": true,
      +    "https://json-schema.org/draft/2019-08/vocab/applicator": true
         },
         "allOf": [
      -    {"$ref": "https://json-schema.org/draft/2019-04/meta/core"},
      -    {"$ref": "https://json-schema.org/draft/2019-04/meta/applicator"}
      +    {"$ref": "https://json-schema.org/draft/2019-08/meta/core"},
      +    {"$ref": "https://json-schema.org/draft/2019-08/meta/applicator"}
         ],
         "patternProperties": {
           "^unevaluated.*$": false
      @@ -1078,7 +1191,7 @@ 

       
       {
      -    "$id": "http://example.com/root.json",
      +    "$id": "https://example.com/root.json",
           "$defs": {
               "A": { "$id": "#foo" },
               "B": {
      @@ -1103,9 +1216,9 @@ 

      -
      http://example.com/root.json
      +
      https://example.com/root.json
      -
      http://example.com/root.json#
      +
      https://example.com/root.json#

      @@ -1113,9 +1226,9 @@

      -
      http://example.com/root.json#foo
      +
      https://example.com/root.json#foo
      -
      http://example.com/root.json#/$defs/A
      +
      https://example.com/root.json#/$defs/A

      @@ -1123,11 +1236,11 @@

      -
      http://example.com/other.json
      +
      https://example.com/other.json
      -
      http://example.com/other.json#
      +
      https://example.com/other.json#
      -
      http://example.com/root.json#/$defs/B
      +
      https://example.com/root.json#/$defs/B

      @@ -1135,11 +1248,11 @@

      -
      http://example.com/other.json#bar
      +
      https://example.com/other.json#bar
      -
      http://example.com/other.json#/$defs/X
      +
      https://example.com/other.json#/$defs/X
      -
      http://example.com/root.json#/$defs/B/$defs/X
      +
      https://example.com/root.json#/$defs/B/$defs/X

      @@ -1147,13 +1260,13 @@

      -
      http://example.com/t/inner.json
      +
      https://example.com/t/inner.json
      -
      http://example.com/t/inner.json#
      +
      https://example.com/t/inner.json#
      -
      http://example.com/other.json#/$defs/Y
      +
      https://example.com/other.json#/$defs/Y
      -
      http://example.com/root.json#/$defs/B/$defs/Y
      +
      https://example.com/root.json#/$defs/B/$defs/Y

      @@ -1165,7 +1278,7 @@

      urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f#
      -
      http://example.com/root.json#/$defs/C
      +
      https://example.com/root.json#/$defs/C

      @@ -1186,11 +1299,11 @@

      9.3.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 ("#").

      Extending a recursive schema with "$ref" alone involves redefining all recursive references in the source schema to point to the root of the extension. This produces the correct recursive behavior in the extension, which is that all recursion should reference the root of the extension.

      -

      Consider the following two schemas. The first schema, identified as "original" as it is the schema to be extended, describes an object with one string property and one recursive reference property, "r". The second schema, identified as "extension", references the first, and describes an additional things" property, which is an array of recursive references. It also repeats the description of "r" from the original schema.

      +

      Consider the following two schemas. The first schema, identified as "original" as it is the schema to be extended, describes an object with one string property and one recursive reference property, "r". The second schema, identified as "extension", references the first, and describes an additional "things" property, which is an array of recursive references. It also repeats the description of "r" from the original schema.

       
       {
      -    "$schema": "http://json-schema.org/draft/2019-04/schema#",
      +    "$schema": "https://json-schema.org/draft/2019-08/schema#",
           "$id": "https://example.com/original",
       
           "properties": {
      @@ -1204,7 +1317,7 @@ 

      } { - "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$schema": "https://json-schema.org/draft/2019-08/schema#", "$id": "https://example.com/extension", "$ref": "original", @@ -1246,7 +1359,7 @@

       
       {
      -    "$schema": "http://json-schema.org/draft/2019-04/schema#",
      +    "$schema": "https://json-schema.org/draft/2019-08/schema#",
           "$id": "https://example.com/original",
           "$recursiveAnchor": true,
       
      @@ -1261,7 +1374,7 @@ 

      } { - "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$schema": "https://json-schema.org/draft/2019-08/schema#", "$id": "https://example.com/extension", "$recursiveAnchor": true, @@ -1303,7 +1416,7 @@

       
       {
      -    "$id": "http://example.net/root.json",
      +    "$id": "https://example.net/root.json",
           "items": {
               "type": "array",
               "items": { "$ref": "#item" }
      @@ -1318,9 +1431,9 @@ 

      }

      -

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

      -

      When an implementation then looks inside the <#/items> schema, it encounters the <#item> reference, and resolves this to <http://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 <http://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. [CREF6]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 <#/$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. [CREF6]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.4. Schema Re-Use With "$defs"

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

      @@ -1344,106 +1457,16 @@

      10. Comments With "$comment"

      This keyword is reserved 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.

      -11. 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.

      +11. 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-08/vocab/applicator>.

      +

      The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-08/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.

      -11.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.

      -

      -11.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.

      -

      -11.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.

      -

      -12. 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-04/vocab/applicator>.

      -

      The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-04/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.

      -

      -12.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:

      +11.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"
      • @@ -1453,147 +1476,147 @@

      -

      -12.2. Keywords for Applying Subschemas in Place +

      +11.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.

      -

      -12.2.1. Keywords for Applying Subschemas With Boolean Logic +

      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.

      +

      +11.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.

      -

      -12.2.1.1. allOf +

      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.

      +

      +11.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.

      -

      -12.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.

      -

      -12.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.

      -

      -12.2.1.4. not +

      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.

      +

      +11.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.

      +

      +11.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.

      +

      +11.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.

      -

      -12.2.2. Keywords for Applying Subschemas Conditionally +

      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.

      +

      +11.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.

      -

      -12.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".

      -

      -12.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.

      -

      -12.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.

      -

      -12.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.

      -

      -12.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.

      -

      -12.3.1. Keywords for Applying Subschemas to Arrays

      -

      -12.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.

      -

      -12.3.1.2. additionalItems +

      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.

      +

      +11.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".

      +

      +11.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.

      +

      +11.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.

      +

      +11.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.

      +

      +11.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.

      +

      +11.3.1. Keywords for Applying Subschemas to Arrays

      +

      +11.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.

      +

      +11.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.

      -

      -12.3.1.3. unevaluatedItems +

      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.

      +

      +11.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.

      -

      -12.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. This keyword does not produce annotation results. [CREF7]Should it produce a set of the indices for which the array element is valid against the subschema? "contains" does not affect "additionalItems" or any other current or proposed keyword, but the information could be useful, and implementation that collect annotations need to apply "contains" to every element anyway.

      -

      -12.3.2. Keywords for Applying Subschemas to Objects

      -

      -12.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.

      -

      -12.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.

      -

      -12.3.2.3. additionalProperties +

      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.

      +

      +11.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.

      +

      +11.3.2. Keywords for Applying Subschemas to Objects

      +

      +11.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.

      +

      +11.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.

      +

      +11.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.

      -

      -12.3.2.4. unevaluatedProperties +

      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.

      +

      +11.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.

      -

      -12.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.

      -

      -13. Output Formatting +

      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.

      +

      +11.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.

      +

      +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.

      -

      -13.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.

      -

      -13.2. Output Formats

      -

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

      +

      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.
      • @@ -1603,47 +1626,47 @@

      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.

      -

      -13.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.

      -

      -13.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".

      +

      +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 "$recursiveRef".

       
       #/properties/minLength/$ref/minimum
       
                               
      -

      Note that this pointer may not be resolvable due to the inclusion of these applicator keywords.

      -

      The JSON key for this information is "keywordLocation".

      -

      -13.3.2. Keyword Absolute Location

      -

      The absolute, dereferenced location of the validating keyword. The value MUST be expressed as an absolute URI, and it MUST NOT include by-reference applicators such as "$ref" or "$recursiveRef".

      +

      Note that this pointer may not be resolvable due to the inclusion of these 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 an absolute URI, and it MUST NOT include by-reference applicators such as "$ref" or "$recursiveRef".

       
      -http://json-schema.org/draft/2019-04/schema#/$defs/nonNegativeInteger/minimum
      +https://json-schema.org/draft/2019-08/schema#/$defs/nonNegativeInteger/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".

      -

      -13.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".

      -

      -13.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.

      -

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

      -

      -13.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".

      -

      -13.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.

      +

      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.

      +

      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".

      +

      +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
      • @@ -1655,8 +1678,8 @@

         
         {
        -  "$id": "http://example.com/polygon#",
        -  "$schema": "http://json-schema.org/draft/2019-04/schema#",
        +  "$id": "https://example.com/polygon#",
        +  "$schema": "https://json-schema.org/draft/2019-08/schema#",
           "$defs": {
             "point": {
               "type": "object",
        @@ -1685,8 +1708,8 @@ 

        ]

        -

        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:

        +

        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.
        • @@ -1695,9 +1718,9 @@

        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.

        -

        -13.4.1. Flag

        -

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

        +

        +12.4.1. Flag

        +

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

         
         {
        @@ -1705,10 +1728,10 @@ 

        }

        -

        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.

        -

        -13.4.2. Basic

        -

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

        +

        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.

         
         {
        @@ -1722,21 +1745,21 @@ 

        { "keywordLocation": "#/items/$ref", "absoluteKeywordLocation": - "http://example.com/polygon#/$defs/point", + "https://example.com/polygon#/$defs/point", "instanceLocation": "#/1", "error": "A subschema had errors." }, { "keywordLocation": "#/items/$ref/required", "absoluteKeywordLocation": - "http://example.com/polygon#/$defs/point/required", + "https://example.com/polygon#/$defs/point/required", "instanceLocation": "#/1", "error": "Required property 'y' not found." }, { "keywordLocation": "#/items/$ref/additionalProperties", "absoluteKeywordLocation": - "http://example.com/polygon#/$defs/point/additionalProperties", + "https://example.com/polygon#/$defs/point/additionalProperties", "instanceLocation": "#/1/z", "error": "Additional property 'z' found but was invalid." }, @@ -1749,10 +1772,10 @@

        }

        -

        -13.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 correllation is more easily identified.

        -

        The following rules govern the construction of the results object:

        +

        +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 correllation 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.
        • @@ -1772,14 +1795,14 @@

          "valid": false, "keywordLocation": "#/items/$ref", "absoluteKeywordLocation": - "http://example.com/polygon#/$defs/point", + "https://example.com/polygon#/$defs/point", "instanceLocation": "#/1", "errors": [ { "valid": false, "keywordLocation": "#/items/$ref/required", "absoluteKeywordLocation": - "http://example.com/polygon#/$defs/point/required", + "https://example.com/polygon#/$defs/point/required", "instanceLocation": "#/1", "error": "Required property 'y' not found." }, @@ -1787,7 +1810,7 @@

          "valid": false, "keywordLocation": "#/items/$ref/additionalProperties", "absoluteKeywordLocation": - "http://example.com/polygon#/$defs/point/additionalProperties", + "https://example.com/polygon#/$defs/point/additionalProperties", "instanceLocation": "#/1/z", "error": "Additional property 'z' found but was invalid." } @@ -1803,17 +1826,17 @@

          }

      -

      -13.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-04/output/verbose-example>.

      +

      +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/2019-08/output/verbose-example>.

       
       // schema
       {
      -  "$id": "http://example.com/polygon#",
      -  "$schema": "http://json-schema.org/draft/2019-04/schema#",
      +  "$id": "https://example.com/polygon#",
      +  "$schema": "https://json-schema.org/draft/2019-08/schema#",
         "type": "object",
         "properties": {
           "validProp": true,
      @@ -1860,85 +1883,85 @@ 

      }

      -

      -13.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-04/output/schema>.

      -

      -14. Usage for Hypermedia +

      +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/2019-08/output/schema>.

      +

      +13. 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.

      -

      -14.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:

      +

      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.

      +

      +13.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: <http://example.com/my-hyper-schema#>; rel="describedby"
      +Link: <https://example.com/my-hyper-schema#>; rel="describedby"
       
                           
      -

      -14.2. Identifying a Schema via a Media Type Parameter +

      +13.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:

      +

      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="http://example.com/my-hyper-schema#"
      +          schema="https://example.com/my-hyper-schema#"
       
                           
      -

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

      +

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

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

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

      +

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

       
       Accept: application/json;
      -          schema="http://example.com/qiang http://example.com/li",
      +          schema="https://example.com/qiang https://example.com/li",
               application/json;
      -          schema="http://example.com/kumar"
      +          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.

      -

      [CREF8]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:

      +

      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.

      +

      [CREF7]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"
       
                           
      -

      -14.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.

      +

      +13.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.

      -

      -15. Security Considerations +

      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.

      +

      +14. 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.

      -

      -16. IANA Considerations

      -

      -16.1. application/schema+json

      -

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

      +

      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.

      +

      +15. IANA Considerations

      +

      +15.1. application/schema+json

      +

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

      • Type name: application
      • @@ -1951,15 +1974,15 @@

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

      -

      -16.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:

      +

      +15.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
      • @@ -1971,16 +1994,16 @@

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

      -17. References

      +16. References

      -17.1. Normative References

      +16.1. Normative References @@ -2018,17 +2041,17 @@

      [ecma262]

      -17.2. Informative References

      +16.2. Informative References +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. +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. @@ -2057,11 +2080,11 @@

      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 B. ChangeLog

      -

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

      +

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

      -
      draft-handrews-json-schema-WIP
      +
      draft-handrews-json-schema-02
      • Update to RFC 8259 for JSON specification
      • @@ -2194,18 +2217,17 @@

        Authors' Addresses

        Andrews - Riverbed Technology + - 680 Folsom St. - + - San Francisco, - CA + + - USA + - EMail: handrews@riverbed.com + EMail: andrews_henry@yahoo.com
        diff --git a/work-in-progress/WIP-jsonschema-core.txt b/work-in-progress/WIP-jsonschema-core.txt index 19706a55..e3f6598e 100644 --- a/work-in-progress/WIP-jsonschema-core.txt +++ b/work-in-progress/WIP-jsonschema-core.txt @@ -5,15 +5,15 @@ Internet Engineering Task Force A. Wright, Ed. Internet-Draft Intended status: Informational H. Andrews, Ed. -Expires: January 14, 2020 Riverbed Technology +Expires: February 11, 2020 B. Hutton, Ed. Wellcome Sanger Institute G. Dennis - July 13, 2019 + August 10, 2019 JSON Schema: A Media Type for Describing JSON Documents - draft-handrews-json-schema-WIP + draft-handrews-json-schema-02 Abstract @@ -30,7 +30,7 @@ Note to Readers The issues list for this draft can be found at . - For additional information, see . + For additional information, see . To provide feedback, use this issue tracker, the communication methods listed on the homepage, or email the document editors. @@ -53,12 +53,12 @@ Status of This Memo -Wright, et al. Expires January 14, 2020 [Page 1] +Wright, et al. Expires February 11, 2020 [Page 1] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 - This Internet-Draft will expire on January 14, 2020. + This Internet-Draft will expire on February 11, 2020. Copyright Notice @@ -79,9 +79,9 @@ Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 2. Conventions and Terminology . . . . . . . . . . . . . . . . . 4 - 3. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 4 - 4. Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 5 - 4.1. JSON Document . . . . . . . . . . . . . . . . . . . . . . 5 + 3. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 5 + 4. Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 6 + 4.1. JSON Document . . . . . . . . . . . . . . . . . . . . . . 6 4.2. Instance . . . . . . . . . . . . . . . . . . . . . . . . 6 4.2.1. Instance Data Model . . . . . . . . . . . . . . . . . 6 4.2.2. Instance Media Types . . . . . . . . . . . . . . . . 7 @@ -89,101 +89,102 @@ Table of Contents 4.3. JSON Schema Documents . . . . . . . . . . . . . . . . . . 8 4.3.1. JSON Schema Objects and Keywords . . . . . . . . . . 8 4.3.2. Boolean JSON Schemas . . . . . . . . . . . . . . . . 9 - 4.3.3. Root Schema and Subschemas . . . . . . . . . . . . . 9 - 4.3.4. Lexical Scope and Dynamic Scope . . . . . . . . . . . 9 - 4.3.5. Referenced and Referencing Schemas . . . . . . . . . 10 - 5. Fragment Identifiers . . . . . . . . . . . . . . . . . . . . 11 - 6. General Considerations . . . . . . . . . . . . . . . . . . . 12 - 6.1. Range of JSON Values . . . . . . . . . . . . . . . . . . 12 - 6.2. Programming Language Independence . . . . . . . . . . . . 12 - 6.3. Mathematical Integers . . . . . . . . . . . . . . . . . . 12 - 6.4. Regular Expressions . . . . . . . . . . . . . . . . . . . 12 - 6.5. Extending JSON Schema . . . . . . . . . . . . . . . . . . 13 - 7. Keyword Behaviors . . . . . . . . . . . . . . . . . . . . . . 14 - 7.1. Keyword Interactions . . . . . . . . . . . . . . . . . . 14 - 7.2. Default Behaviors . . . . . . . . . . . . . . . . . . . . 14 - 7.3. Applicators . . . . . . . . . . . . . . . . . . . . . . . 15 - 7.4. Assertions . . . . . . . . . . . . . . . . . . . . . . . 15 - 7.4.1. Assertions and Instance Primitive Types . . . . . . . 16 - 7.5. Annotations . . . . . . . . . . . . . . . . . . . . . . . 16 - - - -Wright, et al. Expires January 14, 2020 [Page 2] - -Internet-Draft JSON Schema July 2019 - - - 8. Meta-Schemas and Vocabularies . . . . . . . . . . . . . . . . 17 - 8.1. The "$schema" Keyword . . . . . . . . . . . . . . . . . . 17 - 8.2. The "$vocabulary" Keyword . . . . . . . . . . . . . . . . 18 - 8.3. Detecting a Meta-Schema . . . . . . . . . . . . . . . . . 19 - 8.4. Best Practices for Vocabulary and Meta-Schema Authors . . 20 - 8.5. The JSON Schema Core Vocabulary . . . . . . . . . . . . . 20 - 8.6. Example Meta-Schema With Vocabulary Declarations . . . . 21 - 9. Base URI and Dereferencing . . . . . . . . . . . . . . . . . 23 - 9.1. Initial Base URI . . . . . . . . . . . . . . . . . . . . 23 - 9.2. The "$id" Keyword . . . . . . . . . . . . . . . . . . . . 23 - 9.2.1. Identifying the root schema . . . . . . . . . . . . . 23 - 9.2.2. Changing the base URI within a schema file . . . . . 24 - 9.2.3. Location-independent identifiers . . . . . . . . . . 24 - 9.2.4. Schema identification examples . . . . . . . . . . . 24 - 9.3. Schema References . . . . . . . . . . . . . . . . . . . . 26 - 9.3.1. Direct References with "$ref" . . . . . . . . . . . . 26 + 4.3.3. Schema Vocabularies . . . . . . . . . . . . . . . . . 9 + 4.3.4. Meta-Schemas . . . . . . . . . . . . . . . . . . . . 9 + 4.3.5. Root Schema and Subschemas . . . . . . . . . . . . . 10 + 5. Fragment Identifiers . . . . . . . . . . . . . . . . . . . . 10 + 6. General Considerations . . . . . . . . . . . . . . . . . . . 11 + 6.1. Range of JSON Values . . . . . . . . . . . . . . . . . . 11 + 6.2. Programming Language Independence . . . . . . . . . . . . 11 + 6.3. Mathematical Integers . . . . . . . . . . . . . . . . . . 11 + 6.4. Regular Expressions . . . . . . . . . . . . . . . . . . . 11 + 6.5. Extending JSON Schema . . . . . . . . . . . . . . . . . . 12 + 7. Keyword Behaviors . . . . . . . . . . . . . . . . . . . . . . 12 + 7.1. Lexical Scope and Dynamic Scope . . . . . . . . . . . . . 13 + 7.2. Keyword Interactions . . . . . . . . . . . . . . . . . . 14 + 7.3. Default Behaviors . . . . . . . . . . . . . . . . . . . . 14 + 7.4. Applicators . . . . . . . . . . . . . . . . . . . . . . . 15 + 7.4.1. Referenced and Referencing Schemas . . . . . . . . . 15 + 7.5. Assertions . . . . . . . . . . . . . . . . . . . . . . . 16 + + + +Wright, et al. Expires February 11, 2020 [Page 2] + +Internet-Draft JSON Schema August 2019 + + + 7.5.1. Assertions and Instance Primitive Types . . . . . . . 16 + 7.6. Annotations . . . . . . . . . . . . . . . . . . . . . . . 16 + 7.6.1. Collecting Annotations . . . . . . . . . . . . . . . 17 + 8. Meta-Schemas and Vocabularies . . . . . . . . . . . . . . . . 20 + 8.1. The "$schema" Keyword . . . . . . . . . . . . . . . . . . 21 + 8.2. The "$vocabulary" Keyword . . . . . . . . . . . . . . . . 21 + 8.2.1. Default vocabularies . . . . . . . . . . . . . . . . 22 + 8.2.2. Non-inheritability of vocabularies . . . . . . . . . 23 + 8.3. Detecting a Meta-Schema . . . . . . . . . . . . . . . . . 23 + 8.4. Best Practices for Vocabulary and Meta-Schema Authors . . 23 + 8.5. The JSON Schema Core Vocabulary . . . . . . . . . . . . . 25 + 8.6. Example Meta-Schema With Vocabulary Declarations . . . . 25 + 9. Base URI and Dereferencing . . . . . . . . . . . . . . . . . 27 + 9.1. Initial Base URI . . . . . . . . . . . . . . . . . . . . 27 + 9.2. The "$id" Keyword . . . . . . . . . . . . . . . . . . . . 27 + 9.2.1. Identifying the root schema . . . . . . . . . . . . . 27 + 9.2.2. Changing the base URI within a schema file . . . . . 28 + 9.2.3. Location-independent identifiers . . . . . . . . . . 28 + 9.2.4. Schema identification examples . . . . . . . . . . . 28 + 9.3. Schema References . . . . . . . . . . . . . . . . . . . . 30 + 9.3.1. Direct References with "$ref" . . . . . . . . . . . . 30 9.3.2. Recursive References with "$recursiveRef" and - "$recursiveAnchor" . . . . . . . . . . . . . . . . . 27 - 9.3.3. Guarding Against Infinite Recursion . . . . . . . . . 31 - 9.3.4. References to Possible Non-Schemas . . . . . . . . . 31 - 9.3.5. Loading a referenced schema . . . . . . . . . . . . . 32 - 9.3.6. Dereferencing . . . . . . . . . . . . . . . . . . . . 32 - 9.4. Schema Re-Use With "$defs" . . . . . . . . . . . . . . . 33 - 10. Comments With "$comment" . . . . . . . . . . . . . . . . . . 34 - 11. Collecting Annotations . . . . . . . . . . . . . . . . . . . 34 - 11.1. Distinguishing Among Multiple Values . . . . . . . . . . 35 - 11.2. Annotations and Assertions . . . . . . . . . . . . . . . 37 - 11.3. Annotations and Applicators . . . . . . . . . . . . . . 38 - 12. A Vocabulary for Applying Subschemas . . . . . . . . . . . . 38 - 12.1. Keyword Independence . . . . . . . . . . . . . . . . . . 39 - 12.2. Keywords for Applying Subschemas in Place . . . . . . . 39 - 12.2.1. Keywords for Applying Subschemas With Boolean Logic 39 - 12.2.2. Keywords for Applying Subschemas Conditionally . . . 40 - 12.3. Keywords for Applying Subschemas to Child Instances . . 42 - 12.3.1. Keywords for Applying Subschemas to Arrays . . . . . 42 - 12.3.2. Keywords for Applying Subschemas to Objects . . . . 44 - 13. Output Formatting . . . . . . . . . . . . . . . . . . . . . . 47 - 13.1. Format . . . . . . . . . . . . . . . . . . . . . . . . . 47 - 13.2. Output Formats . . . . . . . . . . . . . . . . . . . . . 47 - 13.3. Minimum Information . . . . . . . . . . . . . . . . . . 47 - 13.3.1. Keyword Relative Location . . . . . . . . . . . . . 48 - 13.3.2. Keyword Absolute Location . . . . . . . . . . . . . 48 - 13.3.3. Instance Location . . . . . . . . . . . . . . . . . 48 - 13.3.4. Error or Annotation . . . . . . . . . . . . . . . . 49 - 13.3.5. Nested Results . . . . . . . . . . . . . . . . . . . 49 - 13.4. Output Structure . . . . . . . . . . . . . . . . . . . . 49 - 13.4.1. Flag . . . . . . . . . . . . . . . . . . . . . . . . 51 - 13.4.2. Basic . . . . . . . . . . . . . . . . . . . . . . . 51 - - - -Wright, et al. Expires January 14, 2020 [Page 3] - -Internet-Draft JSON Schema July 2019 - - - 13.4.3. Detailed . . . . . . . . . . . . . . . . . . . . . . 52 - 13.4.4. Verbose . . . . . . . . . . . . . . . . . . . . . . 54 - 13.4.5. Output validation schemas . . . . . . . . . . . . . 56 - 14. Usage for Hypermedia . . . . . . . . . . . . . . . . . . . . 56 - 14.1. Linking to a Schema . . . . . . . . . . . . . . . . . . 56 - 14.2. Identifying a Schema via a Media Type Parameter . . . . 56 - 14.3. Usage Over HTTP . . . . . . . . . . . . . . . . . . . . 58 - 15. Security Considerations . . . . . . . . . . . . . . . . . . . 58 - 16. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 59 - 16.1. application/schema+json . . . . . . . . . . . . . . . . 59 - 16.2. application/schema-instance+json . . . . . . . . . . . . 60 - 17. References . . . . . . . . . . . . . . . . . . . . . . . . . 60 - 17.1. Normative References . . . . . . . . . . . . . . . . . . 60 - 17.2. Informative References . . . . . . . . . . . . . . . . . 61 + "$recursiveAnchor" . . . . . . . . . . . . . . . . . 31 + 9.3.3. Guarding Against Infinite Recursion . . . . . . . . . 35 + 9.3.4. References to Possible Non-Schemas . . . . . . . . . 35 + 9.3.5. Loading a referenced schema . . . . . . . . . . . . . 36 + 9.3.6. Dereferencing . . . . . . . . . . . . . . . . . . . . 36 + 9.4. Schema Re-Use With "$defs" . . . . . . . . . . . . . . . 37 + 10. Comments With "$comment" . . . . . . . . . . . . . . . . . . 38 + 11. A Vocabulary for Applying Subschemas . . . . . . . . . . . . 38 + 11.1. Keyword Independence . . . . . . . . . . . . . . . . . . 39 + 11.2. Keywords for Applying Subschemas in Place . . . . . . . 39 + 11.2.1. Keywords for Applying Subschemas With Boolean Logic 39 + 11.2.2. Keywords for Applying Subschemas Conditionally . . . 40 + 11.3. Keywords for Applying Subschemas to Child Instances . . 42 + 11.3.1. Keywords for Applying Subschemas to Arrays . . . . . 42 + 11.3.2. Keywords for Applying Subschemas to Objects . . . . 44 + 12. Output Formatting . . . . . . . . . . . . . . . . . . . . . . 47 + 12.1. Format . . . . . . . . . . . . . . . . . . . . . . . . . 47 + 12.2. Output Formats . . . . . . . . . . . . . . . . . . . . . 47 + 12.3. Minimum Information . . . . . . . . . . . . . . . . . . 48 + 12.3.1. Keyword Relative Location . . . . . . . . . . . . . 48 + 12.3.2. Keyword Absolute Location . . . . . . . . . . . . . 48 + 12.3.3. Instance Location . . . . . . . . . . . . . . . . . 49 + 12.3.4. Error or Annotation . . . . . . . . . . . . . . . . 49 + 12.3.5. Nested Results . . . . . . . . . . . . . . . . . . . 49 + 12.4. Output Structure . . . . . . . . . . . . . . . . . . . . 49 + 12.4.1. Flag . . . . . . . . . . . . . . . . . . . . . . . . 51 + + + +Wright, et al. Expires February 11, 2020 [Page 3] + +Internet-Draft JSON Schema August 2019 + + + 12.4.2. Basic . . . . . . . . . . . . . . . . . . . . . . . 51 + 12.4.3. Detailed . . . . . . . . . . . . . . . . . . . . . . 52 + 12.4.4. Verbose . . . . . . . . . . . . . . . . . . . . . . 54 + 12.4.5. Output validation schemas . . . . . . . . . . . . . 56 + 13. Usage for Hypermedia . . . . . . . . . . . . . . . . . . . . 56 + 13.1. Linking to a Schema . . . . . . . . . . . . . . . . . . 56 + 13.2. Identifying a Schema via a Media Type Parameter . . . . 56 + 13.3. Usage Over HTTP . . . . . . . . . . . . . . . . . . . . 58 + 14. Security Considerations . . . . . . . . . . . . . . . . . . . 58 + 15. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 59 + 15.1. application/schema+json . . . . . . . . . . . . . . . . 59 + 15.2. application/schema-instance+json . . . . . . . . . . . . 60 + 16. References . . . . . . . . . . . . . . . . . . . . . . . . . 60 + 16.1. Normative References . . . . . . . . . . . . . . . . . . 60 + 16.2. Informative References . . . . . . . . . . . . . . . . . 61 Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . 63 Appendix B. ChangeLog . . . . . . . . . . . . . . . . . . . . . 63 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 66 @@ -213,19 +214,23 @@ Internet-Draft JSON Schema July 2019 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 -Wright, et al. Expires January 14, 2020 [Page 4] + + + +Wright, et al. Expires February 11, 2020 [Page 4] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 + +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. @@ -266,21 +271,23 @@ Internet-Draft JSON Schema July 2019 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. - -Wright, et al. Expires January 14, 2020 [Page 5] +Wright, et al. Expires February 11, 2020 [Page 5] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 + + +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. @@ -323,21 +330,20 @@ Internet-Draft JSON Schema July 2019 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) 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. - - -Wright, et al. Expires January 14, 2020 [Page 6] +Wright, et al. Expires February 11, 2020 [Page 6] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 + thus outside the scope of JSON Schema. JSON Schema vocabularies + (Section 8) 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 @@ -381,18 +387,18 @@ Internet-Draft JSON Schema July 2019 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. +Wright, et al. Expires February 11, 2020 [Page 7] + +Internet-Draft JSON Schema August 2019 -Wright, et al. Expires January 14, 2020 [Page 7] - -Internet-Draft JSON Schema July 2019 + 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 @@ -403,7 +409,7 @@ Internet-Draft JSON Schema July 2019 4.3. JSON Schema Documents A JSON Schema document, or simply a schema, is a JSON document used - to describe an instance. A schema is itself interpreted as an + 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 @@ -436,20 +442,17 @@ Internet-Draft JSON Schema July 2019 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. - - - - -Wright, et al. Expires January 14, 2020 [Page 8] +Wright, et al. Expires February 11, 2020 [Page 8] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 + 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 @@ -463,13 +466,51 @@ Internet-Draft JSON Schema July 2019 true: Always passes validation, as if the empty schema {} - false: Always fails validation, as if the schema { "not":{} } + 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. Root Schema and Subschemas +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 unkonw 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 + + + +Wright, et al. Expires February 11, 2020 [Page 9] + +Internet-Draft JSON Schema August 2019 + + + 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 The root schema is the schema that comprises the entire JSON document in question. @@ -492,92 +533,6 @@ Internet-Draft JSON Schema July 2019 As with the root schema, a subschema is either an object or a boolean. -4.3.4. 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. - - - - -Wright, et al. Expires January 14, 2020 [Page 9] - -Internet-Draft JSON Schema July 2019 - - - 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 the document'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 jumps 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", - "$recursiveAnchor", and should be considered an advanced feature and - used with caution when defining additional keywords. - -4.3.5. Referenced and Referencing Schemas - - As noted in Section 7.3, 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 - - - -Wright, et al. Expires January 14, 2020 [Page 10] - -Internet-Draft JSON Schema July 2019 - - - 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 9.3.1), - 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. - 5. Fragment Identifiers In accordance with section 3.1 of [RFC6839], the syntax and semantics @@ -599,6 +554,14 @@ Internet-Draft JSON Schema July 2019 Per the W3C's best practices for fragment identifiers [W3C.WD-fragid-best-practices-20121025], plain name fragment + + + +Wright, et al. Expires February 11, 2020 [Page 10] + +Internet-Draft JSON Schema August 2019 + + 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 @@ -608,16 +571,6 @@ Internet-Draft JSON Schema July 2019 "application/schema+json" document are specified in the "$id" keyword (Section 9.2) section. - - - - - -Wright, et al. Expires January 14, 2020 [Page 11] - -Internet-Draft JSON Schema July 2019 - - 6. General Considerations 6.1. Range of JSON Values @@ -657,6 +610,14 @@ Internet-Draft JSON Schema July 2019 simple character classes ([abc]), range character classes ([a-z]); + + + +Wright, et al. Expires February 11, 2020 [Page 11] + +Internet-Draft JSON Schema August 2019 + + complemented character classes ([^abc], [^a-z]); simple quantifiers: "+" (one or more), "*" (zero or more), "?" @@ -666,14 +627,6 @@ Internet-Draft JSON Schema July 2019 least x, at most y, occurrences), {x,} (x occurrences or more), and their lazy versions; - - - -Wright, et al. Expires January 14, 2020 [Page 12] - -Internet-Draft JSON Schema July 2019 - - the beginning-of-input ("^") and end-of-input ("$") anchors; simple grouping ("(...)") and alternation ("|"). @@ -690,45 +643,10 @@ Internet-Draft JSON Schema July 2019 implementations that do not explicitly document such support. Implementations SHOULD ignore keywords they do not support. - 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. - - A schema that itself describes a schema is called a meta-schema. - Meta-schemas are used to validate JSON Schemas and specify which - vocabulary they are using. - - Authors of extensions to JSON Schema are encouraged to write their - own meta-schemas, which extend the existing meta-schemas using - "allOf". This extended meta-schema SHOULD be referenced using the - "$schema" keyword, to allow tools to follow the correct behaviour. - - The recursive nature of meta-schemas makes the "$recursiveAnchor" and - "$recursiveRef" keywords particularly useful for such extensions, as - can be seen in the JSON Hyper-Schema meta-schema. - - - - - - - - -Wright, et al. Expires January 14, 2020 [Page 13] - -Internet-Draft JSON Schema July 2019 - + 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 @@ -748,6 +666,14 @@ Internet-Draft JSON Schema July 2019 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 + + + +Wright, et al. Expires February 11, 2020 [Page 12] + +Internet-Draft JSON Schema August 2019 + + 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, @@ -756,17 +682,84 @@ Internet-Draft JSON Schema July 2019 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. + 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 the document'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 + + + + +Wright, et al. Expires February 11, 2020 [Page 13] + +Internet-Draft JSON Schema August 2019 + + + only allowed in the root schema but processing begins in a subschema. + ]] -7.1. Keyword Interactions + 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 (Section 4.3.3) and/or adjacent keywords. Such keywords + subschemas (Section 4.3.5) 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 (Section 4.3). -7.2. Default Behaviors +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 @@ -778,14 +771,6 @@ Internet-Draft JSON Schema July 2019 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 - - - -Wright, et al. Expires January 14, 2020 [Page 14] - -Internet-Draft JSON Schema July 2019 - - the value which produces the default behavior would produce annotation results if present, the default behavior still MUST NOT result in annotations. @@ -793,6 +778,14 @@ Internet-Draft JSON Schema July 2019 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 + + + +Wright, et al. Expires February 11, 2020 [Page 14] + +Internet-Draft JSON Schema August 2019 + + 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 @@ -800,12 +793,12 @@ Internet-Draft JSON Schema July 2019 demonstrated by the "additionalItems" and "additionalProperties" keywords in this document. -7.3. Applicators +7.4. 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.3) to the complete instance document. From + 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. @@ -817,37 +810,58 @@ Internet-Draft JSON Schema July 2019 is defined by the keyword. Applicator keywords also define how subschema or referenced schema - boolean assertion (Section 7.4) results are modified and/or combined + boolean assertion (Section 7.5) 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.5) results are combined according to the rules + Annotation (Section 7.6) results are combined according to the rules specified by each annotation keyword. -7.4. Assertions +7.4.1. Referenced and Referencing Schemas - 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. + As noted in Section 7.4, 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. -Wright, et al. Expires January 14, 2020 [Page 15] + +Wright, et al. Expires February 11, 2020 [Page 15] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 + For some by-reference applicators, such as "$ref" (Section 9.3.1), + 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.5. 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.4.1. Assertions and Instance Primitive Types +7.5.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 @@ -858,7 +872,7 @@ Internet-Draft JSON Schema July 2019 from being valid. If the instance is a number, boolean, null, array, or object, then it is valid against this assertion. -7.5. Annotations +7.6. Annotations JSON Schema can annotate an instance with information, whenever the instance validates against the schema object containing the @@ -876,6 +890,14 @@ Internet-Draft JSON Schema July 2019 applicators, it is not possible to define a universally predictable order of processing. + + + +Wright, et al. Expires February 11, 2020 [Page 16] + +Internet-Draft JSON Schema August 2019 + + 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 @@ -886,79 +908,249 @@ Internet-Draft JSON Schema July 2019 an instance location, even if they cannot change the overall assertion result. +7.6.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) -Wright, et al. Expires January 14, 2020 [Page 16] + 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. + +7.6.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]: + + + + + +Wright, et al. Expires February 11, 2020 [Page 17] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 + + + 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" + + + + +Wright, et al. Expires February 11, 2020 [Page 18] + +Internet-Draft JSON Schema August 2019 + + + 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.6.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: + + + + + + + + + + + + + +Wright, et al. Expires February 11, 2020 [Page 19] + +Internet-Draft JSON Schema August 2019 + + + { + "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.6.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. 8. Meta-Schemas and Vocabularies Two concepts, meta-schemas and vocabularies, are used to inform an - implementation how to interpret a schema. A schema S declares its - meta-schema M with the "$schema" keyword, and meta-schemas declare - vocabularies with the "$vocabulary" keyword. The vocabularies - declared in M are those that are expected to be used in S. The meta- - schema M may itself use a different set of vocabularies, which are - declared in its own meta-schema, M'. - - The role of the meta-schema is to constrain the structure of - conforming schemas, as well as simplify the process of composing - multiple vocabularies into a usable feature set. Schema authoring is - expected to be a common activity, so schema authors need only - understand how to reference a single meta-schema. + 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-schema authoring is an advanced usage of JSON Schema, so the - design of meta-schema features emphasizes flexibility over - simplicity. - A JSON Schema vocabulary is a set of keywords defined for a - particular purpose. The vocabulary specifies the meaning of its - keywords as assertions, annotations, and/or any vocabulary-defined - keyword category. - The role of a vocabulary is to declare which keywords (including sub- - keywords such as those in JSON Hyper-Schema's Link Description - Object) are in use, and with which semantics. The semantics are - indicated by the document that publicizes the vocabulary URI. At - this time, there is no machine-readable description of keywords other - than validation rules, which appear in the meta-schema. - Meta-schemas are separate from vocabularies to allow for the same - sets of 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. +Wright, et al. Expires February 11, 2020 [Page 20] + +Internet-Draft JSON Schema August 2019 + + + 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. The "$schema" Keyword The "$schema" keyword is both used as a JSON Schema feature set - identifier and the location of a resource which is itself a JSON - Schema, which describes any schema written for this particular - 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 [RFC3986] (containing a scheme) and this URI MUST be normalized. The current schema MUST be valid against the meta-schema identified by this URI. - - -Wright, et al. Expires January 14, 2020 [Page 17] - -Internet-Draft JSON Schema July 2019 - - 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 root schema. It MUST NOT - appear in subschemas. + appear in subschemas. If absent from the root schema, the resulting + behavior 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 @@ -969,30 +1161,42 @@ Internet-Draft JSON Schema July 2019 behavior is subject to be revised or liberalized in future drafts. ]] - Values for this property are defined elsewhere in this and other - documents, and by other parties. + Values for this property are defined elsewhere in this and other + documents, and by other parties. + +8.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 + + + +Wright, et al. Expires February 11, 2020 [Page 21] + +Internet-Draft JSON Schema August 2019 -8.2. The "$vocabulary" Keyword - The "$vocabulary" keyword, which appears in a meta-schema, identifies - what sets of keywords are expected to be used in schemas described by - that meta-schema, and with what semantics. This is conceptually - analogous to how most other keywords used in meta-schemas describe - the syntax of keywords used in schemas described by that meta-schema. + 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 resources is + The URI MAY be a URL, but the nature of the retrievable resource is currently undefined, and reserved for future use. Vocabulary authors - SHOULD NOT serve a document at that URL. A server MAY respond with - the relevant protocol's successful "no content" message, such as an - HTTP 204 status. [[CREF3: Vocabulary documents may be added shortly, - or in the next draft. For now, identifying the keyword set is deemed - sufficient as that, along with meta-schema validation, is how the - current "vocabularies" work today. ]] + 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. + [[CREF3: Vocabulary documents may be added shortly, or in the next + draft. 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 @@ -1001,15 +1205,6 @@ Internet-Draft JSON Schema July 2019 recognize the vocabulary MAY choose to proceed with processing such schemas. - - - - -Wright, et al. Expires January 14, 2020 [Page 18] - -Internet-Draft JSON Schema July 2019 - - When processing a schema that uses unrecognized vocabularies, keywords declared by those vocabularies are treated like any other unrecognized keyword, and ignored. @@ -1023,6 +1218,35 @@ Internet-Draft JSON Schema July 2019 meta-schema M against its own meta-schema M' without requiring the validator to understand the vocabularies declared by M. +8.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. + + + + +Wright, et al. Expires February 11, 2020 [Page 22] + +Internet-Draft JSON Schema August 2019 + + + 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.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 @@ -1031,14 +1255,6 @@ Internet-Draft JSON Schema July 2019 meta-schema. This is demonstrated in the example meta-schema (Section 8.6). - 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. If the meta-schema, as - referenced by the schema, is not recognized, then implementations - MUST assume the use of the core vocabulary, and SHOULD assume the use - of all vocabularies in this specification and the companion - Validation specification. - 8.3. Detecting a Meta-Schema Implementations MUST recognize a schema as a meta-schema if it is @@ -1054,22 +1270,37 @@ Internet-Draft JSON Schema July 2019 schema. So the same document is processed both ways in the course of one session. - Implementations MAY allow a schema to be 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 + 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.4. 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 -Wright, et al. Expires January 14, 2020 [Page 19] +Wright, et al. Expires February 11, 2020 [Page 23] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 - front. Meta-schema authors MUST NOT expect such features to be - interoperable across implementations. + namespacing system, but also does not constrain keyword names, + allowing for any number of namespacing approaches. -8.4. Best Practices for Vocabulary and Meta-Schema Authors + 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 @@ -1079,15 +1310,20 @@ Internet-Draft JSON Schema July 2019 behavior is undefined. Vocabulary authors SHOULD provide a meta-schema that validates the - expected usage of the vocabulary's keywords. Such meta-schemas - SHOULD NOT forbid additional keywords, and MUST NOT forbid the "$id", - "$schema", or "$vocabulary" keywords in the root schema. + 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 12.2.1.1) + vocabulary's meta-schema using the "allOf" (Section 11.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 "$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 @@ -1102,6 +1338,14 @@ Internet-Draft JSON Schema July 2019 vocabulary support in arbitrary implementations, can safely omit "$vocabulary" entirely. + + + +Wright, et al. Expires February 11, 2020 [Page 24] + +Internet-Draft JSON Schema August 2019 + + 8.5. The JSON Schema Core Vocabulary Keywords declared in in this specification that begin with "$" make @@ -1113,15 +1357,6 @@ Internet-Draft JSON Schema July 2019 The Core vocabulary MUST be considered mandatory at all times, in order to bootstrap the processing of further vocabularies. Meta- schemas that use "$vocabulary" MUST explicitly list the Core - - - - -Wright, et al. Expires January 14, 2020 [Page 20] - -Internet-Draft JSON Schema July 2019 - - vocabulary, which MUST have a value of true indicating that it is required. @@ -1136,10 +1371,10 @@ Internet-Draft JSON Schema July 2019 of true. The current URI for the Core vocabulary is: . + draft/2019-08/vocab/core>. The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-08/meta/core>. Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations @@ -1162,20 +1397,9 @@ Internet-Draft JSON Schema July 2019 - - - - - - - - - - - -Wright, et al. Expires January 14, 2020 [Page 21] +Wright, et al. Expires February 11, 2020 [Page 25] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 This meta-schema explicitly declares both the Core and Applicator @@ -1189,16 +1413,16 @@ Internet-Draft JSON Schema July 2019 { - "$schema": "https://json-schema.org/draft/2019-04/core-app-example#", - "$id": "https://json-schema.org/draft/2019-04/core-app-example", + "$schema": "https://json-schema.org/draft/2019-08/core-app-example#", + "$id": "https://json-schema.org/draft/2019-08/core-app-example", "$recursiveAnchor": true, "$vocabulary": { - "https://json-schema.org/draft/2019-04/vocab/core": true, - "https://json-schema.org/draft/2019-04/vocab/applicator": true + "https://json-schema.org/draft/2019-08/vocab/core": true, + "https://json-schema.org/draft/2019-08/vocab/applicator": true }, "allOf": [ - {"$ref": "https://json-schema.org/draft/2019-04/meta/core"}, - {"$ref": "https://json-schema.org/draft/2019-04/meta/applicator"} + {"$ref": "https://json-schema.org/draft/2019-08/meta/core"}, + {"$ref": "https://json-schema.org/draft/2019-08/meta/applicator"} ], "patternProperties": { "^unevaluated.*$": false @@ -1229,9 +1453,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 22] +Wright, et al. Expires February 11, 2020 [Page 26] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 9. Base URI and Dereferencing @@ -1285,9 +1509,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 23] +Wright, et al. Expires February 11, 2020 [Page 27] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 9.2.2. Changing the base URI within a schema file @@ -1341,9 +1565,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 24] +Wright, et al. Expires February 11, 2020 [Page 28] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 Consider the following schema, which shows "$id" being used to @@ -1352,7 +1576,7 @@ Internet-Draft JSON Schema July 2019 { - "$id": "http://example.com/root.json", + "$id": "https://example.com/root.json", "$defs": { "A": { "$id": "#foo" }, "B": { @@ -1375,48 +1599,48 @@ Internet-Draft JSON Schema July 2019 # (document root) - http://example.com/root.json + https://example.com/root.json - http://example.com/root.json# + https://example.com/root.json# #/$defs/A - http://example.com/root.json#foo + https://example.com/root.json#foo - http://example.com/root.json#/$defs/A + https://example.com/root.json#/$defs/A #/$defs/B - http://example.com/other.json + https://example.com/other.json - http://example.com/other.json# + https://example.com/other.json# - http://example.com/root.json#/$defs/B + https://example.com/root.json#/$defs/B #/$defs/B/$defs/X -Wright, et al. Expires January 14, 2020 [Page 25] +Wright, et al. Expires February 11, 2020 [Page 29] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 - http://example.com/other.json#bar + https://example.com/other.json#bar - http://example.com/other.json#/$defs/X + https://example.com/other.json#/$defs/X - http://example.com/root.json#/$defs/B/$defs/X + https://example.com/root.json#/$defs/B/$defs/X #/$defs/B/$defs/Y - http://example.com/t/inner.json + https://example.com/t/inner.json - http://example.com/t/inner.json# + https://example.com/t/inner.json# - http://example.com/other.json#/$defs/Y + https://example.com/other.json#/$defs/Y - http://example.com/root.json#/$defs/B/$defs/Y + https://example.com/root.json#/$defs/B/$defs/Y #/$defs/C @@ -1424,7 +1648,7 @@ Internet-Draft JSON Schema July 2019 urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f# - http://example.com/root.json#/$defs/C + https://example.com/root.json#/$defs/C 9.3. Schema References @@ -1453,9 +1677,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 26] +Wright, et al. Expires February 11, 2020 [Page 30] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 The value of the "$ref" property MUST be a string which is a URI @@ -1509,22 +1733,22 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 27] +Wright, et al. Expires February 11, 2020 [Page 31] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 Consider the following two schemas. The first schema, identified as "original" as it is the schema to be extended, describes an object with one string property and one recursive reference property, "r". The second schema, identified as "extension", references the first, - and describes an additional things" property, which is an array of + and describes an additional "things" property, which is an array of recursive references. It also repeats the description of "r" from the original schema. { - "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$schema": "https://json-schema.org/draft/2019-08/schema#", "$id": "https://example.com/original", "properties": { @@ -1538,7 +1762,7 @@ Internet-Draft JSON Schema July 2019 } { - "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$schema": "https://json-schema.org/draft/2019-08/schema#", "$id": "https://example.com/extension", "$ref": "original", @@ -1565,9 +1789,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 28] +Wright, et al. Expires February 11, 2020 [Page 32] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 This approach is fine for a single recursive field, but the more @@ -1621,9 +1845,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 29] +Wright, et al. Expires February 11, 2020 [Page 33] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 Note that if the schema referenced by "$recursiveRef" does not @@ -1636,7 +1860,7 @@ Internet-Draft JSON Schema July 2019 { - "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$schema": "https://json-schema.org/draft/2019-08/schema#", "$id": "https://example.com/original", "$recursiveAnchor": true, @@ -1651,7 +1875,7 @@ Internet-Draft JSON Schema July 2019 } { - "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$schema": "https://json-schema.org/draft/2019-08/schema#", "$id": "https://example.com/extension", "$recursiveAnchor": true, @@ -1677,9 +1901,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 30] +Wright, et al. Expires February 11, 2020 [Page 34] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 the only schema document in the dynamics scope (it references itself, @@ -1733,9 +1957,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 31] +Wright, et al. Expires February 11, 2020 [Page 35] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 Note that single-level custom keywords with identical syntax and @@ -1754,7 +1978,7 @@ Internet-Draft JSON Schema July 2019 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 (Section 14). + Hypermedia (Section 13). Implementations SHOULD be able to associate arbitrary URIs with an arbitrary schema and/or automatically associate a schema's "$id"- @@ -1789,13 +2013,13 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 32] +Wright, et al. Expires February 11, 2020 [Page 36] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 { - "$id": "http://example.net/root.json", + "$id": "https://example.net/root.json", "items": { "type": "array", "items": { "$ref": "#item" } @@ -1812,15 +2036,15 @@ Internet-Draft JSON Schema July 2019 When an implementation encounters the <#/$defs/single> schema, it resolves the "$id" URI reference against the current base URI to form - . + . When an implementation then looks inside the <#/items> schema, it encounters the <#item> reference, and resolves this to - , which it has seen defined in + , 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 , which is not + resolves this to , 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. [[CREF6: What should implementations do when the @@ -1845,9 +2069,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 33] +Wright, et al. Expires February 11, 2020 [Page 37] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 As an example, here is a schema describing an array of positive @@ -1891,231 +2115,31 @@ Internet-Draft JSON Schema July 2019 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. - -11. 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. - - - -Wright, et al. Expires January 14, 2020 [Page 34] - -Internet-Draft JSON Schema July 2019 - - - 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. - -11.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]: - - - - - - - - - - - - - - - - - - - - - -Wright, et al. Expires January 14, 2020 [Page 35] - -Internet-Draft JSON Schema July 2019 - - - 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" - - - - -Wright, et al. Expires January 14, 2020 [Page 36] - -Internet-Draft JSON Schema July 2019 - - - 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. - -11.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: - - - - - - - - - - - - - -Wright, et al. Expires January 14, 2020 [Page 37] - -Internet-Draft JSON Schema July 2019 - - - { - "oneOf": [ - { - "title": "Integer Value", - "type": "integer" - }, - { - "title": "String Value", - "type": "string" - } - ] - } + NOT be collected as an annotation result. +11. A Vocabulary for Applying Subschemas - 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. + This section defines a vocabulary of applicator keywords that are + RECOMMENDED for use as the basis of other vocabularies. -11.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. -12. A Vocabulary for Applying Subschemas - This section defines a vocabulary of applicator keywords that are - RECOMMENDED for use as the basis of other vocabularies. +Wright, et al. Expires February 11, 2020 [Page 38] + +Internet-Draft JSON Schema August 2019 + 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: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-08/meta/applicator>. Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations @@ -2123,14 +2147,7 @@ Internet-Draft JSON Schema July 2019 the next to indicate the same syntax and semantics as those listed here. - - -Wright, et al. Expires January 14, 2020 [Page 38] - -Internet-Draft JSON Schema July 2019 - - -12.1. Keyword Independence +11.1. Keyword Independence Schema keywords typically operate independently, without affecting each other's outcomes. @@ -2150,22 +2167,30 @@ Internet-Draft JSON Schema July 2019 "unevaluatedItems", whose behavior is defined in terms of annotations from "items", "additionalItems" and itself -12.2. Keywords for Applying Subschemas in Place +11.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. -12.2.1. Keywords for Applying Subschemas With Boolean Logic +11.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 + + + +Wright, et al. Expires February 11, 2020 [Page 39] + +Internet-Draft JSON Schema August 2019 + + same annotation keyword to be applied to an instance location with different values. Annotation keywords define their own rules for combining such values. -12.2.1.1. allOf +11.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. @@ -2174,28 +2199,18 @@ Internet-Draft JSON Schema July 2019 validates successfully against all schemas defined by this keyword's value. - - - - - - - -Wright, et al. Expires January 14, 2020 [Page 39] - -Internet-Draft JSON Schema July 2019 - - -12.2.1.2. anyOf +11.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. + 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. -12.2.1.3. oneOf +11.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. @@ -2204,14 +2219,14 @@ Internet-Draft JSON Schema July 2019 validates successfully against exactly one schema defined by this keyword's value. -12.2.1.4. not +11.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. -12.2.2. Keywords for Applying Subschemas Conditionally +11.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. @@ -2219,6 +2234,14 @@ Internet-Draft JSON Schema July 2019 "if", "then", and "else" MUST NOT interact with each other across subschema boundaries. In other words, an "if" in one branch of an + + + +Wright, et al. Expires February 11, 2020 [Page 40] + +Internet-Draft JSON Schema August 2019 + + "allOf" MUST NOT have an impact on a "then" or "else" in another branch. @@ -2227,7 +2250,7 @@ Internet-Draft JSON Schema July 2019 present with an empty schema, and when "if" is not present, both "then" and "else" MUST be entirely ignored. -12.2.2.1. if +11.2.2.1. if This keyword's value MUST be a valid JSON Schema. @@ -2235,13 +2258,6 @@ Internet-Draft JSON Schema July 2019 effect on the overall validation result. Rather, it controls which of the "then" or "else" keywords are evaluated. - - -Wright, et al. Expires January 14, 2020 [Page 40] - -Internet-Draft JSON Schema July 2019 - - Instances that successfully validate against this keyword's subschema MUST also be valid against the subschema value of the "then" keyword, if present. @@ -2250,11 +2266,11 @@ Internet-Draft JSON Schema July 2019 also be valid against the subschema value of the "else" keyword, if present. - If annotations (Section 7.5) are being collected, they are collected + If annotations (Section 7.6) 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". -12.2.2.2. then +11.2.2.2. then This keyword's value MUST be a valid JSON Schema. @@ -2268,10 +2284,20 @@ Internet-Draft JSON Schema July 2019 evaluate the instance against this keyword, for either validation or annotation collection purposes, in such cases. -12.2.2.3. else +11.2.2.3. else This keyword's value MUST be a valid JSON Schema. + + + + + +Wright, et al. Expires February 11, 2020 [Page 41] + +Internet-Draft JSON Schema August 2019 + + 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. @@ -2281,7 +2307,7 @@ Internet-Draft JSON Schema July 2019 NOT evaluate the instance against this keyword, for either validation or annotation collection purposes, in such cases. -12.2.2.4. dependentSchemas +11.2.2.4. dependentSchemas This keyword specifies subschemas that are evaluated if the instance is an object and contains a certain property. @@ -2289,30 +2315,21 @@ Internet-Draft JSON Schema July 2019 This keyword's value MUST be an object. Each value in the object MUST be a valid JSON Schema. - - - - -Wright, et al. Expires January 14, 2020 [Page 41] - -Internet-Draft JSON Schema July 2019 - - 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. -12.3. Keywords for Applying Subschemas to Child Instances +11.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. -12.3.1. Keywords for Applying Subschemas to Arrays +11.3.1. Keywords for Applying Subschemas to Arrays -12.3.1.1. items +11.3.1.1. items The value of "items" MUST be either a valid JSON Schema or an array of valid JSON Schemas. @@ -2329,6 +2346,14 @@ Internet-Draft JSON Schema July 2019 boolean true if a subschema was applied to every index of the instance, such as when "items" is a schema. + + + +Wright, et al. Expires February 11, 2020 [Page 42] + +Internet-Draft JSON Schema August 2019 + + 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 @@ -2337,7 +2362,7 @@ Internet-Draft JSON Schema July 2019 Omitting this keyword has the same assertion behavior as an empty schema. -12.3.1.2. additionalItems +11.3.1.2. additionalItems The value of "additionalItems" MUST be a valid JSON Schema. @@ -2347,13 +2372,6 @@ Internet-Draft JSON Schema July 2019 if every instance element at an index greater than that number validates against "additionalItems". - - -Wright, et al. Expires January 14, 2020 [Page 42] - -Internet-Draft JSON Schema July 2019 - - Otherwise, if "items" is absent or its annotation result is the boolean true, "additionalItems" MUST be ignored. @@ -2372,7 +2390,7 @@ Internet-Draft JSON Schema July 2019 checking for the presence and size of an "items" array. Implementations that do not support annotation collection MUST do so. -12.3.1.3. unevaluatedItems +11.3.1.3. unevaluatedItems The value of "unevaluatedItems" MUST be a valid JSON Schema. @@ -2382,7 +2400,16 @@ Internet-Draft JSON Schema July 2019 "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 (Section 12.2) keywords. This includes + adjacent in-place applicator (Section 11.2) keywords. This includes + + + + +Wright, et al. Expires February 11, 2020 [Page 43] + +Internet-Draft JSON Schema August 2019 + + but is not limited to the in-place applicators defined in this document. @@ -2403,13 +2430,6 @@ Internet-Draft JSON Schema July 2019 Authors of extension keywords MUST NOT define an in-place applicator that would need to be evaluated before this keyword. - - -Wright, et al. Expires January 14, 2020 [Page 43] - -Internet-Draft JSON Schema July 2019 - - 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 @@ -2423,22 +2443,30 @@ Internet-Draft JSON Schema July 2019 Implementations that do not collect annotations MUST raise an error upon encountering this keyword. -12.3.1.4. contains +11.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. This keyword does not - produce annotation results. [[CREF7: Should it produce a set of the - indices for which the array element is valid against the subschema? - "contains" does not affect "additionalItems" or any other current or - proposed keyword, but the information could be useful, and - implementation that collect annotations need to apply "contains" to - every element anyway. ]] + 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. + +11.3.2. Keywords for Applying Subschemas to Objects + + + + + + + +Wright, et al. Expires February 11, 2020 [Page 44] + +Internet-Draft JSON Schema August 2019 -12.3.2. Keywords for Applying Subschemas to Objects -12.3.2.1. properties +11.3.2.1. properties The value of "properties" MUST be an object. Each value of this object MUST be a valid JSON Schema. @@ -2456,17 +2484,7 @@ Internet-Draft JSON Schema July 2019 Omitting this keyword has the same assertion behavior as an empty object. - - - - - -Wright, et al. Expires January 14, 2020 [Page 44] - -Internet-Draft JSON Schema July 2019 - - -12.3.2.2. patternProperties +11.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 @@ -2487,7 +2505,7 @@ Internet-Draft JSON Schema July 2019 Omitting this keyword has the same assertion behavior as an empty object. -12.3.2.3. additionalProperties +11.3.2.3. additionalProperties The value of "additionalProperties" MUST be a valid JSON Schema. @@ -2497,6 +2515,13 @@ Internet-Draft JSON Schema July 2019 to the child values of instance names that do not appear in the annotation results of either "properties" or "patternProperties". + + +Wright, et al. Expires February 11, 2020 [Page 45] + +Internet-Draft JSON Schema August 2019 + + For all such properties, validation succeeds if the child instance validates against the "additionalProperties" schema. @@ -2514,15 +2539,7 @@ Internet-Draft JSON Schema July 2019 "patternProperties" against the instance property set. Implementations that do not support annotation collection MUST do so. - - - -Wright, et al. Expires January 14, 2020 [Page 45] - -Internet-Draft JSON Schema July 2019 - - -12.3.2.4. unevaluatedProperties +11.3.2.4. unevaluatedProperties The value of "unevaluatedProperties" MUST be a valid JSON Schema. @@ -2533,7 +2550,7 @@ Internet-Draft JSON Schema July 2019 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 12.2) keywords. This includes but is + in-place applicator (Section 11.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 @@ -2553,6 +2570,14 @@ Internet-Draft JSON Schema July 2019 The annotation result of this keyword is the set of instance property names validated by this keyword's subschema. Annotation results for + + + +Wright, et al. Expires February 11, 2020 [Page 46] + +Internet-Draft JSON Schema August 2019 + + "unevaluatedProperties" keywords from multiple schemas applied to the same instance location are combined by taking the union of the sets. @@ -2562,7 +2587,7 @@ Internet-Draft JSON Schema July 2019 Implementations that do not collect annotations MUST raise an error upon encountering this keyword. -12.3.2.5. propertyNames +11.3.2.5. propertyNames The value of "propertyNames" MUST be a valid JSON Schema. @@ -2571,16 +2596,9 @@ Internet-Draft JSON Schema July 2019 Note the property name that the schema is testing will always be a string. - - -Wright, et al. Expires January 14, 2020 [Page 46] - -Internet-Draft JSON Schema July 2019 - - Omitting this keyword has the same behavior as an empty schema. -13. Output Formatting +12. Output Formatting JSON Schema is defined to be platform-independent. As such, to increase compatibility across platforms, implementations SHOULD @@ -2588,7 +2606,7 @@ Internet-Draft JSON Schema July 2019 describes the minimum requirements that consumers will need to properly interpret validation results. -13.1. Format +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 @@ -2596,7 +2614,7 @@ Internet-Draft JSON Schema July 2019 however it is RECOMMENDED that the output be convertible to the JSON format defined herein via serialization or other means. -13.2. Output Formats +12.2. Output Formats This specification defines four output formats. See the "Output Structure" section for the requirements of each format. @@ -2609,6 +2627,13 @@ Internet-Draft JSON Schema July 2019 Detailed - Provides validation information in a condensed hierarchical structure based on the structure of the schema. + + +Wright, et al. Expires February 11, 2020 [Page 47] + +Internet-Draft JSON Schema August 2019 + + Verbose - Provides validation information in an uncondensed hierarchical structure that matches the exact structure of the schema. @@ -2619,27 +2644,18 @@ Internet-Draft JSON Schema July 2019 "flag" format. Implementations SHOULD specify in their documentation which formats they support. -13.3. Minimum Information +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. - - - - -Wright, et al. Expires January 14, 2020 [Page 47] - -Internet-Draft JSON Schema July 2019 - - A single object that contains all of these components is considered an output unit. Implementations MAY elect to provide additional information. -13.3.1. Keyword Relative Location +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 @@ -2655,14 +2671,23 @@ Internet-Draft JSON Schema July 2019 The JSON key for this information is "keywordLocation". -13.3.2. Keyword Absolute Location +12.3.2. Keyword Absolute Location The absolute, dereferenced location of the validating keyword. The value MUST be expressed as an absolute URI, and it MUST NOT include by-reference applicators such as "$ref" or "$recursiveRef". -http://json-schema.org/draft/2019-04/schema#/$defs/nonNegativeInteger/minimum +https://json-schema.org/draft/2019-08/schema#/$defs/nonNegativeInteger/minimum + + + + + + +Wright, et al. Expires February 11, 2020 [Page 48] + +Internet-Draft JSON Schema August 2019 This information MAY be omitted only if either the relative location @@ -2671,26 +2696,14 @@ http://json-schema.org/draft/2019-04/schema#/$defs/nonNegativeInteger/minimum The JSON key for this information is "absoluteKeywordLocation". -13.3.3. Instance Location +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". - - - - - - - -Wright, et al. Expires January 14, 2020 [Page 48] - -Internet-Draft JSON Schema July 2019 - - -13.3.4. Error or Annotation +12.3.4. Error or Annotation The error or annotation that is produced by the validation. @@ -2700,7 +2713,7 @@ Internet-Draft JSON Schema July 2019 The JSON key for failed validations is "error"; for successful validations it is "annotation". -13.3.5. Nested Results +12.3.5. Nested Results For the two hierarchical structures, this property will hold nested errors and annotations. @@ -2708,7 +2721,7 @@ Internet-Draft JSON Schema July 2019 The JSON key for nested results in failed validations is "errors"; for successful validations it is "annotations". -13.4. Output Structure +12.4. Output Structure The output MUST be an object containing a boolean property named "valid". When additional information about the result is required, @@ -2728,27 +2741,14 @@ Internet-Draft JSON Schema July 2019 - - - - - - - - - - - - - -Wright, et al. Expires January 14, 2020 [Page 49] +Wright, et al. Expires February 11, 2020 [Page 49] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 { - "$id": "http://example.com/polygon#", - "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "https://example.com/polygon#", + "$schema": "https://json-schema.org/draft/2019-08/schema#", "$defs": { "point": { "type": "object", @@ -2797,15 +2797,15 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 50] +Wright, et al. Expires February 11, 2020 [Page 50] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 templating mechanism that allows their users to craft their own messages. -13.4.1. Flag +12.4.1. Flag In the simplest case, merely the boolean result for the "valid" valid property needs to be fulfilled. @@ -2823,7 +2823,7 @@ Internet-Draft JSON Schema July 2019 second one passes, there is no need to check the other three. The logic can simply return with success. -13.4.2. Basic +12.4.2. Basic The "Basic" structure is a flat list of output units. @@ -2853,50 +2853,50 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 51] +Wright, et al. Expires February 11, 2020 [Page 51] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 - { - "valid": false, - "errors": [ - { - "keywordLocation": "#", - "instanceLocation": "#", - "error": "A subschema had errors." - }, - { - "keywordLocation": "#/items/$ref", - "absoluteKeywordLocation": - "http://example.com/polygon#/$defs/point", - "instanceLocation": "#/1", - "error": "A subschema had errors." - }, - { - "keywordLocation": "#/items/$ref/required", - "absoluteKeywordLocation": - "http://example.com/polygon#/$defs/point/required", - "instanceLocation": "#/1", - "error": "Required property 'y' not found." - }, - { - "keywordLocation": "#/items/$ref/additionalProperties", - "absoluteKeywordLocation": - "http://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" - } - ] - } +{ + "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" + } + ] +} -13.4.3. Detailed +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 @@ -2909,9 +2909,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 52] +Wright, et al. Expires February 11, 2020 [Page 52] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 The following rules govern the construction of the results object: @@ -2965,9 +2965,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 53] +Wright, et al. Expires February 11, 2020 [Page 53] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 { @@ -2979,14 +2979,14 @@ Internet-Draft JSON Schema July 2019 "valid": false, "keywordLocation": "#/items/$ref", "absoluteKeywordLocation": - "http://example.com/polygon#/$defs/point", + "https://example.com/polygon#/$defs/point", "instanceLocation": "#/1", "errors": [ { "valid": false, "keywordLocation": "#/items/$ref/required", "absoluteKeywordLocation": - "http://example.com/polygon#/$defs/point/required", + "https://example.com/polygon#/$defs/point/required", "instanceLocation": "#/1", "error": "Required property 'y' not found." }, @@ -2994,7 +2994,7 @@ Internet-Draft JSON Schema July 2019 "valid": false, "keywordLocation": "#/items/$ref/additionalProperties", "absoluteKeywordLocation": - "http://example.com/polygon#/$defs/point/additionalProperties", + "https://example.com/polygon#/$defs/point/additionalProperties", "instanceLocation": "#/1/z", "error": "Additional property 'z' found but was invalid." } @@ -3010,7 +3010,7 @@ Internet-Draft JSON Schema July 2019 } -13.4.4. Verbose +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 @@ -3021,9 +3021,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 54] +Wright, et al. Expires February 11, 2020 [Page 54] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 results that would otherwise be removed (e.g. annotations for failed @@ -3033,14 +3033,14 @@ Internet-Draft JSON Schema July 2019 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: . // schema { - "$id": "http://example.com/polygon#", - "$schema": "http://json-schema.org/draft/2019-04/schema#", + "$id": "https://example.com/polygon#", + "$schema": "https://json-schema.org/draft/2019-08/schema#", "type": "object", "properties": { "validProp": true, @@ -3077,9 +3077,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 55] +Wright, et al. Expires February 11, 2020 [Page 55] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 "errors": [ @@ -3095,20 +3095,20 @@ Internet-Draft JSON Schema July 2019 } -13.4.5. Output validation schemas +12.4.5. Output validation schemas For convenience, JSON Schema has been provided to validate output generated by implementations. Its URI is: . + draft/2019-08/output/schema>. -14. Usage for Hypermedia +13. 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]. -14.1. Linking to a Schema +13.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", @@ -3119,10 +3119,10 @@ Internet-Draft JSON Schema July 2019 header [RFC8288]. An example of such a header would be: - Link: ; rel="describedby" + Link: ; rel="describedby" -14.2. Identifying a Schema via a Media Type Parameter +13.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 @@ -3133,9 +3133,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 56] +Wright, et al. Expires February 11, 2020 [Page 56] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 When using the media type application/schema-instance+json, the @@ -3163,7 +3163,7 @@ Internet-Draft JSON Schema July 2019 Content-Type: application/json; - schema="http://example.com/my-hyper-schema#" + schema="https://example.com/my-hyper-schema#" Multiple schemas are whitespace separated, and indicate that the @@ -3171,16 +3171,16 @@ Internet-Draft JSON Schema July 2019 Content-Type: application/json; - schema="http://example.com/alice http://example.com/bob" + 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="http://example.com/qiang http://example.com/li", + schema="https://example.com/qiang https://example.com/li", application/json; - schema="http://example.com/kumar" + schema="https://example.com/kumar" As with Content-Type, multiple schema parameters in the same string @@ -3189,9 +3189,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 57] +Wright, et al. Expires February 11, 2020 [Page 57] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 Unlike Content-Type, Accept can contain multiple values to indicate @@ -3200,7 +3200,7 @@ Internet-Draft JSON Schema July 2019 parameter values. This requests an application/json representation that conforms to at least one of the identified schemas. - [[CREF8: This paragraph assumes that we can register a "schema" link + [[CREF7: 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- @@ -3210,7 +3210,7 @@ Internet-Draft JSON Schema July 2019 Link: ;rel="schema", ;rel="schema" -14.3. Usage Over HTTP +13.3. Usage Over HTTP When used for hypermedia systems over a network, HTTP [RFC7231] is frequently the protocol of choice for distributing schemas. @@ -3237,7 +3237,7 @@ Internet-Draft JSON Schema July 2019 server operators can contact the owner of a potentially misbehaving script. -15. Security Considerations +14. Security Considerations Both schemas and instances are JSON values. As such, all security considerations defined in RFC 8259 [RFC8259] apply. @@ -3245,9 +3245,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 58] +Wright, et al. Expires February 11, 2020 [Page 58] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 Instances and schemas are both frequently written by untrusted third @@ -3272,9 +3272,9 @@ Internet-Draft JSON Schema July 2019 dangerous material within a "$comment". Implementations MUST NOT parse or otherwise take action based on "$comment" contents. -16. IANA Considerations +15. IANA Considerations -16.1. application/schema+json +15.1. application/schema+json The proposed MIME media type for JSON Schema is defined as follows: @@ -3301,19 +3301,19 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 59] +Wright, et al. Expires February 11, 2020 [Page 59] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 - Security considerations: See Section 15 above. + Security considerations: See Section 14 above. Interoperability considerations: See Sections 6.2, 6.3, and 6.4 above. Fragment identifier considerations: See Section 5 -16.2. application/schema-instance+json +15.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: @@ -3336,16 +3336,16 @@ Internet-Draft JSON Schema July 2019 those specified for the "application/json" media type. See JSON [RFC8259]. - Security considerations: See Section 15 above. + Security considerations: See Section 14 above. Interoperability considerations: See Sections 6.2, 6.3, and 6.4 above. Fragment identifier considerations: See Section 5 -17. References +16. References -17.1. Normative References +16.1. Normative References [ecma262] "ECMA 262 specification", . -17.2. Informative References +16.2. Informative References [json-hyper-schema] Andrews, H. and A. Wright, "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON", draft- - handrews-json-schema-hyperschema-WIP (work in progress), + handrews-json-schema-hyperschema-02 (work in progress), November 2017. [json-schema-validation] Wright, A., Andrews, H., and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of - JSON", draft-handrews-json-schema-validation-WIP (work in + JSON", draft-handrews-json-schema-validation-02 (work in progress), November 2017. [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object @@ -3413,9 +3413,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 61] +Wright, et al. Expires February 11, 2020 [Page 61] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer @@ -3469,9 +3469,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 62] +Wright, et al. Expires February 11, 2020 [Page 62] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 Appendix A. Acknowledgments @@ -3485,10 +3485,10 @@ Appendix A. Acknowledgments Appendix B. ChangeLog - [[CREF9: This section to be removed before leaving Internet-Draft + [[CREF8: This section to be removed before leaving Internet-Draft status.]] - draft-handrews-json-schema-WIP + draft-handrews-json-schema-02 * Update to RFC 8259 for JSON specification @@ -3525,9 +3525,9 @@ Appendix B. ChangeLog -Wright, et al. Expires January 14, 2020 [Page 63] +Wright, et al. Expires February 11, 2020 [Page 63] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 * Additional guidance on initial base URIs beyond network @@ -3581,9 +3581,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 64] +Wright, et al. Expires February 11, 2020 [Page 64] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 * Add "application/schema-instance+json" media type @@ -3637,9 +3637,9 @@ Internet-Draft JSON Schema July 2019 -Wright, et al. Expires January 14, 2020 [Page 65] +Wright, et al. Expires February 11, 2020 [Page 65] -Internet-Draft JSON Schema July 2019 +Internet-Draft JSON Schema August 2019 * Fixed numerous invalid examples @@ -3672,12 +3672,8 @@ Authors' Addresses Henry Andrews (editor) - Riverbed Technology - 680 Folsom St. - San Francisco, CA - USA - EMail: handrews@riverbed.com + EMail: andrews_henry@yahoo.com Ben Hutton (editor) @@ -3687,17 +3683,6 @@ Authors' Addresses URI: https://jsonschema.dev - - - - - - -Wright, et al. Expires January 14, 2020 [Page 66] - -Internet-Draft JSON Schema July 2019 - - Greg Dennis Auckland NZ @@ -3708,45 +3693,4 @@ Internet-Draft JSON Schema July 2019 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Wright, et al. Expires January 14, 2020 [Page 67] +Wright, et al. Expires February 11, 2020 [Page 66] diff --git a/work-in-progress/WIP-jsonschema-hyperschema.html b/work-in-progress/WIP-jsonschema-hyperschema.html index 0e052baf..4f25c2c7 100644 --- a/work-in-progress/WIP-jsonschema-hyperschema.html +++ b/work-in-progress/WIP-jsonschema-hyperschema.html @@ -449,12 +449,12 @@ - + - - + + @@ -471,15 +471,15 @@
      - + - - + + @@ -487,19 +487,19 @@
      [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-WIP, 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-WIP, November 2017.
      [RFC7049]
      Internet-DraftRiverbed Technology
      Intended status: Informational A. Wright, Ed.
      Expires: December 20, 2019June 18, 2019Expires: February 11, 2020August 10, 2019

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

      + 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 <http://json-schema.org/>.

      +

      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 December 20, 2019.

      +

      This Internet-Draft will expire on February 11, 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.

      @@ -727,11 +727,11 @@

      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 <http://json-schema.org/draft/2019-04/hyper-schema#>.

      -

      The current URI for this vocabulary, known as the Hyper-Schema vocabulary, is: <https://json-schema.org/draft/2019-04/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-04/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: <http://json-schema.org/draft/2019-04/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 <http://json-schema.org/draft/2019-04/output/hyper-schema#>.

      +

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

      +

      The current URI for this vocabulary, known as the Hyper-Schema vocabulary, is: <https://json-schema.org/draft/2019-08/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-08/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-08/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-08/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

      @@ -1189,7 +1189,7 @@

      { "$id": "https://schema.example.com/entry", - "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", "base": "https://example.com/api/", "links": [ { @@ -1231,7 +1231,7 @@

       {
           "$id": "https://schema.example.com/thing",
      -    "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#",
      +    "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
           "base": "https://example.com/api/",
           "type": "object",
           "required": ["data"],
      @@ -1285,7 +1285,7 @@ 

       {
           "$id": "https://schema.example.com/interesting-stuff",
      -    "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#",
      +    "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
           "required": ["stuffWorthEmailingAbout", "email", "title"],
           "properties": {
               "title": {
      @@ -1413,7 +1413,7 @@ 

       {
           "$id": "https://schema.example.com/tree-node",
      -    "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#",
      +    "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
           "base": "trees/{treeId}/",
           "properties": {
               "id": {"type": "integer"},
      @@ -1453,7 +1453,7 @@ 

       {
           "$id": "https://schema.example.com/thing",
      -    "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#",
      +    "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
           "base": "https://example.com/api/",
           "type": "object",
           "required": ["data"],
      @@ -1488,7 +1488,7 @@ 

       {
           "$id": "https://schema.example.com/thing-collection",
      -    "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#",
      +    "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
           "base": "https://example.com/api/",
           "type": "object",
           "required": ["elements"],
      @@ -1751,12 +1751,12 @@ 

      [json-schema] -Wright, A. and H. Andrews, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-handrews-json-schema-WIP, November 2017. +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-WIP, November 2017. +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] @@ -1868,7 +1868,7 @@

      -
      draft-handrews-json-schema-hyperschema-WIP
      +
      draft-handrews-json-schema-hyperschema-02
      • Allow multiple values for "rel"
      • @@ -1968,18 +1968,17 @@

        Authors' Addresses

        Andrews - Riverbed Technology + - 680 Folsom St. - + - San Francisco, - CA + + - USA + - EMail: handrews@riverbed.com + EMail: andrews_henry@yahoo.com
        diff --git a/work-in-progress/WIP-jsonschema-hyperschema.txt b/work-in-progress/WIP-jsonschema-hyperschema.txt index 4bddd66e..4e4b5bd3 100644 --- a/work-in-progress/WIP-jsonschema-hyperschema.txt +++ b/work-in-progress/WIP-jsonschema-hyperschema.txt @@ -3,13 +3,13 @@ Internet Engineering Task Force H. Andrews, Ed. -Internet-Draft Riverbed Technology +Internet-Draft Intended status: Informational A. Wright, Ed. -Expires: November 26, 2019 May 25, 2019 +Expires: February 11, 2020 August 10, 2019 JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON - draft-handrews-json-schema-hyperschema-WIP + draft-handrews-json-schema-hyperschema-02 Abstract @@ -27,7 +27,7 @@ Note to Readers The issues list for this draft can be found at . - For additional information, see . + For additional information, see . To provide feedback, use this issue tracker, the communication methods listed on the homepage, or email the document editors. @@ -47,15 +47,15 @@ Status of This Memo 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 November 26, 2019. + This Internet-Draft will expire on February 11, 2020. -Andrews & Wright Expires November 26, 2019 [Page 1] +Andrews & Wright Expires February 11, 2020 [Page 1] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 Copyright Notice @@ -109,9 +109,9 @@ Table of Contents -Andrews & Wright Expires November 26, 2019 [Page 2] +Andrews & Wright Expires February 11, 2020 [Page 2] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 6.6.2. headerSchema . . . . . . . . . . . . . . . . . . . . 16 @@ -165,9 +165,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 3] +Andrews & Wright Expires February 11, 2020 [Page 3] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 manipulating remote JSON resources through hypermedia environments @@ -221,9 +221,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 4] +Andrews & Wright Expires February 11, 2020 [Page 4] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 representation formats at runtime, or pre-emptively follow links to @@ -277,9 +277,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 5] +Andrews & Wright Expires February 11, 2020 [Page 5] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 JSON Hyper-Schema A JSON Schema using the keywords defined by this @@ -333,9 +333,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 6] +Andrews & Wright Expires February 11, 2020 [Page 6] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 The relation type and target attributes are taken directly from each @@ -358,22 +358,23 @@ Internet-Draft JSON Hyper-Schema May 2019 4. Meta-Schemas and Output Schema The current URI for the JSON Hyper-Schema meta-schema is - . + . The current URI for this vocabulary, known as the Hyper-Schema - vocabulary, is: . 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: . + schema.org/draft/2019-08/meta/hyper-schema>. The link description format (Section 6) 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: . + description schema is: . JSON Hyper-Schema implementations are free to provide output in any format. However, a specific format is defined for use in the @@ -382,16 +383,15 @@ Internet-Draft JSON Hyper-Schema May 2019 generated by examples (Section 9). 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 . + recommended output format is . - -Andrews & Wright Expires November 26, 2019 [Page 7] +Andrews & Wright Expires February 11, 2020 [Page 7] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 Updated vocabulary and meta-schema URIs MAY be published between @@ -445,9 +445,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 8] +Andrews & Wright Expires February 11, 2020 [Page 8] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 provides all of these, along with additional features using JSON @@ -501,9 +501,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 9] +Andrews & Wright Expires February 11, 2020 [Page 9] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 6.1.1. anchor @@ -557,9 +557,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 10] +Andrews & Wright Expires February 11, 2020 [Page 10] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 6.2.1. rel @@ -613,9 +613,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 11] +Andrews & Wright Expires February 11, 2020 [Page 11] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 As such a method would correspond to JSON Hyper-Schema's data @@ -669,9 +669,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 12] +Andrews & Wright Expires February 11, 2020 [Page 12] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 "anchor" keyword being resolved which requires "base" templates to be @@ -725,9 +725,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 13] +Andrews & Wright Expires February 11, 2020 [Page 13] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 User agents MAY use this description when presenting the link to the @@ -781,9 +781,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 14] +Andrews & Wright Expires February 11, 2020 [Page 14] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 section is expected to become more well-defined based on draft @@ -837,9 +837,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 15] +Andrews & Wright Expires February 11, 2020 [Page 15] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 other user agent data for filling out the URI Template in "href" @@ -893,9 +893,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 16] +Andrews & Wright Expires February 11, 2020 [Page 16] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 prevent client applications or user agents from supplying additional @@ -949,9 +949,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 17] +Andrews & Wright Expires February 11, 2020 [Page 17] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 6.6.4.1. submissionMediaType @@ -1005,9 +1005,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 18] +Andrews & Wright Expires February 11, 2020 [Page 18] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 contextUri The fully resolved URI (with scheme) of the context @@ -1061,9 +1061,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 19] +Andrews & Wright Expires February 11, 2020 [Page 19] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 must also be located and associated with the LDO through whatever @@ -1117,9 +1117,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 20] +Andrews & Wright Expires February 11, 2020 [Page 20] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 1. Populate template variable data from the instance @@ -1173,9 +1173,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 21] +Andrews & Wright Expires February 11, 2020 [Page 21] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 for varname in T: @@ -1229,9 +1229,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 22] +Andrews & Wright Expires February 11, 2020 [Page 22] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 "InputForm" represents whatever sort of input mechanism is @@ -1285,9 +1285,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 23] +Andrews & Wright Expires February 11, 2020 [Page 23] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 for varname in templateData: @@ -1341,9 +1341,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 24] +Andrews & Wright Expires February 11, 2020 [Page 24] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 The LDO can express all information needed to perform any operation @@ -1397,9 +1397,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 25] +Andrews & Wright Expires February 11, 2020 [Page 25] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 schemas and use appropriate media types (e.g. "application/ @@ -1453,9 +1453,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 26] +Andrews & Wright Expires February 11, 2020 [Page 26] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 mechanism, although it is RECOMMENDED that the techniques outlined in @@ -1509,9 +1509,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 27] +Andrews & Wright Expires February 11, 2020 [Page 27] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 Per RFC 5789 [RFC5789], the request structure for an HTTP PATCH is @@ -1565,9 +1565,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 28] +Andrews & Wright Expires February 11, 2020 [Page 28] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 response and those that appear in an OPTIONS response can appear. No @@ -1621,9 +1621,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 29] +Andrews & Wright Expires February 11, 2020 [Page 29] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 o Range requests @@ -1677,9 +1677,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 30] +Andrews & Wright Expires February 11, 2020 [Page 30] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 9. Examples @@ -1718,7 +1718,7 @@ Internet-Draft JSON Hyper-Schema May 2019 { "$id": "https://schema.example.com/entry", - "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", "base": "https://example.com/api/", "links": [ { @@ -1733,9 +1733,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 31] +Andrews & Wright Expires February 11, 2020 [Page 31] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 These are the simplest possible links, with only a relation type and @@ -1789,9 +1789,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 32] +Andrews & Wright Expires February 11, 2020 [Page 32] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 9.2. Individually Identified Resources @@ -1800,7 +1800,7 @@ Internet-Draft JSON Hyper-Schema May 2019 { "$id": "https://schema.example.com/thing", - "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", "base": "https://example.com/api/", "type": "object", "required": ["data"], @@ -1845,9 +1845,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 33] +Andrews & Wright Expires February 11, 2020 [Page 33] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 so an extension relationship is defined using the "tag:" URI scheme @@ -1901,9 +1901,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 34] +Andrews & Wright Expires February 11, 2020 [Page 34] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 We use "submissionMediaType" to indicate a multipart/alternative @@ -1924,7 +1924,7 @@ Internet-Draft JSON Hyper-Schema May 2019 { "$id": "https://schema.example.com/interesting-stuff", - "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", "required": ["stuffWorthEmailingAbout", "email", "title"], "properties": { "title": { @@ -1957,9 +1957,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 35] +Andrews & Wright Expires February 11, 2020 [Page 35] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 "email": false @@ -2013,9 +2013,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 36] +Andrews & Wright Expires February 11, 2020 [Page 36] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 { @@ -2069,9 +2069,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 37] +Andrews & Wright Expires February 11, 2020 [Page 37] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 As an example, there is an IANA-registered "up" relation, but there @@ -2125,9 +2125,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 38] +Andrews & Wright Expires February 11, 2020 [Page 38] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 The following hyper-schema, applied to the instance in the response @@ -2137,7 +2137,7 @@ Internet-Draft JSON Hyper-Schema May 2019 { "$id": "https://schema.example.com/tree-node", - "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", "base": "trees/{treeId}/", "properties": { "id": {"type": "integer"}, @@ -2181,9 +2181,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 39] +Andrews & Wright Expires February 11, 2020 [Page 39] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 9.5. Collections @@ -2237,9 +2237,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 40] +Andrews & Wright Expires February 11, 2020 [Page 40] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 For this example, we will re-use the individual thing schema as shown @@ -2249,7 +2249,7 @@ Internet-Draft JSON Hyper-Schema May 2019 { "$id": "https://schema.example.com/thing", - "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", "base": "https://example.com/api/", "type": "object", "required": ["data"], @@ -2293,9 +2293,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 41] +Andrews & Wright Expires February 11, 2020 [Page 41] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 Now we want to describe collections of "thing"s. This schema @@ -2308,7 +2308,7 @@ Internet-Draft JSON Hyper-Schema May 2019 { "$id": "https://schema.example.com/thing-collection", - "$schema": "http://json-schema.org/draft/2019-04/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", "base": "https://example.com/api/", "type": "object", "required": ["elements"], @@ -2349,9 +2349,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 42] +Andrews & Wright Expires February 11, 2020 [Page 42] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 Here is a simple two-element collection instance: @@ -2405,9 +2405,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 43] +Andrews & Wright Expires February 11, 2020 [Page 43] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 { @@ -2461,9 +2461,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 44] +Andrews & Wright Expires February 11, 2020 [Page 44] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 The collection links have identical target URIs as there is only one @@ -2517,9 +2517,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 45] +Andrews & Wright Expires February 11, 2020 [Page 45] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 }, { @@ -2573,9 +2573,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 46] +Andrews & Wright Expires February 11, 2020 [Page 46] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 Given this instance: @@ -2629,9 +2629,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 47] +Andrews & Wright Expires February 11, 2020 [Page 47] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 [[CREF7: It's not clear how pagination should work with the link from @@ -2685,9 +2685,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 48] +Andrews & Wright Expires February 11, 2020 [Page 48] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 Presumably, our custom link relation type in the entry point schema @@ -2741,9 +2741,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 49] +Andrews & Wright Expires February 11, 2020 [Page 49] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 parts of the specification discourage always re-downloading the @@ -2797,9 +2797,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 50] +Andrews & Wright Expires February 11, 2020 [Page 50] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 11. Acknowledgments @@ -2818,13 +2818,13 @@ Internet-Draft JSON Hyper-Schema May 2019 [json-schema] Wright, A. and H. Andrews, "JSON Schema: A Media Type for - Describing JSON Documents", draft-handrews-json-schema-WIP + Describing JSON Documents", draft-handrews-json-schema-02 (work in progress), November 2017. [json-schema-validation] Wright, A., Andrews, H., and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of - JSON", draft-handrews-json-schema-validation-WIP (work in + JSON", draft-handrews-json-schema-validation-02 (work in progress), November 2017. [relative-json-pointer] @@ -2853,9 +2853,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 51] +Andrews & Wright Expires February 11, 2020 [Page 51] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 [RFC6573] Amundsen, M., "The Item and Collection Link Relations", @@ -2909,9 +2909,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 52] +Andrews & Wright Expires February 11, 2020 [Page 52] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 [RFC7807] Nottingham, M. and E. Wilde, "Problem Details for HTTP @@ -2965,9 +2965,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 53] +Andrews & Wright Expires February 11, 2020 [Page 53] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 Appendix A. Using JSON Hyper-Schema in APIs @@ -3021,9 +3021,9 @@ A.2. Responses and Errors -Andrews & Wright Expires November 26, 2019 [Page 54] +Andrews & Wright Expires February 11, 2020 [Page 54] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 [RFC7807], to allow the user agent or client application to interpret @@ -3052,7 +3052,7 @@ Appendix B. ChangeLog [[CREF13: This section to be removed before leaving Internet-Draft status.]] - draft-handrews-json-schema-hyperschema-WIP + draft-handrews-json-schema-hyperschema-02 * Allow multiple values for "rel" @@ -3077,9 +3077,9 @@ Appendix B. ChangeLog -Andrews & Wright Expires November 26, 2019 [Page 55] +Andrews & Wright Expires February 11, 2020 [Page 55] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 * Removed stray "work in progress" language left over from review @@ -3133,9 +3133,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 56] +Andrews & Wright Expires February 11, 2020 [Page 56] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 * Clarified how "hrefSchema" is used @@ -3189,9 +3189,9 @@ Internet-Draft JSON Hyper-Schema May 2019 -Andrews & Wright Expires November 26, 2019 [Page 57] +Andrews & Wright Expires February 11, 2020 [Page 57] -Internet-Draft JSON Hyper-Schema May 2019 +Internet-Draft JSON Hyper-Schema August 2019 * Removed "pathStart" keyword @@ -3210,12 +3210,8 @@ Internet-Draft JSON Hyper-Schema May 2019 Authors' Addresses Henry Andrews (editor) - Riverbed Technology - 680 Folsom St. - San Francisco, CA - USA - EMail: handrews@riverbed.com + EMail: andrews_henry@yahoo.com Austin Wright (editor) @@ -3245,4 +3241,8 @@ Authors' Addresses -Andrews & Wright Expires November 26, 2019 [Page 58] + + + + +Andrews & Wright Expires February 11, 2020 [Page 58] diff --git a/work-in-progress/WIP-jsonschema-validation.html b/work-in-progress/WIP-jsonschema-validation.html index 73f660f6..c33322a5 100644 --- a/work-in-progress/WIP-jsonschema-validation.html +++ b/work-in-progress/WIP-jsonschema-validation.html @@ -408,9 +408,12 @@ - + + + + @@ -443,12 +446,12 @@ - + - - - + + + @@ -472,8 +475,8 @@ H. Andrews, Ed. -Expires: December 20, 2019 -Riverbed Technology +Expires: February 11, 2020 + @@ -485,11 +488,7 @@ -G. Luff - - - -June 18, 2019 +August 10, 2019 @@ -497,19 +496,19 @@

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

        + 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 <http://json-schema.org/>.

        +

        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 December 20, 2019.

        +

        This Internet-Draft will expire on February 11, 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.

        @@ -587,13 +586,19 @@

        Table of Contents

      • 6.5.4. dependentRequired
      • -

  • 7. A Vocabulary for Semantic Validation With "format" +
  • 7. A Vocabulary for Semantic Content With "format"
    • 7.1. Foreword
    • 7.2. Implementation Requirements
    • -
    • 7.3. Defined Formats +
    • 7.3. Defined Formats
      • 7.3.1. Dates, Times, and Duration
      • @@ -684,15 +689,16 @@

        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 JSON Schema Validation meta-schema is <http://json-schema.org/draft/2019-04/schenma#>. For schema author convenience, this meta-schema describes all vocabularies defined in this specification and the JSON Schema Core specification. Individual vocabulary and vocabulary meta-schema URIs are given for each section below.

        +5. Meta-Schema + +

        The current URI for the JSON Schema Validation meta-schema is <http://json-schema.org/draft/2019-08/schema#>. For schema author convenience, this meta-schema describes all vocabularies defined in this specification and the JSON Schema Core specification. 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-04/vocab/validation>.

        -

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

        +

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

        +

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

        6.1. Validation Keywords for Any Instance Type

        @@ -805,27 +811,51 @@

        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 Validation With "format" +7. A Vocabulary for Semantic Content With "format"

        7.1. Foreword

        -

        Structural validation alone may be insufficient to validate that an instance meets all the requirements of an application. The "format" keyword is defined to allow interoperable semantic validation 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.

        -

        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, although 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-04/vocab/format>.

        -

        The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-04/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.

        +

        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-08/vocab/format>.

        +

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

        7.2. Implementation Requirements

        -

        The "format" keyword functions as both an annotation and as an assertion. While no special effort is required to implement it as an annotation conveying semantic meaning, implementing validation is non-trivial.

        -

        Implementations MAY support the "format" keyword as a validation assertion. Should they choose to do so:

        +

        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.

          -
        • they SHOULD implement validation for attributes defined below;
        • -
        • they SHOULD offer an option to disable validation for this keyword.
        • +
        • 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.

        -

        Implementations MAY add custom format attributes. Save for agreement between parties, schema authors SHALL NOT expect a peer implementation to support this keyword and/or custom format attributes.

        +

        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

        @@ -846,7 +876,7 @@

        -

        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. [CREF1]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 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.

        @@ -935,32 +965,32 @@

        8.1. Foreword

        -

        Properties defined in this section indicate that an instance contains non-JSON data encoded in a JSON string. They describe the type of content and how it is encoded.

        -

        These properties provide additional information required to interpret JSON data as rich multimedia documents.

        -

        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, although see the Implementation Requirements below for details.

        -

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

        -

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

        +

        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-08/vocab/content>.

        +

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

        8.2. Implementation Requirements

        -

        The content keywords function as both annotations and as assertions. While no special effort is required to implement them as annotations conveying how applications can interpret the data in the string, implementing validation of conformance to the media type and encoding is non-trivial.

        -

        Implementations MAY support the "contentMediaType" and "contentEncoding" keywords as validation assertions. Should they choose to do so, they SHOULD offer an option to disable validation for these keywords.

        +

        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.

        -

        The value of this property SHOULD be ignored if the instance described is not a string.

        8.4. contentMediaType

        -

        If the instance is a string, this property defines the media type of the contents of the string. If "contentEncoding" is present, this property describes the decoded string.

        +

        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.

        -

        The value of this property SHOULD be ignored if the instance described is not a string.

        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 the instance described is not a string, or if "contentMediaType" is not present.

        +

        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":

        @@ -973,7 +1003,7 @@

        } -

        Instances described by this schema should be strings, and their values should be interpretable as base64-encoded PNG images.

        +

        Instances described by this schema are expected to be strings, and their values should be interpretable as base64-encoded PNG images.

        Another example:

         
        @@ -983,7 +1013,7 @@ 

        }

        -

        Instances described by this schema should 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.

        +

        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.

         
        @@ -1017,8 +1047,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/2019-04/vocab/meta-data>.

        -

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

        +

        The current URI for this vocabulary, known as the Meta-Data vocabulary, is: <https://json-schema.org/draft/2019-08/vocab/meta-data>.

        +

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

        9.1. "title" and "description"

        The value of both of these keywords MUST be a string.

        @@ -1049,7 +1079,8 @@

        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

        +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).

        @@ -1066,7 +1097,7 @@

        [json-schema] -Wright, A. and H. Andrews, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-handrews-json-schema-WIP, November 2017. +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] @@ -1179,7 +1210,7 @@

        "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.
        "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. For this reason, they are better defined as a generic mechanism on which validation, hyper-schema, and extension vocabularies can all be based
        +
        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.
        @@ -1191,16 +1222,21 @@

        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

        -

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

        +

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

        -
        draft-handrews-json-schema-validation-WIP
        +
        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"
        • @@ -1318,18 +1354,17 @@

          Authors' Addresses

          Andrews - Riverbed Technology + - 680 Folsom St. - + - San Francisco, - CA + + - USA + - EMail: handrews@riverbed.com + EMail: andrews_henry@yahoo.com
          @@ -1354,27 +1389,6 @@

          Authors' Addresses

          URI: https://jsonschema.dev - -
          -
          - - Geraint Luff - - - - - - - Cambridge, - - - - UK - - EMail: luffgd@gmail.com -
          diff --git a/work-in-progress/WIP-jsonschema-validation.txt b/work-in-progress/WIP-jsonschema-validation.txt index e1537e27..4892f2ef 100644 --- a/work-in-progress/WIP-jsonschema-validation.txt +++ b/work-in-progress/WIP-jsonschema-validation.txt @@ -5,15 +5,14 @@ Internet Engineering Task Force A. Wright, Ed. Internet-Draft Intended status: Informational H. Andrews, Ed. -Expires: November 26, 2019 Riverbed Technology +Expires: February 11, 2020 B. Hutton, Ed. Wellcome Sanger Institute - G. Luff - May 25, 2019 + August 10, 2019 JSON Schema Validation: A Vocabulary for Structural Validation of JSON - draft-handrews-json-schema-validation-WIP + draft-handrews-json-schema-validation-02 Abstract @@ -28,7 +27,7 @@ Note to Readers The issues list for this draft can be found at . - For additional information, see . + For additional information, see . To provide feedback, use this issue tracker, the communication methods listed on the homepage, or email the document editors. @@ -48,14 +47,15 @@ Status of This Memo 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 November 26, 2019. + This Internet-Draft will expire on February 11, 2020. -Wright, et al. Expires November 26, 2019 [Page 1] + +Wright, et al. Expires February 11, 2020 [Page 1] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 Copyright Notice @@ -109,48 +109,51 @@ Table of Contents -Wright, et al. Expires November 26, 2019 [Page 2] +Wright, et al. Expires February 11, 2020 [Page 2] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 6.5.1. maxProperties . . . . . . . . . . . . . . . . . . . . 9 6.5.2. minProperties . . . . . . . . . . . . . . . . . . . . 9 6.5.3. required . . . . . . . . . . . . . . . . . . . . . . 10 6.5.4. dependentRequired . . . . . . . . . . . . . . . . . . 10 - 7. A Vocabulary for Semantic Validation With "format" . . . . . 10 + 7. A Vocabulary for Semantic Content With "format" . . . . . . . 10 7.1. Foreword . . . . . . . . . . . . . . . . . . . . . . . . 10 7.2. Implementation Requirements . . . . . . . . . . . . . . . 11 - 7.3. Defined Formats . . . . . . . . . . . . . . . . . . . . . 11 - 7.3.1. Dates, Times, and Duration . . . . . . . . . . . . . 11 - 7.3.2. Email Addresses . . . . . . . . . . . . . . . . . . . 12 - 7.3.3. Hostnames . . . . . . . . . . . . . . . . . . . . . . 12 - 7.3.4. IP Addresses . . . . . . . . . . . . . . . . . . . . 13 - 7.3.5. Resource Identifiers . . . . . . . . . . . . . . . . 13 - 7.3.6. uri-template . . . . . . . . . . . . . . . . . . . . 13 - 7.3.7. JSON Pointers . . . . . . . . . . . . . . . . . . . . 14 - 7.3.8. regex . . . . . . . . . . . . . . . . . . . . . . . . 14 - 8. A Vocabulary for the Contents of String-Encoded Data . . . . 14 - 8.1. Foreword . . . . . . . . . . . . . . . . . . . . . . . . 14 - 8.2. Implementation Requirements . . . . . . . . . . . . . . . 15 - 8.3. contentEncoding . . . . . . . . . . . . . . . . . . . . . 15 - 8.4. contentMediaType . . . . . . . . . . . . . . . . . . . . 15 - 8.5. contentSchema . . . . . . . . . . . . . . . . . . . . . . 16 - 8.6. Example . . . . . . . . . . . . . . . . . . . . . . . . . 16 - 9. A Vocabulary for Basic Meta-Data Annotations . . . . . . . . 17 - 9.1. "title" and "description" . . . . . . . . . . . . . . . . 18 - 9.2. "default" . . . . . . . . . . . . . . . . . . . . . . . . 18 - 9.3. "deprecated" . . . . . . . . . . . . . . . . . . . . . . 18 - 9.4. "readOnly" and "writeOnly" . . . . . . . . . . . . . . . 18 - 9.5. "examples" . . . . . . . . . . . . . . . . . . . . . . . 19 - 10. Security Considerations . . . . . . . . . . . . . . . . . . . 20 - 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 20 - 11.1. Normative References . . . . . . . . . . . . . . . . . . 20 - 11.2. Informative References . . . . . . . . . . . . . . . . . 22 - Appendix A. Keywords Moved from Validation to Core . . . . . . . 23 - Appendix B. Acknowledgments . . . . . . . . . . . . . . . . . . 23 - Appendix C. ChangeLog . . . . . . . . . . . . . . . . . . . . . 24 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 27 + 7.2.1. As an annotation . . . . . . . . . . . . . . . . . . 11 + 7.2.2. As an assertion . . . . . . . . . . . . . . . . . . . 12 + 7.2.3. Custom format attributes . . . . . . . . . . . . . . 13 + 7.3. Defined Formats . . . . . . . . . . . . . . . . . . . . . 13 + 7.3.1. Dates, Times, and Duration . . . . . . . . . . . . . 14 + 7.3.2. Email Addresses . . . . . . . . . . . . . . . . . . . 14 + 7.3.3. Hostnames . . . . . . . . . . . . . . . . . . . . . . 15 + 7.3.4. IP Addresses . . . . . . . . . . . . . . . . . . . . 15 + 7.3.5. Resource Identifiers . . . . . . . . . . . . . . . . 15 + 7.3.6. uri-template . . . . . . . . . . . . . . . . . . . . 16 + 7.3.7. JSON Pointers . . . . . . . . . . . . . . . . . . . . 16 + 7.3.8. regex . . . . . . . . . . . . . . . . . . . . . . . . 16 + 8. A Vocabulary for the Contents of String-Encoded Data . . . . 17 + 8.1. Foreword . . . . . . . . . . . . . . . . . . . . . . . . 17 + 8.2. Implementation Requirements . . . . . . . . . . . . . . . 17 + 8.3. contentEncoding . . . . . . . . . . . . . . . . . . . . . 18 + 8.4. contentMediaType . . . . . . . . . . . . . . . . . . . . 18 + 8.5. contentSchema . . . . . . . . . . . . . . . . . . . . . . 18 + 8.6. Example . . . . . . . . . . . . . . . . . . . . . . . . . 19 + 9. A Vocabulary for Basic Meta-Data Annotations . . . . . . . . 20 + 9.1. "title" and "description" . . . . . . . . . . . . . . . . 21 + 9.2. "default" . . . . . . . . . . . . . . . . . . . . . . . . 21 + 9.3. "deprecated" . . . . . . . . . . . . . . . . . . . . . . 21 + 9.4. "readOnly" and "writeOnly" . . . . . . . . . . . . . . . 21 + 9.5. "examples" . . . . . . . . . . . . . . . . . . . . . . . 22 + 10. Security Considerations . . . . . . . . . . . . . . . . . . . 23 + 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 23 + 11.1. Normative References . . . . . . . . . . . . . . . . . . 23 + 11.2. Informative References . . . . . . . . . . . . . . . . . 25 + Appendix A. Keywords Moved from Validation to Core . . . . . . . 26 + Appendix B. Acknowledgments . . . . . . . . . . . . . . . . . . 26 + Appendix C. ChangeLog . . . . . . . . . . . . . . . . . . . . . 27 + Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 30 1. Introduction @@ -160,16 +163,16 @@ Internet-Draft JSON Schema Validation May 2019 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. - -Wright, et al. Expires November 26, 2019 [Page 3] +Wright, et al. Expires February 11, 2020 [Page 3] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 + 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", @@ -218,12 +221,9 @@ Internet-Draft JSON Schema Validation May 2019 - - - -Wright, et al. Expires November 26, 2019 [Page 4] +Wright, et al. Expires February 11, 2020 [Page 4] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 4.2. Validation of Numeric Instances @@ -244,11 +244,12 @@ Internet-Draft JSON Schema Validation May 2019 5. Meta-Schema The current URI for the JSON Schema Validation meta-schema is - . For schema author + . For schema author convenience, this meta-schema describes all vocabularies defined in this specification and the JSON Schema Core specification. Individual vocabulary and vocabulary meta-schema URIs are given for - each section below. + 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 @@ -267,19 +268,18 @@ Internet-Draft JSON Schema Validation May 2019 true. The current URI for this vocabulary, known as the Validation - vocabulary, is: . The current URI for the corresponding meta-schema is: . - + schema.org/draft/2019-08/meta/validation>. -Wright, et al. Expires November 26, 2019 [Page 5] +Wright, et al. Expires February 11, 2020 [Page 5] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 6.1. Validation Keywords for Any Instance Type @@ -333,9 +333,9 @@ Internet-Draft JSON Schema Validation May 2019 -Wright, et al. Expires November 26, 2019 [Page 6] +Wright, et al. Expires February 11, 2020 [Page 6] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 6.2.2. maximum @@ -389,9 +389,9 @@ Internet-Draft JSON Schema Validation May 2019 -Wright, et al. Expires November 26, 2019 [Page 7] +Wright, et al. Expires February 11, 2020 [Page 7] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 6.3.2. minLength @@ -445,9 +445,9 @@ Internet-Draft JSON Schema Validation May 2019 -Wright, et al. Expires November 26, 2019 [Page 8] +Wright, et al. Expires February 11, 2020 [Page 8] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 Omitting this keyword has the same behavior as a value of false. @@ -501,9 +501,9 @@ Internet-Draft JSON Schema Validation May 2019 -Wright, et al. Expires November 26, 2019 [Page 9] +Wright, et al. Expires February 11, 2020 [Page 9] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 6.5.3. required @@ -532,64 +532,204 @@ Internet-Draft JSON Schema Validation May 2019 Omitting this keyword has the same behavior as an empty object. -7. A Vocabulary for Semantic Validation With "format" +7. A Vocabulary for Semantic Content With "format" 7.1. Foreword - Structural validation alone may be insufficient to validate that an - instance meets all the requirements of an application. The "format" - keyword is defined to allow interoperable semantic validation for a - fixed subset of values which are accurately described by - authoritative resources, be they RFCs or other external - specifications. + 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. - - 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, although see the Implementation Requirements below for details. + succeed. All format attributes defined in this section apply to + strings, but a format attribute can be specified to apply to any +Wright, et al. Expires February 11, 2020 [Page 10] + +Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires November 26, 2019 [Page 10] - -Internet-Draft JSON Schema Validation May 2019 + instance types defined in the data model defined in the core JSON + Schema. [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: . + is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-08/meta/format>. 7.2. Implementation Requirements - The "format" keyword functions as both an annotation and as an - assertion. While no special effort is required to implement it as an - annotation conveying semantic meaning, implementing validation is - non-trivial. + 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. - Implementations MAY support the "format" keyword as a validation - assertion. Should they choose to do so: + 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. ]] - they SHOULD implement validation for attributes defined below; - they SHOULD offer an option to disable validation for this - keyword. - Implementations MAY add custom format attributes. Save for agreement - between parties, schema authors SHALL NOT expect a peer - implementation to support this keyword and/or custom format - attributes. +Wright, et al. Expires February 11, 2020 [Page 11] + +Internet-Draft JSON Schema Validation August 2019 + + +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: + + 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. + + [[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. ]] + + When the vocabulary is declared with a value of true, an + implementation that supports this form of the vocabulary: + + 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 + + + +Wright, et al. Expires February 11, 2020 [Page 12] + +Internet-Draft JSON Schema Validation August 2019 + + + implementation would send an email, attempt to connect to a URL, or + otherwise check the existence of an entity identified by a format + instance. [[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. ]] + + 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 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 + + + + + + + +Wright, et al. Expires February 11, 2020 [Page 13] + +Internet-Draft JSON Schema Validation August 2019 + + 7.3.1. Dates, Times, and Duration These attributes apply to string instances. @@ -610,14 +750,6 @@ Internet-Draft JSON Schema Validation May 2019 time: A string instance is valid against this attribute if it is a valid representation according to the "full-time" production. - - - -Wright, et al. Expires November 26, 2019 [Page 11] - -Internet-Draft JSON Schema Validation May 2019 - - duration: A string instance is valid against this attribute if it is a valid representation according to the "duration" production. @@ -627,7 +759,7 @@ Internet-Draft JSON Schema Validation May 2019 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. [[CREF1: There is not currently consensus + 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 @@ -646,6 +778,14 @@ Internet-Draft JSON Schema Validation May 2019 idn-email: As defined by RFC 6531 [RFC6531] + + + +Wright, et al. Expires February 11, 2020 [Page 14] + +Internet-Draft JSON Schema Validation August 2019 + + Note that all strings valid against the "email" attribute are also valid against the "idn-email" attribute. @@ -667,13 +807,6 @@ Internet-Draft JSON Schema Validation May 2019 Note that all strings valid against the "hostname" attribute are also valid against the "idn-hostname" attribute. - - -Wright, et al. Expires November 26, 2019 [Page 12] - -Internet-Draft JSON Schema Validation May 2019 - - 7.3.4. IP Addresses These attributes apply to string instances. @@ -700,6 +833,15 @@ Internet-Draft JSON Schema Validation May 2019 iri: A string instance is valid against this attribute if it is a valid IRI, according to [RFC3987]. + + + + +Wright, et al. Expires February 11, 2020 [Page 15] + +Internet-Draft JSON Schema Validation August 2019 + + 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]. @@ -723,13 +865,6 @@ Internet-Draft JSON Schema Validation May 2019 A string instance is valid against this attribute if it is a valid URI Template (of any level), according to [RFC6570]. - - -Wright, et al. Expires November 26, 2019 [Page 13] - -Internet-Draft JSON Schema Validation May 2019 - - Note that URI Templates may be used for IRIs; there is no separate IRI Template specification. @@ -755,6 +890,14 @@ Internet-Draft JSON Schema Validation May 2019 A regular expression, which SHOULD be valid according to the ECMA 262 [ecma262] regular expression dialect. + + + +Wright, et al. Expires February 11, 2020 [Page 16] + +Internet-Draft JSON Schema Validation August 2019 + + 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 @@ -764,43 +907,62 @@ Internet-Draft JSON Schema Validation May 2019 8.1. Foreword - Properties defined in this section indicate that an instance contains - non-JSON data encoded in a JSON string. They describe the type of - content and how it is encoded. + 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. + 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, although see the Implementation Requirements below for details. + true. The current URI for this vocabulary, known as the Content vocabulary, - is: . + is: . + The current URI for the corresponding meta-schema is: . +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. -Wright, et al. Expires November 26, 2019 [Page 14] - -Internet-Draft JSON Schema Validation May 2019 + 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 - The current URI for the corresponding meta-schema is: . -8.2. Implementation Requirements - The content keywords function as both annotations and as assertions. - While no special effort is required to implement them as annotations - conveying how applications can interpret the data in the string, - implementing validation of conformance to the media type and encoding - is non-trivial. +Wright, et al. Expires February 11, 2020 [Page 17] + +Internet-Draft JSON Schema Validation August 2019 + - Implementations MAY support the "contentMediaType" and - "contentEncoding" keywords as validation assertions. Should they - choose to do so, they SHOULD offer an option to disable validation - for these keywords. + 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 (Section 10) sections for + possible vulnerabilities introduced by automatically processing the + instance string according to these keywords. 8.3. contentEncoding @@ -821,30 +983,15 @@ Internet-Draft JSON Schema Validation May 2019 The value of this property MUST be a string. - The value of this property SHOULD be ignored if the instance - described is not a string. - 8.4. contentMediaType - If the instance is a string, this property defines the media type of - the contents of the string. If "contentEncoding" is present, this + 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]. - - - - -Wright, et al. Expires November 26, 2019 [Page 15] - -Internet-Draft JSON Schema Validation May 2019 - - - The value of this property SHOULD be ignored if the instance - described is not a string. - 8.5. contentSchema If the instance is a string, and if "contentMediaType" is present, @@ -854,8 +1001,17 @@ Internet-Draft JSON Schema Validation May 2019 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 the instance - described is not a string, or if "contentMediaType" is not present. + + + + +Wright, et al. Expires February 11, 2020 [Page 18] + +Internet-Draft JSON Schema Validation August 2019 + + + The value of this property SHOULD be ignored if "contentMediaType" is + not present. 8.6. Example @@ -870,8 +1026,8 @@ Internet-Draft JSON Schema Validation May 2019 } - Instances described by this schema should be strings, and their - values should be interpretable as base64-encoded PNG images. + Instances described by this schema are expected to be strings, and + their values should be interpretable as base64-encoded PNG images. Another example: @@ -882,10 +1038,20 @@ Internet-Draft JSON Schema Validation May 2019 } - Instances described by this schema should 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. + 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. + + + + + + + + + + @@ -893,9 +1059,11 @@ Internet-Draft JSON Schema Validation May 2019 -Wright, et al. Expires November 26, 2019 [Page 16] + + +Wright, et al. Expires February 11, 2020 [Page 19] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 This example describes a JWT that is MACed using the HMAC SHA-256 @@ -949,17 +1117,17 @@ Internet-Draft JSON Schema Validation May 2019 -Wright, et al. Expires November 26, 2019 [Page 17] +Wright, et al. Expires February 11, 2020 [Page 20] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 The current URI for this vocabulary, known as the Meta-Data - vocabulary, is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-08/meta/meta-data>. 9.1. "title" and "description" @@ -1005,9 +1173,9 @@ Internet-Draft JSON Schema Validation May 2019 -Wright, et al. Expires November 26, 2019 [Page 18] +Wright, et al. Expires February 11, 2020 [Page 21] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 instance, the resulting value MUST be true if any occurrence @@ -1061,9 +1229,9 @@ Internet-Draft JSON Schema Validation May 2019 -Wright, et al. Expires November 26, 2019 [Page 19] +Wright, et al. Expires February 11, 2020 [Page 22] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 Implementations MAY use the value(s) of "default", if present, as an @@ -1107,7 +1275,7 @@ Internet-Draft JSON Schema Validation May 2019 [json-schema] Wright, A. and H. Andrews, "JSON Schema: A Media Type for - Describing JSON Documents", draft-handrews-json-schema-WIP + Describing JSON Documents", draft-handrews-json-schema-02 (work in progress), November 2017. [relative-json-pointer] @@ -1117,9 +1285,9 @@ Internet-Draft JSON Schema Validation May 2019 -Wright, et al. Expires November 26, 2019 [Page 20] +Wright, et al. Expires February 11, 2020 [Page 23] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 [RFC1123] Braden, R., Ed., "Requirements for Internet Hosts - @@ -1173,9 +1341,9 @@ Internet-Draft JSON Schema Validation May 2019 -Wright, et al. Expires November 26, 2019 [Page 21] +Wright, et al. Expires February 11, 2020 [Page 24] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data @@ -1229,9 +1397,9 @@ Internet-Draft JSON Schema Validation May 2019 -Wright, et al. Expires November 26, 2019 [Page 22] +Wright, et al. Expires February 11, 2020 [Page 25] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 Appendix A. Keywords Moved from Validation to Core @@ -1254,10 +1422,10 @@ Appendix A. Keywords Moved from Validation to Core 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. For this reason, - they are better defined as a generic mechanism on which - validation, hyper-schema, and extension vocabularies can all be - based + 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 @@ -1285,17 +1453,28 @@ Appendix B. Acknowledgments -Wright, et al. Expires November 26, 2019 [Page 23] +Wright, et al. Expires February 11, 2020 [Page 26] -Internet-Draft JSON Schema Validation May 2019 +Internet-Draft JSON Schema Validation August 2019 Appendix C. ChangeLog - [[CREF2: This section to be removed before leaving Internet-Draft + [[CREF8: This section to be removed before leaving Internet-Draft status.]] - draft-handrews-json-schema-validation-WIP + 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" @@ -1304,6 +1483,9 @@ Appendix C. ChangeLog * 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 @@ -1324,6 +1506,14 @@ Appendix C. ChangeLog * Clarified "if"/"then"/"else" validation interactions + + + +Wright, et al. Expires February 11, 2020 [Page 27] + +Internet-Draft JSON Schema Validation August 2019 + + * Clarified "if"/"then"/"else" behavior for annotation * Minor formatting and cross-referencing improvements @@ -1339,13 +1529,6 @@ Appendix C. ChangeLog * Grouped validation keywords into sub-sections for readability - - -Wright, et al. Expires November 26, 2019 [Page 24] - -Internet-Draft JSON Schema Validation May 2019 - - * Moved "readOnly" from hyper-schema to validation meta-data * Added "writeOnly" @@ -1378,6 +1561,15 @@ Internet-Draft JSON Schema Validation May 2019 * Add the formats "uri-template" and "json-pointer" + + + + +Wright, et al. Expires February 11, 2020 [Page 28] + +Internet-Draft JSON Schema Validation August 2019 + + * Changed "exclusiveMaximum"/"exclusiveMinimum" from boolean modifiers of "maximum"/"minimum" to independent numeric fields. @@ -1394,14 +1586,6 @@ Internet-Draft JSON Schema Validation May 2019 * Fixed "type" reference to primitive types - - - -Wright, et al. Expires November 26, 2019 [Page 25] - -Internet-Draft JSON Schema Validation May 2019 - - * Added "const" keyword * Added "propertyNames" keyword @@ -1434,6 +1618,14 @@ Internet-Draft JSON Schema Validation May 2019 at least one element is required in a property dependency array. + + + +Wright, et al. Expires February 11, 2020 [Page 29] + +Internet-Draft JSON Schema Validation August 2019 + + * Rename "divisibleBy" to "multipleOf". * "type" arrays can no longer have schemas; remove "any" as a @@ -1449,15 +1641,6 @@ Internet-Draft JSON Schema Validation May 2019 * Add interoperability considerations. - - - - -Wright, et al. Expires November 26, 2019 [Page 26] - -Internet-Draft JSON Schema Validation May 2019 - - Authors' Addresses Austin Wright (editor) @@ -1466,30 +1649,15 @@ Authors' Addresses Henry Andrews (editor) - Riverbed Technology - 680 Folsom St. - San Francisco, CA - USA - EMail: handrews@riverbed.com + EMail: andrews_henry@yahoo.com Ben Hutton (editor) Wellcome Sanger Institute EMail: bh7@sanger.ac.uk - - - Geraint Luff - Cambridge - UK - - EMail: luffgd@gmail.com - - - - - + URI: https://jsonschema.dev @@ -1509,4 +1677,4 @@ Authors' Addresses -Wright, et al. Expires November 26, 2019 [Page 27] +Wright, et al. Expires February 11, 2020 [Page 30] diff --git a/work-in-progress/WIP-relative-json-pointer.html b/work-in-progress/WIP-relative-json-pointer.html index 31f3eb8f..caba5e68 100644 --- a/work-in-progress/WIP-relative-json-pointer.html +++ b/work-in-progress/WIP-relative-json-pointer.html @@ -392,12 +392,12 @@ - + - - + + @@ -421,12 +421,8 @@ H. Andrews, Ed. -Expires: December 20, 2019 -Riverbed Technology - - - -June 18, 2019 +Expires: February 11, 2020 +August 10, 2019 @@ -434,7 +430,7 @@

          Relative JSON Pointers
          - draft-handrews-relative-json-pointer-WIP

          + 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.

          @@ -442,7 +438,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 December 20, 2019.

          +

          This Internet-Draft will expire on February 11, 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.

          @@ -616,7 +612,7 @@

          -
          draft-handrews-relative-json-pointer-WIP
          +
          draft-handrews-relative-json-pointer-02
          • Update to the latest JSON RFC

          @@ -672,18 +668,17 @@

          Authors' Addresses

          Andrews - Riverbed Technology + - 680 Folsom St. - + - San Francisco, - CA + + - USA + - EMail: handrews@riverbed.com + EMail: andrews_henry@yahoo.com diff --git a/work-in-progress/WIP-relative-json-pointer.txt b/work-in-progress/WIP-relative-json-pointer.txt index 2f2ae7c5..f591fa18 100644 --- a/work-in-progress/WIP-relative-json-pointer.txt +++ b/work-in-progress/WIP-relative-json-pointer.txt @@ -5,12 +5,11 @@ Internet Engineering Task Force G. Luff Internet-Draft Intended status: Informational H. Andrews, Ed. -Expires: November 26, 2019 Riverbed Technology - May 25, 2019 +Expires: February 11, 2020 August 10, 2019 Relative JSON Pointers - draft-handrews-relative-json-pointer-WIP + draft-handrews-relative-json-pointer-02 Abstract @@ -34,7 +33,7 @@ Status of This Memo 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 November 26, 2019. + This Internet-Draft will expire on February 11, 2020. Copyright Notice @@ -53,9 +52,10 @@ Copyright Notice -Luff & Andrews Expires November 26, 2019 [Page 1] + +Luff & Andrews Expires February 11, 2020 [Page 1] -Internet-Draft Relative JSON Pointers May 2019 +Internet-Draft Relative JSON Pointers August 2019 Table of Contents @@ -109,9 +109,9 @@ Table of Contents -Luff & Andrews Expires November 26, 2019 [Page 2] +Luff & Andrews Expires February 11, 2020 [Page 2] -Internet-Draft Relative JSON Pointers May 2019 +Internet-Draft Relative JSON Pointers August 2019 The ABNF syntax of a Relative JSON Pointer is: @@ -165,9 +165,9 @@ Internet-Draft Relative JSON Pointers May 2019 -Luff & Andrews Expires November 26, 2019 [Page 3] +Luff & Andrews Expires February 11, 2020 [Page 3] -Internet-Draft Relative JSON Pointers May 2019 +Internet-Draft Relative JSON Pointers August 2019 If the referenced value is an object member within an object, then @@ -221,9 +221,9 @@ Internet-Draft Relative JSON Pointers May 2019 -Luff & Andrews Expires November 26, 2019 [Page 4] +Luff & Andrews Expires February 11, 2020 [Page 4] -Internet-Draft Relative JSON Pointers May 2019 +Internet-Draft Relative JSON Pointers August 2019 6. Non-use in URI Fragment Identifiers @@ -277,9 +277,9 @@ Internet-Draft Relative JSON Pointers May 2019 -Luff & Andrews Expires November 26, 2019 [Page 5] +Luff & Andrews Expires February 11, 2020 [Page 5] -Internet-Draft Relative JSON Pointers May 2019 +Internet-Draft Relative JSON Pointers August 2019 11. References @@ -333,9 +333,9 @@ Internet-Draft Relative JSON Pointers May 2019 -Luff & Andrews Expires November 26, 2019 [Page 6] +Luff & Andrews Expires February 11, 2020 [Page 6] -Internet-Draft Relative JSON Pointers May 2019 +Internet-Draft Relative JSON Pointers August 2019 Appendix A. ChangeLog @@ -343,7 +343,7 @@ Appendix A. ChangeLog [[CREF1: This section to be removed before leaving Internet-Draft status.]] - draft-handrews-relative-json-pointer-WIP + draft-handrews-relative-json-pointer-02 * Update to the latest JSON RFC @@ -371,12 +371,12 @@ Authors' Addresses Henry Andrews (editor) - Riverbed Technology - 680 Folsom St. - San Francisco, CA - USA - EMail: handrews@riverbed.com + EMail: andrews_henry@yahoo.com + + + + @@ -389,4 +389,4 @@ Authors' Addresses -Luff & Andrews Expires November 26, 2019 [Page 7] +Luff & Andrews Expires February 11, 2020 [Page 7] From d1298131414e38d699175581ae40a6445023ebe5 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Sat, 10 Aug 2019 12:28:20 -0700 Subject: [PATCH 057/395] WIP fix for draft/2019-xx --- work-in-progress/WIP-jsonschema-core.html | 38 +++++++++---------- work-in-progress/WIP-jsonschema-core.txt | 38 +++++++++---------- .../WIP-jsonschema-hyperschema.html | 22 +++++------ .../WIP-jsonschema-hyperschema.txt | 20 +++++----- .../WIP-jsonschema-validation.html | 18 ++++----- .../WIP-jsonschema-validation.txt | 18 ++++----- 6 files changed, 77 insertions(+), 77 deletions(-) diff --git a/work-in-progress/WIP-jsonschema-core.html b/work-in-progress/WIP-jsonschema-core.html index 92e7b9c3..40cc10c6 100644 --- a/work-in-progress/WIP-jsonschema-core.html +++ b/work-in-progress/WIP-jsonschema-core.html @@ -1124,8 +1124,8 @@

          The Core vocabulary MUST be considered mandatory at all times, in order to bootstrap the processing of further vocabularies. Meta-schemas that use "$vocabulary" 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.

          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-08/vocab/core>.

          -

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

          +

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

          +

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

          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.6. Example Meta-Schema With Vocabulary Declarations @@ -1134,16 +1134,16 @@

           
           {
          -  "$schema": "https://json-schema.org/draft/2019-08/core-app-example#",
          -  "$id": "https://json-schema.org/draft/2019-08/core-app-example",
          +  "$schema": "https://json-schema.org/draft/2019-WIP/core-app-example#",
          +  "$id": "https://json-schema.org/draft/2019-WIP/core-app-example",
             "$recursiveAnchor": true,
             "$vocabulary": {
          -    "https://json-schema.org/draft/2019-08/vocab/core": true,
          -    "https://json-schema.org/draft/2019-08/vocab/applicator": true
          +    "https://json-schema.org/draft/2019-WIP/vocab/core": true,
          +    "https://json-schema.org/draft/2019-WIP/vocab/applicator": true
             },
             "allOf": [
          -    {"$ref": "https://json-schema.org/draft/2019-08/meta/core"},
          -    {"$ref": "https://json-schema.org/draft/2019-08/meta/applicator"}
          +    {"$ref": "https://json-schema.org/draft/2019-WIP/meta/core"},
          +    {"$ref": "https://json-schema.org/draft/2019-WIP/meta/applicator"}
             ],
             "patternProperties": {
               "^unevaluated.*$": false
          @@ -1303,7 +1303,7 @@ 

           
           {
          -    "$schema": "https://json-schema.org/draft/2019-08/schema#",
          +    "$schema": "https://json-schema.org/draft/2019-WIP/schema#",
               "$id": "https://example.com/original",
           
               "properties": {
          @@ -1317,7 +1317,7 @@ 

          } { - "$schema": "https://json-schema.org/draft/2019-08/schema#", + "$schema": "https://json-schema.org/draft/2019-WIP/schema#", "$id": "https://example.com/extension", "$ref": "original", @@ -1359,7 +1359,7 @@

           
           {
          -    "$schema": "https://json-schema.org/draft/2019-08/schema#",
          +    "$schema": "https://json-schema.org/draft/2019-WIP/schema#",
               "$id": "https://example.com/original",
               "$recursiveAnchor": true,
           
          @@ -1374,7 +1374,7 @@ 

          } { - "$schema": "https://json-schema.org/draft/2019-08/schema#", + "$schema": "https://json-schema.org/draft/2019-WIP/schema#", "$id": "https://example.com/extension", "$recursiveAnchor": true, @@ -1460,8 +1460,8 @@

          11. 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-08/vocab/applicator>.

          -

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

          +

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

          +

          The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-WIP/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.

          11.1. Keyword Independence

          @@ -1646,7 +1646,7 @@

          The absolute, dereferenced location of the validating keyword. The value MUST be expressed as an absolute URI, and it MUST NOT include by-reference applicators such as "$ref" or "$recursiveRef".

           
          -https://json-schema.org/draft/2019-08/schema#/$defs/nonNegativeInteger/minimum
          +https://json-schema.org/draft/2019-WIP/schema#/$defs/nonNegativeInteger/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".

          @@ -1679,7 +1679,7 @@

          { "$id": "https://example.com/polygon#", - "$schema": "https://json-schema.org/draft/2019-08/schema#", + "$schema": "https://json-schema.org/draft/2019-WIP/schema#", "$defs": { "point": { "type": "object", @@ -1830,13 +1830,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/2019-08/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/2019-WIP/output/verbose-example>.

           
           // schema
           {
             "$id": "https://example.com/polygon#",
          -  "$schema": "https://json-schema.org/draft/2019-08/schema#",
          +  "$schema": "https://json-schema.org/draft/2019-WIP/schema#",
             "type": "object",
             "properties": {
               "validProp": true,
          @@ -1885,7 +1885,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/2019-08/output/schema>.

          +

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

          13. Usage for Hypermedia

          diff --git a/work-in-progress/WIP-jsonschema-core.txt b/work-in-progress/WIP-jsonschema-core.txt index e3f6598e..547bf464 100644 --- a/work-in-progress/WIP-jsonschema-core.txt +++ b/work-in-progress/WIP-jsonschema-core.txt @@ -1371,10 +1371,10 @@ Internet-Draft JSON Schema August 2019 of true. The current URI for the Core vocabulary is: . + draft/2019-WIP/vocab/core>. The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-WIP/meta/core>. Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations @@ -1413,16 +1413,16 @@ Internet-Draft JSON Schema August 2019 { - "$schema": "https://json-schema.org/draft/2019-08/core-app-example#", - "$id": "https://json-schema.org/draft/2019-08/core-app-example", + "$schema": "https://json-schema.org/draft/2019-WIP/core-app-example#", + "$id": "https://json-schema.org/draft/2019-WIP/core-app-example", "$recursiveAnchor": true, "$vocabulary": { - "https://json-schema.org/draft/2019-08/vocab/core": true, - "https://json-schema.org/draft/2019-08/vocab/applicator": true + "https://json-schema.org/draft/2019-WIP/vocab/core": true, + "https://json-schema.org/draft/2019-WIP/vocab/applicator": true }, "allOf": [ - {"$ref": "https://json-schema.org/draft/2019-08/meta/core"}, - {"$ref": "https://json-schema.org/draft/2019-08/meta/applicator"} + {"$ref": "https://json-schema.org/draft/2019-WIP/meta/core"}, + {"$ref": "https://json-schema.org/draft/2019-WIP/meta/applicator"} ], "patternProperties": { "^unevaluated.*$": false @@ -1748,7 +1748,7 @@ Internet-Draft JSON Schema August 2019 { - "$schema": "https://json-schema.org/draft/2019-08/schema#", + "$schema": "https://json-schema.org/draft/2019-WIP/schema#", "$id": "https://example.com/original", "properties": { @@ -1762,7 +1762,7 @@ Internet-Draft JSON Schema August 2019 } { - "$schema": "https://json-schema.org/draft/2019-08/schema#", + "$schema": "https://json-schema.org/draft/2019-WIP/schema#", "$id": "https://example.com/extension", "$ref": "original", @@ -1860,7 +1860,7 @@ Internet-Draft JSON Schema August 2019 { - "$schema": "https://json-schema.org/draft/2019-08/schema#", + "$schema": "https://json-schema.org/draft/2019-WIP/schema#", "$id": "https://example.com/original", "$recursiveAnchor": true, @@ -1875,7 +1875,7 @@ Internet-Draft JSON Schema August 2019 } { - "$schema": "https://json-schema.org/draft/2019-08/schema#", + "$schema": "https://json-schema.org/draft/2019-WIP/schema#", "$id": "https://example.com/extension", "$recursiveAnchor": true, @@ -2135,11 +2135,11 @@ Internet-Draft JSON Schema August 2019 true. The current URI for this vocabulary, known as the Applicator - vocabulary, is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-WIP/meta/applicator>. Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations @@ -2678,7 +2678,7 @@ Internet-Draft JSON Schema August 2019 by-reference applicators such as "$ref" or "$recursiveRef". -https://json-schema.org/draft/2019-08/schema#/$defs/nonNegativeInteger/minimum +https://json-schema.org/draft/2019-WIP/schema#/$defs/nonNegativeInteger/minimum @@ -2748,7 +2748,7 @@ Internet-Draft JSON Schema August 2019 { "$id": "https://example.com/polygon#", - "$schema": "https://json-schema.org/draft/2019-08/schema#", + "$schema": "https://json-schema.org/draft/2019-WIP/schema#", "$defs": { "point": { "type": "object", @@ -3033,14 +3033,14 @@ Internet-Draft JSON Schema August 2019 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: . // schema { "$id": "https://example.com/polygon#", - "$schema": "https://json-schema.org/draft/2019-08/schema#", + "$schema": "https://json-schema.org/draft/2019-WIP/schema#", "type": "object", "properties": { "validProp": true, @@ -3099,7 +3099,7 @@ Internet-Draft JSON Schema August 2019 For convenience, JSON Schema has been provided to validate output generated by implementations. Its URI is: . + draft/2019-WIP/output/schema>. 13. Usage for Hypermedia diff --git a/work-in-progress/WIP-jsonschema-hyperschema.html b/work-in-progress/WIP-jsonschema-hyperschema.html index 4f25c2c7..34e89a08 100644 --- a/work-in-progress/WIP-jsonschema-hyperschema.html +++ b/work-in-progress/WIP-jsonschema-hyperschema.html @@ -727,11 +727,11 @@

          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-08/hyper-schema#>.

          -

          The current URI for this vocabulary, known as the Hyper-Schema vocabulary, is: <https://json-schema.org/draft/2019-08/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-08/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-08/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-08/output/hyper-schema#>.

          +

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

          +

          The current URI for this vocabulary, known as the Hyper-Schema vocabulary, is: <https://json-schema.org/draft/2019-WIP/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-WIP/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-WIP/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-WIP/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

          @@ -1189,7 +1189,7 @@

          { "$id": "https://schema.example.com/entry", - "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#", "base": "https://example.com/api/", "links": [ { @@ -1231,7 +1231,7 @@

           {
               "$id": "https://schema.example.com/thing",
          -    "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
          +    "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
               "base": "https://example.com/api/",
               "type": "object",
               "required": ["data"],
          @@ -1285,7 +1285,7 @@ 

           {
               "$id": "https://schema.example.com/interesting-stuff",
          -    "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
          +    "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
               "required": ["stuffWorthEmailingAbout", "email", "title"],
               "properties": {
                   "title": {
          @@ -1413,7 +1413,7 @@ 

           {
               "$id": "https://schema.example.com/tree-node",
          -    "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
          +    "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
               "base": "trees/{treeId}/",
               "properties": {
                   "id": {"type": "integer"},
          @@ -1453,7 +1453,7 @@ 

           {
               "$id": "https://schema.example.com/thing",
          -    "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
          +    "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
               "base": "https://example.com/api/",
               "type": "object",
               "required": ["data"],
          @@ -1488,7 +1488,7 @@ 

           {
               "$id": "https://schema.example.com/thing-collection",
          -    "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
          +    "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
               "base": "https://example.com/api/",
               "type": "object",
               "required": ["elements"],
          diff --git a/work-in-progress/WIP-jsonschema-hyperschema.txt b/work-in-progress/WIP-jsonschema-hyperschema.txt
          index 4e4b5bd3..cb039087 100644
          --- a/work-in-progress/WIP-jsonschema-hyperschema.txt
          +++ b/work-in-progress/WIP-jsonschema-hyperschema.txt
          @@ -358,22 +358,22 @@ Internet-Draft              JSON Hyper-Schema                August 2019
           4.  Meta-Schemas and Output Schema
           
              The current URI for the JSON Hyper-Schema meta-schema is
          -   .
          +   .
           
              The current URI for this vocabulary, known as the Hyper-Schema
          -   vocabulary, is: .
           
              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: .
          +   schema.org/draft/2019-WIP/meta/hyper-schema>.
           
              The link description format (Section 6) 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: .
           
              JSON Hyper-Schema implementations are free to provide output in any
          @@ -1718,7 +1718,7 @@ Internet-Draft              JSON Hyper-Schema                August 2019
           
              {
                  "$id": "https://schema.example.com/entry",
          -       "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
          +       "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
                  "base": "https://example.com/api/",
                  "links": [
                      {
          @@ -1800,7 +1800,7 @@ Internet-Draft              JSON Hyper-Schema                August 2019
           
              {
                  "$id": "https://schema.example.com/thing",
          -       "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
          +       "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
                  "base": "https://example.com/api/",
                  "type": "object",
                  "required": ["data"],
          @@ -1924,7 +1924,7 @@ Internet-Draft              JSON Hyper-Schema                August 2019
           
              {
                  "$id": "https://schema.example.com/interesting-stuff",
          -       "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
          +       "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
                  "required": ["stuffWorthEmailingAbout", "email", "title"],
                  "properties": {
                      "title": {
          @@ -2137,7 +2137,7 @@ Internet-Draft              JSON Hyper-Schema                August 2019
           
              {
                  "$id": "https://schema.example.com/tree-node",
          -       "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
          +       "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
                  "base": "trees/{treeId}/",
                  "properties": {
                      "id": {"type": "integer"},
          @@ -2249,7 +2249,7 @@ Internet-Draft              JSON Hyper-Schema                August 2019
           
              {
                  "$id": "https://schema.example.com/thing",
          -       "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
          +       "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
                  "base": "https://example.com/api/",
                  "type": "object",
                  "required": ["data"],
          @@ -2308,7 +2308,7 @@ Internet-Draft              JSON Hyper-Schema                August 2019
           
              {
                  "$id": "https://schema.example.com/thing-collection",
          -       "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#",
          +       "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
                  "base": "https://example.com/api/",
                  "type": "object",
                  "required": ["elements"],
          diff --git a/work-in-progress/WIP-jsonschema-validation.html b/work-in-progress/WIP-jsonschema-validation.html
          index c33322a5..3c1e6cee 100644
          --- a/work-in-progress/WIP-jsonschema-validation.html
          +++ b/work-in-progress/WIP-jsonschema-validation.html
          @@ -691,14 +691,14 @@ 

          5. Meta-Schema

          -

          The current URI for the JSON Schema Validation meta-schema is <http://json-schema.org/draft/2019-08/schema#>. For schema author convenience, this meta-schema describes all vocabularies defined in this specification and the JSON Schema Core specification. 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 JSON Schema Validation meta-schema is <http://json-schema.org/draft/2019-WIP/schema#>. For schema author convenience, this meta-schema describes all vocabularies defined in this specification and the JSON Schema Core specification. 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-08/vocab/validation>.

          -

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

          +

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

          +

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

          6.1. Validation Keywords for Any Instance Type

          @@ -819,8 +819,8 @@

          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-08/vocab/format>.

          -

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

          +

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

          +

          The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-WIP/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.

          @@ -968,8 +968,8 @@

          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-08/vocab/content>.

          -

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

          +

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

          +

          The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-WIP/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.

          @@ -1047,8 +1047,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/2019-08/vocab/meta-data>.

          -

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

          +

          The current URI for this vocabulary, known as the Meta-Data vocabulary, is: <https://json-schema.org/draft/2019-WIP/vocab/meta-data>.

          +

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

          9.1. "title" and "description"

          The value of both of these keywords MUST be a string.

          diff --git a/work-in-progress/WIP-jsonschema-validation.txt b/work-in-progress/WIP-jsonschema-validation.txt index 4892f2ef..42bed3ea 100644 --- a/work-in-progress/WIP-jsonschema-validation.txt +++ b/work-in-progress/WIP-jsonschema-validation.txt @@ -244,7 +244,7 @@ Internet-Draft JSON Schema Validation August 2019 5. Meta-Schema The current URI for the JSON Schema Validation meta-schema is - . For schema author + . For schema author convenience, this meta-schema describes all vocabularies defined in this specification and the JSON Schema Core specification. Individual vocabulary and vocabulary meta-schema URIs are given for @@ -268,11 +268,11 @@ Internet-Draft JSON Schema Validation August 2019 true. The current URI for this vocabulary, known as the Validation - vocabulary, is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-WIP/meta/validation>. @@ -577,10 +577,10 @@ Internet-Draft JSON Schema Validation August 2019 false. See the Implementation Requirements below for details. The current URI for this vocabulary, known as the Format vocabulary, - is: . + is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-WIP/meta/format>. 7.2. Implementation Requirements @@ -922,10 +922,10 @@ Internet-Draft JSON Schema Validation August 2019 true. The current URI for this vocabulary, known as the Content vocabulary, - is: . + is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-WIP/meta/content>. 8.2. Implementation Requirements @@ -1123,11 +1123,11 @@ Internet-Draft JSON Schema Validation August 2019 The current URI for this vocabulary, known as the Meta-Data - vocabulary, is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-WIP/meta/meta-data>. 9.1. "title" and "description" From 3c9766d5d09d224d44cd75f397cc9aebb00aedf6 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Sat, 10 Aug 2019 12:32:43 -0700 Subject: [PATCH 058/395] WIP fix for draft-handrews-*-xx numbers --- work-in-progress/WIP-jsonschema-core.html | 10 +++++----- work-in-progress/WIP-jsonschema-core.txt | 8 ++++---- work-in-progress/WIP-jsonschema-hyperschema.html | 10 +++++----- work-in-progress/WIP-jsonschema-hyperschema.txt | 8 ++++---- work-in-progress/WIP-jsonschema-validation.html | 8 ++++---- work-in-progress/WIP-jsonschema-validation.txt | 6 +++--- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/work-in-progress/WIP-jsonschema-core.html b/work-in-progress/WIP-jsonschema-core.html index 40cc10c6..bb910fbd 100644 --- a/work-in-progress/WIP-jsonschema-core.html +++ b/work-in-progress/WIP-jsonschema-core.html @@ -474,7 +474,7 @@ - + @@ -524,7 +524,7 @@

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

          + draft-handrews-json-schema-WIP

          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.

          @@ -2046,12 +2046,12 @@

          [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. +Andrews, H. and A. Wright, "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON", Internet-Draft draft-handrews-json-schema-hyperschema-WIP, 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. +Wright, A., Andrews, H. and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of JSON", Internet-Draft draft-handrews-json-schema-validation-WIP, November 2017. [RFC7049] @@ -2084,7 +2084,7 @@

          -
          draft-handrews-json-schema-02
          +
          draft-handrews-json-schema-WIP
          • Update to RFC 8259 for JSON specification
          • diff --git a/work-in-progress/WIP-jsonschema-core.txt b/work-in-progress/WIP-jsonschema-core.txt index 547bf464..bafc20cc 100644 --- a/work-in-progress/WIP-jsonschema-core.txt +++ b/work-in-progress/WIP-jsonschema-core.txt @@ -13,7 +13,7 @@ Expires: February 11, 2020 JSON Schema: A Media Type for Describing JSON Documents - draft-handrews-json-schema-02 + draft-handrews-json-schema-WIP Abstract @@ -3398,13 +3398,13 @@ Internet-Draft JSON Schema August 2019 [json-hyper-schema] Andrews, H. and A. Wright, "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON", draft- - handrews-json-schema-hyperschema-02 (work in progress), + handrews-json-schema-hyperschema-WIP (work in progress), November 2017. [json-schema-validation] Wright, A., Andrews, H., and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of - JSON", draft-handrews-json-schema-validation-02 (work in + JSON", draft-handrews-json-schema-validation-WIP (work in progress), November 2017. [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object @@ -3488,7 +3488,7 @@ Appendix B. ChangeLog [[CREF8: This section to be removed before leaving Internet-Draft status.]] - draft-handrews-json-schema-02 + draft-handrews-json-schema-WIP * Update to RFC 8259 for JSON specification diff --git a/work-in-progress/WIP-jsonschema-hyperschema.html b/work-in-progress/WIP-jsonschema-hyperschema.html index 34e89a08..ae944149 100644 --- a/work-in-progress/WIP-jsonschema-hyperschema.html +++ b/work-in-progress/WIP-jsonschema-hyperschema.html @@ -453,7 +453,7 @@ - + @@ -487,7 +487,7 @@

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

            + draft-handrews-json-schema-hyperschema-WIP

            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.

            @@ -1751,12 +1751,12 @@

            [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. +Wright, A. and H. Andrews, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-handrews-json-schema-WIP, 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. +Wright, A., Andrews, H. and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of JSON", Internet-Draft draft-handrews-json-schema-validation-WIP, November 2017. [relative-json-pointer] @@ -1868,7 +1868,7 @@

            -
            draft-handrews-json-schema-hyperschema-02
            +
            draft-handrews-json-schema-hyperschema-WIP
            • Allow multiple values for "rel"
            • diff --git a/work-in-progress/WIP-jsonschema-hyperschema.txt b/work-in-progress/WIP-jsonschema-hyperschema.txt index cb039087..1ce84cfa 100644 --- a/work-in-progress/WIP-jsonschema-hyperschema.txt +++ b/work-in-progress/WIP-jsonschema-hyperschema.txt @@ -9,7 +9,7 @@ Expires: February 11, 2020 August 10, 2019 JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON - draft-handrews-json-schema-hyperschema-02 + draft-handrews-json-schema-hyperschema-WIP Abstract @@ -2818,13 +2818,13 @@ Internet-Draft JSON Hyper-Schema August 2019 [json-schema] Wright, A. and H. Andrews, "JSON Schema: A Media Type for - Describing JSON Documents", draft-handrews-json-schema-02 + Describing JSON Documents", draft-handrews-json-schema-WIP (work in progress), November 2017. [json-schema-validation] Wright, A., Andrews, H., and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of - JSON", draft-handrews-json-schema-validation-02 (work in + JSON", draft-handrews-json-schema-validation-WIP (work in progress), November 2017. [relative-json-pointer] @@ -3052,7 +3052,7 @@ Appendix B. ChangeLog [[CREF13: This section to be removed before leaving Internet-Draft status.]] - draft-handrews-json-schema-hyperschema-02 + draft-handrews-json-schema-hyperschema-WIP * Allow multiple values for "rel" diff --git a/work-in-progress/WIP-jsonschema-validation.html b/work-in-progress/WIP-jsonschema-validation.html index 3c1e6cee..828ffefd 100644 --- a/work-in-progress/WIP-jsonschema-validation.html +++ b/work-in-progress/WIP-jsonschema-validation.html @@ -450,7 +450,7 @@ - + @@ -496,7 +496,7 @@

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

              + draft-handrews-json-schema-validation-WIP

              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.

              @@ -1097,7 +1097,7 @@

              [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. +Wright, A. and H. Andrews, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-handrews-json-schema-WIP, November 2017. [relative-json-pointer] @@ -1226,7 +1226,7 @@

              -
              draft-handrews-json-schema-validation-02
              +
              draft-handrews-json-schema-validation-WIP
              • Grouped keywords into formal vocabuarlies
              • diff --git a/work-in-progress/WIP-jsonschema-validation.txt b/work-in-progress/WIP-jsonschema-validation.txt index 42bed3ea..c6a538f4 100644 --- a/work-in-progress/WIP-jsonschema-validation.txt +++ b/work-in-progress/WIP-jsonschema-validation.txt @@ -12,7 +12,7 @@ Expires: February 11, 2020 JSON Schema Validation: A Vocabulary for Structural Validation of JSON - draft-handrews-json-schema-validation-02 + draft-handrews-json-schema-validation-WIP Abstract @@ -1275,7 +1275,7 @@ Internet-Draft JSON Schema Validation August 2019 [json-schema] Wright, A. and H. Andrews, "JSON Schema: A Media Type for - Describing JSON Documents", draft-handrews-json-schema-02 + Describing JSON Documents", draft-handrews-json-schema-WIP (work in progress), November 2017. [relative-json-pointer] @@ -1463,7 +1463,7 @@ Appendix C. ChangeLog [[CREF8: This section to be removed before leaving Internet-Draft status.]] - draft-handrews-json-schema-validation-02 + draft-handrews-json-schema-validation-WIP * Grouped keywords into formal vocabuarlies From 8ead3f9f8b2be10e24ee55e1bce27340d8b7f643 Mon Sep 17 00:00:00 2001 From: Marcel J Bennett Date: Tue, 13 Aug 2019 23:40:32 +1000 Subject: [PATCH 059/395] Add supported version to new library addition --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index a886bc20..a8dcc864 100644 --- a/implementations.md +++ b/implementations.md @@ -150,7 +150,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 + - [jsonschema-generator](https://github.com/victools/jsonschema-generator) (Apache 2.0) - generates schemas from Java types *supports Draft 7* #### From data From 1ab8d1ec5283eb7fa15f8703801ada721d2ab5e3 Mon Sep 17 00:00:00 2001 From: Peter Urbak Date: Tue, 13 Aug 2019 20:54:40 +0200 Subject: [PATCH 060/395] Adds missing draft version to js2e link --- implementations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implementations.md b/implementations.md index 2dc2ee8a..fcc61d81 100644 --- a/implementations.md +++ b/implementations.md @@ -181,7 +181,7 @@ 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* - 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) + - [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* #### Web UI generation From cc4bc506522d5c466fbb366dceb592a868f5ccfc Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 20 Jun 2019 18:09:45 +0200 Subject: [PATCH 061/395] WIP go at WIP Release Notes --- .../WIP-json-schema-release-notes.md | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 work-in-progress/WIP-json-schema-release-notes.md diff --git a/work-in-progress/WIP-json-schema-release-notes.md b/work-in-progress/WIP-json-schema-release-notes.md new file mode 100644 index 00000000..71c28279 --- /dev/null +++ b/work-in-progress/WIP-json-schema-release-notes.md @@ -0,0 +1,52 @@ +--- +title: JSON Schema Draft-07 Release Notes +layout: page +--- + +There are a few breaking changes with newer keywords based on community feedback, +and internally there has been a lot of restructuring through a new concept called +vocabularies, but on the whole things are mostly the same. + +* TOC +{:toc} + +- Update to RFC 8359 for JSON specification +- Add the concept of formal vocabularies, and how they can be recognized through meta-schemas +- Formalized annotation collection +- Moved applicator keywords from the Validation specification as their own vocabulary +- Define "$ref" behavior in terms of the assertion, applicator, and annotation model +- Note undefined behavior for "$ref" targets involving unknown keywords +- Additional guidance on initial base URIs beyond network retrieval +- Allow "schema" media type parameter for "application/schema+json" + +### Keywords + +* Eight brand new keywords were added +* One keyword was renamed +* One keyword was split in half +* One keyword in Core changed behavior +* One keyword in Hyper-Schema changed behavior + +keyword | change | notes +---- | ---- | ---- +[`"definitions"`](json-schema-core.html#rfc.section.TODO) | **removed** | use new "$defs" core keyword +[`"unevaluatedProperties" and "unevaluatedItems"`](json-schema-core.html#rfc.section.TODO) | **added** | +[`"$ref"`](json-schema-core.html#rfc.section.TODO) | **changed** | can now have siblings (keywords next to it) +[`"$defs"`](json-schema-core.html#rfc.section.10.TODO) | **added** | moved over to core from validation +`"dependencies"` | **removed** | use "dependentRequired" or "dependentSchemas" +[`"dependentRequired"`](json-schema-core.html#rfc.section.10.TODO) | **added** | added to core schema +[`"dependentSchemas"`](json-schema-core.html#rfc.section.10.TODO) | **added** | added to core schema +[`"applicator"`](json-schema-core.html#rfc.section.10.TODO) | **moved** | from validation to core, but is functionally identical +[`"minContains" and "maxContains"`](json-schema-validation.html#rfc.section.TODO) | added | +[`"contentSchema"`](json-schema-validation.html#rfc.section.TODO) | added | allows applying a schema to a string-encoded document +[`"deprecated"`](json-schema-validation.html#rfc.section.TODO) | added | +[`"rel"`](json-schema-hyperschema.html#rfc.section.TODO) | **changed** | Can now be an array of values instead of just a string + +### Formats + +Numerous formats were added, clarified, or restored from older drafts. + +format | change | notes +---- | ---- | ---- +[`"uuid"`](json-schema-validation.html#rfc.section.7.3.5) | added | A string instance is valid against this attribute if it is a valid string representation of a UUID, according to RFC4122 +[`"duration"`](json-schema-validation.html#rfc.section.7.3.5) | added | The duration format is from the ISO 8601 ABNF as given in Appendix A of RFC 3339 From 8471ef22f762619647387cde5ef5addc13f313ed Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 14 Aug 2019 12:17:16 +0200 Subject: [PATCH 062/395] Added a link from WIP index --- .../WIP-json-schema-release-notes.md | 2 +- work-in-progress/index.md | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/work-in-progress/WIP-json-schema-release-notes.md b/work-in-progress/WIP-json-schema-release-notes.md index 71c28279..afb986e8 100644 --- a/work-in-progress/WIP-json-schema-release-notes.md +++ b/work-in-progress/WIP-json-schema-release-notes.md @@ -44,7 +44,7 @@ keyword | change | notes ### Formats -Numerous formats were added, clarified, or restored from older drafts. +Two formats were added. format | change | notes ---- | ---- | ---- diff --git a/work-in-progress/index.md b/work-in-progress/index.md index e9de7c52..820a38e3 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -7,20 +7,21 @@ permalink: /work-in-progress * TOC {:toc} -## The Next Draft (by whatever name) Is Ready for Final Pre-Publication Review! +## The Next Draft is Ready for Final Pre-Publication Review! The forthcoming draft is now feature-frozen and has gone through the initial four-week pre-publication review period. _**UPDATE: July 28th, 2019** We continue to incorporate feedback and clarify sections of the new draft. We expect to finally publish the draft during August._ +To see what changes are involved, read the [release notes](./WIP-json-schema-release-notes.md). + The following sorts of feedback are particularly desired: * Clarity, readability, and accessibility to new readers * Contradictions, inconsistencies and other bugs * Anything so egregious that implementation would be infeasible or impossible -New features or major changes to existing features will be deferred to a future draft, -and work on the next draft will begin immediately after this one is published. +Work on the next draft will begin immediately after this one is published. ## What Is This Draft Called, Anyway? @@ -88,9 +89,9 @@ _**NOTE:** when published, the `.json` will be removed from the final URI_ * [WIP: meta/meta-data.json](/work-in-progress/meta/WIP-meta-data.json) (meta-data annotations, from the validation spec) * [WIP: meta/format.json](/work-in-progress/meta/WIP-format.json) (the format keyword, from the validation spec) * [WIP: meta/content.json](/work-in-progress/meta/WIP-content.json) (content keywords, from the validation spec) -* [WIP: meta/hyper-schema.json](/work-in-progress/meta/WIP-hyper-schema.json) (hyper-schema keywords, from the hyper-shema spec) +* [WIP: meta/hyper-schema.json](/work-in-progress/meta/WIP-hyper-schema.json) (hyper-schema keywords, from the hyper-schema spec) -### Output schema: +### Output Schema The new draft also introduces recommended output formats for reporting errors and annotations. @@ -100,12 +101,12 @@ _**NOTE:** when published, the `.json` will be removed from the final URI_ * [WIP: verbose-example.json](/work-in-progress/output/WIP-verbose-example.json) (example of the most verbose output format) * [WIP: hyper-schema.json](/work-in-progress/output/WIP-hyper-schema.json) (format used by the proposed hyper-schema test suite, and used in examples in the specification) -## Providing Feedback and Tracking Progress in GitHub +## Get Involved We are **particularly interested** in feedback on whether the wording and concepts is an improvement in terms of how easy it is to understand and learn the specifications. -Note that _all drafts have Changelog appendicies_, for a concise list of notable changes. +Note that _all drafts have Changelog appendices_, for a concise list of notable changes. * The active sources are on the ["master" branch of json-schema-org/json-schema-spec](https://github.com/json-schema-org/json-schema-spec) @@ -117,4 +118,3 @@ Note that _all drafts have Changelog appendicies_, for a concise list of notable * [file an issue](https://github.com/json-schema-org/json-schema-spec/issues/new?milestone=draft-08) or [join us on Slack](https://join.slack.com/t/json-schema/shared_invite/enQtMjk1NDcyNDI2NTAwLTcyYmYwMjdmMmUxNzZjYzIxNGU2YjdkNzdlOGZiNjIwNDI2M2Y3NmRkYjA4YmMwODMwYjgyOTFlNWZjZjAyNjg) to submit feedback _(technically there is also a [mailing list](https://groups.google.com/forum/#!forum/json-schema) but it gets very little traffic and is not closely monitored)_ - From 61af29bfd8bd3646922bff429ac9b123ff0c572d Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 14 Aug 2019 12:21:27 +0200 Subject: [PATCH 063/395] docs: feedback from henry --- work-in-progress/WIP-json-schema-release-notes.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/work-in-progress/WIP-json-schema-release-notes.md b/work-in-progress/WIP-json-schema-release-notes.md index afb986e8..36fe86d9 100644 --- a/work-in-progress/WIP-json-schema-release-notes.md +++ b/work-in-progress/WIP-json-schema-release-notes.md @@ -3,9 +3,10 @@ title: JSON Schema Draft-07 Release Notes layout: page --- -There are a few breaking changes with newer keywords based on community feedback, -and internally there has been a lot of restructuring through a new concept called -vocabularies, but on the whole things are mostly the same. +There are a few non-breaking changes with keywords being deprecated and slates +for removal, and a few newer keywords based on community feedback. Internally +there has been a lot of restructuring through a new concept called vocabularies, +but on the whole things are mostly the same. * TOC {:toc} @@ -29,14 +30,13 @@ vocabularies, but on the whole things are mostly the same. keyword | change | notes ---- | ---- | ---- -[`"definitions"`](json-schema-core.html#rfc.section.TODO) | **removed** | use new "$defs" core keyword +[`"definitions"`](json-schema-core.html#rfc.section.TODO) | **renamed** | use new "$defs" core keyword [`"unevaluatedProperties" and "unevaluatedItems"`](json-schema-core.html#rfc.section.TODO) | **added** | [`"$ref"`](json-schema-core.html#rfc.section.TODO) | **changed** | can now have siblings (keywords next to it) [`"$defs"`](json-schema-core.html#rfc.section.10.TODO) | **added** | moved over to core from validation `"dependencies"` | **removed** | use "dependentRequired" or "dependentSchemas" [`"dependentRequired"`](json-schema-core.html#rfc.section.10.TODO) | **added** | added to core schema [`"dependentSchemas"`](json-schema-core.html#rfc.section.10.TODO) | **added** | added to core schema -[`"applicator"`](json-schema-core.html#rfc.section.10.TODO) | **moved** | from validation to core, but is functionally identical [`"minContains" and "maxContains"`](json-schema-validation.html#rfc.section.TODO) | added | [`"contentSchema"`](json-schema-validation.html#rfc.section.TODO) | added | allows applying a schema to a string-encoded document [`"deprecated"`](json-schema-validation.html#rfc.section.TODO) | added | From f5ccacfe67b2ce46d9a24db27072f93ed26b9095 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Fri, 16 Aug 2019 12:51:02 -0700 Subject: [PATCH 064/395] Latest WIP updates --- work-in-progress/WIP-jsonschema-core.html | 1020 ++++++++--------- work-in-progress/WIP-jsonschema-core.txt | 896 ++++++++------- .../WIP-jsonschema-hyperschema.html | 8 +- .../WIP-jsonschema-hyperschema.txt | 120 +- .../WIP-jsonschema-validation.html | 8 +- .../WIP-jsonschema-validation.txt | 66 +- .../WIP-relative-json-pointer.html | 8 +- .../WIP-relative-json-pointer.txt | 18 +- work-in-progress/WIP-schema.json | 2 +- 9 files changed, 1091 insertions(+), 1055 deletions(-) diff --git a/work-in-progress/WIP-jsonschema-core.html b/work-in-progress/WIP-jsonschema-core.html index 92e7b9c3..995a682e 100644 --- a/work-in-progress/WIP-jsonschema-core.html +++ b/work-in-progress/WIP-jsonschema-core.html @@ -406,65 +406,54 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -475,7 +464,7 @@ - + @@ -499,7 +488,7 @@ H. Andrews, Ed. -Expires: February 11, 2020 +Expires: February 17, 2020 @@ -516,7 +505,7 @@ -August 10, 2019 +August 16, 2019 @@ -536,7 +525,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 February 11, 2020.

                +

                This Internet-Draft will expire on February 17, 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.

                @@ -610,123 +599,101 @@

                Table of Contents

            • 8. Meta-Schemas and Vocabularies +

        • 8. The JSON Schema Core Vocabulary
        • -
          • 8.1. The "$schema" Keyword +
          • 9. Base URI and Dereferencing +
          • 9.4. Schema Re-Use With "$defs" +
          • 10. Comments With "$comment" +
          • 10.2. Output Formats
          • -
          • 11. A Vocabulary for Applying Subschemas +
          • 10.3. Minimum Information
          • -
          • 12.4. Output Structure +
          • 13. IANA Considerations
          • -
          • 13. Usage for Hypermedia -
          • -
          • 14. Security Considerations -
          • -
          • 15. IANA Considerations -
          • -
          • 16. References -
          • -
          • Appendix A. Acknowledgments
          • @@ -898,7 +865,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 ECMA 262 regular expression dialect.

            +

            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:

              @@ -962,7 +929,17 @@

              7.5.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.

              +

              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.6. Annotations

              @@ -1062,10 +1039,19 @@

              7.6.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.

              -8. Meta-Schemas and Vocabularies +8. The JSON Schema Core Vocabulary

              +

              Keywords declared in 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-08/vocab/core>.

              +

              The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-08/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:

              +

              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
              @@ -1075,60 +1061,54 @@

              -

              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. 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 root schema. It MUST NOT appear in subschemas. If absent from the root schema, the resulting behavior is implementation-defined.

              +

              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 root schema. It MUST NOT appear in subschemas. If absent from the root schema, the resulting behavior 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.

              -

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

              -

              -8.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. [CREF3]Vocabulary documents may be added shortly, or in the next draft. 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 MAY choose to proceed with processing such schemas.

              -

              When processing a schema that uses unrecognized vocabularies, keywords declared by those vocabularies are treated like any other unrecognized keyword, and ignored.

              -

              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.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.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.

              -

              -8.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.

              -

              -8.4. 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.

              -

              -8.5. The JSON Schema Core Vocabulary

              -

              Keywords declared in in this specification that 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 "$vocabulary" 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.

              -

              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-08/vocab/core>.

              -

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

              -

              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.6. Example Meta-Schema With Vocabulary Declarations +

              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. [CREF3]Vocabulary documents may be added shortly, or in the next draft. 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 MAY choose to proceed with processing such schemas.

              +

              When processing a schema that uses unrecognized vocabularies, keywords declared by those vocabularies are treated like any other unrecognized keyword, and ignored.

              +

              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.

              +

              +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.1.5. 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.

              +

              +8.1.6. Example Meta-Schema With Vocabulary Declarations

              This meta-schema explicitly declares both the Core and Applicator vocabularies, and combines their meta-schemas with an "allOf". It additionally restricts the usage of the Applicator vocabulary by forbidding the keyword prefixed with "unevaluated". It also describes a keyword, "localKeyword", that is not part of either vocabulary. Note that it is its own meta-schema, as it relies on both the Core vocabulary (as all schemas do) and the Applicator vocabulary (for "allOf").

              @@ -1156,36 +1136,36 @@ 

              } } -

              +

          As shown above, even though each of the referenced standard meta-schemas declares its corresponding vocabulary, this new meta-schema must re-declare them for itself. It would be valid to leave the core vocabulary out of the "$vocabulary" keyword, but it needs to be referenced through the "allOf" keyword in order for its terms to be validated. There is no special case for validation of core keywords.

          -

          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.

          -

          -9. Base URI 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.

          -

          -9.1. Initial Base URI

          +

          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.

          +

          +8.2. Base URI 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.

          +

          +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.

          -

          -9.2. The "$id" Keyword +

          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.

          +

          +8.2.2. The "$id" Keyword

          -

          The "$id" keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. A subschema's "$id" is resolved against the base URI of its parent schema. If no parent schema defines an explicit base URI with "$id", the base URI is that of the entire document, as determined per RFC 3986 section 5.

          -

          If present, the value for this keyword MUST be a string, and MUST represent a valid URI-reference. This value SHOULD be normalized, and SHOULD NOT be an empty fragment <#> or an empty string <>.

          -

          -9.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), or this absolute URI but with an empty fragment.

          -

          -9.2.2. Changing the base URI within a schema file

          -

          When an "$id" sets the base URI, the object containing that "$id" and all of its subschemas can be identified by using a JSON Pointer fragment starting from that location. This is true even of subschemas that further change the base URI. Therefore, a single subschema may be accessible by multiple URIs, each consisting of base URI declared in the subschema or a parent, along with a JSON Pointer fragment identifying the path from the schema object that declares the base to the subschema being identified. Examples of this are shown in section 9.2.4.

          -

          -9.2.3. 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.

          -

          To specify such a subschema identifier, the "$id" keyword is set to a URI reference with a plain name fragment (not a JSON Pointer fragment). This value MUST begin with the number sign that specifies a fragment ("#"), then a letter ([A-Za-z]), followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), or periods (".").

          -

          The effect of using a fragment in "$id" that isn't blank or doesn't follow the plain name syntax is undefined. [CREF4]How should an "$id" URI reference containing a fragment with other components be interpreted? There are two cases: when the other components match the current base URI and when they change the base URI.

          -

          -9.2.4. Schema identification examples +

          The "$id" keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. A subschema's "$id" is resolved against the base URI of its parent schema. If no parent schema defines an explicit base URI with "$id", the base URI is that of the entire document, as determined per RFC 3986 section 5.

          +

          If present, the value for this keyword MUST be a string, and MUST represent a valid URI-reference. This value SHOULD be normalized, and SHOULD NOT be an empty fragment <#> or an empty string <>.

          +

          +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), or this absolute URI but with an empty fragment.

          +

          +8.2.2.2. Changing the base URI within a schema file

          +

          When an "$id" sets the base URI, the object containing that "$id" and all of its subschemas can be identified by using a JSON Pointer fragment starting from that location. This is true even of subschemas that further change the base URI. Therefore, a single subschema may be accessible by multiple URIs, each consisting of base URI declared in the subschema or a parent, along with a JSON Pointer fragment identifying the path from the schema object that declares the base to the subschema being identified. Examples of this are shown in section 8.2.2.4.

          +

          +8.2.2.3. 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.

          +

          To specify such a subschema identifier, the "$id" keyword is set to a URI reference with a plain name fragment (not a JSON Pointer fragment). This value MUST begin with the number sign that specifies a fragment ("#"), then a letter ([A-Za-z]), followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), or periods (".").

          +

          The effect of using a fragment in "$id" that isn't blank or doesn't follow the plain name syntax is undefined. [CREF4]How should an "$id" URI reference containing a fragment with other components be interpreted? There are two cases: when the other components match the current base URI and when they change the base URI.

          +

          +8.2.2.4. Schema identification examples

          Consider the following schema, which shows "$id" being used to identify the root schema, change the base URI for subschemas, and assign plain name fragments to subschemas:

          @@ -1207,8 +1187,8 @@ 

          } } -

          -

          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 Section 5 above:

          +
          +

          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 Section 5 above:

          @@ -1285,20 +1265,20 @@

          -

          -9.3. 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 a helper keyword that controls how the referenced schema of "$recursiveRef" is determined.

          -

          As the value 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.

          -

          -9.3.1. Direct References with "$ref" +

          +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 "$recursiveRef" are applicator keywords, applying the referenced schema to the instance. "$recursiveAnchor" is a helper keyword that controls how the referenced schema of "$recursiveRef" is determined.

          +

          As the value 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.3.1. Direct References with "$ref"

          -

          The "$ref" keyword is used to reference a statically identified schema.

          -

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

          -

          -9.3.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 ("#").

          -

          Extending a recursive schema with "$ref" alone involves redefining all recursive references in the source schema to point to the root of the extension. This produces the correct recursive behavior in the extension, which is that all recursion should reference the root of the extension.

          +

          The "$ref" keyword is used to reference a statically identified schema.

          +

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

          +

          +8.2.3.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 ("#").

          +

          Extending a recursive schema with "$ref" alone involves redefining all recursive references in the source schema to point to the root of the extension. This produces the correct recursive behavior in the extension, which is that all recursion should reference the root of the extension.

          Consider the following two schemas. The first schema, identified as "original" as it is the schema to be extended, describes an object with one string property and one recursive reference property, "r". The second schema, identified as "extension", references the first, and describes an additional "things" property, which is an array of recursive references. It also repeats the description of "r" from the original schema.

           
          @@ -1334,13 +1314,13 @@ 

          } } -

          +

          This apparent duplication is important because it resolves to "https://example.com/extension#", meaning that for instance validated against the extension schema, the value of "r" must be valid according to the extension, and not just the original schema as "r" was described there.

          -

          This approach is fine for a single recursive field, but the more complicated the original schema, the more redefinitions are necessary in the extension. This leads to a verbose and error-prone extension, which must be kept synchronized with the original schema if the original changes its recursive fields. This approach can be seen in the meta-schema for JSON Hyper-Schema in all prior drafts.

          -

          -9.3.2.1. Enabling Recursion with "$recursiveAnchor"

          -

          The desired behavior is for the recursive reference, "r", in the original schema to resolve to the original schema when that is the only schema being used, but to resolve to the extension schema when using the extension. Then there would be no need to redefine the "r" property, or others like it, in the extension.

          -

          In order to create a recursive reference, we must do three things:

          +

          This approach is fine for a single recursive field, but the more complicated the original schema, the more redefinitions are necessary in the extension. This leads to a verbose and error-prone extension, which must be kept synchronized with the original schema if the original changes its recursive fields. This approach can be seen in the meta-schema for JSON Hyper-Schema in all prior drafts.

          +

          +8.2.3.2.1. Enabling Recursion with "$recursiveAnchor"

          +

          The desired behavior is for the recursive reference, "r", in the original schema to resolve to the original schema when that is the only schema being used, but to resolve to the extension schema when using the extension. Then there would be no need to redefine the "r" property, or others like it, in the extension.

          +

          In order to create a recursive reference, we must do three things:

          • In our original schema, indicate that the schema author intends for it to be extensible recursively.
          • @@ -1349,12 +1329,12 @@

          These three things together ensure that all schema authors are intentionally constructing a recursive extension, which in turn gives all uses of the regular "$ref" keyword confidence that it only behaves as it appears to, using lexical scoping.

          -

          The "$recursiveAnchor" keyword is how schema authors indicate that a schema can be extended recursively, and be a recursive schema. This keyword MAY appear in the root schema of a schema document, and MUST NOT appear in any subschema.

          -

          The value of "$recursiveAnchor" MUST be of type boolean, and MUST be true. The value false is reserved for possible future use.

          -

          -9.3.2.2. Dynamically recursive references with "$recursiveRef"

          -

          The "$recursiveRef" keyword behaves identically to "$ref", except that if the referenced schema has "$recursiveAnchor" set to true, then the implementation MUST examine the dynamic scope for the outermost (first seen) schema document with "$recursiveAnchor" set to true. If such a schema document exists, then the target of the "$recursiveRef" MUST be set to that document's URI, in place of the URI produced by the rules for "$ref".

          -

          Note that if the schema referenced by "$recursiveRef" does not contain "$recursiveAnchor" set to true, or if there are no other "$recursiveAnchor" keywords set to true anywhere further back in the dynamic scope, then "$recursiveRef"'s behavior is identical to that of "$ref".

          +

          The "$recursiveAnchor" keyword is how schema authors indicate that a schema can be extended recursively, and be a recursive schema. This keyword MAY appear in the root schema of a schema document, and MUST NOT appear in any subschema.

          +

          The value of "$recursiveAnchor" MUST be of type boolean, and MUST be true. The value false is reserved for possible future use.

          +

          +8.2.3.2.2. Dynamically recursive references with "$recursiveRef"

          +

          The "$recursiveRef" keyword behaves identically to "$ref", except that if the referenced schema has "$recursiveAnchor" set to true, then the implementation MUST examine the dynamic scope for the outermost (first seen) schema document with "$recursiveAnchor" set to true. If such a schema document exists, then the target of the "$recursiveRef" MUST be set to that document's URI, in place of the URI produced by the rules for "$ref".

          +

          Note that if the schema referenced by "$recursiveRef" does not contain "$recursiveAnchor" set to true, or if there are no other "$recursiveAnchor" keywords set to true anywhere further back in the dynamic scope, then "$recursiveRef"'s behavior is identical to that of "$ref".

          With this in mind, we can rewrite the previous example:

           
          @@ -1389,30 +1369,30 @@ 

          } } -

          +

          Note that the "r" property no longer appears in the extension schema. Instead, all "$ref"s have been changed to "$recursiveRef"s, and both schemas have "$recursiveAnchor" set to true in their root schema.

          -

          When using the original schema on its own, there is no change in behavior. The "$recursiveRef" does lead to a schema where "$recursiveAnchor" is set to true, but since the original schema is the only schema document in the dynamics scope (it references itself, and does not reference any other schema documents), the behavior is effectively the same as "$ref".

          -

          When using the extension schema, the "$recursiveRef" within that schema (for the array items within "things") also effectively behaves like "$ref". The extension schema is the outermost dynamic scope, so the reference target is not changed.

          -

          In contrast, when using the extension schema, the "$recursiveRef" for "r" in the original schema now behaves differently. Its initial target is the root schema of the original schema document, which has "$recursiveAnchor" set to true. In this case, the outermost dynamic scope that also has "$recursiveAnchor" set to true is the extension schema. So when using the extensions schema, "r"'s reference in the original schema will resolve to "https://example.com/extension#", not "https://example.com/original#".

          -

          -9.3.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.

          -

          -9.3.4. References to Possible Non-Schemas

          -

          Subschema objects (or booleans) are recognized by their use with known applicator keywords. These keywords may be 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. [CREF5]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.3.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 section 9.2.4.

          -

          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.3.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:

          +

          When using the original schema on its own, there is no change in behavior. The "$recursiveRef" does lead to a schema where "$recursiveAnchor" is set to true, but since the original schema is the only schema document in the dynamics scope (it references itself, and does not reference any other schema documents), the behavior is effectively the same as "$ref".

          +

          When using the extension schema, the "$recursiveRef" within that schema (for the array items within "things") also effectively behaves like "$ref". The extension schema is the outermost dynamic scope, so the reference target is not changed.

          +

          In contrast, when using the extension schema, the "$recursiveRef" for "r" in the original schema now behaves differently. Its initial target is the root schema of the original schema document, which has "$recursiveAnchor" set to true. In this case, the outermost dynamic scope that also has "$recursiveAnchor" set to true is the extension schema. So when using the extensions schema, "r"'s reference in the original schema will resolve to "https://example.com/extension#", not "https://example.com/original#".

          +

          +8.2.3.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.3.4. References to Possible Non-Schemas

          +

          Subschema objects (or booleans) are recognized by their use with known applicator keywords. These keywords may be 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. [CREF5]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.3.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 section 8.2.2.4.

          +

          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.3.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:

           
           {
          @@ -1430,14 +1410,14 @@ 

          } } -

          -

          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. [CREF6]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.4. Schema Re-Use With "$defs"

          -

          The "$defs" keyword provides a standardized 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.

          +
          +

          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. [CREF6]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.4. Schema Re-Use With "$defs"

          +

          The "$defs" keyword provides a standardized 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.

           
           {
          @@ -1451,22 +1431,22 @@ 

          } } -

          -

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

          -

          -10. Comments With "$comment"

          -

          This keyword is reserved 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.

          -

          -11. 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-08/vocab/applicator>.

          -

          The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-08/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.

          -

          -11.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:

          +
          +

          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 is reserved 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-08/vocab/applicator>.

          +

          The current URI for the corresponding meta-schema is: <https://json-schema.org/draft/2019-08/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"
          • @@ -1476,147 +1456,147 @@

          -

          -11.2. Keywords for Applying Subschemas in Place +

          +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.

          -

          -11.2.1. Keywords for Applying Subschemas With Boolean Logic +

          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.

          -

          -11.2.1.1. allOf +

          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.

          -

          -11.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.

          -

          -11.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.

          -

          -11.2.1.4. not +

          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.

          -

          -11.2.2. Keywords for Applying Subschemas Conditionally +

          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.

          -

          -11.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".

          -

          -11.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.

          -

          -11.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.

          -

          -11.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.

          -

          -11.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.

          -

          -11.3.1. Keywords for Applying Subschemas to Arrays

          -

          -11.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.

          -

          -11.3.1.2. additionalItems +

          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.

          -

          -11.3.1.3. unevaluatedItems +

          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.

          -

          -11.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.

          -

          -11.3.2. Keywords for Applying Subschemas to Objects

          -

          -11.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.

          -

          -11.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.

          -

          -11.3.2.3. additionalProperties +

          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.

          -

          -11.3.2.4. unevaluatedProperties +

          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.

          -

          -11.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.

          -

          -12. Output Formatting +

          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.

          -

          -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.

          +

          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.
          • @@ -1626,47 +1606,47 @@

          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 "$recursiveRef".

          +

          +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/minLength/$ref/minimum
           
                                   
          -

          Note that this pointer may not be resolvable due to the inclusion of these 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 an absolute URI, and it MUST NOT include by-reference applicators such as "$ref" or "$recursiveRef".

          +

          Note that this pointer may not be resolvable due to the inclusion of these 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, and it MUST NOT include by-reference applicators such as "$ref" or "$recursiveRef".

           
           https://json-schema.org/draft/2019-08/schema#/$defs/nonNegativeInteger/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.

          -

          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".

          -

          -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.

          +

          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 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.

          +

          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".

          +

          +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
          • @@ -1708,8 +1688,8 @@

            ]

          -

          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:

          +

          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.
          • @@ -1718,9 +1698,9 @@

          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.

          +

          +10.4.1. Flag

          +

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

           
           {
          @@ -1728,10 +1708,10 @@ 

          }

          -

          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.

          +

          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.

           
           {
          @@ -1772,10 +1752,10 @@ 

          }

          -

          -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 correllation is more easily identified.

          -

          The following rules govern the construction of the results object:

          +

          +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 correllation 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.
          • @@ -1826,11 +1806,11 @@

            }

          -

          -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/2019-08/output/verbose-example>.

          +

          +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-08/output/verbose-example>.

           
           // schema
          @@ -1883,44 +1863,44 @@ 

          }

          -

          -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/2019-08/output/schema>.

          -

          -13. Usage for Hypermedia +

          +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-08/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.

          -

          -13.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:

          +

          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"
           
                               
          -

          -13.2. Identifying a Schema via a Media Type Parameter +

          +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:

          +

          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:

          +

          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:

          +

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

           
           Accept: application/json;
          @@ -1929,39 +1909,39 @@ 

          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.

          +

          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.

          [CREF7]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"
           
                               
          -

          -13.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.

          +

          +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.

          -

          -14. Security Considerations +

          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.

          -

          -15. IANA Considerations

          -

          -15.1. application/schema+json

          -

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

          +

          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
          • @@ -1974,15 +1954,15 @@

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

          -

          -15.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:

          +

          +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
          • @@ -1994,16 +1974,16 @@

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

          -16. References

          +14. References

          -16.1. Normative References

          +14.1. Normative References @@ -2041,7 +2021,7 @@

          [ecma262]

          -16.2. Informative References

          +14.2. Informative References diff --git a/work-in-progress/WIP-jsonschema-core.txt b/work-in-progress/WIP-jsonschema-core.txt index e3f6598e..bbca3944 100644 --- a/work-in-progress/WIP-jsonschema-core.txt +++ b/work-in-progress/WIP-jsonschema-core.txt @@ -5,11 +5,11 @@ Internet Engineering Task Force A. Wright, Ed. Internet-Draft Intended status: Informational H. Andrews, Ed. -Expires: February 11, 2020 +Expires: February 17, 2020 B. Hutton, Ed. Wellcome Sanger Institute G. Dennis - August 10, 2019 + August 16, 2019 JSON Schema: A Media Type for Describing JSON Documents @@ -53,12 +53,12 @@ Status of This Memo -Wright, et al. Expires February 11, 2020 [Page 1] +Wright, et al. Expires February 17, 2020 [Page 1] Internet-Draft JSON Schema August 2019 - This Internet-Draft will expire on February 11, 2020. + This Internet-Draft will expire on February 17, 2020. Copyright Notice @@ -79,19 +79,19 @@ Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 2. Conventions and Terminology . . . . . . . . . . . . . . . . . 4 - 3. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 5 - 4. Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 6 - 4.1. JSON Document . . . . . . . . . . . . . . . . . . . . . . 6 + 3. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 4 + 4. Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 5 + 4.1. JSON Document . . . . . . . . . . . . . . . . . . . . . . 5 4.2. Instance . . . . . . . . . . . . . . . . . . . . . . . . 6 4.2.1. Instance Data Model . . . . . . . . . . . . . . . . . 6 4.2.2. Instance Media Types . . . . . . . . . . . . . . . . 7 4.2.3. Instance Equality . . . . . . . . . . . . . . . . . . 7 4.3. JSON Schema Documents . . . . . . . . . . . . . . . . . . 8 4.3.1. JSON Schema Objects and Keywords . . . . . . . . . . 8 - 4.3.2. Boolean JSON Schemas . . . . . . . . . . . . . . . . 9 + 4.3.2. Boolean JSON Schemas . . . . . . . . . . . . . . . . 8 4.3.3. Schema Vocabularies . . . . . . . . . . . . . . . . . 9 4.3.4. Meta-Schemas . . . . . . . . . . . . . . . . . . . . 9 - 4.3.5. Root Schema and Subschemas . . . . . . . . . . . . . 10 + 4.3.5. Root Schema and Subschemas . . . . . . . . . . . . . 9 5. Fragment Identifiers . . . . . . . . . . . . . . . . . . . . 10 6. General Considerations . . . . . . . . . . . . . . . . . . . 11 6.1. Range of JSON Values . . . . . . . . . . . . . . . . . . 11 @@ -109,85 +109,73 @@ Table of Contents -Wright, et al. Expires February 11, 2020 [Page 2] +Wright, et al. Expires February 17, 2020 [Page 2] Internet-Draft JSON Schema August 2019 7.5.1. Assertions and Instance Primitive Types . . . . . . . 16 - 7.6. Annotations . . . . . . . . . . . . . . . . . . . . . . . 16 + 7.6. Annotations . . . . . . . . . . . . . . . . . . . . . . . 17 7.6.1. Collecting Annotations . . . . . . . . . . . . . . . 17 - 8. Meta-Schemas and Vocabularies . . . . . . . . . . . . . . . . 20 - 8.1. The "$schema" Keyword . . . . . . . . . . . . . . . . . . 21 - 8.2. The "$vocabulary" Keyword . . . . . . . . . . . . . . . . 21 - 8.2.1. Default vocabularies . . . . . . . . . . . . . . . . 22 - 8.2.2. Non-inheritability of vocabularies . . . . . . . . . 23 - 8.3. Detecting a Meta-Schema . . . . . . . . . . . . . . . . . 23 - 8.4. Best Practices for Vocabulary and Meta-Schema Authors . . 23 - 8.5. The JSON Schema Core Vocabulary . . . . . . . . . . . . . 25 - 8.6. Example Meta-Schema With Vocabulary Declarations . . . . 25 - 9. Base URI and Dereferencing . . . . . . . . . . . . . . . . . 27 - 9.1. Initial Base URI . . . . . . . . . . . . . . . . . . . . 27 - 9.2. The "$id" Keyword . . . . . . . . . . . . . . . . . . . . 27 - 9.2.1. Identifying the root schema . . . . . . . . . . . . . 27 - 9.2.2. Changing the base URI within a schema file . . . . . 28 - 9.2.3. Location-independent identifiers . . . . . . . . . . 28 - 9.2.4. Schema identification examples . . . . . . . . . . . 28 - 9.3. Schema References . . . . . . . . . . . . . . . . . . . . 30 - 9.3.1. Direct References with "$ref" . . . . . . . . . . . . 30 - 9.3.2. Recursive References with "$recursiveRef" and - "$recursiveAnchor" . . . . . . . . . . . . . . . . . 31 - 9.3.3. Guarding Against Infinite Recursion . . . . . . . . . 35 - 9.3.4. References to Possible Non-Schemas . . . . . . . . . 35 - 9.3.5. Loading a referenced schema . . . . . . . . . . . . . 36 - 9.3.6. Dereferencing . . . . . . . . . . . . . . . . . . . . 36 - 9.4. Schema Re-Use With "$defs" . . . . . . . . . . . . . . . 37 - 10. Comments With "$comment" . . . . . . . . . . . . . . . . . . 38 - 11. A Vocabulary for Applying Subschemas . . . . . . . . . . . . 38 - 11.1. Keyword Independence . . . . . . . . . . . . . . . . . . 39 - 11.2. Keywords for Applying Subschemas in Place . . . . . . . 39 - 11.2.1. Keywords for Applying Subschemas With Boolean Logic 39 - 11.2.2. Keywords for Applying Subschemas Conditionally . . . 40 - 11.3. Keywords for Applying Subschemas to Child Instances . . 42 - 11.3.1. Keywords for Applying Subschemas to Arrays . . . . . 42 - 11.3.2. Keywords for Applying Subschemas to Objects . . . . 44 - 12. Output Formatting . . . . . . . . . . . . . . . . . . . . . . 47 - 12.1. Format . . . . . . . . . . . . . . . . . . . . . . . . . 47 - 12.2. Output Formats . . . . . . . . . . . . . . . . . . . . . 47 - 12.3. Minimum Information . . . . . . . . . . . . . . . . . . 48 - 12.3.1. Keyword Relative Location . . . . . . . . . . . . . 48 - 12.3.2. Keyword Absolute Location . . . . . . . . . . . . . 48 - 12.3.3. Instance Location . . . . . . . . . . . . . . . . . 49 - 12.3.4. Error or Annotation . . . . . . . . . . . . . . . . 49 - 12.3.5. Nested Results . . . . . . . . . . . . . . . . . . . 49 - 12.4. Output Structure . . . . . . . . . . . . . . . . . . . . 49 - 12.4.1. Flag . . . . . . . . . . . . . . . . . . . . . . . . 51 - - - -Wright, et al. Expires February 11, 2020 [Page 3] - -Internet-Draft JSON Schema August 2019 - - - 12.4.2. Basic . . . . . . . . . . . . . . . . . . . . . . . 51 - 12.4.3. Detailed . . . . . . . . . . . . . . . . . . . . . . 52 - 12.4.4. Verbose . . . . . . . . . . . . . . . . . . . . . . 54 - 12.4.5. Output validation schemas . . . . . . . . . . . . . 56 - 13. Usage for Hypermedia . . . . . . . . . . . . . . . . . . . . 56 - 13.1. Linking to a Schema . . . . . . . . . . . . . . . . . . 56 - 13.2. Identifying a Schema via a Media Type Parameter . . . . 56 - 13.3. Usage Over HTTP . . . . . . . . . . . . . . . . . . . . 58 - 14. Security Considerations . . . . . . . . . . . . . . . . . . . 58 - 15. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 59 - 15.1. application/schema+json . . . . . . . . . . . . . . . . 59 - 15.2. application/schema-instance+json . . . . . . . . . . . . 60 - 16. References . . . . . . . . . . . . . . . . . . . . . . . . . 60 - 16.1. Normative References . . . . . . . . . . . . . . . . . . 60 - 16.2. Informative References . . . . . . . . . . . . . . . . . 61 - Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . 63 - Appendix B. ChangeLog . . . . . . . . . . . . . . . . . . . . . 63 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 66 + 8. The JSON Schema Core Vocabulary . . . . . . . . . . . . . . . 21 + 8.1. Meta-Schemas and Vocabularies . . . . . . . . . . . . . . 22 + 8.1.1. The "$schema" Keyword . . . . . . . . . . . . . . . . 23 + 8.1.2. The "$vocabulary" Keyword . . . . . . . . . . . . . . 23 + 8.1.3. Updates to Meta-Schema and Vocabulary URIs . . . . . 25 + 8.1.4. Detecting a Meta-Schema . . . . . . . . . . . . . . . 25 + 8.1.5. Best Practices for Vocabulary and Meta-Schema Authors 25 + 8.1.6. Example Meta-Schema With Vocabulary Declarations . . 27 + 8.2. Base URI and Dereferencing . . . . . . . . . . . . . . . 28 + 8.2.1. Initial Base URI . . . . . . . . . . . . . . . . . . 28 + 8.2.2. The "$id" Keyword . . . . . . . . . . . . . . . . . . 28 + 8.2.3. Schema References . . . . . . . . . . . . . . . . . . 31 + 8.2.4. Schema Re-Use With "$defs" . . . . . . . . . . . . . 38 + 8.3. Comments With "$comment" . . . . . . . . . . . . . . . . 39 + 9. A Vocabulary for Applying Subschemas . . . . . . . . . . . . 39 + 9.1. Keyword Independence . . . . . . . . . . . . . . . . . . 40 + 9.2. Keywords for Applying Subschemas in Place . . . . . . . . 40 + 9.2.1. Keywords for Applying Subschemas With Boolean Logic . 40 + 9.2.2. Keywords for Applying Subschemas Conditionally . . . 41 + 9.3. Keywords for Applying Subschemas to Child Instances . . . 43 + 9.3.1. Keywords for Applying Subschemas to Arrays . . . . . 43 + 9.3.2. Keywords for Applying Subschemas to Objects . . . . . 45 + 10. Output Formatting . . . . . . . . . . . . . . . . . . . . . . 48 + 10.1. Format . . . . . . . . . . . . . . . . . . . . . . . . . 48 + 10.2. Output Formats . . . . . . . . . . . . . . . . . . . . . 48 + 10.3. Minimum Information . . . . . . . . . . . . . . . . . . 49 + 10.3.1. Keyword Relative Location . . . . . . . . . . . . . 49 + 10.3.2. Keyword Absolute Location . . . . . . . . . . . . . 49 + 10.3.3. Instance Location . . . . . . . . . . . . . . . . . 50 + 10.3.4. Error or Annotation . . . . . . . . . . . . . . . . 50 + 10.3.5. Nested Results . . . . . . . . . . . . . . . . . . . 50 + 10.4. Output Structure . . . . . . . . . . . . . . . . . . . . 50 + 10.4.1. Flag . . . . . . . . . . . . . . . . . . . . . . . . 52 + 10.4.2. Basic . . . . . . . . . . . . . . . . . . . . . . . 52 + 10.4.3. Detailed . . . . . . . . . . . . . . . . . . . . . . 53 + 10.4.4. Verbose . . . . . . . . . . . . . . . . . . . . . . 55 + 10.4.5. Output validation schemas . . . . . . . . . . . . . 57 + 11. Usage for Hypermedia . . . . . . . . . . . . . . . . . . . . 57 + 11.1. Linking to a Schema . . . . . . . . . . . . . . . . . . 57 + 11.2. Identifying a Schema via a Media Type Parameter . . . . 57 + 11.3. Usage Over HTTP . . . . . . . . . . . . . . . . . . . . 59 + 12. Security Considerations . . . . . . . . . . . . . . . . . . . 59 + 13. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 60 + 13.1. application/schema+json . . . . . . . . . . . . . . . . 60 + 13.2. application/schema-instance+json . . . . . . . . . . . . 61 + + + +Wright, et al. Expires February 17, 2020 [Page 3] + +Internet-Draft JSON Schema August 2019 + + + 14. References . . . . . . . . . . . . . . . . . . . . . . . . . 61 + 14.1. Normative References . . . . . . . . . . . . . . . . . . 61 + 14.2. Informative References . . . . . . . . . . . . . . . . . 62 + Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . 64 + Appendix B. ChangeLog . . . . . . . . . . . . . . . . . . . . . 64 + Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 67 1. Introduction @@ -214,18 +202,6 @@ Internet-Draft JSON Schema August 2019 and "null" in this document are to be interpreted as defined in RFC 8259 [RFC8259]. - - - - - - - -Wright, et al. Expires February 11, 2020 [Page 4] - -Internet-Draft JSON Schema August 2019 - - 3. Overview This document proposes a new media type "application/schema+json" to @@ -240,6 +216,16 @@ Internet-Draft JSON Schema August 2019 keywords are used to apply assertions and annotations to more complex JSON data structures, or based on some sort of condition. + + + + + +Wright, et al. Expires February 17, 2020 [Page 4] + +Internet-Draft JSON Schema August 2019 + + To facilitate re-use, keywords can be organized into vocabularies. A vocabulary consists of a list of keywords, together with their syntax and semantics. @@ -271,17 +257,6 @@ Internet-Draft JSON Schema August 2019 Further vocabularies for purposes such as structural validation or hypermedia annotation are defined in other documents. - - - - - - -Wright, et al. Expires February 11, 2020 [Page 5] - -Internet-Draft JSON Schema August 2019 - - 4. Definitions 4.1. JSON Document @@ -297,6 +272,16 @@ Internet-Draft JSON Schema August 2019 according to the JSON Schema data model can be interpreted against a JSON Schema, including media types like CBOR [RFC7049]. + + + + + +Wright, et al. Expires February 17, 2020 [Page 5] + +Internet-Draft JSON Schema August 2019 + + 4.2. Instance A JSON document to which a schema is applied is known as an @@ -330,16 +315,8 @@ Internet-Draft JSON Schema August 2019 Whitespace and formatting concerns, including different lexical representations of numbers that are equal within the data model, are - - - -Wright, et al. Expires February 11, 2020 [Page 6] - -Internet-Draft JSON Schema August 2019 - - thus outside the scope of JSON Schema. JSON Schema vocabularies - (Section 8) that wish to work with such differences in lexical + (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. @@ -352,6 +329,15 @@ Internet-Draft JSON Schema August 2019 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 + + + + +Wright, et al. Expires February 17, 2020 [Page 6] + +Internet-Draft JSON Schema August 2019 + + type for a vocabulary to define as a value for a keyword, but the data model makes no distinction between integers and other numbers. @@ -387,13 +373,6 @@ Internet-Draft JSON Schema August 2019 both are numbers, and have the same mathematical value; or - - -Wright, et al. Expires February 11, 2020 [Page 7] - -Internet-Draft JSON Schema August 2019 - - both are arrays, and have an equal value item-for-item; or both are objects, and each property in one has exactly one @@ -406,6 +385,15 @@ Internet-Draft JSON Schema August 2019 same key, and mere formatting differences (indentation, placement of commas, trailing zeros) are insignificant. + + + + +Wright, et al. Expires February 17, 2020 [Page 7] + +Internet-Draft JSON Schema August 2019 + + 4.3. JSON Schema Documents A JSON Schema document, or simply a schema, is a JSON document used @@ -442,14 +430,6 @@ Internet-Draft JSON Schema August 2019 A JSON Schema MAY contain properties which are not schema keywords. Unknown keywords SHOULD be ignored. - - - -Wright, et al. Expires February 11, 2020 [Page 8] - -Internet-Draft JSON Schema August 2019 - - An empty schema is a JSON Schema with no properties, or only unknown properties. @@ -461,6 +441,15 @@ Internet-Draft JSON Schema August 2019 These boolean schemas exist to clarify schema author intent and facilitate schema processing optimizations. They behave identically + + + + +Wright, et al. Expires February 17, 2020 [Page 8] + +Internet-Draft JSON Schema August 2019 + + to the following schema objects (where "not" is part of the subschema application vocabulary defined in this document). @@ -498,14 +487,6 @@ Internet-Draft JSON Schema August 2019 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 - - - -Wright, et al. Expires February 11, 2020 [Page 9] - -Internet-Draft JSON Schema August 2019 - - loosely than the vocabularies' specifications call for. Meta-schemas may also describe and validate additional keywords that are not part of a formal vocabulary. @@ -519,6 +500,12 @@ Internet-Draft JSON Schema August 2019 nested: + +Wright, et al. Expires February 17, 2020 [Page 9] + +Internet-Draft JSON Schema August 2019 + + { "title": "root", "items": { @@ -554,14 +541,6 @@ Internet-Draft JSON Schema August 2019 Per the W3C's best practices for fragment identifiers [W3C.WD-fragid-best-practices-20121025], plain name fragment - - - -Wright, et al. Expires February 11, 2020 [Page 10] - -Internet-Draft JSON Schema August 2019 - - 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 @@ -569,7 +548,19 @@ Internet-Draft JSON Schema August 2019 Defining and referencing a plain name fragment identifier within an "application/schema+json" document are specified in the "$id" keyword - (Section 9.2) section. + (Section 8.2.2) section. + + + + + + + + +Wright, et al. Expires February 17, 2020 [Page 10] + +Internet-Draft JSON Schema August 2019 + 6. General Considerations @@ -598,8 +589,8 @@ Internet-Draft JSON Schema August 2019 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 ECMA 262 - [ecma262] regular expression dialect. + regular expressions SHOULD be valid according to the regular + expression dialect described in ECMA 262, section 15.10.1 [ecma262]. Furthermore, given the high disparity in regular expression constructs support, schema authors SHOULD limit themselves to the @@ -610,14 +601,6 @@ Internet-Draft JSON Schema August 2019 simple character classes ([abc]), range character classes ([a-z]); - - - -Wright, et al. Expires February 11, 2020 [Page 11] - -Internet-Draft JSON Schema August 2019 - - complemented character classes ([^abc], [^a-z]); simple quantifiers: "+" (one or more), "*" (zero or more), "?" @@ -627,6 +610,14 @@ Internet-Draft JSON Schema August 2019 least x, at most y, occurrences), {x,} (x occurrences or more), and their lazy versions; + + + +Wright, et al. Expires February 17, 2020 [Page 11] + +Internet-Draft JSON Schema August 2019 + + the beginning-of-input ("^") and end-of-input ("$") anchors; simple grouping ("(...)") and alternation ("|"). @@ -666,14 +657,6 @@ Internet-Draft JSON Schema August 2019 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 - - - -Wright, et al. Expires February 11, 2020 [Page 12] - -Internet-Draft JSON Schema August 2019 - - 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, @@ -683,6 +666,14 @@ Internet-Draft JSON Schema August 2019 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 + + + +Wright, et al. Expires February 17, 2020 [Page 12] + +Internet-Draft JSON Schema August 2019 + + 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 @@ -721,15 +712,6 @@ Internet-Draft JSON Schema August 2019 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 - - - - -Wright, et al. Expires February 11, 2020 [Page 13] - -Internet-Draft JSON Schema August 2019 - - only allowed in the root schema but processing begins in a subschema. ]] @@ -740,6 +722,14 @@ Internet-Draft JSON Schema August 2019 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 + + + +Wright, et al. Expires February 17, 2020 [Page 13] + +Internet-Draft JSON Schema August 2019 + + dynamic parent, rather than examining the local lexically enclosing parent. @@ -778,14 +768,6 @@ Internet-Draft JSON Schema August 2019 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 - - - -Wright, et al. Expires February 11, 2020 [Page 14] - -Internet-Draft JSON Schema August 2019 - - 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 @@ -793,6 +775,17 @@ Internet-Draft JSON Schema August 2019 demonstrated by the "additionalItems" and "additionalProperties" keywords in this document. + + + + + + +Wright, et al. Expires February 17, 2020 [Page 14] + +Internet-Draft JSON Schema August 2019 + + 7.4. Applicators Applicators allow for building more complex schemas than can be @@ -833,22 +826,22 @@ Internet-Draft JSON Schema August 2019 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 "$recursiveRef" and + "$recursiveAnchor", may make use of dynamic scoping, and therefore + only be resolvable in the process of evaluating the schema with an + instance. + -Wright, et al. Expires February 11, 2020 [Page 15] +Wright, et al. Expires February 17, 2020 [Page 15] Internet-Draft JSON Schema August 2019 - For some by-reference applicators, such as "$ref" (Section 9.3.1), - 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.5. Assertions JSON Schema can be used to assert constraints on a JSON document, @@ -868,9 +861,42 @@ Internet-Draft JSON Schema August 2019 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. + 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. + + + + + + + +Wright, et al. Expires February 17, 2020 [Page 16] + +Internet-Draft JSON Schema August 2019 + 7.6. Annotations @@ -890,14 +916,6 @@ Internet-Draft JSON Schema August 2019 applicators, it is not possible to define a universally predictable order of processing. - - - -Wright, et al. Expires February 11, 2020 [Page 16] - -Internet-Draft JSON Schema August 2019 - - 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 @@ -929,6 +947,13 @@ Internet-Draft JSON Schema August 2019 The attached value(s) + + +Wright, et al. Expires February 17, 2020 [Page 17] + +Internet-Draft JSON Schema August 2019 + + 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 @@ -949,7 +974,38 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 17] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Wright, et al. Expires February 17, 2020 [Page 18] Internet-Draft JSON Schema August 2019 @@ -1005,7 +1061,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 18] +Wright, et al. Expires February 17, 2020 [Page 19] Internet-Draft JSON Schema August 2019 @@ -1061,7 +1117,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 19] +Wright, et al. Expires February 17, 2020 [Page 20] Internet-Draft JSON Schema August 2019 @@ -1093,7 +1149,51 @@ Internet-Draft JSON Schema August 2019 annotation values are defined by each annotation keyword, and are not directly affected by the logic used for combining assertion results. -8. Meta-Schemas and Vocabularies +8. The JSON Schema Core Vocabulary + + Keywords declared in 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" (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. + + + + +Wright, et al. Expires February 17, 2020 [Page 21] + +Internet-Draft JSON Schema August 2019 + + + 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: . + + The current URI for the corresponding meta-schema is: . + + 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- @@ -1114,14 +1214,6 @@ Internet-Draft JSON Schema August 2019 describe an incompatible syntax, such a meta-schema would be unlikely to be useful. - - - -Wright, et al. Expires February 11, 2020 [Page 20] - -Internet-Draft JSON Schema August 2019 - - 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 @@ -1134,7 +1226,15 @@ Internet-Draft JSON Schema August 2019 design of meta-schema features emphasizes flexibility over simplicity. -8.1. The "$schema" Keyword + + + +Wright, et al. Expires February 17, 2020 [Page 22] + +Internet-Draft JSON Schema August 2019 + + +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 @@ -1164,20 +1264,12 @@ Internet-Draft JSON Schema August 2019 Values for this property are defined elsewhere in this and other documents, and by other parties. -8.2. The "$vocabulary" Keyword +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 - - - -Wright, et al. Expires February 11, 2020 [Page 21] - -Internet-Draft JSON Schema August 2019 - - understand the required vocabularies in order to successfully process the schema. @@ -1190,6 +1282,14 @@ Internet-Draft JSON Schema August 2019 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. + + + +Wright, et al. Expires February 17, 2020 [Page 23] + +Internet-Draft JSON Schema August 2019 + + [[CREF3: Vocabulary documents may be added shortly, or in the next draft. For now, identifying the keyword set is deemed sufficient as that, along with meta-schema validation, is how the current @@ -1218,7 +1318,7 @@ Internet-Draft JSON Schema August 2019 meta-schema M against its own meta-schema M' without requiring the validator to understand the vocabularies declared by M. -8.2.1. Default vocabularies +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 @@ -1226,14 +1326,6 @@ Internet-Draft JSON Schema August 2019 as Hyper-Schema usage) has been recognized prior to the existence of vocabularies. - - - -Wright, et al. Expires February 11, 2020 [Page 22] - -Internet-Draft JSON Schema August 2019 - - 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 @@ -1245,7 +1337,16 @@ Internet-Draft JSON Schema August 2019 use of all vocabularies in this specification and the companion Validation specification. -8.2.2. Non-inheritability of vocabularies + + + + +Wright, et al. Expires February 17, 2020 [Page 24] + +Internet-Draft JSON Schema August 2019 + + +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 @@ -1253,9 +1354,17 @@ Internet-Draft JSON Schema August 2019 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 - (Section 8.6). + (Section 8.1.6). + +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.3. Detecting a Meta-Schema +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 @@ -1276,23 +1385,23 @@ Internet-Draft JSON Schema August 2019 requirements up front. Meta-schema authors MUST NOT expect such features to be interoperable across implementations. -8.4. Best Practices for Vocabulary and Meta-Schema Authors +8.1.5. 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. + -Wright, et al. Expires February 11, 2020 [Page 23] +Wright, et al. Expires February 17, 2020 [Page 25] Internet-Draft JSON Schema August 2019 - 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 @@ -1315,9 +1424,9 @@ Internet-Draft JSON Schema August 2019 any keywords from the Core vocabulary. It is RECOMMENDED that meta-schema authors reference each - vocabulary's meta-schema using the "allOf" (Section 11.2.1.1) - keyword, although other mechanisms for constructing the meta-schema - may be appropriate for certain use cases. + vocabulary's meta-schema using the "allOf" (Section 9.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 "$recursiveAnchor" and "$recursiveRef" keywords particularly useful for extending existing @@ -1341,67 +1450,16 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 24] - -Internet-Draft JSON Schema August 2019 - -8.5. The JSON Schema Core Vocabulary - Keywords declared in in this specification that 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 "$vocabulary" 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. - - 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: . - - The current URI for the corresponding meta-schema is: . - - 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.6. Example Meta-Schema With Vocabulary Declarations - - - - - - - - - - - - - - -Wright, et al. Expires February 11, 2020 [Page 25] +Wright, et al. Expires February 17, 2020 [Page 26] Internet-Draft JSON Schema August 2019 +8.1.6. Example Meta-Schema With Vocabulary Declarations + This meta-schema explicitly declares both the Core and Applicator vocabularies, and combines their meta-schemas with an "allOf". It additionally restricts the usage of the Applicator vocabulary by @@ -1447,24 +1505,25 @@ Internet-Draft JSON Schema August 2019 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. -Wright, et al. Expires February 11, 2020 [Page 26] +Wright, et al. Expires February 17, 2020 [Page 27] Internet-Draft JSON Schema August 2019 -9. Base URI and Dereferencing + These URIs for these meta-schemas may be found in the Validation and + Hyper-Schema specifications, respectively. + +8.2. Base URI 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. -9.1. Initial Base URI +8.2.1. Initial Base URI RFC3986 Section 5.1 [RFC3986] defines how to determine the default base URI of a document. @@ -1483,7 +1542,7 @@ Internet-Draft JSON Schema August 2019 in RFC 3986 Section 5.1.4 [RFC3986]. It is RECOMMENDED that implementations document any default base URI that they assume. -9.2. The "$id" Keyword +8.2.2. The "$id" Keyword The "$id" keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. A @@ -1497,7 +1556,7 @@ Internet-Draft JSON Schema August 2019 normalized, and SHOULD NOT be an empty fragment <#> or an empty string <>. -9.2.1. Identifying the root schema +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 [RFC3986] (containing a scheme, but no @@ -1506,15 +1565,12 @@ Internet-Draft JSON Schema August 2019 - - - -Wright, et al. Expires February 11, 2020 [Page 27] +Wright, et al. Expires February 17, 2020 [Page 28] Internet-Draft JSON Schema August 2019 -9.2.2. Changing the base URI within a schema file +8.2.2.2. Changing the base URI within a schema file When an "$id" sets the base URI, the object containing that "$id" and all of its subschemas can be identified by using a JSON Pointer @@ -1524,9 +1580,9 @@ Internet-Draft JSON Schema August 2019 URI declared in the subschema or a parent, along with a JSON Pointer fragment identifying the path from the schema object that declares the base to the subschema being identified. Examples of this are - shown in section 9.2.4. + shown in section 8.2.2.4. -9.2.3. Location-independent identifiers +8.2.2.3. Location-independent identifiers Using JSON Pointer fragments requires knowledge of the structure of the schema. When writing schema documents with the intention to @@ -1548,7 +1604,7 @@ Internet-Draft JSON Schema August 2019 interpreted? There are two cases: when the other components match the current base URI and when they change the base URI. ]] -9.2.4. Schema identification examples +8.2.2.4. Schema identification examples @@ -1565,7 +1621,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 28] +Wright, et al. Expires February 17, 2020 [Page 29] Internet-Draft JSON Schema August 2019 @@ -1621,7 +1677,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 29] +Wright, et al. Expires February 17, 2020 [Page 30] Internet-Draft JSON Schema August 2019 @@ -1650,7 +1706,7 @@ Internet-Draft JSON Schema August 2019 https://example.com/root.json#/$defs/C -9.3. Schema References +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 "$recursiveRef" @@ -1669,7 +1725,7 @@ Internet-Draft JSON Schema August 2019 implementations SHOULD NOT assume they should perform a network operation when they encounter a network-addressable URI. -9.3.1. Direct References with "$ref" +8.2.3.1. Direct References with "$ref" The "$ref" keyword is used to reference a statically identified schema. @@ -1677,7 +1733,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 30] +Wright, et al. Expires February 17, 2020 [Page 31] Internet-Draft JSON Schema August 2019 @@ -1686,7 +1742,8 @@ Internet-Draft JSON Schema August 2019 Reference. Resolved against the current URI base, it identifies the URI of a schema to use. -9.3.2. Recursive References with "$recursiveRef" and "$recursiveAnchor" +8.2.3.2. Recursive References with "$recursiveRef" and + "$recursiveAnchor" The "$recursiveRef" and "$recursiveAnchor" keywords are used to construct extensible recursive schemas. A recursive schema is one @@ -1732,8 +1789,7 @@ Internet-Draft JSON Schema August 2019 - -Wright, et al. Expires February 11, 2020 [Page 31] +Wright, et al. Expires February 17, 2020 [Page 32] Internet-Draft JSON Schema August 2019 @@ -1789,7 +1845,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 32] +Wright, et al. Expires February 17, 2020 [Page 33] Internet-Draft JSON Schema August 2019 @@ -1801,7 +1857,7 @@ Internet-Draft JSON Schema August 2019 original changes its recursive fields. This approach can be seen in the meta-schema for JSON Hyper-Schema in all prior drafts. -9.3.2.1. Enabling Recursion with "$recursiveAnchor" +8.2.3.2.1. Enabling Recursion with "$recursiveAnchor" The desired behavior is for the recursive reference, "r", in the original schema to resolve to the original schema when that is the @@ -1833,7 +1889,7 @@ Internet-Draft JSON Schema August 2019 The value of "$recursiveAnchor" MUST be of type boolean, and MUST be true. The value false is reserved for possible future use. -9.3.2.2. Dynamically recursive references with "$recursiveRef" +8.2.3.2.2. Dynamically recursive references with "$recursiveRef" The "$recursiveRef" keyword behaves identically to "$ref", except that if the referenced schema has "$recursiveAnchor" set to true, @@ -1845,7 +1901,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 33] +Wright, et al. Expires February 17, 2020 [Page 34] Internet-Draft JSON Schema August 2019 @@ -1901,7 +1957,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 34] +Wright, et al. Expires February 17, 2020 [Page 35] Internet-Draft JSON Schema August 2019 @@ -1924,7 +1980,7 @@ Internet-Draft JSON Schema August 2019 original schema will resolve to "https://example.com/extension#", not "https://example.com/original#". -9.3.3. Guarding Against Infinite Recursion +8.2.3.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" @@ -1933,7 +1989,7 @@ Internet-Draft JSON Schema August 2019 Schemas SHOULD NOT make use of infinite recursive nesting like this; the behavior is undefined. -9.3.4. References to Possible Non-Schemas +8.2.3.4. References to Possible Non-Schemas Subschema objects (or booleans) are recognized by their use with known applicator keywords. These keywords may be the standard @@ -1957,7 +2013,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 35] +Wright, et al. Expires February 17, 2020 [Page 36] Internet-Draft JSON Schema August 2019 @@ -1969,7 +2025,7 @@ Internet-Draft JSON Schema August 2019 behavior is implementation-specific and MUST NOT be relied upon for interoperability. -9.3.5. Loading a referenced schema +8.2.3.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 @@ -1978,7 +2034,7 @@ Internet-Draft JSON Schema August 2019 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 (Section 13). + Hypermedia (Section 11). Implementations SHOULD be able to associate arbitrary URIs with an arbitrary schema and/or automatically associate a schema's "$id"- @@ -1986,14 +2042,14 @@ Internet-Draft JSON Schema August 2019 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 - section 9.2.4. + section 8.2.2.4. 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.3.6. Dereferencing +8.2.3.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 @@ -2013,7 +2069,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 36] +Wright, et al. Expires February 17, 2020 [Page 37] Internet-Draft JSON Schema August 2019 @@ -2055,7 +2111,7 @@ Internet-Draft JSON Schema August 2019 system dynamically, so placing an absolute requirement of pre-loading schema documents is not feasible. ]] -9.4. Schema Re-Use With "$defs" +8.2.4. Schema Re-Use With "$defs" The "$defs" keyword provides a standardized location for schema authors to inline re-usable JSON Schemas into a more general schema. @@ -2069,7 +2125,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 37] +Wright, et al. Expires February 17, 2020 [Page 38] Internet-Draft JSON Schema August 2019 @@ -2091,7 +2147,7 @@ Internet-Draft JSON Schema August 2019 } -10. Comments With "$comment" +8.3. Comments With "$comment" This keyword is reserved for comments from schema authors to readers or maintainers of the schema. The value of this keyword MUST be a @@ -2117,7 +2173,7 @@ Internet-Draft JSON Schema August 2019 "$comment" properties. In particular, the value of "$comment" MUST NOT be collected as an annotation result. -11. A Vocabulary for Applying Subschemas +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. @@ -2125,7 +2181,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 38] +Wright, et al. Expires February 17, 2020 [Page 39] Internet-Draft JSON Schema August 2019 @@ -2147,7 +2203,7 @@ Internet-Draft JSON Schema August 2019 the next to indicate the same syntax and semantics as those listed here. -11.1. Keyword Independence +9.1. Keyword Independence Schema keywords typically operate independently, without affecting each other's outcomes. @@ -2167,13 +2223,13 @@ Internet-Draft JSON Schema August 2019 "unevaluatedItems", whose behavior is defined in terms of annotations from "items", "additionalItems" and itself -11.2. Keywords for Applying Subschemas in Place +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. -11.2.1. Keywords for Applying Subschemas With Boolean Logic +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 @@ -2181,7 +2237,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 39] +Wright, et al. Expires February 17, 2020 [Page 40] Internet-Draft JSON Schema August 2019 @@ -2190,7 +2246,7 @@ Internet-Draft JSON Schema August 2019 different values. Annotation keywords define their own rules for combining such values. -11.2.1.1. allOf +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. @@ -2199,7 +2255,7 @@ Internet-Draft JSON Schema August 2019 validates successfully against all schemas defined by this keyword's value. -11.2.1.2. anyOf +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. @@ -2210,7 +2266,7 @@ Internet-Draft JSON Schema August 2019 subschemas MUST be examined so that annotations are collected from each subschema that validates successfully. -11.2.1.3. oneOf +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. @@ -2219,14 +2275,14 @@ Internet-Draft JSON Schema August 2019 validates successfully against exactly one schema defined by this keyword's value. -11.2.1.4. not +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. -11.2.2. Keywords for Applying Subschemas Conditionally +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. @@ -2237,7 +2293,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 40] +Wright, et al. Expires February 17, 2020 [Page 41] Internet-Draft JSON Schema August 2019 @@ -2250,7 +2306,7 @@ Internet-Draft JSON Schema August 2019 present with an empty schema, and when "if" is not present, both "then" and "else" MUST be entirely ignored. -11.2.2.1. if +9.2.2.1. if This keyword's value MUST be a valid JSON Schema. @@ -2270,7 +2326,7 @@ Internet-Draft JSON Schema August 2019 from this keyword's subschema in the usual way, including when the keyword is present without either "then" or "else". -11.2.2.2. then +9.2.2.2. then This keyword's value MUST be a valid JSON Schema. @@ -2284,7 +2340,7 @@ Internet-Draft JSON Schema August 2019 evaluate the instance against this keyword, for either validation or annotation collection purposes, in such cases. -11.2.2.3. else +9.2.2.3. else This keyword's value MUST be a valid JSON Schema. @@ -2293,7 +2349,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 41] +Wright, et al. Expires February 17, 2020 [Page 42] Internet-Draft JSON Schema August 2019 @@ -2307,7 +2363,7 @@ Internet-Draft JSON Schema August 2019 NOT evaluate the instance against this keyword, for either validation or annotation collection purposes, in such cases. -11.2.2.4. dependentSchemas +9.2.2.4. dependentSchemas This keyword specifies subschemas that are evaluated if the instance is an object and contains a certain property. @@ -2321,15 +2377,15 @@ Internet-Draft JSON Schema August 2019 Omitting this keyword has the same behavior as an empty object. -11.3. Keywords for Applying Subschemas to Child Instances +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. -11.3.1. Keywords for Applying Subschemas to Arrays +9.3.1. Keywords for Applying Subschemas to Arrays -11.3.1.1. items +9.3.1.1. items The value of "items" MUST be either a valid JSON Schema or an array of valid JSON Schemas. @@ -2349,7 +2405,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 42] +Wright, et al. Expires February 17, 2020 [Page 43] Internet-Draft JSON Schema August 2019 @@ -2362,7 +2418,7 @@ Internet-Draft JSON Schema August 2019 Omitting this keyword has the same assertion behavior as an empty schema. -11.3.1.2. additionalItems +9.3.1.2. additionalItems The value of "additionalItems" MUST be a valid JSON Schema. @@ -2390,7 +2446,7 @@ Internet-Draft JSON Schema August 2019 checking for the presence and size of an "items" array. Implementations that do not support annotation collection MUST do so. -11.3.1.3. unevaluatedItems +9.3.1.3. unevaluatedItems The value of "unevaluatedItems" MUST be a valid JSON Schema. @@ -2400,12 +2456,12 @@ Internet-Draft JSON Schema August 2019 "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 (Section 11.2) keywords. This includes + adjacent in-place applicator (Section 9.2) keywords. This includes -Wright, et al. Expires February 11, 2020 [Page 43] +Wright, et al. Expires February 17, 2020 [Page 44] Internet-Draft JSON Schema August 2019 @@ -2443,7 +2499,7 @@ Internet-Draft JSON Schema August 2019 Implementations that do not collect annotations MUST raise an error upon encountering this keyword. -11.3.1.4. contains +9.3.1.4. contains The value of this keyword MUST be a valid JSON Schema. @@ -2453,7 +2509,7 @@ Internet-Draft JSON Schema August 2019 element even after the first match has been found. This is to ensure that all possible annotations are collected. -11.3.2. Keywords for Applying Subschemas to Objects +9.3.2. Keywords for Applying Subschemas to Objects @@ -2461,12 +2517,12 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 44] +Wright, et al. Expires February 17, 2020 [Page 45] Internet-Draft JSON Schema August 2019 -11.3.2.1. properties +9.3.2.1. properties The value of "properties" MUST be an object. Each value of this object MUST be a valid JSON Schema. @@ -2484,7 +2540,7 @@ Internet-Draft JSON Schema August 2019 Omitting this keyword has the same assertion behavior as an empty object. -11.3.2.2. patternProperties +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 @@ -2505,7 +2561,7 @@ Internet-Draft JSON Schema August 2019 Omitting this keyword has the same assertion behavior as an empty object. -11.3.2.3. additionalProperties +9.3.2.3. additionalProperties The value of "additionalProperties" MUST be a valid JSON Schema. @@ -2517,7 +2573,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 45] +Wright, et al. Expires February 17, 2020 [Page 46] Internet-Draft JSON Schema August 2019 @@ -2539,7 +2595,7 @@ Internet-Draft JSON Schema August 2019 "patternProperties" against the instance property set. Implementations that do not support annotation collection MUST do so. -11.3.2.4. unevaluatedProperties +9.3.2.4. unevaluatedProperties The value of "unevaluatedProperties" MUST be a valid JSON Schema. @@ -2550,8 +2606,8 @@ Internet-Draft JSON Schema August 2019 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 11.2) keywords. This includes but is - not limited to the in-place applicators defined in this document. + in-place applicator (Section 9.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", @@ -2573,7 +2629,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 46] +Wright, et al. Expires February 17, 2020 [Page 47] Internet-Draft JSON Schema August 2019 @@ -2587,7 +2643,7 @@ Internet-Draft JSON Schema August 2019 Implementations that do not collect annotations MUST raise an error upon encountering this keyword. -11.3.2.5. propertyNames +9.3.2.5. propertyNames The value of "propertyNames" MUST be a valid JSON Schema. @@ -2598,7 +2654,7 @@ Internet-Draft JSON Schema August 2019 Omitting this keyword has the same behavior as an empty schema. -12. Output Formatting +10. Output Formatting JSON Schema is defined to be platform-independent. As such, to increase compatibility across platforms, implementations SHOULD @@ -2606,7 +2662,7 @@ Internet-Draft JSON Schema August 2019 describes the minimum requirements that consumers will need to properly interpret validation results. -12.1. Format +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 @@ -2614,7 +2670,7 @@ Internet-Draft JSON Schema August 2019 however it is RECOMMENDED that the output be convertible to the JSON format defined herein via serialization or other means. -12.2. Output Formats +10.2. Output Formats This specification defines four output formats. See the "Output Structure" section for the requirements of each format. @@ -2629,7 +2685,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 47] +Wright, et al. Expires February 17, 2020 [Page 48] Internet-Draft JSON Schema August 2019 @@ -2644,7 +2700,7 @@ Internet-Draft JSON Schema August 2019 "flag" format. Implementations SHOULD specify in their documentation which formats they support. -12.3. Minimum Information +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 @@ -2655,7 +2711,7 @@ Internet-Draft JSON Schema August 2019 Implementations MAY elect to provide additional information. -12.3.1. Keyword Relative Location +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 @@ -2671,7 +2727,7 @@ Internet-Draft JSON Schema August 2019 The JSON key for this information is "keywordLocation". -12.3.2. Keyword Absolute Location +10.3.2. Keyword Absolute Location The absolute, dereferenced location of the validating keyword. The value MUST be expressed as an absolute URI, and it MUST NOT include @@ -2685,7 +2741,7 @@ https://json-schema.org/draft/2019-08/schema#/$defs/nonNegativeInteger/minimum -Wright, et al. Expires February 11, 2020 [Page 48] +Wright, et al. Expires February 17, 2020 [Page 49] Internet-Draft JSON Schema August 2019 @@ -2696,14 +2752,14 @@ Internet-Draft JSON Schema August 2019 The JSON key for this information is "absoluteKeywordLocation". -12.3.3. Instance Location +10.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 +10.3.4. Error or Annotation The error or annotation that is produced by the validation. @@ -2713,7 +2769,7 @@ Internet-Draft JSON Schema August 2019 The JSON key for failed validations is "error"; for successful validations it is "annotation". -12.3.5. Nested Results +10.3.5. Nested Results For the two hierarchical structures, this property will hold nested errors and annotations. @@ -2721,7 +2777,7 @@ Internet-Draft JSON Schema August 2019 The JSON key for nested results in failed validations is "errors"; for successful validations it is "annotations". -12.4. Output Structure +10.4. Output Structure The output MUST be an object containing a boolean property named "valid". When additional information about the result is required, @@ -2741,7 +2797,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 49] +Wright, et al. Expires February 17, 2020 [Page 50] Internet-Draft JSON Schema August 2019 @@ -2797,7 +2853,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 50] +Wright, et al. Expires February 17, 2020 [Page 51] Internet-Draft JSON Schema August 2019 @@ -2805,7 +2861,7 @@ Internet-Draft JSON Schema August 2019 templating mechanism that allows their users to craft their own messages. -12.4.1. Flag +10.4.1. Flag In the simplest case, merely the boolean result for the "valid" valid property needs to be fulfilled. @@ -2823,7 +2879,7 @@ Internet-Draft JSON Schema August 2019 second one passes, there is no need to check the other three. The logic can simply return with success. -12.4.2. Basic +10.4.2. Basic The "Basic" structure is a flat list of output units. @@ -2853,7 +2909,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 51] +Wright, et al. Expires February 17, 2020 [Page 52] Internet-Draft JSON Schema August 2019 @@ -2896,7 +2952,7 @@ Internet-Draft JSON Schema August 2019 } -12.4.3. Detailed +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 @@ -2909,7 +2965,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 52] +Wright, et al. Expires February 17, 2020 [Page 53] Internet-Draft JSON Schema August 2019 @@ -2965,7 +3021,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 53] +Wright, et al. Expires February 17, 2020 [Page 54] Internet-Draft JSON Schema August 2019 @@ -3010,7 +3066,7 @@ Internet-Draft JSON Schema August 2019 } -12.4.4. Verbose +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 @@ -3021,7 +3077,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 54] +Wright, et al. Expires February 17, 2020 [Page 55] Internet-Draft JSON Schema August 2019 @@ -3077,7 +3133,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 55] +Wright, et al. Expires February 17, 2020 [Page 56] Internet-Draft JSON Schema August 2019 @@ -3095,20 +3151,20 @@ Internet-Draft JSON Schema August 2019 } -12.4.5. Output validation schemas +10.4.5. Output validation schemas For convenience, JSON Schema has been provided to validate output generated by implementations. Its URI is: . -13. Usage for Hypermedia +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 [RFC8288]. -13.1. Linking to a Schema +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", @@ -3122,7 +3178,7 @@ Internet-Draft JSON Schema August 2019 Link: ; rel="describedby" -13.2. Identifying a Schema via a Media Type Parameter +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 @@ -3133,7 +3189,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 56] +Wright, et al. Expires February 17, 2020 [Page 57] Internet-Draft JSON Schema August 2019 @@ -3189,7 +3245,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 57] +Wright, et al. Expires February 17, 2020 [Page 58] Internet-Draft JSON Schema August 2019 @@ -3210,7 +3266,7 @@ Internet-Draft JSON Schema August 2019 Link: ;rel="schema", ;rel="schema" -13.3. Usage Over HTTP +11.3. Usage Over HTTP When used for hypermedia systems over a network, HTTP [RFC7231] is frequently the protocol of choice for distributing schemas. @@ -3237,7 +3293,7 @@ Internet-Draft JSON Schema August 2019 server operators can contact the owner of a potentially misbehaving script. -14. Security Considerations +12. Security Considerations Both schemas and instances are JSON values. As such, all security considerations defined in RFC 8259 [RFC8259] apply. @@ -3245,7 +3301,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 58] +Wright, et al. Expires February 17, 2020 [Page 59] Internet-Draft JSON Schema August 2019 @@ -3272,9 +3328,9 @@ Internet-Draft JSON Schema August 2019 dangerous material within a "$comment". Implementations MUST NOT parse or otherwise take action based on "$comment" contents. -15. IANA Considerations +13. IANA Considerations -15.1. application/schema+json +13.1. application/schema+json The proposed MIME media type for JSON Schema is defined as follows: @@ -3301,19 +3357,19 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 59] +Wright, et al. Expires February 17, 2020 [Page 60] Internet-Draft JSON Schema August 2019 - Security considerations: See Section 14 above. + Security considerations: See Section 12 above. Interoperability considerations: See Sections 6.2, 6.3, and 6.4 above. Fragment identifier considerations: See Section 5 -15.2. application/schema-instance+json +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: @@ -3336,16 +3392,16 @@ Internet-Draft JSON Schema August 2019 those specified for the "application/json" media type. See JSON [RFC8259]. - Security considerations: See Section 14 above. + Security considerations: See Section 12 above. Interoperability considerations: See Sections 6.2, 6.3, and 6.4 above. Fragment identifier considerations: See Section 5 -16. References +14. References -16.1. Normative References +14.1. Normative References [ecma262] "ECMA 262 specification", . -16.2. Informative References +14.2. Informative References [json-hyper-schema] Andrews, H. and A. Wright, "JSON Hyper-Schema: A @@ -3413,7 +3469,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 61] +Wright, et al. Expires February 17, 2020 [Page 62] Internet-Draft JSON Schema August 2019 @@ -3469,7 +3525,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 62] +Wright, et al. Expires February 17, 2020 [Page 63] Internet-Draft JSON Schema August 2019 @@ -3525,7 +3581,7 @@ Appendix B. ChangeLog -Wright, et al. Expires February 11, 2020 [Page 63] +Wright, et al. Expires February 17, 2020 [Page 64] Internet-Draft JSON Schema August 2019 @@ -3581,7 +3637,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 64] +Wright, et al. Expires February 17, 2020 [Page 65] Internet-Draft JSON Schema August 2019 @@ -3637,7 +3693,7 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 11, 2020 [Page 65] +Wright, et al. Expires February 17, 2020 [Page 66] Internet-Draft JSON Schema August 2019 @@ -3693,4 +3749,4 @@ Authors' Addresses -Wright, et al. Expires February 11, 2020 [Page 66] +Wright, et al. Expires February 17, 2020 [Page 67] diff --git a/work-in-progress/WIP-jsonschema-hyperschema.html b/work-in-progress/WIP-jsonschema-hyperschema.html index 4f25c2c7..63500744 100644 --- a/work-in-progress/WIP-jsonschema-hyperschema.html +++ b/work-in-progress/WIP-jsonschema-hyperschema.html @@ -454,7 +454,7 @@ - + @@ -478,8 +478,8 @@ - - + + @@ -499,7 +499,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 February 11, 2020.

          +

          This Internet-Draft will expire on February 17, 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.

          diff --git a/work-in-progress/WIP-jsonschema-hyperschema.txt b/work-in-progress/WIP-jsonschema-hyperschema.txt index 4e4b5bd3..120689e7 100644 --- a/work-in-progress/WIP-jsonschema-hyperschema.txt +++ b/work-in-progress/WIP-jsonschema-hyperschema.txt @@ -5,7 +5,7 @@ Internet Engineering Task Force H. Andrews, Ed. Internet-Draft Intended status: Informational A. Wright, Ed. -Expires: February 11, 2020 August 10, 2019 +Expires: February 17, 2020 August 16, 2019 JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON @@ -47,13 +47,13 @@ Status of This Memo 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 February 11, 2020. + This Internet-Draft will expire on February 17, 2020. -Andrews & Wright Expires February 11, 2020 [Page 1] +Andrews & Wright Expires February 17, 2020 [Page 1] Internet-Draft JSON Hyper-Schema August 2019 @@ -109,7 +109,7 @@ Table of Contents -Andrews & Wright Expires February 11, 2020 [Page 2] +Andrews & Wright Expires February 17, 2020 [Page 2] Internet-Draft JSON Hyper-Schema August 2019 @@ -165,7 +165,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 3] +Andrews & Wright Expires February 17, 2020 [Page 3] Internet-Draft JSON Hyper-Schema August 2019 @@ -221,7 +221,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 4] +Andrews & Wright Expires February 17, 2020 [Page 4] Internet-Draft JSON Hyper-Schema August 2019 @@ -277,7 +277,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 5] +Andrews & Wright Expires February 17, 2020 [Page 5] Internet-Draft JSON Hyper-Schema August 2019 @@ -333,7 +333,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 6] +Andrews & Wright Expires February 17, 2020 [Page 6] Internet-Draft JSON Hyper-Schema August 2019 @@ -389,7 +389,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 7] +Andrews & Wright Expires February 17, 2020 [Page 7] Internet-Draft JSON Hyper-Schema August 2019 @@ -445,7 +445,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 8] +Andrews & Wright Expires February 17, 2020 [Page 8] Internet-Draft JSON Hyper-Schema August 2019 @@ -501,7 +501,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 9] +Andrews & Wright Expires February 17, 2020 [Page 9] Internet-Draft JSON Hyper-Schema August 2019 @@ -557,7 +557,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 10] +Andrews & Wright Expires February 17, 2020 [Page 10] Internet-Draft JSON Hyper-Schema August 2019 @@ -613,7 +613,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 11] +Andrews & Wright Expires February 17, 2020 [Page 11] Internet-Draft JSON Hyper-Schema August 2019 @@ -669,7 +669,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 12] +Andrews & Wright Expires February 17, 2020 [Page 12] Internet-Draft JSON Hyper-Schema August 2019 @@ -725,7 +725,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 13] +Andrews & Wright Expires February 17, 2020 [Page 13] Internet-Draft JSON Hyper-Schema August 2019 @@ -781,7 +781,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 14] +Andrews & Wright Expires February 17, 2020 [Page 14] Internet-Draft JSON Hyper-Schema August 2019 @@ -837,7 +837,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 15] +Andrews & Wright Expires February 17, 2020 [Page 15] Internet-Draft JSON Hyper-Schema August 2019 @@ -893,7 +893,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 16] +Andrews & Wright Expires February 17, 2020 [Page 16] Internet-Draft JSON Hyper-Schema August 2019 @@ -949,7 +949,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 17] +Andrews & Wright Expires February 17, 2020 [Page 17] Internet-Draft JSON Hyper-Schema August 2019 @@ -1005,7 +1005,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 18] +Andrews & Wright Expires February 17, 2020 [Page 18] Internet-Draft JSON Hyper-Schema August 2019 @@ -1061,7 +1061,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 19] +Andrews & Wright Expires February 17, 2020 [Page 19] Internet-Draft JSON Hyper-Schema August 2019 @@ -1117,7 +1117,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 20] +Andrews & Wright Expires February 17, 2020 [Page 20] Internet-Draft JSON Hyper-Schema August 2019 @@ -1173,7 +1173,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 21] +Andrews & Wright Expires February 17, 2020 [Page 21] Internet-Draft JSON Hyper-Schema August 2019 @@ -1229,7 +1229,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 22] +Andrews & Wright Expires February 17, 2020 [Page 22] Internet-Draft JSON Hyper-Schema August 2019 @@ -1285,7 +1285,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 23] +Andrews & Wright Expires February 17, 2020 [Page 23] Internet-Draft JSON Hyper-Schema August 2019 @@ -1341,7 +1341,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 24] +Andrews & Wright Expires February 17, 2020 [Page 24] Internet-Draft JSON Hyper-Schema August 2019 @@ -1397,7 +1397,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 25] +Andrews & Wright Expires February 17, 2020 [Page 25] Internet-Draft JSON Hyper-Schema August 2019 @@ -1453,7 +1453,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 26] +Andrews & Wright Expires February 17, 2020 [Page 26] Internet-Draft JSON Hyper-Schema August 2019 @@ -1509,7 +1509,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 27] +Andrews & Wright Expires February 17, 2020 [Page 27] Internet-Draft JSON Hyper-Schema August 2019 @@ -1565,7 +1565,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 28] +Andrews & Wright Expires February 17, 2020 [Page 28] Internet-Draft JSON Hyper-Schema August 2019 @@ -1621,7 +1621,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 29] +Andrews & Wright Expires February 17, 2020 [Page 29] Internet-Draft JSON Hyper-Schema August 2019 @@ -1677,7 +1677,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 30] +Andrews & Wright Expires February 17, 2020 [Page 30] Internet-Draft JSON Hyper-Schema August 2019 @@ -1733,7 +1733,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 31] +Andrews & Wright Expires February 17, 2020 [Page 31] Internet-Draft JSON Hyper-Schema August 2019 @@ -1789,7 +1789,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 32] +Andrews & Wright Expires February 17, 2020 [Page 32] Internet-Draft JSON Hyper-Schema August 2019 @@ -1845,7 +1845,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 33] +Andrews & Wright Expires February 17, 2020 [Page 33] Internet-Draft JSON Hyper-Schema August 2019 @@ -1901,7 +1901,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 34] +Andrews & Wright Expires February 17, 2020 [Page 34] Internet-Draft JSON Hyper-Schema August 2019 @@ -1957,7 +1957,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 35] +Andrews & Wright Expires February 17, 2020 [Page 35] Internet-Draft JSON Hyper-Schema August 2019 @@ -2013,7 +2013,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 36] +Andrews & Wright Expires February 17, 2020 [Page 36] Internet-Draft JSON Hyper-Schema August 2019 @@ -2069,7 +2069,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 37] +Andrews & Wright Expires February 17, 2020 [Page 37] Internet-Draft JSON Hyper-Schema August 2019 @@ -2125,7 +2125,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 38] +Andrews & Wright Expires February 17, 2020 [Page 38] Internet-Draft JSON Hyper-Schema August 2019 @@ -2181,7 +2181,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 39] +Andrews & Wright Expires February 17, 2020 [Page 39] Internet-Draft JSON Hyper-Schema August 2019 @@ -2237,7 +2237,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 40] +Andrews & Wright Expires February 17, 2020 [Page 40] Internet-Draft JSON Hyper-Schema August 2019 @@ -2293,7 +2293,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 41] +Andrews & Wright Expires February 17, 2020 [Page 41] Internet-Draft JSON Hyper-Schema August 2019 @@ -2349,7 +2349,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 42] +Andrews & Wright Expires February 17, 2020 [Page 42] Internet-Draft JSON Hyper-Schema August 2019 @@ -2405,7 +2405,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 43] +Andrews & Wright Expires February 17, 2020 [Page 43] Internet-Draft JSON Hyper-Schema August 2019 @@ -2461,7 +2461,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 44] +Andrews & Wright Expires February 17, 2020 [Page 44] Internet-Draft JSON Hyper-Schema August 2019 @@ -2517,7 +2517,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 45] +Andrews & Wright Expires February 17, 2020 [Page 45] Internet-Draft JSON Hyper-Schema August 2019 @@ -2573,7 +2573,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 46] +Andrews & Wright Expires February 17, 2020 [Page 46] Internet-Draft JSON Hyper-Schema August 2019 @@ -2629,7 +2629,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 47] +Andrews & Wright Expires February 17, 2020 [Page 47] Internet-Draft JSON Hyper-Schema August 2019 @@ -2685,7 +2685,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 48] +Andrews & Wright Expires February 17, 2020 [Page 48] Internet-Draft JSON Hyper-Schema August 2019 @@ -2741,7 +2741,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 49] +Andrews & Wright Expires February 17, 2020 [Page 49] Internet-Draft JSON Hyper-Schema August 2019 @@ -2797,7 +2797,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 50] +Andrews & Wright Expires February 17, 2020 [Page 50] Internet-Draft JSON Hyper-Schema August 2019 @@ -2853,7 +2853,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 51] +Andrews & Wright Expires February 17, 2020 [Page 51] Internet-Draft JSON Hyper-Schema August 2019 @@ -2909,7 +2909,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 52] +Andrews & Wright Expires February 17, 2020 [Page 52] Internet-Draft JSON Hyper-Schema August 2019 @@ -2965,7 +2965,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 53] +Andrews & Wright Expires February 17, 2020 [Page 53] Internet-Draft JSON Hyper-Schema August 2019 @@ -3021,7 +3021,7 @@ A.2. Responses and Errors -Andrews & Wright Expires February 11, 2020 [Page 54] +Andrews & Wright Expires February 17, 2020 [Page 54] Internet-Draft JSON Hyper-Schema August 2019 @@ -3077,7 +3077,7 @@ Appendix B. ChangeLog -Andrews & Wright Expires February 11, 2020 [Page 55] +Andrews & Wright Expires February 17, 2020 [Page 55] Internet-Draft JSON Hyper-Schema August 2019 @@ -3133,7 +3133,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 56] +Andrews & Wright Expires February 17, 2020 [Page 56] Internet-Draft JSON Hyper-Schema August 2019 @@ -3189,7 +3189,7 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 11, 2020 [Page 57] +Andrews & Wright Expires February 17, 2020 [Page 57] Internet-Draft JSON Hyper-Schema August 2019 @@ -3245,4 +3245,4 @@ Authors' Addresses -Andrews & Wright Expires February 11, 2020 [Page 58] +Andrews & Wright Expires February 17, 2020 [Page 58] diff --git a/work-in-progress/WIP-jsonschema-validation.html b/work-in-progress/WIP-jsonschema-validation.html index c33322a5..754c9cda 100644 --- a/work-in-progress/WIP-jsonschema-validation.html +++ b/work-in-progress/WIP-jsonschema-validation.html @@ -451,7 +451,7 @@ - + @@ -475,7 +475,7 @@ - + @@ -488,7 +488,7 @@ - + @@ -508,7 +508,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 February 11, 2020.

          +

          This Internet-Draft will expire on February 17, 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.

          diff --git a/work-in-progress/WIP-jsonschema-validation.txt b/work-in-progress/WIP-jsonschema-validation.txt index 4892f2ef..566ad141 100644 --- a/work-in-progress/WIP-jsonschema-validation.txt +++ b/work-in-progress/WIP-jsonschema-validation.txt @@ -5,10 +5,10 @@ Internet Engineering Task Force A. Wright, Ed. Internet-Draft Intended status: Informational H. Andrews, Ed. -Expires: February 11, 2020 +Expires: February 17, 2020 B. Hutton, Ed. Wellcome Sanger Institute - August 10, 2019 + August 16, 2019 JSON Schema Validation: A Vocabulary for Structural Validation of JSON @@ -47,13 +47,13 @@ Status of This Memo 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 February 11, 2020. + This Internet-Draft will expire on February 17, 2020. -Wright, et al. Expires February 11, 2020 [Page 1] +Wright, et al. Expires February 17, 2020 [Page 1] Internet-Draft JSON Schema Validation August 2019 @@ -109,7 +109,7 @@ Table of Contents -Wright, et al. Expires February 11, 2020 [Page 2] +Wright, et al. Expires February 17, 2020 [Page 2] Internet-Draft JSON Schema Validation August 2019 @@ -165,7 +165,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 3] +Wright, et al. Expires February 17, 2020 [Page 3] Internet-Draft JSON Schema Validation August 2019 @@ -221,7 +221,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 4] +Wright, et al. Expires February 17, 2020 [Page 4] Internet-Draft JSON Schema Validation August 2019 @@ -277,7 +277,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 5] +Wright, et al. Expires February 17, 2020 [Page 5] Internet-Draft JSON Schema Validation August 2019 @@ -333,7 +333,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 6] +Wright, et al. Expires February 17, 2020 [Page 6] Internet-Draft JSON Schema Validation August 2019 @@ -389,7 +389,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 7] +Wright, et al. Expires February 17, 2020 [Page 7] Internet-Draft JSON Schema Validation August 2019 @@ -445,7 +445,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 8] +Wright, et al. Expires February 17, 2020 [Page 8] Internet-Draft JSON Schema Validation August 2019 @@ -501,7 +501,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 9] +Wright, et al. Expires February 17, 2020 [Page 9] Internet-Draft JSON Schema Validation August 2019 @@ -557,7 +557,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 10] +Wright, et al. Expires February 17, 2020 [Page 10] Internet-Draft JSON Schema Validation August 2019 @@ -613,7 +613,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 11] +Wright, et al. Expires February 17, 2020 [Page 11] Internet-Draft JSON Schema Validation August 2019 @@ -669,7 +669,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 12] +Wright, et al. Expires February 17, 2020 [Page 12] Internet-Draft JSON Schema Validation August 2019 @@ -725,7 +725,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 13] +Wright, et al. Expires February 17, 2020 [Page 13] Internet-Draft JSON Schema Validation August 2019 @@ -781,7 +781,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 14] +Wright, et al. Expires February 17, 2020 [Page 14] Internet-Draft JSON Schema Validation August 2019 @@ -837,7 +837,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 15] +Wright, et al. Expires February 17, 2020 [Page 15] Internet-Draft JSON Schema Validation August 2019 @@ -893,7 +893,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 16] +Wright, et al. Expires February 17, 2020 [Page 16] Internet-Draft JSON Schema Validation August 2019 @@ -949,7 +949,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 17] +Wright, et al. Expires February 17, 2020 [Page 17] Internet-Draft JSON Schema Validation August 2019 @@ -1005,7 +1005,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 18] +Wright, et al. Expires February 17, 2020 [Page 18] Internet-Draft JSON Schema Validation August 2019 @@ -1061,7 +1061,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 19] +Wright, et al. Expires February 17, 2020 [Page 19] Internet-Draft JSON Schema Validation August 2019 @@ -1117,7 +1117,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 20] +Wright, et al. Expires February 17, 2020 [Page 20] Internet-Draft JSON Schema Validation August 2019 @@ -1173,7 +1173,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 21] +Wright, et al. Expires February 17, 2020 [Page 21] Internet-Draft JSON Schema Validation August 2019 @@ -1229,7 +1229,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 22] +Wright, et al. Expires February 17, 2020 [Page 22] Internet-Draft JSON Schema Validation August 2019 @@ -1285,7 +1285,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 23] +Wright, et al. Expires February 17, 2020 [Page 23] Internet-Draft JSON Schema Validation August 2019 @@ -1341,7 +1341,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 24] +Wright, et al. Expires February 17, 2020 [Page 24] Internet-Draft JSON Schema Validation August 2019 @@ -1397,7 +1397,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 25] +Wright, et al. Expires February 17, 2020 [Page 25] Internet-Draft JSON Schema Validation August 2019 @@ -1453,7 +1453,7 @@ Appendix B. Acknowledgments -Wright, et al. Expires February 11, 2020 [Page 26] +Wright, et al. Expires February 17, 2020 [Page 26] Internet-Draft JSON Schema Validation August 2019 @@ -1509,7 +1509,7 @@ Appendix C. ChangeLog -Wright, et al. Expires February 11, 2020 [Page 27] +Wright, et al. Expires February 17, 2020 [Page 27] Internet-Draft JSON Schema Validation August 2019 @@ -1565,7 +1565,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 28] +Wright, et al. Expires February 17, 2020 [Page 28] Internet-Draft JSON Schema Validation August 2019 @@ -1621,7 +1621,7 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 11, 2020 [Page 29] +Wright, et al. Expires February 17, 2020 [Page 29] Internet-Draft JSON Schema Validation August 2019 @@ -1677,4 +1677,4 @@ Authors' Addresses -Wright, et al. Expires February 11, 2020 [Page 30] +Wright, et al. Expires February 17, 2020 [Page 30] diff --git a/work-in-progress/WIP-relative-json-pointer.html b/work-in-progress/WIP-relative-json-pointer.html index caba5e68..8d5dfa42 100644 --- a/work-in-progress/WIP-relative-json-pointer.html +++ b/work-in-progress/WIP-relative-json-pointer.html @@ -397,7 +397,7 @@ - + @@ -421,8 +421,8 @@ - - + + @@ -438,7 +438,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 February 11, 2020.

          +

          This Internet-Draft will expire on February 17, 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.

          diff --git a/work-in-progress/WIP-relative-json-pointer.txt b/work-in-progress/WIP-relative-json-pointer.txt index f591fa18..7c23f8ff 100644 --- a/work-in-progress/WIP-relative-json-pointer.txt +++ b/work-in-progress/WIP-relative-json-pointer.txt @@ -5,7 +5,7 @@ Internet Engineering Task Force G. Luff Internet-Draft Intended status: Informational H. Andrews, Ed. -Expires: February 11, 2020 August 10, 2019 +Expires: February 17, 2020 August 16, 2019 Relative JSON Pointers @@ -33,7 +33,7 @@ Status of This Memo 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 February 11, 2020. + This Internet-Draft will expire on February 17, 2020. Copyright Notice @@ -53,7 +53,7 @@ Copyright Notice -Luff & Andrews Expires February 11, 2020 [Page 1] +Luff & Andrews Expires February 17, 2020 [Page 1] Internet-Draft Relative JSON Pointers August 2019 @@ -109,7 +109,7 @@ Table of Contents -Luff & Andrews Expires February 11, 2020 [Page 2] +Luff & Andrews Expires February 17, 2020 [Page 2] Internet-Draft Relative JSON Pointers August 2019 @@ -165,7 +165,7 @@ Internet-Draft Relative JSON Pointers August 2019 -Luff & Andrews Expires February 11, 2020 [Page 3] +Luff & Andrews Expires February 17, 2020 [Page 3] Internet-Draft Relative JSON Pointers August 2019 @@ -221,7 +221,7 @@ Internet-Draft Relative JSON Pointers August 2019 -Luff & Andrews Expires February 11, 2020 [Page 4] +Luff & Andrews Expires February 17, 2020 [Page 4] Internet-Draft Relative JSON Pointers August 2019 @@ -277,7 +277,7 @@ Internet-Draft Relative JSON Pointers August 2019 -Luff & Andrews Expires February 11, 2020 [Page 5] +Luff & Andrews Expires February 17, 2020 [Page 5] Internet-Draft Relative JSON Pointers August 2019 @@ -333,7 +333,7 @@ Internet-Draft Relative JSON Pointers August 2019 -Luff & Andrews Expires February 11, 2020 [Page 6] +Luff & Andrews Expires February 17, 2020 [Page 6] Internet-Draft Relative JSON Pointers August 2019 @@ -389,4 +389,4 @@ Authors' Addresses -Luff & Andrews Expires February 11, 2020 [Page 7] +Luff & Andrews Expires February 17, 2020 [Page 7] diff --git a/work-in-progress/WIP-schema.json b/work-in-progress/WIP-schema.json index 6855b335..6765ac43 100644 --- a/work-in-progress/WIP-schema.json +++ b/work-in-progress/WIP-schema.json @@ -6,7 +6,7 @@ "https://json-schema.org/draft/2019-WIP/vocab/applicator": true, "https://json-schema.org/draft/2019-WIP/vocab/validation": true, "https://json-schema.org/draft/2019-WIP/vocab/meta-data": true, - "https://json-schema.org/draft/2019-WIP/vocab/format": true, + "https://json-schema.org/draft/2019-WIP/vocab/format": false, "https://json-schema.org/draft/2019-WIP/vocab/content": true }, "$recursiveAnchor": true, From d12d04634ad473c8c26d69ae5a4f81543a667ce9 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Fri, 16 Aug 2019 20:35:50 -0700 Subject: [PATCH 065/395] Fix accidental reversion to draft-07 WIP index --- work-in-progress/index.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/work-in-progress/index.md b/work-in-progress/index.md index 820a38e3..e9de7c52 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -7,21 +7,20 @@ permalink: /work-in-progress * TOC {:toc} -## The Next Draft is Ready for Final Pre-Publication Review! +## The Next Draft (by whatever name) Is Ready for Final Pre-Publication Review! The forthcoming draft is now feature-frozen and has gone through the initial four-week pre-publication review period. _**UPDATE: July 28th, 2019** We continue to incorporate feedback and clarify sections of the new draft. We expect to finally publish the draft during August._ -To see what changes are involved, read the [release notes](./WIP-json-schema-release-notes.md). - The following sorts of feedback are particularly desired: * Clarity, readability, and accessibility to new readers * Contradictions, inconsistencies and other bugs * Anything so egregious that implementation would be infeasible or impossible -Work on the next draft will begin immediately after this one is published. +New features or major changes to existing features will be deferred to a future draft, +and work on the next draft will begin immediately after this one is published. ## What Is This Draft Called, Anyway? @@ -89,9 +88,9 @@ _**NOTE:** when published, the `.json` will be removed from the final URI_ * [WIP: meta/meta-data.json](/work-in-progress/meta/WIP-meta-data.json) (meta-data annotations, from the validation spec) * [WIP: meta/format.json](/work-in-progress/meta/WIP-format.json) (the format keyword, from the validation spec) * [WIP: meta/content.json](/work-in-progress/meta/WIP-content.json) (content keywords, from the validation spec) -* [WIP: meta/hyper-schema.json](/work-in-progress/meta/WIP-hyper-schema.json) (hyper-schema keywords, from the hyper-schema spec) +* [WIP: meta/hyper-schema.json](/work-in-progress/meta/WIP-hyper-schema.json) (hyper-schema keywords, from the hyper-shema spec) -### Output Schema +### Output schema: The new draft also introduces recommended output formats for reporting errors and annotations. @@ -101,12 +100,12 @@ _**NOTE:** when published, the `.json` will be removed from the final URI_ * [WIP: verbose-example.json](/work-in-progress/output/WIP-verbose-example.json) (example of the most verbose output format) * [WIP: hyper-schema.json](/work-in-progress/output/WIP-hyper-schema.json) (format used by the proposed hyper-schema test suite, and used in examples in the specification) -## Get Involved +## Providing Feedback and Tracking Progress in GitHub We are **particularly interested** in feedback on whether the wording and concepts is an improvement in terms of how easy it is to understand and learn the specifications. -Note that _all drafts have Changelog appendices_, for a concise list of notable changes. +Note that _all drafts have Changelog appendicies_, for a concise list of notable changes. * The active sources are on the ["master" branch of json-schema-org/json-schema-spec](https://github.com/json-schema-org/json-schema-spec) @@ -118,3 +117,4 @@ Note that _all drafts have Changelog appendices_, for a concise list of notable * [file an issue](https://github.com/json-schema-org/json-schema-spec/issues/new?milestone=draft-08) or [join us on Slack](https://join.slack.com/t/json-schema/shared_invite/enQtMjk1NDcyNDI2NTAwLTcyYmYwMjdmMmUxNzZjYzIxNGU2YjdkNzdlOGZiNjIwNDI2M2Y3NmRkYjA4YmMwODMwYjgyOTFlNWZjZjAyNjg) to submit feedback _(technically there is also a [mailing list](https://groups.google.com/forum/#!forum/json-schema) but it gets very little traffic and is not closely monitored)_ + From d1d3d3b03376085c0f165facf957636dd79a630b Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Fri, 16 Aug 2019 20:44:44 -0700 Subject: [PATCH 066/395] Add link to WIP change log / release notes back in --- work-in-progress/index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/work-in-progress/index.md b/work-in-progress/index.md index e9de7c52..4c45b145 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -43,6 +43,10 @@ and expiration dates of the IETF documents. This will make it more clear when a meta-schema is produced, and also make it more obvious that the IETF and meta-schema identifiers are not expected to match exactly. +## Change Log + +To see what changes are involved, read the [release notes](./WIP-json-schema-release-notes.md). + ## Pre-Built Review Documents To encourage as many reviewers as possible, pre-built documents are available. These may From a36fa9f4562edc61e3b72f303d709556c55f7d16 Mon Sep 17 00:00:00 2001 From: Andrey Onistchuk Date: Wed, 21 Aug 2019 23:11:58 -0700 Subject: [PATCH 067/395] From Code Generation: Scala Add Library supporting Scala Language --- implementations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implementations.md b/implementations.md index 4e7dde1f..9e721bd4 100644 --- a/implementations.md +++ b/implementations.md @@ -154,6 +154,8 @@ 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. - Java - [jsonschema-generator](https://github.com/victools/jsonschema-generator) (Apache 2.0) - generates schemas from Java types *supports Draft 7* +- Scala + - [scala-jsonschema](https://github.com/andyglow/scala-jsonschema) (Apache 2.0) - generates schemad out of Scala case classes #### From data From fc4c2f5cb3b9f028d693d2e146f45f1a4c25c97e Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Fri, 23 Aug 2019 00:03:13 +0100 Subject: [PATCH 068/395] I assume this is supposed to be referencing the geographical location schema? --- learn/examples/calendar.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learn/examples/calendar.schema.json b/learn/examples/calendar.schema.json index 7eab280b..7e235efc 100644 --- a/learn/examples/calendar.schema.json +++ b/learn/examples/calendar.schema.json @@ -41,7 +41,7 @@ "type": "string" }, "geo": { - "$ref": "http://example.com/geo.schema.json" + "$ref": "http://example.com/geographical-location.schema.json" } } } From 5ea13c5d7b3fb1cfe7c3455827a75e50907be370 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 27 Aug 2019 13:33:18 -0700 Subject: [PATCH 069/395] Update with the latest on publication --- index.md | 10 ++++++++-- work-in-progress/index.md | 15 ++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/index.md b/index.md index b32c29d4..fe9771cf 100644 --- a/index.md +++ b/index.md @@ -40,14 +40,20 @@ permalink: / ## Project Status -### Update as of 27 May 2019 +### Update as of 26 Aug 2019 -**The forthcoming draft is in [final review](work-in-progress).** +***All PRs from our final review feedback for the next draft have been posted!*** + +_The draft will be published as soon as we have sufficient reviews from the spec team and/or implementation owners. As this is summer vacation season, that may still take a few weeks._ This draft has also taken more time than expected because it tackles deep, long-term issues that have long been a challenge for JSON Schema. This includes building in a formal extensibility mechanism so that we can more easily draw a line to finalize the contents of the Core and Validation specifications. Additionally, numerous life issues reduced the availability of key contributors during the process. +And finally, the feedback process demonstrated that our first attempt at a publishable draft needed substantial additional work, adding another few months to the timeline. + +Since the most intractable problems are all addressed to one degree or another in this draft, we do not anticipate future drafts taking so long. + ### 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. diff --git a/work-in-progress/index.md b/work-in-progress/index.md index 4c45b145..c8d5a464 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -7,20 +7,17 @@ permalink: /work-in-progress * TOC {:toc} -## The Next Draft (by whatever name) Is Ready for Final Pre-Publication Review! +## The Next Draft (by whatever name) Is Approaching Publication! -The forthcoming draft is now feature-frozen and has gone through the initial four-week pre-publication review period. +The draft is feature-complete, including late additions based on our first try at a final review period several months ago. -_**UPDATE: July 28th, 2019** We continue to incorporate feedback and clarify sections of the new draft. We expect to finally publish the draft during August._ +We will be working on a more user-friendly and extensive guide to the new draft shortly. -The following sorts of feedback are particularly desired: +### Update as of 26 Aug 2019 -* Clarity, readability, and accessibility to new readers -* Contradictions, inconsistencies and other bugs -* Anything so egregious that implementation would be infeasible or impossible +***All PRs from our final review feedback have been posted.*** -New features or major changes to existing features will be deferred to a future draft, -and work on the next draft will begin immediately after this one is published. +_The draft will be published as soon as we have sufficient reviews from the spec team and/or implementation owners. As this is summer vacation season, that may still take a few weeks._ ## What Is This Draft Called, Anyway? From fbaa14eb872e177d297076f5510b20339ef087ee Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Wed, 28 Aug 2019 18:01:52 -0700 Subject: [PATCH 070/395] Fix release notes title --- work-in-progress/WIP-json-schema-release-notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/work-in-progress/WIP-json-schema-release-notes.md b/work-in-progress/WIP-json-schema-release-notes.md index 36fe86d9..30589b61 100644 --- a/work-in-progress/WIP-json-schema-release-notes.md +++ b/work-in-progress/WIP-json-schema-release-notes.md @@ -1,5 +1,5 @@ --- -title: JSON Schema Draft-07 Release Notes +title: JSON Schema Draft-2019/09 Release Notes layout: page --- From ff6a6d90c18137bd41ad9906c6d695ae84f9346e Mon Sep 17 00:00:00 2001 From: Malcolm Sparks Date: Mon, 2 Sep 2019 08:06:49 +0100 Subject: [PATCH 071/395] Add JUXT's Clojure jinx implementation --- _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 2bb74b33..3cc7f269 100644 --- a/_data/validator-libraries-modern.yml +++ b/_data/validator-libraries-modern.yml @@ -28,6 +28,10 @@ license: MIT - name: Clojure implementations: + - name: jinx + url: https://github.com/juxt/jinx + draft: [7] + license: MIT - name: json-schema url: https://github.com/luposlip/json-schema draft: [7] From d82ea38b85768de924f4106d7c447796fa5d05f9 Mon Sep 17 00:00:00 2001 From: Anthony Deschamps Date: Tue, 3 Sep 2019 15:38:39 -0400 Subject: [PATCH 072/395] 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 2732fb38fc552a3f42da401a27a02f4e49895c4e Mon Sep 17 00:00:00 2001 From: Stephan Plath Date: Wed, 4 Sep 2019 09:17:57 +0200 Subject: [PATCH 073/395] added code generation tools --- implementations.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/implementations.md b/implementations.md index 9e721bd4..818ae0e7 100644 --- a/implementations.md +++ b/implementations.md @@ -183,12 +183,16 @@ 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* +- 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. - 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 - [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* #### Web UI generation From e81cc1b138414e1eeb4af7b8644341687e59cc38 Mon Sep 17 00:00:00 2001 From: Stephan Plath Date: Wed, 4 Sep 2019 09:26:23 +0200 Subject: [PATCH 074/395] improved description of jsonCodeGen --- implementations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/implementations.md b/implementations.md index 818ae0e7..5c403105 100644 --- a/implementations.md +++ b/implementations.md @@ -187,8 +187,8 @@ are the only keywords that changed. - [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* -- 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. +- 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. - 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 b9984327f67d0c54e51b0cfd0ca68b94931c591b Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Mon, 9 Sep 2019 23:16:17 -0700 Subject: [PATCH 075/395] Updates for latest WIP, and change notes --- index.md | 4 +- work-in-progress/WIP-hyper-schema.json | 22 +- .../WIP-json-schema-release-notes.md | 180 +++- work-in-progress/WIP-jsonschema-core.html | 954 ++++++++++-------- work-in-progress/WIP-jsonschema-core.txt | 42 +- .../WIP-jsonschema-hyperschema.html | 495 ++++++++- .../WIP-jsonschema-hyperschema.txt | 28 +- .../WIP-jsonschema-validation.html | 36 +- .../WIP-jsonschema-validation.txt | 24 +- work-in-progress/WIP-links.json | 12 +- .../WIP-relative-json-pointer.html | 8 +- work-in-progress/WIP-schema.json | 16 +- work-in-progress/index.md | 16 +- work-in-progress/meta/WIP-applicator.json | 6 +- work-in-progress/meta/WIP-content.json | 6 +- work-in-progress/meta/WIP-core.json | 14 +- work-in-progress/meta/WIP-format.json | 6 +- work-in-progress/meta/WIP-hyper-schema.json | 8 +- work-in-progress/meta/WIP-meta-data.json | 6 +- work-in-progress/meta/WIP-validation.json | 6 +- work-in-progress/output/WIP-hyper-schema.json | 6 +- work-in-progress/output/WIP-schema.json | 4 +- .../output/WIP-verbose-example.json | 28 +- 23 files changed, 1323 insertions(+), 604 deletions(-) diff --git a/index.md b/index.md index fe9771cf..eafbc63d 100644 --- a/index.md +++ b/index.md @@ -40,11 +40,11 @@ permalink: / ## Project Status -### Update as of 26 Aug 2019 +### Update as of 8 September 2019 ***All PRs from our final review feedback for the next draft have been posted!*** -_The draft will be published as soon as we have sufficient reviews from the spec team and/or implementation owners. As this is summer vacation season, that may still take a few weeks._ +_The draft will be published as soon as we have sufficient reviews from the spec team and/or implementation owners. As this is summer vacation season, that may still take a few weeks. As of September 8th, all but one team member have completed their reviews, and the last team member is now looking at the remaining PRs._ This draft has also taken more time than expected because it tackles deep, long-term issues that have long been a challenge for JSON Schema. This includes building in a formal extensibility mechanism so that we can more easily draw a line to finalize the contents of the Core and Validation specifications. diff --git a/work-in-progress/WIP-hyper-schema.json b/work-in-progress/WIP-hyper-schema.json index 406455d3..28f9ad4f 100644 --- a/work-in-progress/WIP-hyper-schema.json +++ b/work-in-progress/WIP-hyper-schema.json @@ -1,21 +1,21 @@ { - "$schema": "http://json-schema.org/draft/2019-WIP/hyper-schema#", - "$id": "http://json-schema.org/draft/2019-WIP/hyper-schema", + "$schema": "https://json-schema.org/draft/2019-09/hyper-schema", + "$id": "https://json-schema.org/draft/2019-09/hyper-schema", "$vocabulary": { - "https://json-schema.org/draft/2019-WIP/vocab/core": true, - "https://json-schema.org/draft/2019-WIP/vocab/applicator": true, - "https://json-schema.org/draft/2019-WIP/vocab/validation": true, - "https://json-schema.org/draft/2019-WIP/vocab/meta-data": true, - "https://json-schema.org/draft/2019-WIP/vocab/format": true, - "https://json-schema.org/draft/2019-WIP/vocab/content": true, - "https://json-schema.org/draft/2019-WIP/vocab/hyper-schema": true + "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://json-schema.org/draft/2019-09/vocab/meta-data": true, + "https://json-schema.org/draft/2019-09/vocab/format": false, + "https://json-schema.org/draft/2019-09/vocab/content": true, + "https://json-schema.org/draft/2019-09/vocab/hyper-schema": true }, "$recursiveAnchor": true, "title": "JSON Hyper-Schema", "allOf": [ - {"$ref": "http://json-schema.org/draft/2019-WIP/schema"}, - {"$ref": "http://json-schema.org/draft/2019-WIP/meta/hyper-schema"} + {"$ref": "https://json-schema.org/draft/2019-09/schema"}, + {"$ref": "https://json-schema.org/draft/2019-09/meta/hyper-schema"} ], "links": [ { diff --git a/work-in-progress/WIP-json-schema-release-notes.md b/work-in-progress/WIP-json-schema-release-notes.md index 30589b61..626ac96d 100644 --- a/work-in-progress/WIP-json-schema-release-notes.md +++ b/work-in-progress/WIP-json-schema-release-notes.md @@ -3,50 +3,160 @@ title: JSON Schema Draft-2019/09 Release Notes layout: page --- -There are a few non-breaking changes with keywords being deprecated and slates -for removal, and a few newer keywords based on community feedback. Internally -there has been a lot of restructuring through a new concept called vocabularies, -but on the whole things are mostly the same. +For the vast majority of schema authors, we hope that these changes are minimally disruptive. The most likely to be frustrating is `format`, which we decided was acceptable as many schema authors are already extremely frustrated by its inconsistent behavior. + +For implementors, there is a lot more to consider, and further guidance on implementation topics will be forthcoming. * TOC {:toc} -- Update to RFC 8359 for JSON specification -- Add the concept of formal vocabularies, and how they can be recognized through meta-schemas -- Formalized annotation collection -- Moved applicator keywords from the Validation specification as their own vocabulary -- Define "$ref" behavior in terms of the assertion, applicator, and annotation model -- Note undefined behavior for "$ref" targets involving unknown keywords -- Additional guidance on initial base URIs beyond network retrieval -- Allow "schema" media type parameter for "application/schema+json" +For a basic list of changes to each document, see their change logs: +* [Core](WIP-jsonschema-core.html#rfc.appendix.G) +* [Validation](WIP-jsonschema-validation.html#rfc.appendix.C) +* [Hyper-Schema](WIP-jsonschema-hyperschema.html#rfc.appendix.B) + +### Incompatible Changes + +* By default, `format` is no longer an assertion. This has been done because the inconsistent implementation of `format` as an assertion has been an endless source of surprising problems for schema authors. The default behavior will now be predictable, if not ideal. There are several ways to turn on assertion functionality, as explained below. However, we recommend doing semantic validation in the application layer. +* Plain name fragments are no longer defined with `$id`, but instead with the new keyword `$anchor` (which has a different syntax). +* `$id` cannot contain a fragment anymore (except possibly an empty fragment, although that is discouraged). +* In cases where multiple URIs could be used for the same schema, some are now discouraged. These are believed to have rarely been used, as the behavior involved was fairly confusing and not well explained until the updated version of draft-07 (draft-handrews-json-schema-01). If this doesn't mean much to you, you are probably safe. + +### Semi-incompatible Changes + +The old syntax for these keywords is not an error (and the default meta-schema still validates them), so implementations can therefore offer a compatibility mode. However, migrating to the new keywords is straightforward and should be preferred. + +* `definitions` is now `$defs` +* `dependencies` has been split into `dependentSchemas` and `dependentRequired` + +### Annotations, Errors, and Outputs + +[Annotation keywords](WIP-jsonschema-core.html#rfc.section.7.7) such as `title`, `readOnly`, and `default` have always been a part of JSON Schema, but without any guidance on how to make use of them. This draft formalizes how implementations can make annotation information available to applications. + +Similarly, there has not previously been guidance on what constitutes useful error reporting when validation fails. + +To solve both of these problems, we now recommend that implementations support one or more of standardized [output formats](WIP-jsonschema-core.html#rfc.section.10). + +### Keyword Changes + +All keywords have now been organized into [vocabularies](WIP-jsonschema-core.html#rfc.section.8.1), with the Core and Validation specifications containing multiple vocabularies. In this process, some keywords have moved from Validation into Core. + +#### Core Vocabulary + +[Core Specification, Section 8](WIP-jsonschema-core.html#rfc.section.8) + +keyword | change | notes +---- | ---- | ---- +[`$anchor`](WIP-jsonschema-core.html#rfc.section.8.2.3) | **new** | Replaces the `#plain-name` form of `$id`, with a different syntax and approach +[`$defs` (renamed from `definitions`)](WIP-jsonschema-core.html#rfc.section.8.2.5) | **renamed** | Note that the standard meta-schema still reserves `definitions` for backwards compatibility +[`$id`](WIP-jsonschema-core.html#rfc.section.8.2.2) | **changed** | Only URI-references without fragments are allowed; see `$anchor` for a replacement for plain-name fragments; all other fragments in `$id` had undefined behavior previously +[`$recursiveAnchor` and `$recursiveRef`](WIP-jsonschema-core.html#rfc.section.8.2.4.2) | **new** | Used for extending recursive schemas such as meta-schemas +[`$ref`] | **changed** | Other keywords are now allowed alongside of it +[`$vocabulary`](WIP-jsonschema-core.html#rfc.section.8.1) | **new** | Has effects only in meta-schemas, and is used to control what keywords an implementation must or can support in order to process a schema using that meta-schema -### Keywords +#### Applicator Vocabulary -* Eight brand new keywords were added -* One keyword was renamed -* One keyword was split in half -* One keyword in Core changed behavior -* One keyword in Hyper-Schema changed behavior +[Core Specification, Section 9](WIP-jsonschema-core.html#rfc.section.9) + +These keywords were formerly found in the Validation Specification. keyword | change | notes ---- | ---- | ---- -[`"definitions"`](json-schema-core.html#rfc.section.TODO) | **renamed** | use new "$defs" core keyword -[`"unevaluatedProperties" and "unevaluatedItems"`](json-schema-core.html#rfc.section.TODO) | **added** | -[`"$ref"`](json-schema-core.html#rfc.section.TODO) | **changed** | can now have siblings (keywords next to it) -[`"$defs"`](json-schema-core.html#rfc.section.10.TODO) | **added** | moved over to core from validation -`"dependencies"` | **removed** | use "dependentRequired" or "dependentSchemas" -[`"dependentRequired"`](json-schema-core.html#rfc.section.10.TODO) | **added** | added to core schema -[`"dependentSchemas"`](json-schema-core.html#rfc.section.10.TODO) | **added** | added to core schema -[`"minContains" and "maxContains"`](json-schema-validation.html#rfc.section.TODO) | added | -[`"contentSchema"`](json-schema-validation.html#rfc.section.TODO) | added | allows applying a schema to a string-encoded document -[`"deprecated"`](json-schema-validation.html#rfc.section.TODO) | added | -[`"rel"`](json-schema-hyperschema.html#rfc.section.TODO) | **changed** | Can now be an array of values instead of just a string - -### Formats - -Two formats were added. +[`dependentSchemas` (split from `dependencies`)](WIP-jsonschema-core.html#rfc.section.9.2.2.4) | **split** | This is the schema form of `dependencies`; note that the standard meta-schema still reserves `dependencies` for backwards compatibility +[`unevaluatedItems`](WIP-jsonschema-core.html#rfc.section.9.3.1.3) | **new** | Similar to `additionalItems`, but can "see" into subschemas and across references +[`unevaluatedProperties`](WIP-jsonschema-core.html#rfc.section.9.3.2.4) | **new** | Similar to `additionalProperties`, but can "see" into subschemas and across references + +The other applicator vocabulary keywords are `items`, `additionalItems`, `properties`, `patternProperties`, `additionalProperties`, `anyOf`, `allOf`, `oneOf`, `not`, `if`, `then`, `else`. + +#### Validation Vocabulary + +[Validation Specification, Section 6](WIP-jsonschema-validation.html#rfc.section.6) + +keyword | change | notes +---- | ---- | ---- +[`dependentRequired` (split from `dependencies`)](WIP-jsonschema-validation.html#rfc.section.6.5.4) | **split** | This is the string array form of `dependencies`; note that the standard meta-schema still reserves `dependencies` for backwards compatibility +[`maxContains` and `minContains`](WIP-jsonschema-validation.html#rfc.section.6.4.4) | **new** | Assertion for controlling how many times a subschema must be matched within an array + + +#### Format Vocabulary + +[Validation Specification, Section 7](WIP-jsonschema-validation.html#rfc.section.7) + +The `format` keywords has always been problematic due to its optional nature. There has never been a way to ensure that the implementation processing your schema supports `format` at all, or if it does, to what degree it validates each type of format. In theory, since each format references a standard specification, if a format is supported, it should behave consistently. In practice, this is not the case. + +There are two ways for an application to validate formats: It can rely on a JSON Schema implementation to validate them (which may or may not have the expected results), or it can note where the `format` keyword has been used and perform its own validation based on that. This second approach is supported by treating `format` as an [annotation keyword](WIP-jsonschema-core.html#rfc.section.7.7) and supporting the [basic, detailed, or verbose output formats](WIP-jsonschema-core.html#rfc.section.10.4.2). + +To impose some predictability on this system, the behavior has changed in several ways, as illustrated below. The key difference here is that `format` validation is now predictably off by default, but can be configured to be turned on. In draft-07, it was on (but possibly unimplemented) by default and could be configured to be turned off. + +In the following charts, the "supported" column refers to whether and (for `2019-09`) to what degree the implementation claims to support the `format` keyword. The "configuration" column refers to whether some non-default behavior for `format` is configured somehow (in a configuration file, or through a command-line option, or whatever). + +**Summary of draft-07 behavior** + +supported | configuration | outcome +----------- | ------------- | ------------- +no | n/a | not validated +yes | _default_ (on)| inconsistently validated +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** + +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. + +* "best effort" validation is a fairly weak requirement, which matches how things work in practice today. Simple formats are probably fully valid, complex formats may be minimally validated or even not validated at all. + +* "full syntax" validation means that you can expect a reasonably thorough syntactic validation, probably corresponding to whatever commonly available libraries can do in the implementation language. For formats such as IP addresses and dates, this is expected to be complete validation. For more complex formats such as email addresses, support will probably still vary significantly. It's unclear how many implementations have ever provided this level of support. + +* An outcome of _vocabulary error_ means that the implementation will refuse to process the schema as it cannot satisfy the vocabulary requirement. + +supported | configuration | vocabulary | outcome +----------- | -------------- | ------------- | ------------- +no | n/a | false | not validated +no | n/a | true | _vocabulary error_ +best effort | _default_ (off)| false | not validated +best effort | _default_ (off)| true | _vocabulary error_ +best effort | on | false | best effort validation +best effort | on | true | _vocabulary error_ +full syntax | _default_ (off)| false | not validated +full syntax | _default_ (off)| true | full syntax validation +full syntax | on | false | full syntax validation +full syntax | on | true | full syntax validation + +Note that, given that almost no draft-07 or earlier implementations have offered strict and complete validation of every single format, it seems unlikely that any implementations will support option 3 option in practice. + +Additionally, two new formats were added, and a specification reference was updated: format | change | notes ---- | ---- | ---- -[`"uuid"`](json-schema-validation.html#rfc.section.7.3.5) | added | A string instance is valid against this attribute if it is a valid string representation of a UUID, according to RFC4122 -[`"duration"`](json-schema-validation.html#rfc.section.7.3.5) | added | The duration format is from the ISO 8601 ABNF as given in Appendix A of RFC 3339 +[`"duration"`](WIP-jsonschema-validation.html#rfc.section.7.3.1) | **added** | The duration format is from the ISO 8601 ABNF as given in Appendix A of RFC 3339 +[`"hostname"` and `"idn-hostname"`](WIP-jsonschema-validation.html#rfc.section.7.3.3) | **updated** | Use RFC 1123 instead of RFC 1034; this allows for a leading digit +[`"uuid"`](WIP-jsonschema-validation.html#rfc.section.7.3.5) | **added** | A string instance is valid against this attribute if it is a valid string representation of a UUID, according to RFC4122 + + +#### Content Vocabulary + +[Validation Specification, Section 8](WIP-jsonschema-validation.html#rfc.section.8) + +These keywords are now specified purely as annotations, and never assertions. Some guidance is provided around how an implementation can optionally offer further automatic processing of this information outside of the validation process. + +keyword | change | notes +---- | ---- | ---- +[`contentEncoding`](WIP-jsonschema-validation.html#rfc.section.8.3) | **updated** | Encodings from RFC 4648 are now allowed, and take precedence over RFC 2045 when there is a difference +[`contentSchema`](WIP-jsonschema-validation.html#rfc.section.8.5) | **added** | Schema for use with the decoded content string; note that it is _not_ automatically applied as not all content media types can be understood in advance + +#### Meta-Data Vocabulary + +[Validation Specification, Section 9](WIP-jsonschema-validation.html#rfc.section.9) + +keyword | change | notes +---- | ---- | ---- +[`deprecated`](WIP-jsonschema-validation.html#rfc.section.9.3) | **added** | Used to indicate that a field is deprecated in some application-specific manner + +#### Hyper-Schema Vocabulary + +[Hyper-Schema Specification, Sections 5 and 6](WIP-jsonschema-hyperschema.html#rfc.section.5) + +keyword | change | notes +---- | ---- | ---- +[`rel`](WIP-jsonschema-hyperschema.html#rfc.section.6.2.1) | **changed** | Can now be an array of values instead of just a string diff --git a/work-in-progress/WIP-jsonschema-core.html b/work-in-progress/WIP-jsonschema-core.html index d5e562f0..6e6dda93 100644 --- a/work-in-progress/WIP-jsonschema-core.html +++ b/work-in-progress/WIP-jsonschema-core.html @@ -388,7 +388,7 @@ - + @@ -400,25 +400,26 @@ - - - - - - + + + + + + + + - - - + - - + + + @@ -454,8 +455,17 @@ - - + + + + + + + + + + + @@ -463,8 +473,8 @@ - - + + @@ -488,7 +498,7 @@ - + @@ -505,7 +515,7 @@ - + @@ -513,7 +523,7 @@
          [json-hyper-schema]A. Wright, Ed.
          Expires: February 11, 2020August 10, 2019Expires: February 17, 2020August 16, 2019
          H. Andrews, Ed.
          Expires: February 11, 2020Expires: February 17, 2020
          August 10, 2019August 16, 2019
          H. Andrews, Ed.
          Expires: February 11, 2020August 10, 2019Expires: February 17, 2020August 16, 2019
          H. Andrews, Ed.
          Expires: February 17, 2020Expires: March 11, 2020
          August 16, 2019September 8, 2019

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

          + 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.

          @@ -525,7 +535,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 February 17, 2020.

          +

          This Internet-Draft will expire on March 11, 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.

          @@ -563,7 +573,7 @@

          Table of Contents

        • 4.3.4. Meta-Schemas
        • -
        • 4.3.5. Root Schema and Subschemas +
        • 4.3.5. Root Schema and Subschemas and Resources
    • 5. Fragment Identifiers
    • @@ -587,19 +597,23 @@

      Table of Contents

    • 7.3. Default Behaviors
    • -
    • 7.4. Applicators +
    • 7.4. Identifiers
    • -
    • 7.5. Assertions +
    • 7.6. Annotations +
  • 8. The JSON Schema Core Vocabulary +
  • 7.8. Reserved Locations +
  • +
  • 8. The JSON Schema Core Vocabulary
  • 8.2. Base URI and Dereferencing +
  • 8.2. Base URI, Anchors, and Dereferencing
  • 8.3. Comments With "$comment"
  • @@ -695,9 +707,27 @@

    Table of Contents

  • 14.2. Informative References
  • -
  • Appendix A. Acknowledgments +
  • Appendix A. Schema identification examples +
  • +
  • Appendix B. Manipulating schema documents and references +
  • +
  • Appendix C. Example of recursive schema extension +
  • +
  • Appendix D. Working with vocabularies
  • -
  • Appendix B. ChangeLog +
  • Appendix E. References and generative use cases +
  • +
  • Appendix F. Acknowledgments +
  • +
  • Appendix G. ChangeLog
  • Authors' Addresses
  • @@ -785,15 +815,19 @@

    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 three categories:

    +

    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

    @@ -823,10 +857,11 @@

    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 +4.3.5. Root Schema and Subschemas and Resources

    -

    The root schema is the schema that comprises the entire JSON document in question.

    -

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

    +

    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:

     
     {
    @@ -837,8 +872,9 @@ 

    }

    -

    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.

    +

    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

    @@ -846,7 +882,7 @@

    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 "$id" keyword section.

    +

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

    6. General Considerations

    @@ -881,7 +917,8 @@

    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

    +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.

    @@ -891,11 +928,12 @@

    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

    +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 the document's root schema.

    +

    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.

    @@ -908,29 +946,35 @@

    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. 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.4.1. Referenced and Referencing Schemas +7.4. Identifiers

    -

    As noted in Section 7.4, 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.

    +

    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. Assertions +7.5. Applicators

    -

    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.

    +

    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. 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:

    +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:

     
     {
    @@ -940,18 +984,18 @@ 

    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.6. Annotations +

    +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.

    -

    The default behavior is simply to collect all values in a list in indeterminate order. Given the extensibility of keywords, including applicators, it is not possible to define a universally predictable order of processing.

    -

    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.

    -

    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.

    -

    -7.6.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:

    +

    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.

    +

    The default behavior is simply to collect all values in a list in indeterminate order. Given the extensibility of keywords, including applicators, it is not possible to define a universally predictable order of processing.

    +

    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.

    +

    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.

    +

    +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
    • @@ -962,11 +1006,11 @@

    -

    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.

    -

    -7.6.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:

    +

    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.

    +

    +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.

     
    @@ -1009,15 +1053,15 @@ 

    }

    -

    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.6.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:

    +

    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:

     
     {
    @@ -1034,18 +1078,22 @@ 

    }

    -

    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.6.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.

    +

    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 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-08/vocab/core>.

    -

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

    +

    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 @@ -1068,16 +1116,16 @@

    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 root schema. It MUST NOT appear in subschemas. If absent from the root schema, the resulting behavior 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.

    +

    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. [CREF3]Vocabulary documents may be added shortly, or in the next draft. 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 MAY choose to proceed with processing such schemas.

    -

    When processing a schema that uses unrecognized vocabularies, keywords declared by those vocabularies are treated like any other unrecognized keyword, and ignored.

    +

    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.

    @@ -1087,7 +1135,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.

    +

    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.

    @@ -1096,303 +1144,129 @@

    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.1.5. 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.

    -

    -8.1.6. Example Meta-Schema With Vocabulary Declarations -

    -

    This meta-schema explicitly declares both the Core and Applicator vocabularies, and combines their meta-schemas with an "allOf". It additionally restricts the usage of the Applicator vocabulary by forbidding the keyword prefixed with "unevaluated". It also describes a keyword, "localKeyword", that is not part of either vocabulary. Note that it is its own meta-schema, as it relies on both the Core vocabulary (as all schemas do) and the Applicator vocabulary (for "allOf").

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

    As shown above, even though each of the referenced standard meta-schemas declares its corresponding vocabulary, this new meta-schema must re-declare them for itself. It would be valid to leave the core vocabulary out of the "$vocabulary" keyword, but it needs to be referenced through the "allOf" keyword in order for its terms to be validated. There is no special case for validation of core keywords.

    -

    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.

    -8.2. Base URI and Dereferencing

    +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

    +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 defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. A subschema's "$id" is resolved against the base URI of its parent schema. If no parent schema defines an explicit base URI with "$id", the base URI is that of the entire document, as determined per RFC 3986 section 5.

    -

    If present, the value for this keyword MUST be a string, and MUST represent a valid URI-reference. This value SHOULD be normalized, and SHOULD NOT be an empty fragment <#> or an empty string <>.

    +

    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), or this absolute URI but with an empty fragment.

    +

    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. Changing the base URI within a schema file

    -

    When an "$id" sets the base URI, the object containing that "$id" and all of its subschemas can be identified by using a JSON Pointer fragment starting from that location. This is true even of subschemas that further change the base URI. Therefore, a single subschema may be accessible by multiple URIs, each consisting of base URI declared in the subschema or a parent, along with a JSON Pointer fragment identifying the path from the schema object that declares the base to the subschema being identified. Examples of this are shown in section 8.2.2.4.

    -

    -8.2.2.3. 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.

    -

    To specify such a subschema identifier, the "$id" keyword is set to a URI reference with a plain name fragment (not a JSON Pointer fragment). This value MUST begin with the number sign that specifies a fragment ("#"), then a letter ([A-Za-z]), followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), or periods (".").

    -

    The effect of using a fragment in "$id" that isn't blank or doesn't follow the plain name syntax is undefined. [CREF4]How should an "$id" URI reference containing a fragment with other components be interpreted? There are two cases: when the other components match the current base URI and when they change the base URI.

    -

    -8.2.2.4. Schema identification examples +8.2.2.2. JSON Pointer fragments and embedded schema resources

    -

    Consider the following schema, which shows "$id" being used to identify the root schema, change the base URI for subschemas, and assign plain name fragments to subschemas:

    +

    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/root.json",
    -    "$defs": {
    -        "A": { "$id": "#foo" },
    -        "B": {
    -            "$id": "other.json",
    -            "$defs": {
    -                "X": { "$id": "#bar" },
    -                "Y": { "$id": "t/inner.json" }
    -            }
    -        },
    -        "C": {
    -            "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f"
    -        }
    -    }
    +  "$id": "https://example.com/foo",
    +  "items": {
    +    "$id": "https://example.com/bar",
    +    "additionalProperties": { }
    +  }
     }
     
                                 
    -

    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 Section 5 above:

    -

    - -
    -
    # (document root)
    -
    -
    -
    -
    https://example.com/root.json
    -
    -
    https://example.com/root.json#
    -
    -

    -
    -
    #/$defs/A
    -
    -
    -
    -
    https://example.com/root.json#foo
    -
    -
    https://example.com/root.json#/$defs/A
    -
    -

    -
    -
    #/$defs/B
    -
    -
    -
    -
    https://example.com/other.json
    -
    -
    https://example.com/other.json#
    -
    -
    https://example.com/root.json#/$defs/B
    -
    -

    -
    -
    #/$defs/B/$defs/X
    -
    -
    -
    -
    https://example.com/other.json#bar
    -
    -
    https://example.com/other.json#/$defs/X
    -
    -
    https://example.com/root.json#/$defs/B/$defs/X
    -
    -

    -
    -
    #/$defs/B/$defs/Y
    -
    -
    -
    -
    https://example.com/t/inner.json
    -
    -
    https://example.com/t/inner.json#
    -
    -
    https://example.com/other.json#/$defs/Y
    -
    -
    https://example.com/root.json#/$defs/B/$defs/Y
    -
    -

    -
    -
    #/$defs/C
    -
    -
    -
    -
    urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f
    -
    -
    urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f#
    -
    -
    https://example.com/root.json#/$defs/C
    -
    -

    -
    -
    - -

    -

    -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 "$recursiveRef" are applicator keywords, applying the referenced schema to the instance. "$recursiveAnchor" is a helper keyword that controls how the referenced schema of "$recursiveRef" is determined.

    -

    As the value 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.3.1. Direct References with "$ref" -

    -

    The "$ref" keyword is used to reference a statically identified schema.

    -

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

    -

    -8.2.3.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 ("#").

    -

    Extending a recursive schema with "$ref" alone involves redefining all recursive references in the source schema to point to the root of the extension. This produces the correct recursive behavior in the extension, which is that all recursion should reference the root of the extension.

    -

    Consider the following two schemas. The first schema, identified as "original" as it is the schema to be extended, describes an object with one string property and one recursive reference property, "r". The second schema, identified as "extension", references the first, and describes an additional "things" property, which is an array of recursive references. It also repeats the description of "r" from the original schema.

    +

    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":

     
     {
    -    "$schema": "https://json-schema.org/draft/2019-WIP/schema#",
    -    "$id": "https://example.com/original",
    -
    -    "properties": {
    -        "name": {
    -            "type": "string"
    -        },
    -        "r": {
    -            "$ref": "#"
    -        }
    -    }
    +  "$id": "https://example.com/foo",
    +  "items": {
    +    "$ref": "bar"
    +  }
     }
     
     {
    -    "$schema": "https://json-schema.org/draft/2019-WIP/schema#",
    -    "$id": "https://example.com/extension",
    -
    -    "$ref": "original",
    -    "properties": {
    -        "r": {
    -            "$ref": "#"
    -        },
    -        "things": {
    -            "type": "array"
    -            "items": {
    -                "$ref": "#"
    -            }
    -        }
    -    }
    +  "$id": "https://example.com/bar",
    +  "additionalProperties": { }
     }
     
                                 
    -

    This apparent duplication is important because it resolves to "https://example.com/extension#", meaning that for instance validated against the extension schema, the value of "r" must be valid according to the extension, and not just the original schema as "r" was described there.

    -

    This approach is fine for a single recursive field, but the more complicated the original schema, the more redefinitions are necessary in the extension. This leads to a verbose and error-prone extension, which must be kept synchronized with the original schema if the original changes its recursive fields. This approach can be seen in the meta-schema for JSON Hyper-Schema in all prior drafts.

    -

    -8.2.3.2.1. Enabling Recursion with "$recursiveAnchor"

    -

    The desired behavior is for the recursive reference, "r", in the original schema to resolve to the original schema when that is the only schema being used, but to resolve to the extension schema when using the extension. Then there would be no need to redefine the "r" property, or others like it, in the extension.

    -

    In order to create a recursive reference, we must do three things:

    - -
      -
    • In our original schema, indicate that the schema author intends for it to be extensible recursively.
    • -
    • In our extension schema, indicate that it is intended to be a recursive extension.
    • -
    • Use a reference keyword that explicitly activates the recursive behavior at the point of reference.
    • -
    - -

    These three things together ensure that all schema authors are intentionally constructing a recursive extension, which in turn gives all uses of the regular "$ref" keyword confidence that it only behaves as it appears to, using lexical scoping.

    -

    The "$recursiveAnchor" keyword is how schema authors indicate that a schema can be extended recursively, and be a recursive schema. This keyword MAY appear in the root schema of a schema document, and MUST NOT appear in any subschema.

    -

    The value of "$recursiveAnchor" MUST be of type boolean, and MUST be true. The value false is reserved for possible future use.

    -

    -8.2.3.2.2. Dynamically recursive references with "$recursiveRef"

    -

    The "$recursiveRef" keyword behaves identically to "$ref", except that if the referenced schema has "$recursiveAnchor" set to true, then the implementation MUST examine the dynamic scope for the outermost (first seen) schema document with "$recursiveAnchor" set to true. If such a schema document exists, then the target of the "$recursiveRef" MUST be set to that document's URI, in place of the URI produced by the rules for "$ref".

    -

    Note that if the schema referenced by "$recursiveRef" does not contain "$recursiveAnchor" set to true, or if there are no other "$recursiveAnchor" keywords set to true anywhere further back in the dynamic scope, then "$recursiveRef"'s behavior is identical to that of "$ref".

    -

    With this in mind, we can rewrite the previous example:

    -
    -
    -{
    -    "$schema": "https://json-schema.org/draft/2019-WIP/schema#",
    -    "$id": "https://example.com/original",
    -    "$recursiveAnchor": true,
    -
    -    "properties": {
    -        "name": {
    -            "type": "string"
    -        },
    -        "r": {
    -            "$recursiveRef": "#"
    -        }
    -    }
    -}
    -
    -{
    -    "$schema": "https://json-schema.org/draft/2019-WIP/schema#",
    -    "$id": "https://example.com/extension",
    -    "$recursiveAnchor": true,
    -
    -    "$ref": "original",
    -    "properties": {
    -        "things": {
    -            "type": "array"
    -            "items": {
    -                "$recursiveRef": "#"
    -            }
    -        }
    -    }
    -}
    -
    -                                
    -

    Note that the "r" property no longer appears in the extension schema. Instead, all "$ref"s have been changed to "$recursiveRef"s, and both schemas have "$recursiveAnchor" set to true in their root schema.

    -

    When using the original schema on its own, there is no change in behavior. The "$recursiveRef" does lead to a schema where "$recursiveAnchor" is set to true, but since the original schema is the only schema document in the dynamics scope (it references itself, and does not reference any other schema documents), the behavior is effectively the same as "$ref".

    -

    When using the extension schema, the "$recursiveRef" within that schema (for the array items within "things") also effectively behaves like "$ref". The extension schema is the outermost dynamic scope, so the reference target is not changed.

    -

    In contrast, when using the extension schema, the "$recursiveRef" for "r" in the original schema now behaves differently. Its initial target is the root schema of the original schema document, which has "$recursiveAnchor" set to true. In this case, the outermost dynamic scope that also has "$recursiveAnchor" set to true is the extension schema. So when using the extensions schema, "r"'s reference in the original schema will resolve to "https://example.com/extension#", not "https://example.com/original#".

    -

    -8.2.3.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.3.4. References to Possible Non-Schemas

    -

    Subschema objects (or booleans) are recognized by their use with known applicator keywords. These keywords may be 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. [CREF5]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.3.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 section 8.2.2.4.

    -

    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.3.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:

    +

    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. [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 used to reference a statically identified schema. 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. [CREF9]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. [CREF10]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".

    +

    +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. [CREF11]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:

     
     {
    @@ -1403,7 +1277,7 @@ 

    }, "$defs": { "single": { - "$id": "#item", + "$anchor": "item", "type": "object", "additionalProperties": { "$ref": "other.json" } } @@ -1411,13 +1285,14 @@

    }

    -

    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. [CREF6]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.4. Schema Re-Use With "$defs"

    -

    The "$defs" keyword provides a standardized 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.

    +

    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. [CREF12]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.

     
     {
    @@ -1432,16 +1307,16 @@ 

    }

    -

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

    +

    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 is reserved 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.

    +

    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-08/vocab/applicator>.

    -

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

    +

    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

    @@ -1626,7 +1501,7 @@

    The absolute, dereferenced location of the validating keyword. The value MUST be expressed as an absolute URI, and it MUST NOT include by-reference applicators such as "$ref" or "$recursiveRef".

     
    -https://json-schema.org/draft/2019-WIP/schema#/$defs/nonNegativeInteger/minimum
    +https://json-schema.org/draft/2019-09/schema#/$defs/nonNegativeInteger/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".

    @@ -1658,8 +1533,8 @@

     
     {
    -  "$id": "https://example.com/polygon#",
    -  "$schema": "https://json-schema.org/draft/2019-WIP/schema#",
    +  "$id": "https://example.com/polygon",
    +  "$schema": "https://json-schema.org/draft/2019-09/schema",
       "$defs": {
         "point": {
           "type": "object",
    @@ -1810,13 +1685,13 @@ 

    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-08/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/2019-09/output/verbose-example>.

     
     // schema
     {
    -  "$id": "https://example.com/polygon#",
    -  "$schema": "https://json-schema.org/draft/2019-WIP/schema#",
    +  "$id": "https://example.com/polygon",
    +  "$schema": "https://json-schema.org/draft/2019-09/schema",
       "type": "object",
       "properties": {
         "validProp": true,
    @@ -1865,7 +1740,7 @@ 

    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-08/output/schema>.

    +

    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

    @@ -1911,7 +1786,7 @@

    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.

    -

    [CREF7]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:

    +

    [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"
    @@ -2026,12 +1901,17 @@ 

    [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-WIP, November 2017. +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-WIP, November 2017. +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] @@ -2055,16 +1935,289 @@

    -Appendix A. 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 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. ChangeLog

    -

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

    +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

    +

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

    -
    draft-handrews-json-schema-WIP
    +
    draft-handrews-json-schema-02
    • Update to RFC 8259 for JSON specification
    • @@ -2083,6 +2236,9 @@

    • 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

    diff --git a/work-in-progress/WIP-jsonschema-core.txt b/work-in-progress/WIP-jsonschema-core.txt index 103d1164..bbca3944 100644 --- a/work-in-progress/WIP-jsonschema-core.txt +++ b/work-in-progress/WIP-jsonschema-core.txt @@ -13,7 +13,7 @@ Expires: February 17, 2020 JSON Schema: A Media Type for Describing JSON Documents - draft-handrews-json-schema-WIP + draft-handrews-json-schema-02 Abstract @@ -1471,16 +1471,16 @@ Internet-Draft JSON Schema August 2019 { - "$schema": "https://json-schema.org/draft/2019-WIP/core-app-example#", - "$id": "https://json-schema.org/draft/2019-WIP/core-app-example", + "$schema": "https://json-schema.org/draft/2019-08/core-app-example#", + "$id": "https://json-schema.org/draft/2019-08/core-app-example", "$recursiveAnchor": true, "$vocabulary": { - "https://json-schema.org/draft/2019-WIP/vocab/core": true, - "https://json-schema.org/draft/2019-WIP/vocab/applicator": true + "https://json-schema.org/draft/2019-08/vocab/core": true, + "https://json-schema.org/draft/2019-08/vocab/applicator": true }, "allOf": [ - {"$ref": "https://json-schema.org/draft/2019-WIP/meta/core"}, - {"$ref": "https://json-schema.org/draft/2019-WIP/meta/applicator"} + {"$ref": "https://json-schema.org/draft/2019-08/meta/core"}, + {"$ref": "https://json-schema.org/draft/2019-08/meta/applicator"} ], "patternProperties": { "^unevaluated.*$": false @@ -1804,7 +1804,7 @@ Internet-Draft JSON Schema August 2019 { - "$schema": "https://json-schema.org/draft/2019-WIP/schema#", + "$schema": "https://json-schema.org/draft/2019-08/schema#", "$id": "https://example.com/original", "properties": { @@ -1818,7 +1818,7 @@ Internet-Draft JSON Schema August 2019 } { - "$schema": "https://json-schema.org/draft/2019-WIP/schema#", + "$schema": "https://json-schema.org/draft/2019-08/schema#", "$id": "https://example.com/extension", "$ref": "original", @@ -1916,7 +1916,7 @@ Internet-Draft JSON Schema August 2019 { - "$schema": "https://json-schema.org/draft/2019-WIP/schema#", + "$schema": "https://json-schema.org/draft/2019-08/schema#", "$id": "https://example.com/original", "$recursiveAnchor": true, @@ -1931,7 +1931,7 @@ Internet-Draft JSON Schema August 2019 } { - "$schema": "https://json-schema.org/draft/2019-WIP/schema#", + "$schema": "https://json-schema.org/draft/2019-08/schema#", "$id": "https://example.com/extension", "$recursiveAnchor": true, @@ -2191,11 +2191,11 @@ Internet-Draft JSON Schema August 2019 true. The current URI for this vocabulary, known as the Applicator - vocabulary, is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-08/meta/applicator>. Updated vocabulary and meta-schema URIs MAY be published between specification drafts in order to correct errors. Implementations @@ -2734,7 +2734,7 @@ Internet-Draft JSON Schema August 2019 by-reference applicators such as "$ref" or "$recursiveRef". -https://json-schema.org/draft/2019-WIP/schema#/$defs/nonNegativeInteger/minimum +https://json-schema.org/draft/2019-08/schema#/$defs/nonNegativeInteger/minimum @@ -2804,7 +2804,7 @@ Internet-Draft JSON Schema August 2019 { "$id": "https://example.com/polygon#", - "$schema": "https://json-schema.org/draft/2019-WIP/schema#", + "$schema": "https://json-schema.org/draft/2019-08/schema#", "$defs": { "point": { "type": "object", @@ -3089,14 +3089,14 @@ Internet-Draft JSON Schema August 2019 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: . // schema { "$id": "https://example.com/polygon#", - "$schema": "https://json-schema.org/draft/2019-WIP/schema#", + "$schema": "https://json-schema.org/draft/2019-08/schema#", "type": "object", "properties": { "validProp": true, @@ -3155,7 +3155,7 @@ Internet-Draft JSON Schema August 2019 For convenience, JSON Schema has been provided to validate output generated by implementations. Its URI is: . + draft/2019-08/output/schema>. 11. Usage for Hypermedia @@ -3454,13 +3454,13 @@ Internet-Draft JSON Schema August 2019 [json-hyper-schema] Andrews, H. and A. Wright, "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON", draft- - handrews-json-schema-hyperschema-WIP (work in progress), + handrews-json-schema-hyperschema-02 (work in progress), November 2017. [json-schema-validation] Wright, A., Andrews, H., and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of - JSON", draft-handrews-json-schema-validation-WIP (work in + JSON", draft-handrews-json-schema-validation-02 (work in progress), November 2017. [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object @@ -3544,7 +3544,7 @@ Appendix B. ChangeLog [[CREF8: This section to be removed before leaving Internet-Draft status.]] - draft-handrews-json-schema-WIP + draft-handrews-json-schema-02 * Update to RFC 8259 for JSON specification diff --git a/work-in-progress/WIP-jsonschema-hyperschema.html b/work-in-progress/WIP-jsonschema-hyperschema.html index b64a06d8..be5f1bb2 100644 --- a/work-in-progress/WIP-jsonschema-hyperschema.html +++ b/work-in-progress/WIP-jsonschema-hyperschema.html @@ -1,5 +1,460 @@ - - + + + + + + + JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -23,8 +478,8 @@ A. Wright, Ed. -Expires: February 17, 2020 -August 16, 2019 +Expires: March 11, 2020 +September 8, 2019 @@ -32,7 +487,7 @@

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

    + 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.

    @@ -44,7 +499,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 February 17, 2020.

    +

    This Internet-Draft will expire on March 11, 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.

    @@ -272,11 +727,11 @@

    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-WIP/hyper-schema#>.

    -

    The current URI for this vocabulary, known as the Hyper-Schema vocabulary, is: <https://json-schema.org/draft/2019-WIP/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-WIP/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-WIP/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-WIP/output/hyper-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

    @@ -734,7 +1189,7 @@

    { "$id": "https://schema.example.com/entry", - "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-09/hyper-schema", "base": "https://example.com/api/", "links": [ { @@ -776,7 +1231,7 @@

     {
         "$id": "https://schema.example.com/thing",
    -    "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
    +    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
         "base": "https://example.com/api/",
         "type": "object",
         "required": ["data"],
    @@ -830,7 +1285,7 @@ 

     {
         "$id": "https://schema.example.com/interesting-stuff",
    -    "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
    +    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
         "required": ["stuffWorthEmailingAbout", "email", "title"],
         "properties": {
             "title": {
    @@ -958,7 +1413,7 @@ 

     {
         "$id": "https://schema.example.com/tree-node",
    -    "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
    +    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
         "base": "trees/{treeId}/",
         "properties": {
             "id": {"type": "integer"},
    @@ -998,7 +1453,7 @@ 

     {
         "$id": "https://schema.example.com/thing",
    -    "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
    +    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
         "base": "https://example.com/api/",
         "type": "object",
         "required": ["data"],
    @@ -1033,7 +1488,7 @@ 

     {
         "$id": "https://schema.example.com/thing-collection",
    -    "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#",
    +    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
         "base": "https://example.com/api/",
         "type": "object",
         "required": ["elements"],
    @@ -1296,12 +1751,12 @@ 

    [json-schema] -Wright, A. and H. Andrews, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-handrews-json-schema-WIP, November 2017. +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-WIP, November 2017. +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] @@ -1413,7 +1868,7 @@

    -
    draft-handrews-json-schema-hyperschema-WIP
    +
    draft-handrews-json-schema-hyperschema-02
    • Allow multiple values for "rel"
    • diff --git a/work-in-progress/WIP-jsonschema-hyperschema.txt b/work-in-progress/WIP-jsonschema-hyperschema.txt index 431525a8..120689e7 100644 --- a/work-in-progress/WIP-jsonschema-hyperschema.txt +++ b/work-in-progress/WIP-jsonschema-hyperschema.txt @@ -9,7 +9,7 @@ Expires: February 17, 2020 August 16, 2019 JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON - draft-handrews-json-schema-hyperschema-WIP + draft-handrews-json-schema-hyperschema-02 Abstract @@ -358,22 +358,22 @@ Internet-Draft JSON Hyper-Schema August 2019 4. Meta-Schemas and Output Schema The current URI for the JSON Hyper-Schema meta-schema is - . + . The current URI for this vocabulary, known as the Hyper-Schema - vocabulary, is: . 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: . + schema.org/draft/2019-08/meta/hyper-schema>. The link description format (Section 6) 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: . JSON Hyper-Schema implementations are free to provide output in any @@ -1718,7 +1718,7 @@ Internet-Draft JSON Hyper-Schema August 2019 { "$id": "https://schema.example.com/entry", - "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", "base": "https://example.com/api/", "links": [ { @@ -1800,7 +1800,7 @@ Internet-Draft JSON Hyper-Schema August 2019 { "$id": "https://schema.example.com/thing", - "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", "base": "https://example.com/api/", "type": "object", "required": ["data"], @@ -1924,7 +1924,7 @@ Internet-Draft JSON Hyper-Schema August 2019 { "$id": "https://schema.example.com/interesting-stuff", - "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", "required": ["stuffWorthEmailingAbout", "email", "title"], "properties": { "title": { @@ -2137,7 +2137,7 @@ Internet-Draft JSON Hyper-Schema August 2019 { "$id": "https://schema.example.com/tree-node", - "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", "base": "trees/{treeId}/", "properties": { "id": {"type": "integer"}, @@ -2249,7 +2249,7 @@ Internet-Draft JSON Hyper-Schema August 2019 { "$id": "https://schema.example.com/thing", - "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", "base": "https://example.com/api/", "type": "object", "required": ["data"], @@ -2308,7 +2308,7 @@ Internet-Draft JSON Hyper-Schema August 2019 { "$id": "https://schema.example.com/thing-collection", - "$schema": "https://json-schema.org/draft/2019-WIP/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", "base": "https://example.com/api/", "type": "object", "required": ["elements"], @@ -2818,13 +2818,13 @@ Internet-Draft JSON Hyper-Schema August 2019 [json-schema] Wright, A. and H. Andrews, "JSON Schema: A Media Type for - Describing JSON Documents", draft-handrews-json-schema-WIP + Describing JSON Documents", draft-handrews-json-schema-02 (work in progress), November 2017. [json-schema-validation] Wright, A., Andrews, H., and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of - JSON", draft-handrews-json-schema-validation-WIP (work in + JSON", draft-handrews-json-schema-validation-02 (work in progress), November 2017. [relative-json-pointer] @@ -3052,7 +3052,7 @@ Appendix B. ChangeLog [[CREF13: This section to be removed before leaving Internet-Draft status.]] - draft-handrews-json-schema-hyperschema-WIP + draft-handrews-json-schema-hyperschema-02 * Allow multiple values for "rel" diff --git a/work-in-progress/WIP-jsonschema-validation.html b/work-in-progress/WIP-jsonschema-validation.html index 19302352..3fa9278f 100644 --- a/work-in-progress/WIP-jsonschema-validation.html +++ b/work-in-progress/WIP-jsonschema-validation.html @@ -450,8 +450,8 @@ - - + + @@ -475,7 +475,7 @@ H. Andrews, Ed. -Expires: February 17, 2020 +Expires: March 11, 2020 @@ -488,7 +488,7 @@ -August 16, 2019 +September 8, 2019 @@ -496,7 +496,7 @@

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

      + 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.

      @@ -508,7 +508,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 February 17, 2020.

      +

      This Internet-Draft will expire on March 11, 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.

      @@ -691,14 +691,14 @@

      5. Meta-Schema

      -

      The current URI for the JSON Schema Validation meta-schema is <http://json-schema.org/draft/2019-WIP/schema#>. For schema author convenience, this meta-schema describes all vocabularies defined in this specification and the JSON Schema Core specification. 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 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-WIP/vocab/validation>.

      -

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

      +

      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

      @@ -819,8 +819,8 @@

      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-WIP/vocab/format>.

      -

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

      +

      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.

      @@ -968,8 +968,8 @@

      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-WIP/vocab/content>.

      -

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

      +

      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.

      @@ -1047,8 +1047,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/2019-WIP/vocab/meta-data>.

      -

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

      +

      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.

      @@ -1097,7 +1097,7 @@

      [json-schema] -Wright, A. and H. Andrews, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-handrews-json-schema-WIP, November 2017. +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] @@ -1208,7 +1208,7 @@

      "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.
      +
      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"
      @@ -1226,7 +1226,7 @@

      -
      draft-handrews-json-schema-validation-WIP
      +
      draft-handrews-json-schema-validation-02
      • Grouped keywords into formal vocabuarlies
      • diff --git a/work-in-progress/WIP-jsonschema-validation.txt b/work-in-progress/WIP-jsonschema-validation.txt index bf6bb7d9..566ad141 100644 --- a/work-in-progress/WIP-jsonschema-validation.txt +++ b/work-in-progress/WIP-jsonschema-validation.txt @@ -12,7 +12,7 @@ Expires: February 17, 2020 JSON Schema Validation: A Vocabulary for Structural Validation of JSON - draft-handrews-json-schema-validation-WIP + draft-handrews-json-schema-validation-02 Abstract @@ -244,7 +244,7 @@ Internet-Draft JSON Schema Validation August 2019 5. Meta-Schema The current URI for the JSON Schema Validation meta-schema is - . For schema author + . For schema author convenience, this meta-schema describes all vocabularies defined in this specification and the JSON Schema Core specification. Individual vocabulary and vocabulary meta-schema URIs are given for @@ -268,11 +268,11 @@ Internet-Draft JSON Schema Validation August 2019 true. The current URI for this vocabulary, known as the Validation - vocabulary, is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-08/meta/validation>. @@ -577,10 +577,10 @@ Internet-Draft JSON Schema Validation August 2019 false. See the Implementation Requirements below for details. The current URI for this vocabulary, known as the Format vocabulary, - is: . + is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-08/meta/format>. 7.2. Implementation Requirements @@ -922,10 +922,10 @@ Internet-Draft JSON Schema Validation August 2019 true. The current URI for this vocabulary, known as the Content vocabulary, - is: . + is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-08/meta/content>. 8.2. Implementation Requirements @@ -1123,11 +1123,11 @@ Internet-Draft JSON Schema Validation August 2019 The current URI for this vocabulary, known as the Meta-Data - vocabulary, is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-08/meta/meta-data>. 9.1. "title" and "description" @@ -1275,7 +1275,7 @@ Internet-Draft JSON Schema Validation August 2019 [json-schema] Wright, A. and H. Andrews, "JSON Schema: A Media Type for - Describing JSON Documents", draft-handrews-json-schema-WIP + Describing JSON Documents", draft-handrews-json-schema-02 (work in progress), November 2017. [relative-json-pointer] @@ -1463,7 +1463,7 @@ Appendix C. ChangeLog [[CREF8: This section to be removed before leaving Internet-Draft status.]] - draft-handrews-json-schema-validation-WIP + draft-handrews-json-schema-validation-02 * Grouped keywords into formal vocabuarlies diff --git a/work-in-progress/WIP-links.json b/work-in-progress/WIP-links.json index c5b3a20c..7b1a578f 100644 --- a/work-in-progress/WIP-links.json +++ b/work-in-progress/WIP-links.json @@ -1,6 +1,6 @@ { - "$schema": "http://json-schema.org/draft/2019-WIP/hyper-schema#", - "$id": "http://json-schema.org/draft/2019-WIP/links", + "$schema": "https://json-schema.org/draft/2019-09/hyper-schema", + "$id": "https://json-schema.org/draft/2019-09/links", "title": "Link Description Object", "allOf": [ { "required": [ "rel", "href" ] }, @@ -36,7 +36,7 @@ "format": "uri-template" }, "hrefSchema": { - "$recursiveRef": "http://json-schema.org/draft/2019-WIP/hyper-schema", + "$recursiveRef": "https://json-schema.org/draft/2019-09/hyper-schema", "default": false }, "templatePointers": { @@ -63,7 +63,7 @@ "type": "string" }, "targetSchema": { - "$recursiveRef": "http://json-schema.org/draft/2019-WIP/hyper-schema", + "$recursiveRef": "https://json-schema.org/draft/2019-09/hyper-schema", "default": true }, "targetMediaType": { @@ -71,7 +71,7 @@ }, "targetHints": { }, "headerSchema": { - "$recursiveRef": "http://json-schema.org/draft/2019-WIP/hyper-schema", + "$recursiveRef": "https://json-schema.org/draft/2019-09/hyper-schema", "default": true }, "submissionMediaType": { @@ -79,7 +79,7 @@ "default": "application/json" }, "submissionSchema": { - "$recursiveRef": "http://json-schema.org/draft/2019-WIP/hyper-schema", + "$recursiveRef": "https://json-schema.org/draft/2019-09/hyper-schema", "default": true }, "$comment": { diff --git a/work-in-progress/WIP-relative-json-pointer.html b/work-in-progress/WIP-relative-json-pointer.html index 8d5dfa42..b26e87e3 100644 --- a/work-in-progress/WIP-relative-json-pointer.html +++ b/work-in-progress/WIP-relative-json-pointer.html @@ -397,7 +397,7 @@ - + @@ -421,8 +421,8 @@ H. Andrews, Ed. -Expires: February 17, 2020 -August 16, 2019 +Expires: February 23, 2020 +August 22, 2019 @@ -438,7 +438,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 February 17, 2020.

        +

        This Internet-Draft will expire on February 23, 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.

        diff --git a/work-in-progress/WIP-schema.json b/work-in-progress/WIP-schema.json index 6765ac43..2248a0c8 100644 --- a/work-in-progress/WIP-schema.json +++ b/work-in-progress/WIP-schema.json @@ -1,13 +1,13 @@ { - "$schema": "http://json-schema.org/draft/2019-WIP/schema#", - "$id": "http://json-schema.org/draft/2019-WIP/schema#", + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://json-schema.org/draft/2019-09/schema", "$vocabulary": { - "https://json-schema.org/draft/2019-WIP/vocab/core": true, - "https://json-schema.org/draft/2019-WIP/vocab/applicator": true, - "https://json-schema.org/draft/2019-WIP/vocab/validation": true, - "https://json-schema.org/draft/2019-WIP/vocab/meta-data": true, - "https://json-schema.org/draft/2019-WIP/vocab/format": false, - "https://json-schema.org/draft/2019-WIP/vocab/content": true + "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://json-schema.org/draft/2019-09/vocab/meta-data": true, + "https://json-schema.org/draft/2019-09/vocab/format": false, + "https://json-schema.org/draft/2019-09/vocab/content": true }, "$recursiveAnchor": true, diff --git a/work-in-progress/index.md b/work-in-progress/index.md index c8d5a464..12eae454 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -7,17 +7,13 @@ permalink: /work-in-progress * TOC {:toc} -## The Next Draft (by whatever name) Is Approaching Publication! +## The Next Draft (by whatever name) Is Ready for Final Pre-Publication Review! -The draft is feature-complete, including late additions based on our first try at a final review period several months ago. +The forthcoming draft is now feature-frozen and has gone through the initial four-week pre-publication review period. -We will be working on a more user-friendly and extensive guide to the new draft shortly. +_**UPDATE: Sept 8th, 2019** All PRs have been posted, and we are waiting on final reviews from one team member. The WIP documents here incorporate the PRs as they are currently posted._ -### Update as of 26 Aug 2019 - -***All PRs from our final review feedback have been posted.*** - -_The draft will be published as soon as we have sufficient reviews from the spec team and/or implementation owners. As this is summer vacation season, that may still take a few weeks._ +Once we have completed reviews within the core JSON Schema team, we will publish this draft. ## What Is This Draft Called, Anyway? @@ -40,10 +36,6 @@ and expiration dates of the IETF documents. This will make it more clear when a meta-schema is produced, and also make it more obvious that the IETF and meta-schema identifiers are not expected to match exactly. -## Change Log - -To see what changes are involved, read the [release notes](./WIP-json-schema-release-notes.md). - ## Pre-Built Review Documents To encourage as many reviewers as possible, pre-built documents are available. These may diff --git a/work-in-progress/meta/WIP-applicator.json b/work-in-progress/meta/WIP-applicator.json index 73788361..b17d35c5 100644 --- a/work-in-progress/meta/WIP-applicator.json +++ b/work-in-progress/meta/WIP-applicator.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft/2019-WIP/schema#", - "$id": "https://json-schema.org/draft/2019-WIP/meta/applicator", + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://json-schema.org/draft/2019-09/meta/applicator", "$vocabulary": { - "https://json-schema.org/draft/2019-WIP/vocab/applicator": true + "https://json-schema.org/draft/2019-09/vocab/applicator": true }, "$recursiveAnchor": true, diff --git a/work-in-progress/meta/WIP-content.json b/work-in-progress/meta/WIP-content.json index 79882081..f6752a8e 100644 --- a/work-in-progress/meta/WIP-content.json +++ b/work-in-progress/meta/WIP-content.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft/2019-WIP/schema#", - "$id": "http://json-schema.org/draft/2019-WIP/meta/content", + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://json-schema.org/draft/2019-09/meta/content", "$vocabulary": { - "https://json-schema.org/draft/2019-WIP/vocab/content": true + "https://json-schema.org/draft/2019-09/vocab/content": true }, "$recursiveAnchor": true, diff --git a/work-in-progress/meta/WIP-core.json b/work-in-progress/meta/WIP-core.json index 82ad7e25..0a1fc68a 100644 --- a/work-in-progress/meta/WIP-core.json +++ b/work-in-progress/meta/WIP-core.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft/2019-WIP/schema#", - "$id": "https://json-schema.org/draft/2019-WIP/meta/core", + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://json-schema.org/draft/2019-09/meta/core", "$vocabulary": { - "https://json-schema.org/draft/2019-WIP/vocab/core": true + "https://json-schema.org/draft/2019-09/vocab/core": true }, "$recursiveAnchor": true, @@ -11,12 +11,18 @@ "properties": { "$id": { "type": "string", - "format": "uri-reference" + "format": "uri-reference", + "$comment": "Non-empty fragments not allowed.", + "pattern": "^[^#]#?$" }, "$schema": { "type": "string", "format": "uri" }, + "$anchor": { + "type": "string", + "pattern": "^[A-Za-z][-A-Za-z0-9.:_]*$" + }, "$ref": { "type": "string", "format": "uri-reference" diff --git a/work-in-progress/meta/WIP-format.json b/work-in-progress/meta/WIP-format.json index 7a2bd28f..09bbfdda 100644 --- a/work-in-progress/meta/WIP-format.json +++ b/work-in-progress/meta/WIP-format.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft/2019-WIP/schema#", - "$id": "http://json-schema.org/draft/2019-WIP/meta/format", + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://json-schema.org/draft/2019-09/meta/format", "$vocabulary": { - "https://json-schema.org/draft/2019-WIP/vocab/format": true + "https://json-schema.org/draft/2019-09/vocab/format": true }, "$recursiveAnchor": true, diff --git a/work-in-progress/meta/WIP-hyper-schema.json b/work-in-progress/meta/WIP-hyper-schema.json index 357747c6..3d230589 100644 --- a/work-in-progress/meta/WIP-hyper-schema.json +++ b/work-in-progress/meta/WIP-hyper-schema.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft/2019-WIP/hyper-schema#", - "$id": "http://json-schema.org/draft/2019-WIP/meta/hyper-schema", + "$schema": "https://json-schema.org/draft/2019-09/hyper-schema", + "$id": "https://json-schema.org/draft/2019-09/meta/hyper-schema", "$vocabulary": { - "https://json-schema.org/draft/2019-WIP/vocab/hyper-schema": true + "https://json-schema.org/draft/2019-09/vocab/hyper-schema": true }, "$recursiveAnchor": true, @@ -16,7 +16,7 @@ "links": { "type": "array", "items": { - "$ref": "http://json-schema.org/draft/2019-WIP/links" + "$ref": "https://json-schema.org/draft/2019-09/links" } } }, diff --git a/work-in-progress/meta/WIP-meta-data.json b/work-in-progress/meta/WIP-meta-data.json index 0bbbdeaf..da04cff6 100644 --- a/work-in-progress/meta/WIP-meta-data.json +++ b/work-in-progress/meta/WIP-meta-data.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft/2019-WIP/schema#", - "$id": "http://json-schema.org/draft/2019-WIP/meta/meta-data", + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://json-schema.org/draft/2019-09/meta/meta-data", "$vocabulary": { - "https://json-schema.org/draft/2019-WIP/vocab/meta-data": true + "https://json-schema.org/draft/2019-09/vocab/meta-data": true }, "$recursiveAnchor": true, diff --git a/work-in-progress/meta/WIP-validation.json b/work-in-progress/meta/WIP-validation.json index 4d5fcc96..9f59677b 100644 --- a/work-in-progress/meta/WIP-validation.json +++ b/work-in-progress/meta/WIP-validation.json @@ -1,8 +1,8 @@ { - "$schema": "http://json-schema.org/draft/2019-WIP/schema#", - "$id": "http://json-schema.org/draft/2019-WIP/meta/validation", + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://json-schema.org/draft/2019-09/meta/validation", "$vocabulary": { - "https://json-schema.org/draft/2019-WIP/vocab/validation": true + "https://json-schema.org/draft/2019-09/vocab/validation": true }, "$recursiveAnchor": true, diff --git a/work-in-progress/output/WIP-hyper-schema.json b/work-in-progress/output/WIP-hyper-schema.json index ebb53d46..216eb383 100644 --- a/work-in-progress/output/WIP-hyper-schema.json +++ b/work-in-progress/output/WIP-hyper-schema.json @@ -1,11 +1,11 @@ { - "$schema": "http://json-schema.org/draft/2019-WIP/schema#", - "$id": "http://json-schema.org/draft/2019-WIP/output/hyper-schema", + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://json-schema.org/draft/2019-09/output/hyper-schema", "title": "JSON Hyper-Schema Output", "type": "array", "items": { "allOf": [ - {"$ref": "http://json-schema.org/draft/2019-WIP/links#/$defs/noRequiredFields" } + {"$ref": "https://json-schema.org/draft/2019-09/links#/$defs/noRequiredFields" } ], "type": "object", "required": [ diff --git a/work-in-progress/output/WIP-schema.json b/work-in-progress/output/WIP-schema.json index 45187ee0..7cf4c4ac 100644 --- a/work-in-progress/output/WIP-schema.json +++ b/work-in-progress/output/WIP-schema.json @@ -1,6 +1,6 @@ { - "$schema": "http://json-schema.org/draft/2019-WIP/schema#", - "$id": "http://json-schema.org/draft/2019-WIP/output/schema", + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://json-schema.org/draft/2019-09/output/schema", "description": "A schema that validates the minimum requirements for validation output", "oneOf": [ diff --git a/work-in-progress/output/WIP-verbose-example.json b/work-in-progress/output/WIP-verbose-example.json index ef50444f..37acb2d5 100644 --- a/work-in-progress/output/WIP-verbose-example.json +++ b/work-in-progress/output/WIP-verbose-example.json @@ -5,7 +5,7 @@ "errors": [ { "valid": true, - "keywordLocation": "#/definitions", + "keywordLocation": "#/$defs", "instanceLocation": "#" }, { @@ -22,42 +22,42 @@ "valid": true, "keywordLocation": "#/items/$ref", "absoluteKeywordLocation": - "http://example.com/polygon#/items/$ref", + "https://example.com/polygon#/items/$ref", "instanceLocation": "#/0", "annotations": [ { "valid": true, "keywordLocation": "#/items/$ref", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point", + "https://example.com/polygon#/$defs/point", "instanceLocation": "#/0", "annotations": [ { "valid": true, "keywordLocation": "#/items/$ref/type", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/type", + "https://example.com/polygon#/$defs/point/type", "instanceLocation": "#/0" }, { "valid": true, "keywordLocation": "#/items/$ref/properties", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/properties", + "https://example.com/polygon#/$defs/point/properties", "instanceLocation": "#/0" }, { "valid": true, "keywordLocation": "#/items/$ref/required", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/required", + "https://example.com/polygon#/$defs/point/required", "instanceLocation": "#/0" }, { "valid": true, "keywordLocation": "#/items/$ref/additionalProperties", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/additionalProperties", + "https://example.com/polygon#/$defs/point/additionalProperties", "instanceLocation": "#/0" } ] @@ -68,49 +68,49 @@ "valid": false, "keywordLocation": "#/items/$ref", "absoluteKeywordLocation": - "http://example.com/polygon#/items/$ref", + "https://example.com/polygon#/items/$ref", "instanceLocation": "#/1", "errors": [ { "valid": false, "keywordLocation": "#/items/$ref", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point", + "https://example.com/polygon#/$defs/point", "instanceLocation": "#/1", "errors": [ { "valid": true, "keywordLocation": "#/items/$ref/type", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/type", + "https://example.com/polygon#/$defs/point/type", "instanceLocation": "#/1" }, { "valid": true, "keywordLocation": "#/items/$ref/properties", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/properties", + "https://example.com/polygon#/$defs/point/properties", "instanceLocation": "#/1" }, { "valid": false, "keywordLocation": "#/items/$ref/required", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/required", + "https://example.com/polygon#/$defs/point/required", "instanceLocation": "#/1" }, { "valid": false, "keywordLocation": "#/items/$ref/additionalProperties", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/additionalProperties", + "https://example.com/polygon#/$defs/point/additionalProperties", "instanceLocation": "#/1", "errors": [ { "valid": false, "keywordLocation": "#/items/$ref/additionalProperties", "absoluteKeywordLocation": - "http://example.com/polygon#/definitions/point/additionalProperties", + "https://example.com/polygon#/$defs/point/additionalProperties", "instanceLocation": "#/1/z" } ] From 02a4d6ce7760a0534745b9a735e0eb67f1ebaebe Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Mon, 9 Sep 2019 23:20:53 -0700 Subject: [PATCH 076/395] Forgot to restore change log link. --- work-in-progress/index.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/work-in-progress/index.md b/work-in-progress/index.md index 12eae454..a9b1dede 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -15,6 +15,8 @@ _**UPDATE: Sept 8th, 2019** All PRs have been posted, and we are waiting on fina Once we have completed reviews within the core JSON Schema team, we will publish this draft. +Learn more about the [changes](WIP-json-schema-release-notes.html) in this draft. + ## What Is This Draft Called, Anyway? We have typically referred to this as `draft-08`, following our own convention of just @@ -55,6 +57,10 @@ _**NOTE:** Links to meta-schemas and among the drafts will not work correctly in * [WIP: JSON Schema Hyper-Schema](/work-in-progress/WIP-jsonschema-hyperschema.html) * [WIP: Relative JSON Pointer](/work-in-progress/WIP-relative-json-pointer.html) +### Change Log / Release Notes: + +Learn more about the [changes](WIP-json-schema-release-notes.html) in this draft. + ### General use meta-schemas: These are the traditional non-normative meta-schemas, which serve the same purpose as From faf1639784d5f9592335672e535514daecf30c87 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 10 Sep 2019 11:26:37 -0700 Subject: [PATCH 077/395] Production doesn't work like development Apparently relative links only work in the development server. --- .../WIP-json-schema-release-notes.md | 62 +++++++++---------- work-in-progress/index.md | 4 +- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/work-in-progress/WIP-json-schema-release-notes.md b/work-in-progress/WIP-json-schema-release-notes.md index 626ac96d..c61c2d5f 100644 --- a/work-in-progress/WIP-json-schema-release-notes.md +++ b/work-in-progress/WIP-json-schema-release-notes.md @@ -11,9 +11,9 @@ For implementors, there is a lot more to consider, and further guidance on imple {:toc} For a basic list of changes to each document, see their change logs: -* [Core](WIP-jsonschema-core.html#rfc.appendix.G) -* [Validation](WIP-jsonschema-validation.html#rfc.appendix.C) -* [Hyper-Schema](WIP-jsonschema-hyperschema.html#rfc.appendix.B) +* [Core](/work-in-progress/WIP-jsonschema-core.html#rfc.appendix.G) +* [Validation](/work-in-progress/WIP-jsonschema-validation.html#rfc.appendix.C) +* [Hyper-Schema](/work-in-progress/WIP-jsonschema-hyperschema.html#rfc.appendix.B) ### Incompatible Changes @@ -31,60 +31,60 @@ The old syntax for these keywords is not an error (and the default meta-schema s ### Annotations, Errors, and Outputs -[Annotation keywords](WIP-jsonschema-core.html#rfc.section.7.7) such as `title`, `readOnly`, and `default` have always been a part of JSON Schema, but without any guidance on how to make use of them. This draft formalizes how implementations can make annotation information available to applications. +[Annotation keywords](/work-in-progress/WIP-jsonschema-core.html#rfc.section.7.7) such as `title`, `readOnly`, and `default` have always been a part of JSON Schema, but without any guidance on how to make use of them. This draft formalizes how implementations can make annotation information available to applications. Similarly, there has not previously been guidance on what constitutes useful error reporting when validation fails. -To solve both of these problems, we now recommend that implementations support one or more of standardized [output formats](WIP-jsonschema-core.html#rfc.section.10). +To solve both of these problems, we now recommend that implementations support one or more of standardized [output formats](/work-in-progress/WIP-jsonschema-core.html#rfc.section.10). ### Keyword Changes -All keywords have now been organized into [vocabularies](WIP-jsonschema-core.html#rfc.section.8.1), with the Core and Validation specifications containing multiple vocabularies. In this process, some keywords have moved from Validation into Core. +All keywords have now been organized into [vocabularies](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.1), with the Core and Validation specifications containing multiple vocabularies. In this process, some keywords have moved from Validation into Core. #### Core Vocabulary -[Core Specification, Section 8](WIP-jsonschema-core.html#rfc.section.8) +[Core Specification, Section 8](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8) keyword | change | notes ---- | ---- | ---- -[`$anchor`](WIP-jsonschema-core.html#rfc.section.8.2.3) | **new** | Replaces the `#plain-name` form of `$id`, with a different syntax and approach -[`$defs` (renamed from `definitions`)](WIP-jsonschema-core.html#rfc.section.8.2.5) | **renamed** | Note that the standard meta-schema still reserves `definitions` for backwards compatibility -[`$id`](WIP-jsonschema-core.html#rfc.section.8.2.2) | **changed** | Only URI-references without fragments are allowed; see `$anchor` for a replacement for plain-name fragments; all other fragments in `$id` had undefined behavior previously -[`$recursiveAnchor` and `$recursiveRef`](WIP-jsonschema-core.html#rfc.section.8.2.4.2) | **new** | Used for extending recursive schemas such as meta-schemas +[`$anchor`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.2.3) | **new** | Replaces the `#plain-name` form of `$id`, with a different syntax and approach +[`$defs` (renamed from `definitions`)](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.2.5) | **renamed** | Note that the standard meta-schema still reserves `definitions` for backwards compatibility +[`$id`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.2.2) | **changed** | Only URI-references without fragments are allowed; see `$anchor` for a replacement for plain-name fragments; all other fragments in `$id` had undefined behavior previously +[`$recursiveAnchor` and `$recursiveRef`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.2.4.2) | **new** | Used for extending recursive schemas such as meta-schemas [`$ref`] | **changed** | Other keywords are now allowed alongside of it -[`$vocabulary`](WIP-jsonschema-core.html#rfc.section.8.1) | **new** | Has effects only in meta-schemas, and is used to control what keywords an implementation must or can support in order to process a schema using that meta-schema +[`$vocabulary`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.1) | **new** | Has effects only in meta-schemas, and is used to control what keywords an implementation must or can support in order to process a schema using that meta-schema #### Applicator Vocabulary -[Core Specification, Section 9](WIP-jsonschema-core.html#rfc.section.9) +[Core Specification, Section 9](/work-in-progress/WIP-jsonschema-core.html#rfc.section.9) These keywords were formerly found in the Validation Specification. keyword | change | notes ---- | ---- | ---- -[`dependentSchemas` (split from `dependencies`)](WIP-jsonschema-core.html#rfc.section.9.2.2.4) | **split** | This is the schema form of `dependencies`; note that the standard meta-schema still reserves `dependencies` for backwards compatibility -[`unevaluatedItems`](WIP-jsonschema-core.html#rfc.section.9.3.1.3) | **new** | Similar to `additionalItems`, but can "see" into subschemas and across references -[`unevaluatedProperties`](WIP-jsonschema-core.html#rfc.section.9.3.2.4) | **new** | Similar to `additionalProperties`, but can "see" into subschemas and across references +[`dependentSchemas` (split from `dependencies`)](/work-in-progress/WIP-jsonschema-core.html#rfc.section.9.2.2.4) | **split** | This is the schema form of `dependencies`; note that the standard meta-schema still reserves `dependencies` for backwards compatibility +[`unevaluatedItems`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.9.3.1.3) | **new** | Similar to `additionalItems`, but can "see" into subschemas and across references +[`unevaluatedProperties`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.9.3.2.4) | **new** | Similar to `additionalProperties`, but can "see" into subschemas and across references The other applicator vocabulary keywords are `items`, `additionalItems`, `properties`, `patternProperties`, `additionalProperties`, `anyOf`, `allOf`, `oneOf`, `not`, `if`, `then`, `else`. #### Validation Vocabulary -[Validation Specification, Section 6](WIP-jsonschema-validation.html#rfc.section.6) +[Validation Specification, Section 6](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.6) keyword | change | notes ---- | ---- | ---- -[`dependentRequired` (split from `dependencies`)](WIP-jsonschema-validation.html#rfc.section.6.5.4) | **split** | This is the string array form of `dependencies`; note that the standard meta-schema still reserves `dependencies` for backwards compatibility -[`maxContains` and `minContains`](WIP-jsonschema-validation.html#rfc.section.6.4.4) | **new** | Assertion for controlling how many times a subschema must be matched within an array +[`dependentRequired` (split from `dependencies`)](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.6.5.4) | **split** | This is the string array form of `dependencies`; note that the standard meta-schema still reserves `dependencies` for backwards compatibility +[`maxContains` and `minContains`](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.6.4.4) | **new** | Assertion for controlling how many times a subschema must be matched within an array #### Format Vocabulary -[Validation Specification, Section 7](WIP-jsonschema-validation.html#rfc.section.7) +[Validation Specification, Section 7](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.7) The `format` keywords has always been problematic due to its optional nature. There has never been a way to ensure that the implementation processing your schema supports `format` at all, or if it does, to what degree it validates each type of format. In theory, since each format references a standard specification, if a format is supported, it should behave consistently. In practice, this is not the case. -There are two ways for an application to validate formats: It can rely on a JSON Schema implementation to validate them (which may or may not have the expected results), or it can note where the `format` keyword has been used and perform its own validation based on that. This second approach is supported by treating `format` as an [annotation keyword](WIP-jsonschema-core.html#rfc.section.7.7) and supporting the [basic, detailed, or verbose output formats](WIP-jsonschema-core.html#rfc.section.10.4.2). +There are two ways for an application to validate formats: It can rely on a JSON Schema implementation to validate them (which may or may not have the expected results), or it can note where the `format` keyword has been used and perform its own validation based on that. This second approach is supported by treating `format` as an [annotation keyword](/work-in-progress/WIP-jsonschema-core.html#rfc.section.7.7) and supporting the [basic, detailed, or verbose output formats](/work-in-progress/WIP-jsonschema-core.html#rfc.section.10.4.2). To impose some predictability on this system, the behavior has changed in several ways, as illustrated below. The key difference here is that `format` validation is now predictably off by default, but can be configured to be turned on. In draft-07, it was on (but possibly unimplemented) by default and could be configured to be turned off. @@ -129,34 +129,34 @@ Additionally, two new formats were added, and a specification reference was upda format | change | notes ---- | ---- | ---- -[`"duration"`](WIP-jsonschema-validation.html#rfc.section.7.3.1) | **added** | The duration format is from the ISO 8601 ABNF as given in Appendix A of RFC 3339 -[`"hostname"` and `"idn-hostname"`](WIP-jsonschema-validation.html#rfc.section.7.3.3) | **updated** | Use RFC 1123 instead of RFC 1034; this allows for a leading digit -[`"uuid"`](WIP-jsonschema-validation.html#rfc.section.7.3.5) | **added** | A string instance is valid against this attribute if it is a valid string representation of a UUID, according to RFC4122 +[`"duration"`](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.7.3.1) | **added** | The duration format is from the ISO 8601 ABNF as given in Appendix A of RFC 3339 +[`"hostname"` and `"idn-hostname"`](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.7.3.3) | **updated** | Use RFC 1123 instead of RFC 1034; this allows for a leading digit +[`"uuid"`](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.7.3.5) | **added** | A string instance is valid against this attribute if it is a valid string representation of a UUID, according to RFC4122 #### Content Vocabulary -[Validation Specification, Section 8](WIP-jsonschema-validation.html#rfc.section.8) +[Validation Specification, Section 8](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.8) These keywords are now specified purely as annotations, and never assertions. Some guidance is provided around how an implementation can optionally offer further automatic processing of this information outside of the validation process. keyword | change | notes ---- | ---- | ---- -[`contentEncoding`](WIP-jsonschema-validation.html#rfc.section.8.3) | **updated** | Encodings from RFC 4648 are now allowed, and take precedence over RFC 2045 when there is a difference -[`contentSchema`](WIP-jsonschema-validation.html#rfc.section.8.5) | **added** | Schema for use with the decoded content string; note that it is _not_ automatically applied as not all content media types can be understood in advance +[`contentEncoding`](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.8.3) | **updated** | Encodings from RFC 4648 are now allowed, and take precedence over RFC 2045 when there is a difference +[`contentSchema`](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.8.5) | **added** | Schema for use with the decoded content string; note that it is _not_ automatically applied as not all content media types can be understood in advance #### Meta-Data Vocabulary -[Validation Specification, Section 9](WIP-jsonschema-validation.html#rfc.section.9) +[Validation Specification, Section 9](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.9) keyword | change | notes ---- | ---- | ---- -[`deprecated`](WIP-jsonschema-validation.html#rfc.section.9.3) | **added** | Used to indicate that a field is deprecated in some application-specific manner +[`deprecated`](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.9.3) | **added** | Used to indicate that a field is deprecated in some application-specific manner #### Hyper-Schema Vocabulary -[Hyper-Schema Specification, Sections 5 and 6](WIP-jsonschema-hyperschema.html#rfc.section.5) +[Hyper-Schema Specification, Sections 5 and 6](/work-in-progress/WIP-jsonschema-hyperschema.html#rfc.section.5) keyword | change | notes ---- | ---- | ---- -[`rel`](WIP-jsonschema-hyperschema.html#rfc.section.6.2.1) | **changed** | Can now be an array of values instead of just a string +[`rel`](/work-in-progress/WIP-jsonschema-hyperschema.html#rfc.section.6.2.1) | **changed** | Can now be an array of values instead of just a string diff --git a/work-in-progress/index.md b/work-in-progress/index.md index a9b1dede..36c8a2fa 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -15,7 +15,7 @@ _**UPDATE: Sept 8th, 2019** All PRs have been posted, and we are waiting on fina Once we have completed reviews within the core JSON Schema team, we will publish this draft. -Learn more about the [changes](WIP-json-schema-release-notes.html) in this draft. +Learn more about the [changes](/work-in-progress/WIP-json-schema-release-notes.html) in this draft. ## What Is This Draft Called, Anyway? @@ -59,7 +59,7 @@ _**NOTE:** Links to meta-schemas and among the drafts will not work correctly in ### Change Log / Release Notes: -Learn more about the [changes](WIP-json-schema-release-notes.html) in this draft. +Learn more about the [changes](/work-in-progress/WIP-json-schema-release-notes.html) in this draft. ### General use meta-schemas: From 7e6dd2609937acecc3cdcf1e8743774479e558c9 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 10 Sep 2019 14:54:12 -0700 Subject: [PATCH 078/395] Fix typo for $ref link, better intro wording. --- work-in-progress/WIP-json-schema-release-notes.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/work-in-progress/WIP-json-schema-release-notes.md b/work-in-progress/WIP-json-schema-release-notes.md index c61c2d5f..7a79bf73 100644 --- a/work-in-progress/WIP-json-schema-release-notes.md +++ b/work-in-progress/WIP-json-schema-release-notes.md @@ -3,7 +3,9 @@ title: JSON Schema Draft-2019/09 Release Notes layout: page --- -For the vast majority of schema authors, we hope that these changes are minimally disruptive. The most likely to be frustrating is `format`, which we decided was acceptable as many schema authors are already extremely frustrated by its inconsistent behavior. +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. For implementors, there is a lot more to consider, and further guidance on implementation topics will be forthcoming. @@ -51,7 +53,7 @@ keyword | change | notes [`$defs` (renamed from `definitions`)](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.2.5) | **renamed** | Note that the standard meta-schema still reserves `definitions` for backwards compatibility [`$id`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.2.2) | **changed** | Only URI-references without fragments are allowed; see `$anchor` for a replacement for plain-name fragments; all other fragments in `$id` had undefined behavior previously [`$recursiveAnchor` and `$recursiveRef`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.2.4.2) | **new** | Used for extending recursive schemas such as meta-schemas -[`$ref`] | **changed** | Other keywords are now allowed alongside of it +[`$ref`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.2.4) | **changed** | Other keywords are now allowed alongside of it [`$vocabulary`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.1) | **new** | Has effects only in meta-schemas, and is used to control what keywords an implementation must or can support in order to process a schema using that meta-schema #### Applicator Vocabulary From edeae284fcf289096bf7dd32177a96c518b7c445 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Sat, 14 Sep 2019 16:07:30 -0700 Subject: [PATCH 079/395] One more review update for 2019/09 --- work-in-progress/WIP-jsonschema-core.html | 101 +- work-in-progress/WIP-jsonschema-core.txt | 2774 ++++++++++------- .../WIP-jsonschema-hyperschema.html | 10 +- .../WIP-jsonschema-hyperschema.txt | 258 +- .../WIP-jsonschema-validation.html | 19 +- .../WIP-jsonschema-validation.txt | 240 +- .../WIP-relative-json-pointer.html | 8 +- .../WIP-relative-json-pointer.txt | 30 +- work-in-progress/output/WIP-hyper-schema.json | 2 +- 9 files changed, 1949 insertions(+), 1493 deletions(-) diff --git a/work-in-progress/WIP-jsonschema-core.html b/work-in-progress/WIP-jsonschema-core.html index 6e6dda93..3c3ae48f 100644 --- a/work-in-progress/WIP-jsonschema-core.html +++ b/work-in-progress/WIP-jsonschema-core.html @@ -474,7 +474,7 @@ - + @@ -498,7 +498,7 @@ H. Andrews, Ed. -Expires: March 11, 2020 +Expires: March 17, 2020 @@ -515,7 +515,7 @@ -September 8, 2019 +September 14, 2019 @@ -535,7 +535,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 March 11, 2020.

        +

        This Internet-Draft will expire on March 17, 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.

        @@ -851,7 +851,7 @@

        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 unkonw vocabularies. While keywords can be supported outside of any vocabulary, there is no analogous mechanism to indicate individual keyword usage.

        +

        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.

        @@ -989,9 +989,9 @@

        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.

        -

        The default behavior is simply to collect all values in a list in indeterminate order. Given the extensibility of keywords, including applicators, it is not possible to define a universally predictable order of processing.

        -

        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.

        -

        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.

        +

        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.

        @@ -1006,7 +1006,7 @@

      -

      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.

      +

      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.

      @@ -1017,29 +1017,28 @@

      { "title": "Feature list", "type": "array", - "items": [ - { - "title": "Feature A", - "properties": { - "enabled": { - "$ref": "#/$defs/enabledToggle", - "default": true - } + "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" - } + } + }, + { + "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", @@ -1088,7 +1087,7 @@

      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 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.

      +

      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.

      @@ -1206,7 +1205,7 @@

    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. [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.

    +

    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" @@ -1224,21 +1223,23 @@

    8.2.4.1. Direct References with "$ref"

    -

    The "$ref" keyword is used to reference a statically identified schema. 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.

    +

    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. [CREF9]The difference between the hyper-schema meta-schema in previous drafts and an this draft dramatically demonstrates the utility of these 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. [CREF10]This restriction may be relaxed in the future, but to date only the value "#" has a clear use case.

    +

    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.

    @@ -1254,7 +1255,7 @@

    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. [CREF11]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. [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

    @@ -1287,7 +1288,7 @@

    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. [CREF12]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. [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"

    @@ -1310,7 +1311,12 @@

    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.

    +

    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.

    @@ -1491,34 +1497,35 @@

    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/minLength/$ref/minimum
    +#/properties/width/$ref/minimum
     
                             
    -

    Note that this pointer may not be resolvable due to the inclusion of these applicator keywords.

    +

    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, and it MUST NOT include by-reference applicators such as "$ref" or "$recursiveRef".

    +

    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://json-schema.org/draft/2019-09/schema#/$defs/nonNegativeInteger/minimum
    +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 JSON Pointer.

    +

    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.

    -

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

    +

    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".

    +

    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.

    @@ -1629,7 +1636,7 @@

    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 correllation is more easily identified.

    +

    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:

      @@ -1786,7 +1793,7 @@

    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.

    -

    [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:

    +

    [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"
    @@ -2213,7 +2220,7 @@ 

    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

    -

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

    +

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

    diff --git a/work-in-progress/WIP-jsonschema-core.txt b/work-in-progress/WIP-jsonschema-core.txt index bbca3944..7a407516 100644 --- a/work-in-progress/WIP-jsonschema-core.txt +++ b/work-in-progress/WIP-jsonschema-core.txt @@ -5,11 +5,11 @@ Internet Engineering Task Force A. Wright, Ed. Internet-Draft Intended status: Informational H. Andrews, Ed. -Expires: February 17, 2020 +Expires: March 17, 2020 B. Hutton, Ed. Wellcome Sanger Institute G. Dennis - August 16, 2019 + September 14, 2019 JSON Schema: A Media Type for Describing JSON Documents @@ -53,12 +53,12 @@ Status of This Memo -Wright, et al. Expires February 17, 2020 [Page 1] +Wright, et al. Expires March 17, 2020 [Page 1] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 - This Internet-Draft will expire on February 17, 2020. + This Internet-Draft will expire on March 17, 2020. Copyright Notice @@ -88,94 +88,105 @@ Table of Contents 4.2.3. Instance Equality . . . . . . . . . . . . . . . . . . 7 4.3. JSON Schema Documents . . . . . . . . . . . . . . . . . . 8 4.3.1. JSON Schema Objects and Keywords . . . . . . . . . . 8 - 4.3.2. Boolean JSON Schemas . . . . . . . . . . . . . . . . 8 + 4.3.2. Boolean JSON Schemas . . . . . . . . . . . . . . . . 9 4.3.3. Schema Vocabularies . . . . . . . . . . . . . . . . . 9 4.3.4. Meta-Schemas . . . . . . . . . . . . . . . . . . . . 9 - 4.3.5. Root Schema and Subschemas . . . . . . . . . . . . . 9 + 4.3.5. Root Schema and Subschemas and Resources . . . . . . 10 5. Fragment Identifiers . . . . . . . . . . . . . . . . . . . . 10 6. General Considerations . . . . . . . . . . . . . . . . . . . 11 6.1. Range of JSON Values . . . . . . . . . . . . . . . . . . 11 6.2. Programming Language Independence . . . . . . . . . . . . 11 6.3. Mathematical Integers . . . . . . . . . . . . . . . . . . 11 - 6.4. Regular Expressions . . . . . . . . . . . . . . . . . . . 11 + 6.4. Regular Expressions . . . . . . . . . . . . . . . . . . . 12 6.5. Extending JSON Schema . . . . . . . . . . . . . . . . . . 12 - 7. Keyword Behaviors . . . . . . . . . . . . . . . . . . . . . . 12 + 7. Keyword Behaviors . . . . . . . . . . . . . . . . . . . . . . 13 7.1. Lexical Scope and Dynamic Scope . . . . . . . . . . . . . 13 7.2. Keyword Interactions . . . . . . . . . . . . . . . . . . 14 - 7.3. Default Behaviors . . . . . . . . . . . . . . . . . . . . 14 - 7.4. Applicators . . . . . . . . . . . . . . . . . . . . . . . 15 - 7.4.1. Referenced and Referencing Schemas . . . . . . . . . 15 - 7.5. Assertions . . . . . . . . . . . . . . . . . . . . . . . 16 + 7.3. Default Behaviors . . . . . . . . . . . . . . . . . . . . 15 + 7.4. Identifiers . . . . . . . . . . . . . . . . . . . . . . . 15 + 7.5. Applicators . . . . . . . . . . . . . . . . . . . . . . . 15 + 7.5.1. Referenced and Referencing Schemas . . . . . . . . . 16 -Wright, et al. Expires February 17, 2020 [Page 2] +Wright, et al. Expires March 17, 2020 [Page 2] -Internet-Draft JSON Schema August 2019 - - - 7.5.1. Assertions and Instance Primitive Types . . . . . . . 16 - 7.6. Annotations . . . . . . . . . . . . . . . . . . . . . . . 17 - 7.6.1. Collecting Annotations . . . . . . . . . . . . . . . 17 - 8. The JSON Schema Core Vocabulary . . . . . . . . . . . . . . . 21 - 8.1. Meta-Schemas and Vocabularies . . . . . . . . . . . . . . 22 - 8.1.1. The "$schema" Keyword . . . . . . . . . . . . . . . . 23 - 8.1.2. The "$vocabulary" Keyword . . . . . . . . . . . . . . 23 - 8.1.3. Updates to Meta-Schema and Vocabulary URIs . . . . . 25 - 8.1.4. Detecting a Meta-Schema . . . . . . . . . . . . . . . 25 - 8.1.5. Best Practices for Vocabulary and Meta-Schema Authors 25 - 8.1.6. Example Meta-Schema With Vocabulary Declarations . . 27 - 8.2. Base URI and Dereferencing . . . . . . . . . . . . . . . 28 - 8.2.1. Initial Base URI . . . . . . . . . . . . . . . . . . 28 +Internet-Draft JSON Schema September 2019 + + + 7.6. Assertions . . . . . . . . . . . . . . . . . . . . . . . 16 + 7.6.1. Assertions and Instance Primitive Types . . . . . . . 17 + 7.7. Annotations . . . . . . . . . . . . . . . . . . . . . . . 17 + 7.7.1. Collecting Annotations . . . . . . . . . . . . . . . 18 + 7.8. Reserved Locations . . . . . . . . . . . . . . . . . . . 22 + 8. The JSON Schema Core Vocabulary . . . . . . . . . . . . . . . 22 + 8.1. Meta-Schemas and Vocabularies . . . . . . . . . . . . . . 23 + 8.1.1. The "$schema" Keyword . . . . . . . . . . . . . . . . 24 + 8.1.2. The "$vocabulary" Keyword . . . . . . . . . . . . . . 25 + 8.1.3. Updates to Meta-Schema and Vocabulary URIs . . . . . 26 + 8.1.4. Detecting a Meta-Schema . . . . . . . . . . . . . . . 26 + 8.2. Base URI, Anchors, and Dereferencing . . . . . . . . . . 27 + 8.2.1. Initial Base URI . . . . . . . . . . . . . . . . . . 27 8.2.2. The "$id" Keyword . . . . . . . . . . . . . . . . . . 28 - 8.2.3. Schema References . . . . . . . . . . . . . . . . . . 31 - 8.2.4. Schema Re-Use With "$defs" . . . . . . . . . . . . . 38 - 8.3. Comments With "$comment" . . . . . . . . . . . . . . . . 39 - 9. A Vocabulary for Applying Subschemas . . . . . . . . . . . . 39 - 9.1. Keyword Independence . . . . . . . . . . . . . . . . . . 40 - 9.2. Keywords for Applying Subschemas in Place . . . . . . . . 40 - 9.2.1. Keywords for Applying Subschemas With Boolean Logic . 40 - 9.2.2. Keywords for Applying Subschemas Conditionally . . . 41 - 9.3. Keywords for Applying Subschemas to Child Instances . . . 43 - 9.3.1. Keywords for Applying Subschemas to Arrays . . . . . 43 - 9.3.2. Keywords for Applying Subschemas to Objects . . . . . 45 - 10. Output Formatting . . . . . . . . . . . . . . . . . . . . . . 48 - 10.1. Format . . . . . . . . . . . . . . . . . . . . . . . . . 48 - 10.2. Output Formats . . . . . . . . . . . . . . . . . . . . . 48 - 10.3. Minimum Information . . . . . . . . . . . . . . . . . . 49 - 10.3.1. Keyword Relative Location . . . . . . . . . . . . . 49 - 10.3.2. Keyword Absolute Location . . . . . . . . . . . . . 49 - 10.3.3. Instance Location . . . . . . . . . . . . . . . . . 50 - 10.3.4. Error or Annotation . . . . . . . . . . . . . . . . 50 - 10.3.5. Nested Results . . . . . . . . . . . . . . . . . . . 50 - 10.4. Output Structure . . . . . . . . . . . . . . . . . . . . 50 - 10.4.1. Flag . . . . . . . . . . . . . . . . . . . . . . . . 52 - 10.4.2. Basic . . . . . . . . . . . . . . . . . . . . . . . 52 - 10.4.3. Detailed . . . . . . . . . . . . . . . . . . . . . . 53 - 10.4.4. Verbose . . . . . . . . . . . . . . . . . . . . . . 55 - 10.4.5. Output validation schemas . . . . . . . . . . . . . 57 - 11. Usage for Hypermedia . . . . . . . . . . . . . . . . . . . . 57 - 11.1. Linking to a Schema . . . . . . . . . . . . . . . . . . 57 - 11.2. Identifying a Schema via a Media Type Parameter . . . . 57 - 11.3. Usage Over HTTP . . . . . . . . . . . . . . . . . . . . 59 - 12. Security Considerations . . . . . . . . . . . . . . . . . . . 59 - 13. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 60 - 13.1. application/schema+json . . . . . . . . . . . . . . . . 60 - 13.2. application/schema-instance+json . . . . . . . . . . . . 61 - - - -Wright, et al. Expires February 17, 2020 [Page 3] - -Internet-Draft JSON Schema August 2019 - - - 14. References . . . . . . . . . . . . . . . . . . . . . . . . . 61 - 14.1. Normative References . . . . . . . . . . . . . . . . . . 61 - 14.2. Informative References . . . . . . . . . . . . . . . . . 62 - Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . 64 - Appendix B. ChangeLog . . . . . . . . . . . . . . . . . . . . . 64 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 67 + 8.2.3. Defining location-independent identifiers with + "$anchor" . . . . . . . . . . . . . . . . . . . . . . 30 + 8.2.4. Schema References . . . . . . . . . . . . . . . . . . 31 + 8.2.5. Schema Re-Use With "$defs" . . . . . . . . . . . . . 36 + 8.3. Comments With "$comment" . . . . . . . . . . . . . . . . 36 + 9. A Vocabulary for Applying Subschemas . . . . . . . . . . . . 37 + 9.1. Keyword Independence . . . . . . . . . . . . . . . . . . 37 + 9.2. Keywords for Applying Subschemas in Place . . . . . . . . 38 + 9.2.1. Keywords for Applying Subschemas With Boolean Logic . 38 + 9.2.2. Keywords for Applying Subschemas Conditionally . . . 39 + 9.3. Keywords for Applying Subschemas to Child Instances . . . 41 + 9.3.1. Keywords for Applying Subschemas to Arrays . . . . . 41 + 9.3.2. Keywords for Applying Subschemas to Objects . . . . . 43 + 10. Output Formatting . . . . . . . . . . . . . . . . . . . . . . 45 + 10.1. Format . . . . . . . . . . . . . . . . . . . . . . . . . 46 + 10.2. Output Formats . . . . . . . . . . . . . . . . . . . . . 46 + 10.3. Minimum Information . . . . . . . . . . . . . . . . . . 46 + 10.3.1. Keyword Relative Location . . . . . . . . . . . . . 47 + 10.3.2. Keyword Absolute Location . . . . . . . . . . . . . 47 + 10.3.3. Instance Location . . . . . . . . . . . . . . . . . 47 + 10.3.4. Error or Annotation . . . . . . . . . . . . . . . . 47 + 10.3.5. Nested Results . . . . . . . . . . . . . . . . . . . 48 + 10.4. Output Structure . . . . . . . . . . . . . . . . . . . . 48 + 10.4.1. Flag . . . . . . . . . . . . . . . . . . . . . . . . 50 + 10.4.2. Basic . . . . . . . . . . . . . . . . . . . . . . . 50 + 10.4.3. Detailed . . . . . . . . . . . . . . . . . . . . . . 51 + 10.4.4. Verbose . . . . . . . . . . . . . . . . . . . . . . 53 + 10.4.5. Output validation schemas . . . . . . . . . . . . . 55 + 11. Usage for Hypermedia . . . . . . . . . . . . . . . . . . . . 55 + 11.1. Linking to a Schema . . . . . . . . . . . . . . . . . . 55 + 11.2. Identifying a Schema via a Media Type Parameter . . . . 55 + 11.3. Usage Over HTTP . . . . . . . . . . . . . . . . . . . . 57 + 12. Security Considerations . . . . . . . . . . . . . . . . . . . 57 + 13. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 58 + + + +Wright, et al. Expires March 17, 2020 [Page 3] + +Internet-Draft JSON Schema September 2019 + + + 13.1. application/schema+json . . . . . . . . . . . . . . . . 58 + 13.2. application/schema-instance+json . . . . . . . . . . . . 59 + 14. References . . . . . . . . . . . . . . . . . . . . . . . . . 59 + 14.1. Normative References . . . . . . . . . . . . . . . . . . 59 + 14.2. Informative References . . . . . . . . . . . . . . . . . 60 + Appendix A. Schema identification examples . . . . . . . . . . . 62 + Appendix B. Manipulating schema documents and references . . . . 64 + B.1. Bundling schema resources into a single document . . . . 64 + B.2. Reference removal is not always safe . . . . . . . . . . 64 + Appendix C. Example of recursive schema extension . . . . . . . 65 + Appendix D. Working with vocabularies . . . . . . . . . . . . . 66 + D.1. Best practices for vocabulary and meta-schema authors . . 66 + D.2. Example meta-schema with vocabulary declarations . . . . 67 + Appendix E. References and generative use cases . . . . . . . . 70 + Appendix F. Acknowledgments . . . . . . . . . . . . . . . . . . 71 + Appendix G. ChangeLog . . . . . . . . . . . . . . . . . . . . . 71 + Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 74 1. Introduction @@ -207,6 +218,14 @@ Internet-Draft JSON Schema August 2019 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 + + + +Wright, et al. Expires March 17, 2020 [Page 4] + +Internet-Draft JSON Schema September 2019 + + 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. @@ -216,16 +235,6 @@ Internet-Draft JSON Schema August 2019 keywords are used to apply assertions and annotations to more complex JSON data structures, or based on some sort of condition. - - - - - -Wright, et al. Expires February 17, 2020 [Page 4] - -Internet-Draft JSON Schema August 2019 - - To facilitate re-use, keywords can be organized into vocabularies. A vocabulary consists of a list of keywords, together with their syntax and semantics. @@ -264,23 +273,22 @@ Internet-Draft JSON Schema August 2019 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]. +Wright, et al. Expires March 17, 2020 [Page 5] + +Internet-Draft JSON Schema September 2019 -Wright, et al. Expires February 17, 2020 [Page 5] - -Internet-Draft JSON Schema August 2019 + 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 @@ -321,6 +329,15 @@ Internet-Draft JSON Schema August 2019 formatted strings within the data model rather than relying on having the original JSON representation Unicode characters available. + + + + +Wright, et al. Expires March 17, 2020 [Page 6] + +Internet-Draft JSON Schema September 2019 + + 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 @@ -329,15 +346,6 @@ Internet-Draft JSON Schema August 2019 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 - - - - -Wright, et al. Expires February 17, 2020 [Page 6] - -Internet-Draft JSON Schema August 2019 - - type for a vocabulary to define as a value for a keyword, but the data model makes no distinction between integers and other numbers. @@ -379,21 +387,19 @@ Internet-Draft JSON Schema August 2019 property with a key equal to the other's, and that other property has an equal value. + + +Wright, et al. Expires March 17, 2020 [Page 7] + +Internet-Draft JSON Schema September 2019 + + 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. - - - - -Wright, et al. Expires February 17, 2020 [Page 7] - -Internet-Draft JSON Schema August 2019 - - 4.3. JSON Schema Documents A JSON Schema document, or simply a schema, is a JSON document used @@ -410,7 +416,11 @@ Internet-Draft JSON Schema August 2019 Object properties that are applied to the instance are called keywords, or schema keywords. Broadly speaking, keywords fall into - one of three categories: + 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 @@ -419,6 +429,9 @@ Internet-Draft JSON Schema August 2019 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 @@ -430,6 +443,13 @@ Internet-Draft JSON Schema August 2019 A JSON Schema MAY contain properties which are not schema keywords. Unknown keywords SHOULD be ignored. + + +Wright, et al. Expires March 17, 2020 [Page 8] + +Internet-Draft JSON Schema September 2019 + + An empty schema is a JSON Schema with no properties, or only unknown properties. @@ -441,15 +461,6 @@ Internet-Draft JSON Schema August 2019 These boolean schemas exist to clarify schema author intent and facilitate schema processing optimizations. They behave identically - - - - -Wright, et al. Expires February 17, 2020 [Page 8] - -Internet-Draft JSON Schema August 2019 - - to the following schema objects (where "not" is part of the subschema application vocabulary defined in this document). @@ -473,7 +484,7 @@ Internet-Draft JSON Schema August 2019 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 unkonw vocabularies. While keywords can be + to support previously unknown vocabularies. While keywords can be supported outside of any vocabulary, there is no analogous mechanism to indicate individual keyword usage. @@ -487,25 +498,31 @@ Internet-Draft JSON Schema August 2019 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 + + + +Wright, et al. Expires March 17, 2020 [Page 9] + +Internet-Draft JSON Schema September 2019 + + 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 +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]. The root schema is the schema that comprises the entire JSON document - in question. + 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: - -Wright, et al. Expires February 17, 2020 [Page 9] - -Internet-Draft JSON Schema August 2019 - - { "title": "root", "items": { @@ -520,6 +537,14 @@ Internet-Draft JSON Schema August 2019 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 @@ -528,6 +553,15 @@ Internet-Draft JSON Schema August 2019 document, there is no fragment identification syntax defined for "application/json".) + + + + +Wright, et al. Expires March 17, 2020 [Page 10] + +Internet-Draft JSON Schema September 2019 + + 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 @@ -547,20 +581,8 @@ Internet-Draft JSON Schema August 2019 identifiers. Defining and referencing a plain name fragment identifier within an - "application/schema+json" document are specified in the "$id" keyword - (Section 8.2.2) section. - - - - - - - - -Wright, et al. Expires February 17, 2020 [Page 10] - -Internet-Draft JSON Schema August 2019 - + "application/schema+json" document are specified in the "$anchor" + keyword (Section 8.2.3) section. 6. General Considerations @@ -585,6 +607,17 @@ Internet-Draft JSON Schema August 2019 For consistency, integer JSON numbers SHOULD NOT be encoded with a fractional part. + + + + + + +Wright, et al. Expires March 17, 2020 [Page 11] + +Internet-Draft JSON Schema September 2019 + + 6.4. Regular Expressions Keywords MAY use regular expressions to express constraints, or @@ -610,14 +643,6 @@ Internet-Draft JSON Schema August 2019 least x, at most y, occurrences), {x,} (x occurrences or more), and their lazy versions; - - - -Wright, et al. Expires February 17, 2020 [Page 11] - -Internet-Draft JSON Schema August 2019 - - the beginning-of-input ("^") and end-of-input ("$") anchors; simple grouping ("(...)") and alternation ("|"). @@ -639,6 +664,16 @@ Internet-Draft JSON Schema August 2019 mechanism for registering and implementing such handlers is implementation-dependent. + + + + + +Wright, et al. Expires March 17, 2020 [Page 12] + +Internet-Draft JSON Schema September 2019 + + 7. Keyword Behaviors JSON Schema keywords fall into several general behavior categories. @@ -666,14 +701,6 @@ Internet-Draft JSON Schema August 2019 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 - - - -Wright, et al. Expires February 17, 2020 [Page 12] - -Internet-Draft JSON Schema August 2019 - - 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 @@ -695,13 +722,21 @@ Internet-Draft JSON Schema August 2019 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 + + + +Wright, et al. Expires March 17, 2020 [Page 13] + +Internet-Draft JSON Schema September 2019 + + 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 the document's root schema. + 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 @@ -722,14 +757,6 @@ Internet-Draft JSON Schema August 2019 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 - - - -Wright, et al. Expires February 17, 2020 [Page 13] - -Internet-Draft JSON Schema August 2019 - - dynamic parent, rather than examining the local lexically enclosing parent. @@ -749,6 +776,16 @@ Internet-Draft JSON Schema August 2019 behavior based on the presence or absence of another keyword in the same schema object (Section 4.3). + + + + + +Wright, et al. Expires March 17, 2020 [Page 14] + +Internet-Draft JSON Schema September 2019 + + 7.3. Default Behaviors A missing keyword MUST NOT produce a false assertion result, MUST NOT @@ -775,22 +812,36 @@ Internet-Draft JSON Schema August 2019 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 (Section 8.2.4), 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 (Section 4.3) begins by applying the root -Wright, et al. Expires February 17, 2020 [Page 14] +Wright, et al. Expires March 17, 2020 [Page 15] -Internet-Draft JSON Schema August 2019 - +Internet-Draft JSON Schema September 2019 -7.4. 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 @@ -803,18 +854,18 @@ Internet-Draft JSON Schema August 2019 is defined by the keyword. Applicator keywords also define how subschema or referenced schema - boolean assertion (Section 7.5) results are modified and/or combined + 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.6) results are combined according to the rules + Annotation (Section 7.7) results are combined according to the rules specified by each annotation keyword. -7.4.1. Referenced and Referencing Schemas +7.5.1. Referenced and Referencing Schemas - As noted in Section 7.4, an applicator keyword may refer to a schema + 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 @@ -826,35 +877,33 @@ Internet-Draft JSON Schema August 2019 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), + For some by-reference applicators, such as "$ref" (Section 8.2.4.1), 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. -Wright, et al. Expires February 17, 2020 [Page 15] +Wright, et al. Expires March 17, 2020 [Page 16] -Internet-Draft JSON Schema August 2019 - +Internet-Draft JSON Schema September 2019 -7.5. 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.5.1. Assertions and Instance Primitive Types +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 @@ -887,18 +936,7 @@ Internet-Draft JSON Schema August 2019 otherwise, so if "maxLength" restricted the instance to strings, then including "null" in "type" would not have any useful effect. - - - - - - -Wright, et al. Expires February 17, 2020 [Page 16] - -Internet-Draft JSON Schema August 2019 - - -7.6. Annotations +7.7. Annotations JSON Schema can annotate an instance with information, whenever the instance validates against the schema object containing the @@ -908,25 +946,36 @@ Internet-Draft JSON Schema August 2019 Annotations are attached to specific locations in an instance. Since many subschemas can be applied to any single location, annotation + + + +Wright, et al. Expires March 17, 2020 [Page 17] + +Internet-Draft JSON Schema September 2019 + + keywords need to specify any unusual handling of multiple applicable occurrences of the keyword with different values. - The default behavior is simply to collect all values in a list in - indeterminate order. Given the extensibility of keywords, including - applicators, it is not possible to define a universally predictable - order of processing. - 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 [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. + 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.6.1. Collecting Annotations +7.7.1. Collecting Annotations Annotations are collected by keywords that explicitly define annotation-collecting behavior. Note that boolean schemas cannot @@ -947,19 +996,21 @@ Internet-Draft JSON Schema August 2019 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 + (Section 10) described in this specification that include annotation + information meet this requirement. + -Wright, et al. Expires February 17, 2020 [Page 17] +Wright, et al. Expires March 17, 2020 [Page 18] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 - 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. - -7.6.1.1. Distinguishing Among Multiple Values +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 @@ -1005,9 +1056,14 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 17, 2020 [Page 18] + + + + + +Wright, et al. Expires March 17, 2020 [Page 19] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 Note that some lines are wrapped for clarity. @@ -1016,29 +1072,28 @@ Internet-Draft JSON Schema August 2019 { "title": "Feature list", "type": "array", - "items": [ - { - "title": "Feature A", - "properties": { - "enabled": { - "$ref": "#/$defs/enabledToggle", - "default": true - } + "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" - } + } + }, + { + "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", @@ -1057,18 +1112,16 @@ Internet-Draft JSON Schema August 2019 "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. - -Wright, et al. Expires February 17, 2020 [Page 19] +Wright, et al. Expires March 17, 2020 [Page 20] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 - 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 @@ -1096,7 +1149,7 @@ Internet-Draft JSON Schema August 2019 presence of two different values for "default" to be an error, regardless of their schema locations. -7.6.1.2. Annotations and Assertions +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 @@ -1117,9 +1170,12 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 17, 2020 [Page 20] + + + +Wright, et al. Expires March 17, 2020 [Page 21] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 { @@ -1141,7 +1197,7 @@ Internet-Draft JSON Schema August 2019 fails. The title annotation "String Value" is kept, as the instance passes the string type assertions. -7.6.1.3. Annotations and Applicators +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 @@ -1149,13 +1205,34 @@ Internet-Draft JSON Schema August 2019 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 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. + 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. + + + +Wright, et al. Expires March 17, 2020 [Page 22] + +Internet-Draft JSON Schema September 2019 + The Core vocabulary MUST be considered mandatory at all times, in order to bootstrap the processing of further vocabularies. Meta- @@ -1170,23 +1247,15 @@ Internet-Draft JSON Schema August 2019 error when they occur. It is not meaningful to declare that a meta- schema optionally uses Core. - - - -Wright, et al. Expires February 17, 2020 [Page 21] - -Internet-Draft JSON Schema August 2019 - - 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: . + draft/2019-09/vocab/core>. The current URI for the corresponding meta-schema is: . + 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 @@ -1214,6 +1283,13 @@ Internet-Draft JSON Schema August 2019 describe an incompatible syntax, such a meta-schema would be unlikely to be useful. + + +Wright, et al. Expires March 17, 2020 [Page 23] + +Internet-Draft JSON Schema September 2019 + + 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 @@ -1226,14 +1302,6 @@ Internet-Draft JSON Schema August 2019 design of meta-schema features emphasizes flexibility over simplicity. - - - -Wright, et al. Expires February 17, 2020 [Page 22] - -Internet-Draft JSON Schema August 2019 - - 8.1.1. The "$schema" Keyword The "$schema" keyword is both used as a JSON Schema feature set @@ -1248,22 +1316,36 @@ Internet-Draft JSON Schema August 2019 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 root schema. It MUST NOT - appear in subschemas. If absent from the root schema, the resulting - behavior 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. - ]] + 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. + + + +Wright, et al. Expires March 17, 2020 [Page 24] + +Internet-Draft JSON Schema September 2019 + + 8.1.2. The "$vocabulary" Keyword The "$vocabulary" keyword is used in meta-schemas to identify the @@ -1282,32 +1364,24 @@ Internet-Draft JSON Schema August 2019 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. - - - -Wright, et al. Expires February 17, 2020 [Page 23] - -Internet-Draft JSON Schema August 2019 - - - [[CREF3: Vocabulary documents may be added shortly, or in the next - draft. 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. ]] + [[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 MAY choose to proceed with processing such - schemas. + recognize the vocabulary SHOULD proceed with processing such schemas. - When processing a schema that uses unrecognized vocabularies, - keywords declared by those vocabularies are treated like any other - unrecognized keyword, and ignored. + 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 @@ -1318,11 +1392,21 @@ Internet-Draft JSON Schema August 2019 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 + + + + +Wright, et al. Expires March 17, 2020 [Page 25] + +Internet-Draft JSON Schema September 2019 + + +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. @@ -1337,15 +1421,6 @@ Internet-Draft JSON Schema August 2019 use of all vocabularies in this specification and the companion Validation specification. - - - - -Wright, et al. Expires February 17, 2020 [Page 24] - -Internet-Draft JSON Schema August 2019 - - 8.1.2.2. Non-inheritability of vocabularies Note that the processing restrictions on "$vocabulary" mean that @@ -1354,7 +1429,13 @@ Internet-Draft JSON Schema August 2019 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 - (Section 8.1.6). + (Appendix D.2). [[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 @@ -1369,6 +1450,14 @@ Internet-Draft JSON Schema August 2019 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 + + + +Wright, et al. Expires March 17, 2020 [Page 26] + +Internet-Draft JSON Schema September 2019 + + sometimes be considered a regular schema, and other times be considered a meta-schema. @@ -1385,144 +1474,17 @@ Internet-Draft JSON Schema August 2019 requirements up front. Meta-schema authors MUST NOT expect such features to be interoperable across implementations. -8.1.5. 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. - - - - - -Wright, et al. Expires February 17, 2020 [Page 25] - -Internet-Draft JSON Schema August 2019 - - - 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 9.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 "$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. - - - - - - - -Wright, et al. Expires February 17, 2020 [Page 26] - -Internet-Draft JSON Schema August 2019 - - -8.1.6. Example Meta-Schema With Vocabulary Declarations - - This meta-schema explicitly declares both the Core and Applicator - vocabularies, and combines their meta-schemas with an "allOf". It - additionally restricts the usage of the Applicator vocabulary by - forbidding the keyword prefixed with "unevaluated". It also - describes a keyword, "localKeyword", that is not part of either - vocabulary. Note that it is its own meta-schema, as it relies on - both the Core vocabulary (as all schemas do) and the Applicator - vocabulary (for "allOf"). - - - { - "$schema": "https://json-schema.org/draft/2019-08/core-app-example#", - "$id": "https://json-schema.org/draft/2019-08/core-app-example", - "$recursiveAnchor": true, - "$vocabulary": { - "https://json-schema.org/draft/2019-08/vocab/core": true, - "https://json-schema.org/draft/2019-08/vocab/applicator": true - }, - "allOf": [ - {"$ref": "https://json-schema.org/draft/2019-08/meta/core"}, - {"$ref": "https://json-schema.org/draft/2019-08/meta/applicator"} - ], - "patternProperties": { - "^unevaluated.*$": false - }, - "properties": { - "$comment": "Not in vocabulary, but validated if used", - "localKeyword": { - "type": "string" - } - } - } - - - As shown above, even though each of the referenced standard meta- - schemas declares its corresponding vocabulary, this new meta-schema - must re-declare them for itself. It would be valid to leave the core - vocabulary out of the "$vocabulary" keyword, but it needs to be - referenced through the "allOf" keyword in order for its terms to be - validated. There is no special case for validation of core keywords. - - 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. - - - - -Wright, et al. Expires February 17, 2020 [Page 27] - -Internet-Draft JSON Schema August 2019 - - - These URIs for these meta-schemas may be found in the Validation and - Hyper-Schema specifications, respectively. - -8.2. Base URI and Dereferencing +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. Initial Base URI RFC3986 Section 5.1 [RFC3986] defines how to determine the default @@ -1542,71 +1504,59 @@ Internet-Draft JSON Schema August 2019 in RFC 3986 Section 5.1.4 [RFC3986]. It is RECOMMENDED that implementations document any default base URI that they assume. -8.2.2. The "$id" Keyword - - The "$id" keyword defines a URI for the schema, and the base URI that - other URI references within the schema are resolved against. A - subschema's "$id" is resolved against the base URI of its parent - schema. If no parent schema defines an explicit base URI with "$id", - the base URI is that of the entire document, as determined per RFC - 3986 section 5 [RFC3986]. - - If present, the value for this keyword MUST be a string, and MUST - represent a valid URI-reference [RFC3986]. This value SHOULD be - normalized, and SHOULD NOT be an empty fragment <#> or an empty - string <>. - -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 [RFC3986] (containing a scheme, but no - fragment), or this absolute URI but with an empty fragment. -Wright, et al. Expires February 17, 2020 [Page 28] +Wright, et al. Expires March 17, 2020 [Page 27] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 -8.2.2.2. Changing the base URI within a schema file + 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. - When an "$id" sets the base URI, the object containing that "$id" and - all of its subschemas can be identified by using a JSON Pointer - fragment starting from that location. This is true even of - subschemas that further change the base URI. Therefore, a single - subschema may be accessible by multiple URIs, each consisting of base - URI declared in the subschema or a parent, along with a JSON Pointer - fragment identifying the path from the schema object that declares - the base to the subschema being identified. Examples of this are - shown in section 8.2.2.4. +8.2.2. The "$id" Keyword -8.2.2.3. Location-independent identifiers + The "$id" keyword identifies a schema resource with its canonical + [RFC6596] URI. - 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. + 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. - To specify such a subschema identifier, the "$id" keyword is set to a - URI reference with a plain name fragment (not a JSON Pointer - fragment). This value MUST begin with the number sign that specifies - a fragment ("#"), then a letter ([A-Za-z]), followed by any number of - letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons - (":"), or periods ("."). + 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). Therefore, "$id" MUST NOT contain a non-empty fragment, + and SHOULD NOT contain an empty fragment. - The effect of using a fragment in "$id" that isn't blank or doesn't - follow the plain name syntax is undefined. [[CREF4: How should an - "$id" URI reference containing a fragment with other components be - interpreted? There are two cases: when the other components match - the current base URI and when they change the base URI. ]] + 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". ]] -8.2.2.4. Schema identification examples + 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 [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 8.2.1) @@ -1615,106 +1565,157 @@ Internet-Draft JSON Schema August 2019 +Wright, et al. Expires March 17, 2020 [Page 28] + +Internet-Draft JSON Schema September 2019 +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 [RFC3986] (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. -Wright, et al. Expires February 17, 2020 [Page 29] - -Internet-Draft JSON Schema August 2019 + Conceptually, a set of linked schema resources should behave + identically whether each resource is a separate document connected + with schema references (Section 8.2.4), 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, which shows "$id" being used to - identify the root schema, change the base URI for subschemas, and - assign plain name fragments to subschemas: + Consider the following schema document that contains another schema + resource embedded within it: { - "$id": "https://example.com/root.json", - "$defs": { - "A": { "$id": "#foo" }, - "B": { - "$id": "other.json", - "$defs": { - "X": { "$id": "#bar" }, - "Y": { "$id": "t/inner.json" } - } - }, - "C": { - "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f" - } - } + "$id": "https://example.com/foo", + "items": { + "$id": "https://example.com/bar", + "additionalProperties": { } + } } - 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 Section 5 above: + 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". - # (document root) - https://example.com/root.json - https://example.com/root.json# - #/$defs/A - https://example.com/root.json#foo - https://example.com/root.json#/$defs/A - #/$defs/B - https://example.com/other.json - https://example.com/other.json# +Wright, et al. Expires March 17, 2020 [Page 29] + +Internet-Draft JSON Schema September 2019 - https://example.com/root.json#/$defs/B - #/$defs/B/$defs/X + Now consider the following two schema resources linked by reference + using a URI value for "$ref": + { + "$id": "https://example.com/foo", + "items": { + "$ref": "bar" + } + } -Wright, et al. Expires February 17, 2020 [Page 30] - -Internet-Draft JSON Schema August 2019 + { + "$id": "https://example.com/bar", + "additionalProperties": { } + } - https://example.com/other.json#bar + 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. - https://example.com/other.json#/$defs/X + 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. - https://example.com/root.json#/$defs/B/$defs/X + 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. ]] - #/$defs/B/$defs/Y + Further examples of such non-canonical URIs, as well as the + appropriate canonical URIs to use instead, are provided in appendix + A. - https://example.com/t/inner.json +8.2.3. Defining location-independent identifiers with "$anchor" - https://example.com/t/inner.json# + 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 - https://example.com/other.json#/$defs/Y - https://example.com/root.json#/$defs/B/$defs/Y - #/$defs/C +Wright, et al. Expires March 17, 2020 [Page 30] + +Internet-Draft JSON Schema September 2019 - urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f - urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f# + 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. - https://example.com/root.json#/$defs/C + 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. ]] -8.2.3. Schema References + 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 a helper keyword that controls how - the referenced schema of "$recursiveRef" is determined. + instance. "$recursiveAnchor" is an identifier keyword that controls + how the base URI for resolving the URI-reference value of + "$recursiveRef is determined. - As the value of "$ref" and "$recursiveRef" are URI References, this + 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. @@ -1725,24 +1726,31 @@ Internet-Draft JSON Schema August 2019 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 used to reference a statically identified - schema. -Wright, et al. Expires February 17, 2020 [Page 31] + + +Wright, et al. Expires March 17, 2020 [Page 31] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 - The value of the "$ref" property MUST be a string which is a URI - Reference. Resolved against the current URI base, it identifies the - URI of a schema to use. +8.2.4.1. Direct References with "$ref" -8.2.3.2. Recursive References with "$recursiveRef" and + 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 @@ -1750,38 +1758,86 @@ Internet-Draft JSON Schema August 2019 that has a reference to its own root, identified by the empty fragment URI reference ("#"). - Extending a recursive schema with "$ref" alone involves redefining - all recursive references in the source schema to point to the root of - the extension. This produces the correct recursive behavior in the - extension, which is that all recursion should reference the root of - the extension. - - - + 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". +Wright, et al. Expires March 17, 2020 [Page 32] + +Internet-Draft JSON Schema September 2019 + 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 (Section 7.1) 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. @@ -1789,305 +1845,104 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 17, 2020 [Page 32] +Wright, et al. Expires March 17, 2020 [Page 33] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 - Consider the following two schemas. The first schema, identified as - "original" as it is the schema to be extended, describes an object - with one string property and one recursive reference property, "r". - The second schema, identified as "extension", references the first, - and describes an additional "things" property, which is an array of - recursive references. It also repeats the description of "r" from - the original schema. +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" (Section 8.2.5) 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. - { - "$schema": "https://json-schema.org/draft/2019-08/schema#", - "$id": "https://example.com/original", + 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. ]] - "properties": { - "name": { - "type": "string" - }, - "r": { - "$ref": "#" - } - } - } + 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. - { - "$schema": "https://json-schema.org/draft/2019-08/schema#", - "$id": "https://example.com/extension", +8.2.4.5. Loading a referenced schema - "$ref": "original", - "properties": { - "r": { - "$ref": "#" - }, - "things": { - "type": "array" - "items": { - "$ref": "#" - } - } - } - } + 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 (Section 11). - This apparent duplication is important because it resolves to - "https://example.com/extension#", meaning that for instance validated - against the extension schema, the value of "r" must be valid - according to the extension, and not just the original schema as "r" - was described there. + 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 -Wright, et al. Expires February 17, 2020 [Page 33] +Wright, et al. Expires March 17, 2020 [Page 34] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 - This approach is fine for a single recursive field, but the more - complicated the original schema, the more redefinitions are necessary - in the extension. This leads to a verbose and error-prone extension, - which must be kept synchronized with the original schema if the - original changes its recursive fields. This approach can be seen in - the meta-schema for JSON Hyper-Schema in all prior drafts. - -8.2.3.2.1. Enabling Recursion with "$recursiveAnchor" + document as it is processed, producing associations as shown in + appendix A. - The desired behavior is for the recursive reference, "r", in the - original schema to resolve to the original schema when that is the - only schema being used, but to resolve to the extension schema when - using the extension. Then there would be no need to redefine the "r" - property, or others like it, in the extension. + 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. - In order to create a recursive reference, we must do three things: +8.2.4.6. Dereferencing - In our original schema, indicate that the schema author intends - for it to be extensible recursively. + 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]. - In our extension schema, indicate that it is intended to be a - recursive extension. + 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. - Use a reference keyword that explicitly activates the recursive - behavior at the point of reference. + For example, consider this schema: - These three things together ensure that all schema authors are - intentionally constructing a recursive extension, which in turn gives - all uses of the regular "$ref" keyword confidence that it only - behaves as it appears to, using lexical scoping. - The "$recursiveAnchor" keyword is how schema authors indicate that a - schema can be extended recursively, and be a recursive schema. This - keyword MAY appear in the root schema of a schema document, and MUST - NOT appear in any subschema. - - The value of "$recursiveAnchor" MUST be of type boolean, and MUST be - true. The value false is reserved for possible future use. - -8.2.3.2.2. Dynamically recursive references with "$recursiveRef" - - The "$recursiveRef" keyword behaves identically to "$ref", except - that if the referenced schema has "$recursiveAnchor" set to true, - then the implementation MUST examine the dynamic scope for the - outermost (first seen) schema document with "$recursiveAnchor" set to - true. If such a schema document exists, then the target of the - "$recursiveRef" MUST be set to that document's URI, in place of the - URI produced by the rules for "$ref". - - - -Wright, et al. Expires February 17, 2020 [Page 34] - -Internet-Draft JSON Schema August 2019 - - - Note that if the schema referenced by "$recursiveRef" does not - contain "$recursiveAnchor" set to true, or if there are no other - "$recursiveAnchor" keywords set to true anywhere further back in the - dynamic scope, then "$recursiveRef"'s behavior is identical to that - of "$ref". - - With this in mind, we can rewrite the previous example: - - - { - "$schema": "https://json-schema.org/draft/2019-08/schema#", - "$id": "https://example.com/original", - "$recursiveAnchor": true, - - "properties": { - "name": { - "type": "string" - }, - "r": { - "$recursiveRef": "#" - } - } - } - - { - "$schema": "https://json-schema.org/draft/2019-08/schema#", - "$id": "https://example.com/extension", - "$recursiveAnchor": true, - - "$ref": "original", - "properties": { - "things": { - "type": "array" - "items": { - "$recursiveRef": "#" - } - } - } - } - - - Note that the "r" property no longer appears in the extension schema. - Instead, all "$ref"s have been changed to "$recursiveRef"s, and both - schemas have "$recursiveAnchor" set to true in their root schema. - - When using the original schema on its own, there is no change in - behavior. The "$recursiveRef" does lead to a schema where - "$recursiveAnchor" is set to true, but since the original schema is - - - -Wright, et al. Expires February 17, 2020 [Page 35] - -Internet-Draft JSON Schema August 2019 - - - the only schema document in the dynamics scope (it references itself, - and does not reference any other schema documents), the behavior is - effectively the same as "$ref". - - When using the extension schema, the "$recursiveRef" within that - schema (for the array items within "things") also effectively behaves - like "$ref". The extension schema is the outermost dynamic scope, so - the reference target is not changed. - - In contrast, when using the extension schema, the "$recursiveRef" for - "r" in the original schema now behaves differently. Its initial - target is the root schema of the original schema document, which has - "$recursiveAnchor" set to true. In this case, the outermost dynamic - scope that also has "$recursiveAnchor" set to true is the extension - schema. So when using the extensions schema, "r"'s reference in the - original schema will resolve to "https://example.com/extension#", not - "https://example.com/original#". - -8.2.3.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.3.4. References to Possible Non-Schemas - - Subschema objects (or booleans) are recognized by their use with - known applicator keywords. These keywords may be 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. [[CREF5: 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. ]] - - - -Wright, et al. Expires February 17, 2020 [Page 36] - -Internet-Draft JSON Schema August 2019 - - - 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.3.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 (Section 11). - - 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 - section 8.2.2.4. - - 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.3.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 [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: - - - - - - - -Wright, et al. Expires February 17, 2020 [Page 37] - -Internet-Draft JSON Schema August 2019 - - - { - "$id": "https://example.net/root.json", - "items": { - "type": "array", - "items": { "$ref": "#item" } - }, - "$defs": { - "single": { - "$id": "#item", - "type": "object", - "additionalProperties": { "$ref": "other.json" } - } - } - } + { + "$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 @@ -2099,11 +1954,19 @@ Internet-Draft JSON Schema August 2019 , which it has seen defined in this same document and can therefore use automatically. + + + +Wright, et al. Expires March 17, 2020 [Page 35] + +Internet-Draft JSON Schema September 2019 + + When an implementation encounters the reference to "other.json", it resolves this to , 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. [[CREF6: What should implementations do when the + 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 @@ -2111,25 +1974,15 @@ Internet-Draft JSON Schema August 2019 system dynamically, so placing an absolute requirement of pre-loading schema documents is not feasible. ]] -8.2.4. Schema Re-Use With "$defs" +8.2.5. Schema Re-Use With "$defs" - The "$defs" keyword provides a standardized location for schema - authors to inline re-usable JSON Schemas into a more general schema. - The keyword does not directly affect the validation result. + 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. - - - - - -Wright, et al. Expires February 17, 2020 [Page 38] - -Internet-Draft JSON Schema August 2019 - - As an example, here is a schema describing an array of positive integers, where the positive integer constraint is a subschema in "$defs": @@ -2149,53 +2002,58 @@ Internet-Draft JSON Schema August 2019 8.3. Comments With "$comment" - This keyword is reserved 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. + 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. + + + +Wright, et al. Expires March 17, 2020 [Page 36] + +Internet-Draft JSON Schema September 2019 + + 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. + described in this specification. -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. + 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 -Wright, et al. Expires February 17, 2020 [Page 39] - -Internet-Draft JSON Schema August 2019 - + 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: . The current URI for the corresponding meta-schema is: . + 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 @@ -2208,6 +2066,14 @@ Internet-Draft JSON Schema August 2019 Schema keywords typically operate independently, without affecting each other's outcomes. + + + +Wright, et al. Expires March 17, 2020 [Page 37] + +Internet-Draft JSON Schema September 2019 + + For schema author convenience, there are some exceptions among the keywords in this vocabulary: @@ -2234,14 +2100,6 @@ Internet-Draft JSON Schema August 2019 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 - - - -Wright, et al. Expires February 17, 2020 [Page 40] - -Internet-Draft JSON Schema August 2019 - - same annotation keyword to be applied to an instance location with different values. Annotation keywords define their own rules for combining such values. @@ -2263,6 +2121,15 @@ Internet-Draft JSON Schema August 2019 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 + + + + +Wright, et al. Expires March 17, 2020 [Page 38] + +Internet-Draft JSON Schema September 2019 + + subschemas MUST be examined so that annotations are collected from each subschema that validates successfully. @@ -2290,14 +2157,6 @@ Internet-Draft JSON Schema August 2019 "if", "then", and "else" MUST NOT interact with each other across subschema boundaries. In other words, an "if" in one branch of an - - - -Wright, et al. Expires February 17, 2020 [Page 41] - -Internet-Draft JSON Schema August 2019 - - "allOf" MUST NOT have an impact on a "then" or "else" in another branch. @@ -2318,11 +2177,20 @@ Internet-Draft JSON Schema August 2019 MUST also be valid against the subschema value of the "then" keyword, if present. + + + + +Wright, et al. Expires March 17, 2020 [Page 39] + +Internet-Draft JSON Schema September 2019 + + 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.6) are being collected, they are collected + 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". @@ -2344,16 +2212,6 @@ Internet-Draft JSON Schema August 2019 This keyword's value MUST be a valid JSON Schema. - - - - - -Wright, et al. Expires February 17, 2020 [Page 42] - -Internet-Draft JSON Schema August 2019 - - 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. @@ -2377,6 +2235,13 @@ Internet-Draft JSON Schema August 2019 Omitting this keyword has the same behavior as an empty object. + + +Wright, et al. Expires March 17, 2020 [Page 40] + +Internet-Draft JSON Schema September 2019 + + 9.3. Keywords for Applying Subschemas to Child Instances Each of these keywords defines a rule for applying its subschema(s) @@ -2402,14 +2267,6 @@ Internet-Draft JSON Schema August 2019 boolean true if a subschema was applied to every index of the instance, such as when "items" is a schema. - - - -Wright, et al. Expires February 17, 2020 [Page 43] - -Internet-Draft JSON Schema August 2019 - - 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 @@ -2433,6 +2290,14 @@ Internet-Draft JSON Schema August 2019 If the "additionalItems" subschema is applied to any positions within the instance array, it produces an annotation result of boolean true, + + + +Wright, et al. Expires March 17, 2020 [Page 41] + +Internet-Draft JSON Schema September 2019 + + 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 @@ -2457,15 +2322,6 @@ Internet-Draft JSON Schema August 2019 adjacent to the "unevaluatedItems" keyword. Those two annotations, as well as "unevaluatedItems", can also result from any and all adjacent in-place applicator (Section 9.2) keywords. This includes - - - - -Wright, et al. Expires February 17, 2020 [Page 44] - -Internet-Draft JSON Schema August 2019 - - but is not limited to the in-place applicators defined in this document. @@ -2490,6 +2346,14 @@ Internet-Draft JSON Schema August 2019 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 + + + +Wright, et al. Expires March 17, 2020 [Page 42] + +Internet-Draft JSON Schema September 2019 + + instance location produces an annotation value of true, then the combined result from these keywords is also true. @@ -2511,17 +2375,6 @@ Internet-Draft JSON Schema August 2019 9.3.2. Keywords for Applying Subschemas to Objects - - - - - - -Wright, et al. Expires February 17, 2020 [Page 45] - -Internet-Draft JSON Schema August 2019 - - 9.3.2.1. properties The value of "properties" MUST be an object. Each value of this @@ -2549,6 +2402,14 @@ Internet-Draft JSON Schema August 2019 Validation succeeds if, for each instance name that matches any regular expressions that appear as a property name in this keyword's + + + +Wright, et al. Expires March 17, 2020 [Page 43] + +Internet-Draft JSON Schema September 2019 + + value, the child instance for that name successfully validates against each schema that corresponds to a matching regular expression. @@ -2571,15 +2432,8 @@ Internet-Draft JSON Schema August 2019 to the child values of instance names that do not appear in the annotation results of either "properties" or "patternProperties". - - -Wright, et al. Expires February 17, 2020 [Page 46] - -Internet-Draft JSON Schema August 2019 - - - For all such properties, validation succeeds if the child instance - validates against the "additionalProperties" schema. + 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 @@ -2604,6 +2458,14 @@ Internet-Draft JSON Schema August 2019 validated. Specifically, the annotations from "properties", "patternProperties", and "additionalProperties", which can come from those keywords when they are adjacent to the "unevaluatedProperties" + + + +Wright, et al. Expires March 17, 2020 [Page 44] + +Internet-Draft JSON Schema September 2019 + + keyword. Those three annotations, as well as "unevaluatedProperties", can also result from any and all adjacent in-place applicator (Section 9.2) keywords. This includes but is not @@ -2626,14 +2488,6 @@ Internet-Draft JSON Schema August 2019 The annotation result of this keyword is the set of instance property names validated by this keyword's subschema. Annotation results for - - - -Wright, et al. Expires February 17, 2020 [Page 47] - -Internet-Draft JSON Schema August 2019 - - "unevaluatedProperties" keywords from multiple schemas applied to the same instance location are combined by taking the union of the sets. @@ -2659,6 +2513,15 @@ Internet-Draft JSON Schema August 2019 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 + + + + +Wright, et al. Expires March 17, 2020 [Page 45] + +Internet-Draft JSON Schema September 2019 + + describes the minimum requirements that consumers will need to properly interpret validation results. @@ -2683,13 +2546,6 @@ Internet-Draft JSON Schema August 2019 Detailed - Provides validation information in a condensed hierarchical structure based on the structure of the schema. - - -Wright, et al. Expires February 17, 2020 [Page 48] - -Internet-Draft JSON Schema August 2019 - - Verbose - Provides validation information in an uncondensed hierarchical structure that matches the exact structure of the schema. @@ -2711,6 +2567,17 @@ Internet-Draft JSON Schema August 2019 Implementations MAY elect to provide additional information. + + + + + + +Wright, et al. Expires March 17, 2020 [Page 46] + +Internet-Draft JSON Schema September 2019 + + 10.3.1. Keyword Relative Location The relative location of the validating keyword that follows the @@ -2719,31 +2586,26 @@ Internet-Draft JSON Schema August 2019 "$recursiveRef". - #/properties/minLength/$ref/minimum + #/properties/width/$ref/minimum - Note that this pointer may not be resolvable due to the inclusion of - these applicator keywords. + 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, and it MUST NOT include - by-reference applicators such as "$ref" or "$recursiveRef". - - -https://json-schema.org/draft/2019-08/schema#/$defs/nonNegativeInteger/minimum - - - + 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. - -Wright, et al. Expires February 17, 2020 [Page 49] - -Internet-Draft JSON Schema August 2019 + https://example.com/schemas/common#/$defs/count/minimum This information MAY be omitted only if either the relative location @@ -2755,7 +2617,7 @@ Internet-Draft JSON Schema August 2019 10.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 value MUST be expressed as a URI fragment-encoded JSON Pointer. The JSON key for this information is "instanceLocation". @@ -2763,9 +2625,21 @@ Internet-Draft JSON Schema August 2019 The error or annotation that is produced by the validation. + + + + +Wright, et al. Expires March 17, 2020 [Page 47] + +Internet-Draft JSON Schema September 2019 + + 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". @@ -2775,7 +2649,9 @@ Internet-Draft JSON Schema August 2019 errors and annotations. The JSON key for nested results in failed validations is "errors"; - for successful validations it is "annotations". + 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 @@ -2797,14 +2673,26 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 17, 2020 [Page 50] + + + + + + + + + + + + +Wright, et al. Expires March 17, 2020 [Page 48] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 { - "$id": "https://example.com/polygon#", - "$schema": "https://json-schema.org/draft/2019-08/schema#", + "$id": "https://example.com/polygon", + "$schema": "https://json-schema.org/draft/2019-09/schema", "$defs": { "point": { "type": "object", @@ -2853,9 +2741,9 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 17, 2020 [Page 51] +Wright, et al. Expires March 17, 2020 [Page 49] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 templating mechanism that allows their users to craft their own @@ -2909,9 +2797,9 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 17, 2020 [Page 52] +Wright, et al. Expires March 17, 2020 [Page 50] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 { @@ -2960,14 +2848,14 @@ Internet-Draft JSON Schema August 2019 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 correllation is more easily identified. + hierarchy, the correlation is more easily identified. -Wright, et al. Expires February 17, 2020 [Page 53] +Wright, et al. Expires March 17, 2020 [Page 51] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 The following rules govern the construction of the results object: @@ -3021,9 +2909,9 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 17, 2020 [Page 54] +Wright, et al. Expires March 17, 2020 [Page 52] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 { @@ -3077,9 +2965,9 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 17, 2020 [Page 55] +Wright, et al. Expires March 17, 2020 [Page 53] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 results that would otherwise be removed (e.g. annotations for failed @@ -3089,14 +2977,14 @@ Internet-Draft JSON Schema August 2019 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: . // schema { - "$id": "https://example.com/polygon#", - "$schema": "https://json-schema.org/draft/2019-08/schema#", + "$id": "https://example.com/polygon", + "$schema": "https://json-schema.org/draft/2019-09/schema", "type": "object", "properties": { "validProp": true, @@ -3133,9 +3021,9 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 17, 2020 [Page 56] +Wright, et al. Expires March 17, 2020 [Page 54] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 "errors": [ @@ -3155,7 +3043,7 @@ Internet-Draft JSON Schema August 2019 For convenience, JSON Schema has been provided to validate output generated by implementations. Its URI is: . + draft/2019-09/output/schema>. 11. Usage for Hypermedia @@ -3189,9 +3077,9 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 17, 2020 [Page 57] +Wright, et al. Expires March 17, 2020 [Page 55] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 When using the media type application/schema-instance+json, the @@ -3245,9 +3133,9 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 17, 2020 [Page 58] +Wright, et al. Expires March 17, 2020 [Page 56] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 Unlike Content-Type, Accept can contain multiple values to indicate @@ -3256,7 +3144,7 @@ Internet-Draft JSON Schema August 2019 parameter values. This requests an application/json representation that conforms to at least one of the identified schemas. - [[CREF7: This paragraph assumes that we can register a "schema" link + [[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- @@ -3301,9 +3189,9 @@ Internet-Draft JSON Schema August 2019 -Wright, et al. Expires February 17, 2020 [Page 59] +Wright, et al. Expires March 17, 2020 [Page 57] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 Instances and schemas are both frequently written by untrusted third @@ -3316,192 +3204,655 @@ Internet-Draft JSON Schema August 2019 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. + 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 + [RFC8259]. + + + + +Wright, et al. Expires March 17, 2020 [Page 58] + +Internet-Draft JSON Schema September 2019 + + + 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 + [RFC8259]. + + 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", . + + + + + + + +Wright, et al. Expires March 17, 2020 [Page 59] + +Internet-Draft JSON Schema September 2019 + + + [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., Ed., Zyp, K., and M. Nottingham, Ed., + "JavaScript Object Notation (JSON) Pointer", RFC 6901, + DOI 10.17487/RFC6901, April 2013, + . + + [RFC8259] Bray, T., Ed., "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", draft- + handrews-json-schema-hyperschema-02 (work in progress), + November 2017. + + [json-schema-validation] + Wright, A., Andrews, H., and G. Luff, "JSON Schema + Validation: A Vocabulary for Structural Validation of + JSON", draft-handrews-json-schema-validation-02 (work in + progress), November 2017. + + [RFC6596] Ohye, M. and J. Kupke, "The Canonical Link Relation", + RFC 6596, DOI 10.17487/RFC6596, April 2012, + . + + + +Wright, et al. Expires March 17, 2020 [Page 60] + +Internet-Draft JSON Schema September 2019 + + + [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object + Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, + October 2013, . + + [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "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, + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Wright, et al. Expires March 17, 2020 [Page 61] + +Internet-Draft JSON Schema September 2019 + + +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 + 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 + + + + +Wright, et al. Expires March 17, 2020 [Page 62] + +Internet-Draft JSON Schema September 2019 + + + 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# + + + +Wright, et al. Expires March 17, 2020 [Page 63] + +Internet-Draft JSON Schema September 2019 + + + 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. + + + + +Wright, et al. Expires March 17, 2020 [Page 64] + +Internet-Draft JSON Schema September 2019 + + +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, - 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. + "$ref": "tree", + "unevaluatedProperties": false + } - 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. + // instance with misspelled field + { + "children": [ { "daat": 1 } ] + } -13. IANA Considerations -13.1. application/schema+json + 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 - The proposed MIME media type for JSON Schema is defined as follows: - Type name: application - Subtype name: schema+json - Required parameters: N/A +Wright, et al. Expires March 17, 2020 [Page 65] + +Internet-Draft JSON Schema September 2019 - 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. + point, the dynamic path is "#/$ref/properties/children/ + items/$recursiveRef". - Encoding considerations: Encoding considerations are identical to - those specified for the "application/json" media type. See JSON - [RFC8259]. + 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 -Wright, et al. Expires February 17, 2020 [Page 60] - -Internet-Draft JSON Schema August 2019 +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. - Security considerations: See Section 12 above. + 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. - Interoperability considerations: See Sections 6.2, 6.3, and 6.4 - above. + 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. - Fragment identifier considerations: See Section 5 + 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. -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 +Wright, et al. Expires March 17, 2020 [Page 66] + +Internet-Draft JSON Schema September 2019 - Subtype name: schema-instance+json - Required parameters: + It is recommended that meta-schema authors reference each + vocabulary's meta-schema using the "allOf" (Section 9.2.1.1) keyword, + although other mechanisms for constructing the meta-schema may be + appropriate for certain use cases. - 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. + 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. - Encoding considerations: Encoding considerations are identical to - those specified for the "application/json" media type. See JSON - [RFC8259]. + 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. - Security considerations: See Section 12 above. + 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. - Interoperability considerations: See Sections 6.2, 6.3, and 6.4 - above. + Meta-schemas intended for local use, with no need to test for + vocabulary support in arbitrary implementations, can safely omit + "$vocabulary" entirely. - Fragment identifier considerations: See Section 5 +D.2. Example meta-schema with vocabulary declarations -14. References + 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. -14.1. Normative References + 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. - [ecma262] "ECMA 262 specification", . + 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. +Wright, et al. Expires March 17, 2020 [Page 67] + +Internet-Draft JSON Schema September 2019 + This meta-schema combines several vocabularies for general use. -Wright, et al. Expires February 17, 2020 [Page 61] - -Internet-Draft JSON Schema August 2019 + { + "$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" + } + } + } - [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., Ed., Zyp, K., and M. Nottingham, Ed., - "JavaScript Object Notation (JSON) Pointer", RFC 6901, - DOI 10.17487/RFC6901, April 2013, - . - [RFC8259] Bray, T., Ed., "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", draft- - handrews-json-schema-hyperschema-02 (work in progress), - November 2017. - [json-schema-validation] - Wright, A., Andrews, H., and G. Luff, "JSON Schema - Validation: A Vocabulary for Structural Validation of - JSON", draft-handrews-json-schema-validation-02 (work in - progress), November 2017. - [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object - Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, - October 2013, . -Wright, et al. Expires February 17, 2020 [Page 62] - -Internet-Draft JSON Schema August 2019 - [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "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, - . +Wright, et al. Expires March 17, 2020 [Page 68] + +Internet-Draft JSON Schema September 2019 + 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 [json-schema-validation]. @@ -3510,27 +3861,75 @@ Internet-Draft JSON Schema August 2019 +Wright, et al. Expires March 17, 2020 [Page 69] + +Internet-Draft JSON Schema September 2019 +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. -Wright, et al. Expires February 17, 2020 [Page 63] +Wright, et al. Expires March 17, 2020 [Page 70] -Internet-Draft JSON Schema August 2019 +Internet-Draft JSON Schema September 2019 -Appendix A. Acknowledgments + 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. @@ -3539,9 +3938,9 @@ Appendix A. Acknowledgments Evgeny Poberezkin, Brad Bowman, Gowry Sankar, Donald Pipowitch, and Dave Finlay for their submissions and patches to the document. -Appendix B. ChangeLog +Appendix G. ChangeLog - [[CREF8: This section to be removed before leaving Internet-Draft + [[CREF15: This section to be removed before leaving Internet-Draft status.]] draft-handrews-json-schema-02 @@ -3571,6 +3970,14 @@ Appendix B. ChangeLog * Allow keywords adjacent to "$ref" + + + +Wright, et al. Expires March 17, 2020 [Page 71] + +Internet-Draft JSON Schema September 2019 + + * Note undefined behavior for "$ref" targets involving unknown keywords @@ -3579,13 +3986,6 @@ Appendix B. ChangeLog * Add the concept of formal vocabularies, and how they can be recognized through meta-schemas - - -Wright, et al. Expires February 17, 2020 [Page 64] - -Internet-Draft JSON Schema August 2019 - - * Additional guidance on initial base URIs beyond network retrieval @@ -3595,6 +3995,14 @@ Internet-Draft JSON Schema August 2019 * 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 @@ -3618,6 +4026,14 @@ Internet-Draft JSON Schema August 2019 draft-handrews-json-schema-00 + + + +Wright, et al. Expires March 17, 2020 [Page 72] + +Internet-Draft JSON Schema September 2019 + + * Make the concept of a schema keyword vocabulary more clear * Note that the concept of "integer" is from a vocabulary, not @@ -3635,13 +4051,6 @@ Internet-Draft JSON Schema August 2019 * Note the challenges of extending meta-schemas with recursive references - - -Wright, et al. Expires February 17, 2020 [Page 65] - -Internet-Draft JSON Schema August 2019 - - * Add "application/schema-instance+json" media type * Recommend a "schema" link relation / parameter instead of @@ -3673,6 +4082,14 @@ Internet-Draft JSON Schema August 2019 * Behavior for "id" is now specified in terms of RFC3986 + + + +Wright, et al. Expires March 17, 2020 [Page 73] + +Internet-Draft JSON Schema September 2019 + + * Aligned vocabulary usage for URIs with RFC3986 * Removed reference to draft-pbryan-zyp-json-ref-03 @@ -3690,14 +4107,6 @@ Internet-Draft JSON Schema August 2019 * Rewrote section on usage with rel="describedBy" and rel="profile" - - - -Wright, et al. Expires February 17, 2020 [Page 66] - -Internet-Draft JSON Schema August 2019 - - * Fixed numerous invalid examples draft-zyp-json-schema-04 @@ -3727,6 +4136,16 @@ Authors' Addresses EMail: aaa@bzfx.net + + + + + +Wright, et al. Expires March 17, 2020 [Page 74] + +Internet-Draft JSON Schema September 2019 + + Henry Andrews (editor) EMail: andrews_henry@yahoo.com @@ -3749,4 +4168,33 @@ Authors' Addresses -Wright, et al. Expires February 17, 2020 [Page 67] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Wright, et al. Expires March 17, 2020 [Page 75] diff --git a/work-in-progress/WIP-jsonschema-hyperschema.html b/work-in-progress/WIP-jsonschema-hyperschema.html index be5f1bb2..bb8a2c80 100644 --- a/work-in-progress/WIP-jsonschema-hyperschema.html +++ b/work-in-progress/WIP-jsonschema-hyperschema.html @@ -454,7 +454,7 @@ - + @@ -478,8 +478,8 @@ A. Wright, Ed. -Expires: March 11, 2020 -September 8, 2019 +Expires: March 17, 2020 +September 14, 2019 @@ -499,7 +499,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 March 11, 2020.

    +

    This Internet-Draft will expire on March 17, 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.

    @@ -1055,7 +1055,7 @@

    if value is true: templateData[varname] = "true" else if value is false: - temlateData[varname] = "false" + templateData[varname] = "false" else if value is null: templateData[varname] = "null" else if value is a number: diff --git a/work-in-progress/WIP-jsonschema-hyperschema.txt b/work-in-progress/WIP-jsonschema-hyperschema.txt index 120689e7..89b5b7f0 100644 --- a/work-in-progress/WIP-jsonschema-hyperschema.txt +++ b/work-in-progress/WIP-jsonschema-hyperschema.txt @@ -5,7 +5,7 @@ Internet Engineering Task Force H. Andrews, Ed. Internet-Draft Intended status: Informational A. Wright, Ed. -Expires: February 17, 2020 August 16, 2019 +Expires: March 17, 2020 September 14, 2019 JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON @@ -47,15 +47,15 @@ Status of This Memo 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 February 17, 2020. + This Internet-Draft will expire on March 17, 2020. -Andrews & Wright Expires February 17, 2020 [Page 1] +Andrews & Wright Expires March 17, 2020 [Page 1] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 Copyright Notice @@ -109,9 +109,9 @@ Table of Contents -Andrews & Wright Expires February 17, 2020 [Page 2] +Andrews & Wright Expires March 17, 2020 [Page 2] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 6.6.2. headerSchema . . . . . . . . . . . . . . . . . . . . 16 @@ -165,9 +165,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 3] +Andrews & Wright Expires March 17, 2020 [Page 3] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 manipulating remote JSON resources through hypermedia environments @@ -221,9 +221,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 4] +Andrews & Wright Expires March 17, 2020 [Page 4] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 representation formats at runtime, or pre-emptively follow links to @@ -277,9 +277,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 5] +Andrews & Wright Expires March 17, 2020 [Page 5] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 JSON Hyper-Schema A JSON Schema using the keywords defined by this @@ -333,9 +333,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 6] +Andrews & Wright Expires March 17, 2020 [Page 6] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 The relation type and target attributes are taken directly from each @@ -358,22 +358,22 @@ Internet-Draft JSON Hyper-Schema August 2019 4. Meta-Schemas and Output Schema The current URI for the JSON Hyper-Schema meta-schema is - . + . The current URI for this vocabulary, known as the Hyper-Schema - vocabulary, is: . 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: . + schema.org/draft/2019-09/meta/hyper-schema>. The link description format (Section 6) 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: . JSON Hyper-Schema implementations are free to provide output in any @@ -384,14 +384,14 @@ Internet-Draft JSON Hyper-Schema August 2019 implementations be capable of producing output in this format to facilitated testing. The URI of the JSON Schema describing the recommended output format is . + 09/output/hyper-schema#>. -Andrews & Wright Expires February 17, 2020 [Page 7] +Andrews & Wright Expires March 17, 2020 [Page 7] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 Updated vocabulary and meta-schema URIs MAY be published between @@ -445,9 +445,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 8] +Andrews & Wright Expires March 17, 2020 [Page 8] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 provides all of these, along with additional features using JSON @@ -501,9 +501,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 9] +Andrews & Wright Expires March 17, 2020 [Page 9] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 6.1.1. anchor @@ -557,9 +557,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 10] +Andrews & Wright Expires March 17, 2020 [Page 10] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 6.2.1. rel @@ -613,9 +613,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 11] +Andrews & Wright Expires March 17, 2020 [Page 11] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 As such a method would correspond to JSON Hyper-Schema's data @@ -669,9 +669,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 12] +Andrews & Wright Expires March 17, 2020 [Page 12] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 "anchor" keyword being resolved which requires "base" templates to be @@ -725,9 +725,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 13] +Andrews & Wright Expires March 17, 2020 [Page 13] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 User agents MAY use this description when presenting the link to the @@ -781,9 +781,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 14] +Andrews & Wright Expires March 17, 2020 [Page 14] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 section is expected to become more well-defined based on draft @@ -837,9 +837,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 15] +Andrews & Wright Expires March 17, 2020 [Page 15] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 other user agent data for filling out the URI Template in "href" @@ -893,9 +893,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 16] +Andrews & Wright Expires March 17, 2020 [Page 16] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 prevent client applications or user agents from supplying additional @@ -949,9 +949,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 17] +Andrews & Wright Expires March 17, 2020 [Page 17] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 6.6.4.1. submissionMediaType @@ -1005,9 +1005,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 18] +Andrews & Wright Expires March 17, 2020 [Page 18] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 contextUri The fully resolved URI (with scheme) of the context @@ -1061,9 +1061,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 19] +Andrews & Wright Expires March 17, 2020 [Page 19] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 must also be located and associated with the LDO through whatever @@ -1117,9 +1117,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 20] +Andrews & Wright Expires March 17, 2020 [Page 20] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 1. Populate template variable data from the instance @@ -1173,9 +1173,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 21] +Andrews & Wright Expires March 17, 2020 [Page 21] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 for varname in T: @@ -1229,9 +1229,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 22] +Andrews & Wright Expires March 17, 2020 [Page 22] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 "InputForm" represents whatever sort of input mechanism is @@ -1285,9 +1285,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 23] +Andrews & Wright Expires March 17, 2020 [Page 23] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 for varname in templateData: @@ -1295,7 +1295,7 @@ Internet-Draft JSON Hyper-Schema August 2019 if value is true: templateData[varname] = "true" else if value is false: - temlateData[varname] = "false" + templateData[varname] = "false" else if value is null: templateData[varname] = "null" else if value is a number: @@ -1341,9 +1341,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 24] +Andrews & Wright Expires March 17, 2020 [Page 24] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 The LDO can express all information needed to perform any operation @@ -1397,9 +1397,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 25] +Andrews & Wright Expires March 17, 2020 [Page 25] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 schemas and use appropriate media types (e.g. "application/ @@ -1453,9 +1453,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 26] +Andrews & Wright Expires March 17, 2020 [Page 26] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 mechanism, although it is RECOMMENDED that the techniques outlined in @@ -1509,9 +1509,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 27] +Andrews & Wright Expires March 17, 2020 [Page 27] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 Per RFC 5789 [RFC5789], the request structure for an HTTP PATCH is @@ -1565,9 +1565,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 28] +Andrews & Wright Expires March 17, 2020 [Page 28] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 response and those that appear in an OPTIONS response can appear. No @@ -1621,9 +1621,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 29] +Andrews & Wright Expires March 17, 2020 [Page 29] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 o Range requests @@ -1677,9 +1677,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 30] +Andrews & Wright Expires March 17, 2020 [Page 30] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 9. Examples @@ -1718,7 +1718,7 @@ Internet-Draft JSON Hyper-Schema August 2019 { "$id": "https://schema.example.com/entry", - "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-09/hyper-schema", "base": "https://example.com/api/", "links": [ { @@ -1733,9 +1733,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 31] +Andrews & Wright Expires March 17, 2020 [Page 31] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 These are the simplest possible links, with only a relation type and @@ -1789,9 +1789,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 32] +Andrews & Wright Expires March 17, 2020 [Page 32] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 9.2. Individually Identified Resources @@ -1800,7 +1800,7 @@ Internet-Draft JSON Hyper-Schema August 2019 { "$id": "https://schema.example.com/thing", - "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-09/hyper-schema", "base": "https://example.com/api/", "type": "object", "required": ["data"], @@ -1845,9 +1845,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 33] +Andrews & Wright Expires March 17, 2020 [Page 33] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 so an extension relationship is defined using the "tag:" URI scheme @@ -1901,9 +1901,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 34] +Andrews & Wright Expires March 17, 2020 [Page 34] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 We use "submissionMediaType" to indicate a multipart/alternative @@ -1924,7 +1924,7 @@ Internet-Draft JSON Hyper-Schema August 2019 { "$id": "https://schema.example.com/interesting-stuff", - "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-09/hyper-schema", "required": ["stuffWorthEmailingAbout", "email", "title"], "properties": { "title": { @@ -1957,9 +1957,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 35] +Andrews & Wright Expires March 17, 2020 [Page 35] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 "email": false @@ -2013,9 +2013,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 36] +Andrews & Wright Expires March 17, 2020 [Page 36] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 { @@ -2069,9 +2069,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 37] +Andrews & Wright Expires March 17, 2020 [Page 37] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 As an example, there is an IANA-registered "up" relation, but there @@ -2125,9 +2125,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 38] +Andrews & Wright Expires March 17, 2020 [Page 38] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 The following hyper-schema, applied to the instance in the response @@ -2137,7 +2137,7 @@ Internet-Draft JSON Hyper-Schema August 2019 { "$id": "https://schema.example.com/tree-node", - "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-09/hyper-schema", "base": "trees/{treeId}/", "properties": { "id": {"type": "integer"}, @@ -2181,9 +2181,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 39] +Andrews & Wright Expires March 17, 2020 [Page 39] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 9.5. Collections @@ -2237,9 +2237,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 40] +Andrews & Wright Expires March 17, 2020 [Page 40] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 For this example, we will re-use the individual thing schema as shown @@ -2249,7 +2249,7 @@ Internet-Draft JSON Hyper-Schema August 2019 { "$id": "https://schema.example.com/thing", - "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-09/hyper-schema", "base": "https://example.com/api/", "type": "object", "required": ["data"], @@ -2293,9 +2293,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 41] +Andrews & Wright Expires March 17, 2020 [Page 41] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 Now we want to describe collections of "thing"s. This schema @@ -2308,7 +2308,7 @@ Internet-Draft JSON Hyper-Schema August 2019 { "$id": "https://schema.example.com/thing-collection", - "$schema": "https://json-schema.org/draft/2019-08/hyper-schema#", + "$schema": "https://json-schema.org/draft/2019-09/hyper-schema", "base": "https://example.com/api/", "type": "object", "required": ["elements"], @@ -2349,9 +2349,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 42] +Andrews & Wright Expires March 17, 2020 [Page 42] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 Here is a simple two-element collection instance: @@ -2405,9 +2405,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 43] +Andrews & Wright Expires March 17, 2020 [Page 43] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 { @@ -2461,9 +2461,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 44] +Andrews & Wright Expires March 17, 2020 [Page 44] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 The collection links have identical target URIs as there is only one @@ -2517,9 +2517,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 45] +Andrews & Wright Expires March 17, 2020 [Page 45] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 }, { @@ -2573,9 +2573,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 46] +Andrews & Wright Expires March 17, 2020 [Page 46] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 Given this instance: @@ -2629,9 +2629,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 47] +Andrews & Wright Expires March 17, 2020 [Page 47] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 [[CREF7: It's not clear how pagination should work with the link from @@ -2685,9 +2685,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 48] +Andrews & Wright Expires March 17, 2020 [Page 48] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 Presumably, our custom link relation type in the entry point schema @@ -2741,9 +2741,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 49] +Andrews & Wright Expires March 17, 2020 [Page 49] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 parts of the specification discourage always re-downloading the @@ -2797,9 +2797,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 50] +Andrews & Wright Expires March 17, 2020 [Page 50] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 11. Acknowledgments @@ -2853,9 +2853,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 51] +Andrews & Wright Expires March 17, 2020 [Page 51] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 [RFC6573] Amundsen, M., "The Item and Collection Link Relations", @@ -2909,9 +2909,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 52] +Andrews & Wright Expires March 17, 2020 [Page 52] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 [RFC7807] Nottingham, M. and E. Wilde, "Problem Details for HTTP @@ -2965,9 +2965,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 53] +Andrews & Wright Expires March 17, 2020 [Page 53] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 Appendix A. Using JSON Hyper-Schema in APIs @@ -3021,9 +3021,9 @@ A.2. Responses and Errors -Andrews & Wright Expires February 17, 2020 [Page 54] +Andrews & Wright Expires March 17, 2020 [Page 54] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 [RFC7807], to allow the user agent or client application to interpret @@ -3077,9 +3077,9 @@ Appendix B. ChangeLog -Andrews & Wright Expires February 17, 2020 [Page 55] +Andrews & Wright Expires March 17, 2020 [Page 55] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 * Removed stray "work in progress" language left over from review @@ -3133,9 +3133,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 56] +Andrews & Wright Expires March 17, 2020 [Page 56] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 * Clarified how "hrefSchema" is used @@ -3189,9 +3189,9 @@ Internet-Draft JSON Hyper-Schema August 2019 -Andrews & Wright Expires February 17, 2020 [Page 57] +Andrews & Wright Expires March 17, 2020 [Page 57] -Internet-Draft JSON Hyper-Schema August 2019 +Internet-Draft JSON Hyper-Schema September 2019 * Removed "pathStart" keyword @@ -3245,4 +3245,4 @@ Authors' Addresses -Andrews & Wright Expires February 17, 2020 [Page 58] +Andrews & Wright Expires March 17, 2020 [Page 58] diff --git a/work-in-progress/WIP-jsonschema-validation.html b/work-in-progress/WIP-jsonschema-validation.html index 3fa9278f..cd921cc5 100644 --- a/work-in-progress/WIP-jsonschema-validation.html +++ b/work-in-progress/WIP-jsonschema-validation.html @@ -451,7 +451,7 @@ - + @@ -475,7 +475,7 @@ H. Andrews, Ed. -Expires: March 11, 2020 +Expires: March 17, 2020 @@ -488,7 +488,7 @@ -September 8, 2019 +September 14, 2019 @@ -508,7 +508,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 March 11, 2020.

    +

    This Internet-Draft will expire on March 17, 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.

    @@ -675,7 +675,7 @@

    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 and Section 8 keywords are also useful as annotations as well as being optional assertions, as they convey additional usage guidance for the instance data.

    +

    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

    @@ -1059,13 +1059,14 @@

    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, the resulting value MUST be true if any occurrence specifies a true value, and MUST be false otherwise.

    +

    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 the entire root schema MAY be removed in the future.

    -

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

    +

    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 value MUST be true if any occurrence specifies a true value, and MUST be false otherwise.

    +

    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.

    diff --git a/work-in-progress/WIP-jsonschema-validation.txt b/work-in-progress/WIP-jsonschema-validation.txt index 566ad141..46be7345 100644 --- a/work-in-progress/WIP-jsonschema-validation.txt +++ b/work-in-progress/WIP-jsonschema-validation.txt @@ -5,10 +5,10 @@ Internet Engineering Task Force A. Wright, Ed. Internet-Draft Intended status: Informational H. Andrews, Ed. -Expires: February 17, 2020 +Expires: March 17, 2020 B. Hutton, Ed. Wellcome Sanger Institute - August 16, 2019 + September 14, 2019 JSON Schema Validation: A Vocabulary for Structural Validation of JSON @@ -47,15 +47,15 @@ Status of This Memo 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 February 17, 2020. + This Internet-Draft will expire on March 17, 2020. -Wright, et al. Expires February 17, 2020 [Page 1] +Wright, et al. Expires March 17, 2020 [Page 1] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 Copyright Notice @@ -109,9 +109,9 @@ Table of Contents -Wright, et al. Expires February 17, 2020 [Page 2] +Wright, et al. Expires March 17, 2020 [Page 2] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 6.5.1. maxProperties . . . . . . . . . . . . . . . . . . . . 9 @@ -144,7 +144,7 @@ Internet-Draft JSON Schema Validation August 2019 9.1. "title" and "description" . . . . . . . . . . . . . . . . 21 9.2. "default" . . . . . . . . . . . . . . . . . . . . . . . . 21 9.3. "deprecated" . . . . . . . . . . . . . . . . . . . . . . 21 - 9.4. "readOnly" and "writeOnly" . . . . . . . . . . . . . . . 21 + 9.4. "readOnly" and "writeOnly" . . . . . . . . . . . . . . . 22 9.5. "examples" . . . . . . . . . . . . . . . . . . . . . . . 22 10. Security Considerations . . . . . . . . . . . . . . . . . . . 23 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 23 @@ -165,9 +165,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 3] +Wright, et al. Expires March 17, 2020 [Page 3] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 This specification will use the concepts, syntax, and terminology @@ -204,10 +204,10 @@ Internet-Draft JSON Schema Validation August 2019 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 and - Section 8 keywords are also useful as annotations as well as being - optional assertions, as they convey additional usage guidance for the - instance data. + 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 @@ -221,9 +221,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 4] +Wright, et al. Expires March 17, 2020 [Page 4] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 4.2. Validation of Numeric Instances @@ -243,10 +243,11 @@ Internet-Draft JSON Schema Validation August 2019 5. Meta-Schema - The current URI for the JSON Schema Validation meta-schema is - . For schema author + The current URI for the default JSON Schema meta-schema is + . For schema author convenience, this meta-schema describes all vocabularies defined in - this specification and the JSON Schema Core specification. + 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. @@ -268,18 +269,17 @@ Internet-Draft JSON Schema Validation August 2019 true. The current URI for this vocabulary, known as the Validation - vocabulary, is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-09/meta/validation>. - -Wright, et al. Expires February 17, 2020 [Page 5] +Wright, et al. Expires March 17, 2020 [Page 5] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 6.1. Validation Keywords for Any Instance Type @@ -333,9 +333,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 6] +Wright, et al. Expires March 17, 2020 [Page 6] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 6.2.2. maximum @@ -389,9 +389,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 7] +Wright, et al. Expires March 17, 2020 [Page 7] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 6.3.2. minLength @@ -445,9 +445,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 8] +Wright, et al. Expires March 17, 2020 [Page 8] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 Omitting this keyword has the same behavior as a value of false. @@ -501,9 +501,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 9] +Wright, et al. Expires March 17, 2020 [Page 9] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 6.5.3. required @@ -557,9 +557,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 10] +Wright, et al. Expires March 17, 2020 [Page 10] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 instance types defined in the data model defined in the core JSON @@ -577,10 +577,10 @@ Internet-Draft JSON Schema Validation August 2019 false. See the Implementation Requirements below for details. The current URI for this vocabulary, known as the Format vocabulary, - is: . + is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-09/meta/format>. 7.2. Implementation Requirements @@ -613,9 +613,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 11] +Wright, et al. Expires March 17, 2020 [Page 11] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 7.2.2. As an assertion @@ -669,9 +669,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 12] +Wright, et al. Expires March 17, 2020 [Page 12] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 implementation would send an email, attempt to connect to a URL, or @@ -725,9 +725,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 13] +Wright, et al. Expires March 17, 2020 [Page 13] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 7.3.1. Dates, Times, and Duration @@ -781,9 +781,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 14] +Wright, et al. Expires March 17, 2020 [Page 14] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 Note that all strings valid against the "email" attribute are also @@ -837,9 +837,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 15] +Wright, et al. Expires March 17, 2020 [Page 15] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 iri-reference: A string instance is valid against this attribute if @@ -893,9 +893,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 16] +Wright, et al. Expires March 17, 2020 [Page 16] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 Implementations that validate formats MUST accept at least the subset @@ -922,10 +922,10 @@ Internet-Draft JSON Schema Validation August 2019 true. The current URI for this vocabulary, known as the Content vocabulary, - is: . + is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-09/meta/content>. 8.2. Implementation Requirements @@ -949,9 +949,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 17] +Wright, et al. Expires March 17, 2020 [Page 17] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 document. [[CREF7: For now, the exact mechanism of performing and @@ -1005,9 +1005,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 18] +Wright, et al. Expires March 17, 2020 [Page 18] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 The value of this property SHOULD be ignored if "contentMediaType" is @@ -1061,9 +1061,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 19] +Wright, et al. Expires March 17, 2020 [Page 19] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 This example describes a JWT that is MACed using the HMAC SHA-256 @@ -1117,17 +1117,17 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 20] +Wright, et al. Expires March 17, 2020 [Page 20] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 The current URI for this vocabulary, known as the Meta-Data - vocabulary, is: . The current URI for the corresponding meta-schema is: . + schema.org/draft/2019-09/meta/meta-data>. 9.1. "title" and "description" @@ -1153,33 +1153,40 @@ Internet-Draft JSON Schema Validation August 2019 The value of this keyword MUST be a boolean. When multiple occurrences of this keyword are applicable to a single sub-instance, - the resulting value MUST be true if any occurrence specifies a true - value, and MUST be false otherwise. + 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 - the entire root schema MAY be removed in the future. + that the entire resource being described MAY be removed in the + future. - Omitting this keyword has the same behavior as a value of false. + 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. -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- +Wright, et al. Expires March 17, 2020 [Page 21] + +Internet-Draft JSON Schema Validation September 2019 -Wright, et al. Expires February 17, 2020 [Page 21] - -Internet-Draft JSON Schema Validation August 2019 + Omitting this keyword has the same behavior as a value of false. +9.4. "readOnly" and "writeOnly" - instance, the resulting value MUST be true if any occurrence - specifies a true value, and MUST be false otherwise. + 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, @@ -1220,19 +1227,17 @@ Internet-Draft JSON Schema Validation August 2019 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. - - - -Wright, et al. Expires February 17, 2020 [Page 22] +Wright, et al. Expires March 17, 2020 [Page 22] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 + + 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 @@ -1278,17 +1283,17 @@ Internet-Draft JSON Schema Validation August 2019 Describing JSON Documents", draft-handrews-json-schema-02 (work in progress), November 2017. - [relative-json-pointer] - Luff, G. and H. Andrews, "Relative JSON Pointers", draft- - handrews-relative-json-pointer-01 (work in progress), - November 2017. - -Wright, et al. Expires February 17, 2020 [Page 23] +Wright, et al. Expires March 17, 2020 [Page 23] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 + + [relative-json-pointer] + Luff, G. and H. Andrews, "Relative JSON Pointers", draft- + handrews-relative-json-pointer-01 (work in progress), + November 2017. [RFC1123] Braden, R., Ed., "Requirements for Internet Hosts - Application and Support", STD 3, RFC 1123, @@ -1332,20 +1337,19 @@ Internet-Draft JSON Schema Validation August 2019 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, . - - -Wright, et al. Expires February 17, 2020 [Page 24] +Wright, et al. Expires March 17, 2020 [Page 24] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 + [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, . @@ -1393,13 +1397,9 @@ Internet-Draft JSON Schema Validation August 2019 - - - - -Wright, et al. Expires February 17, 2020 [Page 25] +Wright, et al. Expires March 17, 2020 [Page 25] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 Appendix A. Keywords Moved from Validation to Core @@ -1412,7 +1412,11 @@ Appendix A. Keywords Moved from Validation to Core "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. + 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", @@ -1445,18 +1449,17 @@ Appendix B. Acknowledgments 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. - - -Wright, et al. Expires February 17, 2020 [Page 26] +Wright, et al. Expires March 17, 2020 [Page 26] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 + + Finlay, and Denis Laxalde for their submissions and patches to the + document. Appendix C. ChangeLog @@ -1504,16 +1507,15 @@ Appendix C. ChangeLog * Provided the general principle behind ignoring annotations under "not" and similar cases - * Clarified "if"/"then"/"else" validation interactions - - -Wright, et al. Expires February 17, 2020 [Page 27] +Wright, et al. Expires March 17, 2020 [Page 27] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 + * Clarified "if"/"then"/"else" validation interactions + * Clarified "if"/"then"/"else" behavior for annotation * Minor formatting and cross-referencing improvements @@ -1563,11 +1565,9 @@ Internet-Draft JSON Schema Validation August 2019 - - -Wright, et al. Expires February 17, 2020 [Page 28] +Wright, et al. Expires March 17, 2020 [Page 28] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 * Changed "exclusiveMaximum"/"exclusiveMinimum" from boolean @@ -1621,9 +1621,9 @@ Internet-Draft JSON Schema Validation August 2019 -Wright, et al. Expires February 17, 2020 [Page 29] +Wright, et al. Expires March 17, 2020 [Page 29] -Internet-Draft JSON Schema Validation August 2019 +Internet-Draft JSON Schema Validation September 2019 * Rename "divisibleBy" to "multipleOf". @@ -1677,4 +1677,4 @@ Authors' Addresses -Wright, et al. Expires February 17, 2020 [Page 30] +Wright, et al. Expires March 17, 2020 [Page 30] diff --git a/work-in-progress/WIP-relative-json-pointer.html b/work-in-progress/WIP-relative-json-pointer.html index b26e87e3..ea7f3025 100644 --- a/work-in-progress/WIP-relative-json-pointer.html +++ b/work-in-progress/WIP-relative-json-pointer.html @@ -397,7 +397,7 @@ - + @@ -421,8 +421,8 @@ H. Andrews, Ed. -Expires: February 23, 2020 -August 22, 2019 +Expires: March 17, 2020 +September 14, 2019 @@ -438,7 +438,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 February 23, 2020.

    +

    This Internet-Draft will expire on March 17, 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.

    diff --git a/work-in-progress/WIP-relative-json-pointer.txt b/work-in-progress/WIP-relative-json-pointer.txt index 7c23f8ff..f952342c 100644 --- a/work-in-progress/WIP-relative-json-pointer.txt +++ b/work-in-progress/WIP-relative-json-pointer.txt @@ -5,7 +5,7 @@ Internet Engineering Task Force G. Luff Internet-Draft Intended status: Informational H. Andrews, Ed. -Expires: February 17, 2020 August 16, 2019 +Expires: March 17, 2020 September 14, 2019 Relative JSON Pointers @@ -33,7 +33,7 @@ Status of This Memo 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 February 17, 2020. + This Internet-Draft will expire on March 17, 2020. Copyright Notice @@ -53,9 +53,9 @@ Copyright Notice -Luff & Andrews Expires February 17, 2020 [Page 1] +Luff & Andrews Expires March 17, 2020 [Page 1] -Internet-Draft Relative JSON Pointers August 2019 +Internet-Draft Relative JSON Pointers September 2019 Table of Contents @@ -109,9 +109,9 @@ Table of Contents -Luff & Andrews Expires February 17, 2020 [Page 2] +Luff & Andrews Expires March 17, 2020 [Page 2] -Internet-Draft Relative JSON Pointers August 2019 +Internet-Draft Relative JSON Pointers September 2019 The ABNF syntax of a Relative JSON Pointer is: @@ -165,9 +165,9 @@ Internet-Draft Relative JSON Pointers August 2019 -Luff & Andrews Expires February 17, 2020 [Page 3] +Luff & Andrews Expires March 17, 2020 [Page 3] -Internet-Draft Relative JSON Pointers August 2019 +Internet-Draft Relative JSON Pointers September 2019 If the referenced value is an object member within an object, then @@ -221,9 +221,9 @@ Internet-Draft Relative JSON Pointers August 2019 -Luff & Andrews Expires February 17, 2020 [Page 4] +Luff & Andrews Expires March 17, 2020 [Page 4] -Internet-Draft Relative JSON Pointers August 2019 +Internet-Draft Relative JSON Pointers September 2019 6. Non-use in URI Fragment Identifiers @@ -277,9 +277,9 @@ Internet-Draft Relative JSON Pointers August 2019 -Luff & Andrews Expires February 17, 2020 [Page 5] +Luff & Andrews Expires March 17, 2020 [Page 5] -Internet-Draft Relative JSON Pointers August 2019 +Internet-Draft Relative JSON Pointers September 2019 11. References @@ -333,9 +333,9 @@ Internet-Draft Relative JSON Pointers August 2019 -Luff & Andrews Expires February 17, 2020 [Page 6] +Luff & Andrews Expires March 17, 2020 [Page 6] -Internet-Draft Relative JSON Pointers August 2019 +Internet-Draft Relative JSON Pointers September 2019 Appendix A. ChangeLog @@ -389,4 +389,4 @@ Authors' Addresses -Luff & Andrews Expires February 17, 2020 [Page 7] +Luff & Andrews Expires March 17, 2020 [Page 7] diff --git a/work-in-progress/output/WIP-hyper-schema.json b/work-in-progress/output/WIP-hyper-schema.json index 216eb383..34e67303 100644 --- a/work-in-progress/output/WIP-hyper-schema.json +++ b/work-in-progress/output/WIP-hyper-schema.json @@ -45,7 +45,7 @@ } }, "hrefPrepopulatedInput": { - "$comment": "The initial data set to be presented with the input form when URI Tempalte input is accepted.", + "$comment": "The initial data set to be presented with the input form when URI Template input is accepted.", "type": "object", "propertyNames": { "$comment": "These are all URI Template variable names, specifically the 'varname' production from RFC 6570, Section 2.3", From 06ed5c28578691b37a3e3333ed5f7830a9cf7b28 Mon Sep 17 00:00:00 2001 From: Todd O'Bryan Date: Sat, 14 Sep 2019 19:16:16 -0700 Subject: [PATCH 080/395] 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 d842db08b026b271b1501f91ffcd9d08f8262c71 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 17 Sep 2019 13:57:09 -0700 Subject: [PATCH 081/395] Add specifications handrews-*-02 Along with meta-schemas, example output, etc. Also update the "latest" documents with the same HTML files. --- draft/2019-09/json-schema-core.html | 2423 +++++++++++++++++++++ draft/2019-09/json-schema-hypermedia.html | 2008 +++++++++++++++++ draft/2019-09/json-schema-validation.html | 1397 ++++++++++++ draft/2019-09/relative-json-pointer.html | 687 ++++++ latest/json-schema-core.html | 2414 +++++++++++++++----- latest/json-schema-hypermedia.html | 1475 +++++++------ latest/json-schema-validation.html | 1514 +++++++------ latest/relative-json-pointer.html | 311 +-- 8 files changed, 10152 insertions(+), 2077 deletions(-) create mode 100644 draft/2019-09/json-schema-core.html create mode 100644 draft/2019-09/json-schema-hypermedia.html create mode 100644 draft/2019-09/json-schema-validation.html create mode 100644 draft/2019-09/relative-json-pointer.html diff --git a/draft/2019-09/json-schema-core.html b/draft/2019-09/json-schema-core.html new file mode 100644 index 00000000..80fb2685 --- /dev/null +++ b/draft/2019-09/json-schema-core.html @@ -0,0 +1,2423 @@ + + + + + + + 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/draft/2019-09/json-schema-hypermedia.html b/draft/2019-09/json-schema-hypermedia.html new file mode 100644 index 00000000..2c919aae --- /dev/null +++ b/draft/2019-09/json-schema-hypermedia.html @@ -0,0 +1,2008 @@ + + + + + + + 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/draft/2019-09/json-schema-validation.html b/draft/2019-09/json-schema-validation.html new file mode 100644 index 00000000..4635b1f6 --- /dev/null +++ b/draft/2019-09/json-schema-validation.html @@ -0,0 +1,1397 @@ + + + + + + + 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/draft/2019-09/relative-json-pointer.html b/draft/2019-09/relative-json-pointer.html new file mode 100644 index 00000000..5710a004 --- /dev/null +++ b/draft/2019-09/relative-json-pointer.html @@ -0,0 +1,687 @@ + + + + + + + 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/json-schema-core.html b/latest/json-schema-core.html index 23e22842..80fb2685 100644 --- a/latest/json-schema-core.html +++ b/latest/json-schema-core.html @@ -373,63 +373,108 @@ /*]]>*/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + @@ -441,24 +486,36 @@ - Internet Engineering Task Force - A. Wright, Ed. +Internet Engineering Task Force +A. Wright, Ed. + + +Internet-Draft + + + +Intended status: Informational +H. Andrews, Ed. - Internet-Draft - +Expires: March 20, 2020 + - Intended status: Informational - H. Andrews, Ed. + +B. Hutton, Ed. - Expires: September 20, 2018 - Cloudflare, Inc. + +Wellcome Sanger Institute - - March 19, 2018 + +G. Dennis + + + +September 17, 2019 @@ -466,190 +523,345 @@

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

    + draft-handrews-json-schema-02

    -

    - Abstract -

    +

    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 -

    +

    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 <http://json-schema.org/>.

    +

    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 -

    +

    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 http://datatracker.ietf.org/drafts/current/.

    +

    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 September 20, 2018.

    -

    - Copyright Notice -

    -

    Copyright (c) 2018 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 (http://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.

    +

    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

    +

    +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, and specifying the vocabulary being used.

    +

    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 [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 7159 [RFC7159].

    -

    3. Overview

    +

    +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.

    -

    3.1. Validation

    -

    JSON Schema describes the structure of a JSON document (for instance, required properties and length limitations). Applications can use this information to validate instances (check that constraints are met), or inform interfaces to collect user input such that the constraints are satisfied.

    -

    Validation behaviour and keywords are specified in a separate document [json-schema-validation].

    -

    3.2. Annotation

    -

    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.

    -

    Detailed annotation behavior, along with a small set of basic annotation keywords are defined in the validation specification [json-schema-validation].

    -

    3.3. Hypermedia and Linking

    -

    JSON Hyper-Schema describes the hypertext structure of a JSON document. This includes link relations from the instance to other resources, interpretation of instances as multimedia data, and submission data required to use an API.

    -

    Hyper-schema behaviour and keywords are specified in a separate document [json-hyper-schema].

    -

    4. Definitions

    -

    4.1. JSON Document

    +

    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 [RFC7049].

    -

    4.2. Instance

    +

    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

    +

    +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
    +
    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 [vocabulary] 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.

    +

    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

    +

    +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

    +

    +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.
    • +
    • 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 is itself 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".

    -

    4.3.1. JSON Schema Values and Keywords

    -

    A JSON Schema MUST be an object or a boolean.

    -

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

    +

    +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:

    -
    assertions:
    -
    produce a boolean result when applied to an instance
    -
    annotations:
    -
    attach information to an instance for application use
    +
    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 either or both categories. Extension keywords, meaning those defined outside of this document and its companions, are free to define other behaviors as well.

    -

    The boolean schema values "true" and "false" are trivial assertions that always return themselves regardless of the instance value. As an example, in terms of the validation vocabulary, boolean schemas are equivalent to the following behaviors:

    +

    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":{} }
    +
    true:
    +
    Always passes validation, as if the empty schema {}
    +
    false:
    +
    Always fails validation, as if the schema { "not": {} }
    -

    -

    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. JSON Schema Vocabularies

    -

    A JSON Schema vocabulary is a set of keywords defined for a particular purpose. The vocabulary specifies the meaning of its keywords as assertions, annotations, and/or any vocabulary-defined keyword category. The two companion standards to this document each define a vocabulary: One for instance validation, and one for hypermedia annotations. Vocabularies are the primary mechanism for extensibility within the JSON Schema media type.

    -

    Vocabularies may be defined by any entity. 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.

    -

    A schema that itself describes a schema is called a meta-schema. Meta-schemas are used to validate JSON Schemas and specify which vocabulary it is using. [CREF1]Currently, only a single meta-schema may be specified per schema, meaning that in order to use multiple vocabularies, a meta-schema must be written that encompasses all of them. The hyper-schema meta-schema is an example of this, as it encompasses the validation vocabulary as well as the hypermedia vocabulary.

    -

    4.3.3. Root Schema and Subschemas

    -

    The root schema is the schema that comprises the entire JSON document in question.

    -

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

    +

    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:

     
     {
    @@ -660,443 +872,1465 @@ 

    4.3.3. Root Schema a }

    -

    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.

    -

    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".)

    +

    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 [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 "$id" keyword [id-keyword] section.

    -

    -

    6. General Considerations

    -

    6.1. Range of JSON Values

    -

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

    -

    6.2. Programming Language Independence

    +

    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

    +

    +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. Extending JSON Schema

    -

    Implementations MAY define additional keywords to JSON Schema. Save for explicit agreement, schema authors SHALL NOT expect these additional keywords to be supported by peer implementations. Implementations SHOULD ignore keywords they do not support.

    -

    Authors of extensions to JSON Schema are encouraged to write their own meta-schemas, which extend the existing meta-schemas using "allOf". This extended meta-schema SHOULD be referenced using the "$schema" keyword, to allow tools to follow the correct behaviour.

    -

    Note that the recursive nature of meta-schemas requires re-defining recursive keywords in the extended meta-schema, as can be seen in the JSON Hyper-Schema meta-schema.

    -

    7. The "$schema" Keyword

    -

    The "$schema" keyword is both used as a JSON Schema version identifier and the location of a resource which is itself a JSON Schema, which describes any schema written for this particular version.

    -

    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 a root schema. It MUST NOT appear in subschemas.

    -

    [CREF2]Using multiple "$schema" keywords in the same document would imply that the vocabulary 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.

    -

    Values for this property are defined in other documents and by other parties. JSON Schema implementations SHOULD implement support for current and previous published drafts of JSON Schema vocabularies as deemed reasonable.

    -

    8. Base URI 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.

    -

    8.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, or a suitable substitute URI if none is known.

    -

    8.2. The "$id" Keyword

    -

    The "$id" keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. A subschema's "$id" is resolved against the base URI of its parent schema. If no parent sets an explicit base with "$id", the base URI is that of the entire document, as determined per RFC 3986 section 5 [RFC3986].

    -

    If present, the value for this keyword MUST be a string, and MUST represent a valid URI-reference [RFC3986]. This value SHOULD be normalized, and SHOULD NOT be an empty fragment <#> or an empty string <>.

    -

    8.2.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), or this absolute URI but with an empty fragment.

    -

    8.2.2. Changing the base URI within a schema file

    -

    When an "$id" sets the base URI, the object containing that "$id" and all of its subschemas can be identified by using a JSON Pointer fragment starting from that location. This is true even of subschemas that further change the base URI. Therefore, a single subschema may be accessible by multiple URIs, each consisting of base URI declared in the subschema or a parent, along with a JSON Pointer fragment identifying the path from the schema object that declares the base to the subschema being identified. Examples of this are shown in section 8.2.4.

    -

    8.2.3. 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.

    -

    To specify such a subschema identifier, the "$id" keyword is set to a URI reference with a plain name fragment (not a JSON Pointer fragment). This value MUST begin with the number sign that specifies a fragment ("#"), then a letter ([A-Za-z]), followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), or periods (".").

    -

    The effect of using a fragment in "$id" that isn't blank or doesn't follow the plain name syntax is undefined. [CREF3]How should an "$id" URI reference containing a fragment with other components be interpreted? There are two cases: when the other components match the current base URI and when they change the base URI.

    -

    8.2.4. Schema identification examples

    -

    Consider the following schema, which shows "$id" being used to identify the root schema, change the base URI for subschemas, and assign plain name fragments to subschemas:

    +

    +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:

     
     {
    -    "$id": "http://example.com/root.json",
    -    "definitions": {
    -        "A": { "$id": "#foo" },
    -        "B": {
    -            "$id": "other.json",
    -            "definitions": {
    -                "X": { "$id": "#bar" },
    -                "Y": { "$id": "t/inner.json" }
    +    "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
    +                }
                 }
             },
    -        "C": {
    -            "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f"
    +        {
    +            "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
             }
         }
     }
     
    -                        
    -

    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 Section 5 above:

    -

    +

    +

    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:

    -
    # (document root)
    -
    -
    -
    -
    http://example.com/root.json
    -
    -
    http://example.com/root.json#
    -
    -

    -
    -
    #/definitions/A
    -
    -
    -
    -
    http://example.com/root.json#foo
    -
    -
    http://example.com/root.json#/definitions/A
    -
    -

    -
    -
    #/definitions/B
    -
    -
    -
    -
    http://example.com/other.json
    -
    -
    http://example.com/other.json#
    -
    -
    http://example.com/root.json#/definitions/B
    -
    -

    -
    -
    #/definitions/B/definitions/X
    -
    -
    -
    -
    http://example.com/other.json#bar
    -
    -
    http://example.com/other.json#/definitions/X
    -
    -
    http://example.com/root.json#/definitions/B/definitions/X
    -
    -

    -
    -
    #/definitions/B/definitions/Y
    -
    -
    -
    -
    http://example.com/t/inner.json
    -
    -
    http://example.com/t/inner.json#
    -
    -
    http://example.com/other.json#/definitions/Y
    -
    -
    http://example.com/root.json#/definitions/B/definitions/Y
    -
    -

    -
    -
    #/definitions/C
    -
    -
    -
    -
    urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f
    -
    -
    urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f#
    -
    -
    http://example.com/root.json#/definitions/C
    -
    -

    -
    +
    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.

    -

    8.3. Schema References With "$ref"

    -

    The "$ref" keyword is used to reference a schema, and provides the ability to validate recursive structures through self-reference.

    -

    An object schema with a "$ref" property MUST be interpreted as a "$ref" reference. The value of the "$ref" property MUST be a URI Reference. Resolved against the current URI base, it identifies the URI of a schema to use. All other properties in a "$ref" object MUST be ignored.

    -

    The URI is not 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.

    -

    A schema MUST NOT be run into an infinite loop against a schema. 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.3.1. 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 [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 section 8.2.4.

    -

    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.3.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:

    +

    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": "http://example.net/root.json",
    +  "$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" }
         },
    -    "definitions": {
    +    "$defs": {
             "single": {
    -            "$id": "#item",
    +            "$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
    +
                             
    -

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

    -

    When an implementation then looks inside the <#/items> schema, it encounters the <#item> reference, and resolves this to <http://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 <http://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. [CREF4]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. Comments With "$comment"

    -

    This keyword is reserved 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.

    -

    10. 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].

    -

    10.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:

    +

    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.

     
    -Link: <http://example.com/my-hyper-schema#>; rel="describedby"
    +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
    +  }
    +]
     
                         
    -

    10.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.

    -

    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:

    +

    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="http://example.com/my-hyper-schema#"
    +          schema="https://example.com/my-hyper-schema#"
     
                         
    -

    Multiple schemas are whitespace separated:

    +

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

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

    [CREF5]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:

    +

    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"
     
                         
    -

    10.3. 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.

    +

    +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.

    -

    11. Security Considerations

    -

    Both schemas and instances are JSON values. As such, all security considerations defined in RFC 7159 [RFC7159] 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 an 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.

    -

    12. IANA Considerations

    -

    12.1. application/schema+json

    -

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

    +

    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
    • -
    • Encoding considerations: Encoding considerations are identical to those specified for the "application/json" media type. See JSON [RFC7159].
    • -
    • Security considerations: See Section 11 above.
    • -
    • Interoperability considerations: See Sections 6.2 and 6.3 above.
    • -
    • Fragment identifier considerations: See Section 5
    • +
    • 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

    -

    12.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:

    +

    +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 [RFC7159].
    • -
    • Security considerations: See Section 11 above.
    • -
    • Interoperability considerations: See Sections 6.2 and 6.3 above.
    • -
    • Fragment identifier considerations: See Section 5
    • +
    • 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

    -

    13. References

    -

    13.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.
    - [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.
    - [RFC7159] - Bray, T., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March 2014.
    - [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.
    -

    13.2. Informative References

    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - [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 LastCall WD-fragid-best-practices-20121025, October 2012.
    - [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-01, November 2017.
    - [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-01, November 2017.
    -

    Appendix A. 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 B. ChangeLog

    -

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

    -

    +

    +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.

    +

    -
    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 doucment
    • -
    • 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.
    • -
    -

    -
    +
    # (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
    +
    +

    +

    -

    - Authors' Addresses +

    +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

    @@ -1126,17 +2360,61 @@

    Andrews - Cloudflare, Inc. + - San Francisco, - CA + + + + + + + EMail: andrews_henry@yahoo.com + +

    +
    +
    + + Ben Hutton (editor) + + + Wellcome Sanger Institute + + + + + + + + + + EMail: bh7@sanger.ac.uk + +URI: https://jsonschema.dev + +
    +
    +
    + + Greg Dennis + + + + + + + Auckland, + - USA + NZ - EMail: henry@cloudflare.com + EMail: gregsdennis@yahoo.com
    diff --git a/latest/json-schema-hypermedia.html b/latest/json-schema-hypermedia.html index 76470132..2c919aae 100644 --- a/latest/json-schema-hypermedia.html +++ b/latest/json-schema-hypermedia.html @@ -373,88 +373,88 @@ /*]]>*/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -466,20 +466,20 @@ - Internet Engineering Task Force - H. Andrews, Ed. +Internet Engineering Task Force +H. Andrews, Ed. - Internet-Draft - Cloudflare, Inc. +Internet-Draft + - Intended status: Informational - A. Wright, Ed. +Intended status: Informational +A. Wright, Ed. - Expires: July 23, 2018 - January 19, 2018 +Expires: March 20, 2020 +September 17, 2019 @@ -487,121 +487,189 @@

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

    + draft-handrews-json-schema-hyperschema-02

    -

    - Abstract -

    +

    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 -

    +

    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 <http://json-schema.org/>.

    +

    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 -

    +

    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 http://datatracker.ietf.org/drafts/current/.

    +

    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 July 23, 2018.

    -

    - Copyright Notice -

    -

    Copyright (c) 2018 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 (http://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.

    +

    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

    +

    +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 [RFC8288].

    -

    This specification will use the concepts, syntax, and terminology defined by the JSON Schema core [json-schema] and JSON Schema validation [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 [RFC2119].

    -

    3. Overview

    +

    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.

    @@ -624,114 +692,161 @@

    3. Overview

    ] }
    -

    If the instance is {"id": 1234}, and its base URI according to RFC 3986 section 5.1 [RFC3986], is "https://api.example.com/", then "https://api.example.com/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 [json-schema].

    -

    The terms "applicable" and "attached" are to be interpreted as defined in Section 3 of the JSON Schema validation specification [json-schema-validation].

    -

    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 [RFC8288].

    -

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

    +

    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.
    -
    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.
    +
    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 [RFC8288], a link consists of a context, a typed relation, a target, and optionally additional target attributes.

    +

    +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 <http://json-schema.org/draft-07/hyper-schema#>.

    -

    The link description format [ldo] 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: <http://json-schema.org/draft-07/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" [implementation], and to show the output generated by examples [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 <http://json-schema.org/draft-07/hyper-schema-output#>.

    -

    5. Schema Keywords

    -

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

    +

    +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 [uriTemplating], 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.

    +

    +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

    +

    +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 [RFC8288]. 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.

    +

    +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" [href] and "rel" [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 of the JSON Schema validation specification [json-schema-validation]). This is often not the entire instance document. This default context can be changed using the keywords in this section.

    +

    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 [RFC6901] in place of a URI fragment. The process for constructing a URI based on a URI template is given in the URI Templating [uriTemplating] section.

    -

    6.1.1. anchor

    -

    This property sets the context URI of the link. The value of the property is a URI Template [RFC6570], and the resulting URI-reference [RFC3986] 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" [href] property, with the exception that "hrefSchema" [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 [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" [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.

    +

    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

    +

    +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 a string, and MUST be a single Link Relation Type as defined in RFC 8288, Section 2.1.

    -

    This property is required.

    -

    6.2.2. "self" Links

    -

    A "self" link, as originally defined by Section 4.2.7.2 of RFC 4287 [RFC4287], 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.

    +

    +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 [RFC6573] defines and registers the "item" and "collection" link relation types. JSON Hyper-Schema imposes additional semantics on collection resources indicated by these types.

    +

    +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" [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 [RFC8288]. 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 [RFC4151].

    +

    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" [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 [uriTemplating] 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 [RFC3986] against the base URI of the instance.

    +

    +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 [uriTemplating] section for the complete template resolution algorithm.

    +

    +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 [RFC6901], or a valid Relative JSON Pointer [relative-json-pointer] which is evaluated relative to the attachment point of the link for which the template is being resolved.

    +

    +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

    +

    +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

    +

    +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

    +

    +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

    +

    +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 [RFC2046], 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 [RFC7231].

    -

    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" [security] 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" [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.

    +

    +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 [HTTP] section for an in-depth discussion of how this keyword is used with HTTP.

    -

    6.5.5. targetHints

    +

    +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.

    @@ -739,72 +854,90 @@

    6.5.5. 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" [HTTP] for guidance on using this keyword with HTTP and analogous protocols.

    -

    6.6. Link Input

    +

    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" [href].

    +

    +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

    +

    +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. See the "JSON Hyper-Schema and HTTP" [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" [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.

    +

    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" [HTTP] for detailed examples.

    -

    6.6.4. Submitting Data for Processing

    -

    The "submissionSchema" [submissionSchema] and "submissionMediaType" [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" [submissionSchema].

    +

    "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

    +

    +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" [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.

    +

    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

    +

    +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 [relationType] section and are not repeated here.

    +

    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, as it appears in the LDO.
    -
    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 "attachmentUri" are the same, but "contextUri" can be changed by LDO keywords, while "attachmentUri" cannot.
    +
    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" [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.

    +

    +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 [RFC6570]: "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).

    +

    +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.
    • +
    • "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.

    @@ -812,10 +945,10 @@

    7.2. 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. +
    9. Populate template variable data from the instance
    10. +
    11. If input is desired, accept input
    12. +
    13. Check that all required variables have a value
    14. +
    15. Encode values into strings and fill out the template

    @@ -837,13 +970,14 @@

    7.2. 7.2.1. Populating Template Data From the Instance

    +

    +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. +
    7. Use "templatePointers" to find a value if the variable appears in that keyword's value
    8. +
    9. Otherwise, look for a property name matching the variable in the instance location to which the link is attached
    10. +
    11. In either case, if there is a value at the location, put it in the template resolution data set

    @@ -864,16 +998,17 @@

    7.2.1. Populating Te templateData[varname] = value -

    7.2.2. Accepting Input for Template Data

    +

    +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. +
    11. Determine which variables can accept input
    12. +
    13. Pre-populate the input data set if the template resolution data set has a value
    14. +
    15. Accept input (present a web form, make a callback, etc.)
    16. +
    17. Validate the input data set, (not the template resolution data set)
    18. +
    19. Put the input in the template resolution data set, overriding any existing values

    @@ -910,7 +1045,8 @@

    7.2.2. Accepting Inp return inputData: -

    7.2.3. Encoding Data as Strings

    +

    +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.

     
    @@ -919,7 +1055,7 @@ 

    7.2.3. Encoding Data if value is true: templateData[varname] = "true" else if value is false: - temlateData[varname] = "false" + templateData[varname] = "false" else if value is null: templateData[varname] = "null" else if value is a number: @@ -930,12 +1066,14 @@

    7.2.3. Encoding Data

    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

    +

    +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

    +

    +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.

    @@ -943,129 +1081,162 @@

    7.4. Requests

    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

    +

    +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" [RFC7807] 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.

    +

    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

    +

    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

    +

    +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 11 of the JSON Schema core specification [json-schema] 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 [rel] and URI schemes.

    +

    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

    +

    +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 replaces the resource in 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" [RFC7231].

    -

    Per RFC 5789 [RFC5789], 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

    +

    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"

    +

    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" [I-D.reschke-http-jfv]. Approaches shown in that document's examples SHOULD be applied to other similarly structured headers wherever possible.

    +

    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
    • +
    • 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".

    -

    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" [I-D.reschke-http-jfv] Approaches shown in that document's examples SHOULD be applied to other similarly structured headers wherever possible.

    +

    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
    • +
    • 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

    +

    +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

    +

    +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 [HTTP].

    -

    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, 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:

    +

    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://api.example.com HTTP/1.1
    +GET https://example.com/api HTTP/1.1
     
     200 OK
     Content-Type: application/json
    -Link: <https://schema.example.com/entry> rel=describedBy
    +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. In this case the base URI is also the entry point URI.

    +

    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": "http://json-schema.org/draft-07/hyper-schema#",
    -    "base": "https://api.example.com/",
    +    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
    +    "base": "https://example.com/api/",
         "links": [
             {
                 "rel": "self",
    -            "href": ""
    +            "href": "../api",
             }, {
                 "rel": "about",
    -            "href": "/docs"
    +            "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://api.example.com",
    +        "contextUri": "https://example.com/api",
             "contextPointer": "",
             "rel": "self",
    -        "targetUri": "https://api.example.com",
    +        "targetUri": "https://example.com/api",
             "attachmentPointer": ""
         },
         {
    -        "contextUri": "https://api.example.com",
    +        "contextUri": "https://example.com/api",
             "contextPointer": "",
             "rel": "about",
    -        "targetUri": "https://api.example.com/docs",
    +        "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

    +

    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": "http://json-schema.org/draft-07/hyper-schema#",
    -    "base": "https://api.example.com/",
    +    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
    +    "base": "https://example.com/api/",
         "type": "object",
         "required": ["data"],
         "properties": {
    -        "id": {"$ref": "#/definitions/id"},
    +        "id": {"$ref": "#/$defs/id"},
             "data": true
         },
         "links": [
    @@ -1076,7 +1247,7 @@ 

    9.2. Individually Identi "targetSchema": {"$ref": "#"} } ], - "definitions": { + "$defs": { "id": { "type": "integer", "minimum": 1, @@ -1085,9 +1256,9 @@

    9.2. Individually Identi } }

    -

    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 "definitions" section will be clear in the next example.

    +

    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 [RFC4151]:

    +

    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",
    @@ -1095,24 +1266,26 @@ 

    9.2. Individually Identi "hrefSchema": { "required": ["id"], "properties": { - "id": {"$ref": "thing#/definitions/id"} + "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

    +

    +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 [HTTP].

    -

    In this case, we use a "mailto:" URI, which, per RFC 6068, Section 3" [RFC6068], 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".

    +

    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": "http://json-schema.org/draft-07/hyper-schema#",
    +    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
         "required": ["stuffWorthEmailingAbout", "email", "title"],
         "properties": {
             "title": {
    @@ -1169,34 +1342,34 @@ 

    9.3. 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.
    +
    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://api.example.com/stuff":

    +

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

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

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

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

    9.3. 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"
    +
    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

    +

    +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://api.example.com/trees/1/nodes/123 HTTP/1.1
    +GET https://example.com/api/trees/1/nodes/123 HTTP/1.1
     
     200 OK
     Content-Type: application/json
    -Link: <https://api.example.com/trees/1/nodes/123> rel=self
    -Link: <https://api.example.com/trees/1/nodes/123> rel=up
    -        anchor=<https://api.example.com/trees/1/nodes/456>
    -Link: <https://api.example.com/trees/1/nodes/456> rev=up
    +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,
    @@ -1239,7 +1413,7 @@ 

    9.4. "anchor", "base" an
     {
         "$id": "https://schema.example.com/tree-node",
    -    "$schema": "http://json-schema.org/draft-07/hyper-schema#",
    +    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
         "base": "trees/{treeId}/",
         "properties": {
             "id": {"type": "integer"},
    @@ -1272,18 +1446,19 @@ 

    9.4. "anchor", "base" an

    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

    +

    +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": "http://json-schema.org/draft-07/hyper-schema#",
    -    "base": "https://api.example.com/",
    +    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
    +    "base": "https://example.com/api/",
         "type": "object",
         "required": ["data"],
         "properties": {
    -        "id": {"$ref": "#/definitions/id"},
    +        "id": {"$ref": "#/$defs/id"},
             "data": true
         },
         "links": [
    @@ -1299,7 +1474,7 @@ 

    9.5. Collections

    "submissionSchema": {"$ref": "#"} } ], - "definitions": { + "$defs": { "id": { "type": "integer", "minimum": 1, @@ -1308,13 +1483,13 @@

    9.5. Collections

    } }
    -

    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.

    +

    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": "http://json-schema.org/draft-07/hyper-schema#",
    -    "base": "https://api.example.com/",
    +    "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
    +    "base": "https://example.com/api/",
         "type": "object",
         "required": ["elements"],
         "properties": {
    @@ -1357,63 +1532,64 @@ 

    9.5. Collections

     [
         {
    -        "contextUri": "https://api.example.com/things",
    +        "contextUri": "https://example.com/api/things",
             "contextPointer": "",
             "rel": "self",
    -        "targetUri": "https://api.example.com/things",
    +        "targetUri": "https://example.com/api/things",
             "attachmentPointer": ""
         },
         {
    -        "contextUri": "https://api.example.com/things",
    +        "contextUri": "https://example.com/api/things",
             "contextPointer": "/elements/0",
             "rel": "self",
    -        "targetUri": "https://api.example.com/things/12345",
    +        "targetUri": "https://example.com/api/things/12345",
             "attachmentPointer": "/elements/0"
         },
         {
    -        "contextUri": "https://api.example.com/things",
    +        "contextUri": "https://example.com/api/things",
             "contextPointer": "/elements/1",
             "rel": "self",
    -        "targetUri": "https://api.example.com/things/67890",
    +        "targetUri": "https://example.com/api/things/67890",
             "attachmentPointer": "/elements/1"
         },
         {
    -        "contextUri": "https://api.example.com/things",
    +        "contextUri": "https://example.com/api/things",
             "contextPointer": "",
             "rel": "item",
    -        "targetUri": "https://api.example.com/things/12345",
    +        "targetUri": "https://example.com/api/things/12345",
             "attachmentPointer": "/elements/0"
         },
         {
    -        "contextUri": "https://api.example.com/things",
    +        "contextUri": "https://example.com/api/things",
             "contextPointer": "",
             "rel": "item",
    -        "targetUri": "https://api.example.com/things/67890",
    +        "targetUri": "https://example.com/api/things/67890",
             "attachmentPointer": "/elements/1"
         },
         {
    -        "contextUri": "https://api.example.com/things",
    +        "contextUri": "https://example.com/api/things",
             "contextPointer": "/elements/0",
             "rel": "collection",
    -        "targetUri": "https://api.example.com/things",
    +        "targetUri": "https://example.com/api/things",
             "attachmentPointer": "/elements/0"
         },
         {
    -        "contextUri": "https://api.example.com/things",
    +        "contextUri": "https://example.com/api/things",
             "contextPointer": "/elements/1",
             "rel": "collection",
    -        "targetUri": "https://api.example.com/things",
    +        "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 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

    +

    +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.

     {
    @@ -1424,9 +1600,9 @@ 

    9.5.1. Pagination9.5.1. Pagination9.5.1. Pagination [ { - "contextUri": "https://api.example.com/things", + "contextUri": "https://example.com/api/things", "contextPointer": "", "rel": "self", "targetUri": - "https://api.example.com/things?offset=20,limit=2", + "https://example.com/api/things?offset=0&limit=2", "attachmentPointer": "" }, { - "contextUri": "https://api.example.com/things", + "contextUri": "https://example.com/api/things", "contextPointer": "", "rel": "next", "targetUri": - "https://api.example.com/things?offset=22,limit=2", + "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:

    +

    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#/definitions/pagination"
    +        "$ref": "thing-collection#/$defs/pagination"
         },
         "submissionSchema": {
             "$ref": "thing#"
    @@ -1540,247 +1716,250 @@ 

    9.5.1. Pagination

    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

    +

    +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 [RFC8288] 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.

    +

    +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

    +

    +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

    +

    +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

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - [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.
    - [relative-json-pointer] - Luff, G. and H. Andrews, "Relative JSON Pointers", Internet-Draft draft-handrews-relative-json-pointer-01, January 2018.
    - [json-schema] - Wright, A. and H. Andrews, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-handrews-json-schema-00, 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-00, November 2017.
    -

    12.2. Informative References

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - [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.
    - [I-D.reschke-http-jfv] - Reschke, J., "A JSON Encoding for HTTP Header Field Values", Internet-Draft draft-reschke-http-jfv-06, June 2017.
    -

    Appendix A. Using JSON Hyper-Schema in APIs

    +

    +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

    +

    +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" [RFC7807], 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

    +

    +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

    +

    +Appendix B. ChangeLog

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

    -

    +

    -
    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.
    • -
    -

    -
    +
    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 -

    +

    Authors' Addresses

    @@ -1789,17 +1968,17 @@

    Andrews - Cloudflare, Inc. + - San Francisco, - CA + + - USA + - EMail: henry@cloudflare.com + EMail: andrews_henry@yahoo.com

    diff --git a/latest/json-schema-validation.html b/latest/json-schema-validation.html index 77c144ba..4635b1f6 100644 --- a/latest/json-schema-validation.html +++ b/latest/json-schema-validation.html @@ -373,101 +373,85 @@ /*]]>*/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + @@ -479,28 +463,32 @@ - Internet Engineering Task Force - A. Wright, Ed. +Internet Engineering Task Force +A. Wright, Ed. - Internet-Draft - +Internet-Draft + - Intended status: Informational - H. Andrews, Ed. +Intended status: Informational +H. Andrews, Ed. - Expires: September 20, 2018 - Cloudflare, Inc. +Expires: March 20, 2020 + - - G. Luff + +B. Hutton, Ed. - - March 19, 2018 + +Wellcome Sanger Institute + + + +September 17, 2019 @@ -508,452 +496,503 @@

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

    + draft-handrews-json-schema-validation-02

    -

    - Abstract -

    +

    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 -

    +

    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 <http://json-schema.org/>.

    +

    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 -

    +

    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 http://datatracker.ietf.org/drafts/current/.

    +

    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 September 20, 2018.

    -

    - Copyright Notice -

    -

    Copyright (c) 2018 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 (http://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.

    +

    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

    +

    +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 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 [json-schema].

    -

    3. Overview

    -

    JSON Schema validation applies schemas to locations within the instance, and asserts constraints on the structure of the data at each location. 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.

    +

    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.

    -

    3.1. Applicability

    -

    Validation begins by applying the root schema to the complete instance document. From there, various keywords are used to determine which additional subschemas are applied to either the current location, or a child location. These keywords also define whether and how subschema assertion results are modified and/or combined. Such keywords do not assert conditions on their own. Rather, they control how assertions are applied and evaluated.

    -

    The keywords in the boolean logic [logic] and conditional [conditional] sections of this specification apply subschemas to the same location as the parent schema. The former group defines boolean operations on the subschema assertion results, while the latter evaluates one subschema and uses its assertion results to determine which of two other subschemas to apply as well.

    -

    Several keywords determine which subschemas are applied to array items, object property values, and object property names. They are: "items", "additionalItems", "contains", "properties", "patternProperties", "additionalProperties", and "propertyNames". The "contains" keyword only requires its subschema to be valid against at least one child instance, while the other keywords require that all subschemas are valid against all child instances to which they apply.

    -

    3.1.1. Keyword Independence

    -

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

    -

    For schema author convenience, there are some exceptions among the keywords that control subschema applicability:

    - -
      -
    • "additionalProperties", whose behavior is defined in terms of "properties" and "patternProperties"; and
    • -
    • "additionalItems", whose behavior is defined in terms of "items".
    • -
    - -

    -

    3.2. Assertions

    -

    Validation is a process of checking assertions. Each assertion adds constraints that an instance must satisfy in order to successfully validate.

    -

    Assertion keywords that are absent never restrict validation. In some cases, this no-op behavior is identical to a keyword that exists with certain values, and these values are noted where known.

    -

    All of the keywords in the general [general], numeric [numeric], and string [string] sections are assertions, as well as "minItems", "maxItems", "uniqueItems", "minProperties", "maxProperties", and "required". Additionally, "dependencies" is shorthand for a combination of conditional and assertion keywords.

    -

    The "format", "contentType", and "contentEncoding" keywords can also be implemented as assertions, although that functionality is an optional part of this specification, and the keywords convey additional non-assertion information.

    -

    3.2.1. Assertions and Instance Primitive Types

    -

    Most validation 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 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.

    -

    3.3. Annotations

    -

    In addition to assertions, this specification provides a small vocabulary of metadata keywords that can be used to annotate the JSON instance with useful information. The Section 7 and Section 8 keywords are also useful as annotations as well as being optional assertions, as they convey additional usage guidance for the instance data.

    -

    A schema that is applicable to a particular location in the instance, against which the instance location is valid, attaches its annotations to that location in the instance. Since many subschemas can be applicable to any single location, annotation keywords need to specify any unusual handling of multiple applicable occurrences of the keyword with different values. The default behavior is simply to collect all values.

    -

    Additional vocabularies SHOULD make use of this mechanism for applying their own annotations to instances.

    -

    3.3.1. Annotations and Validation Outcomes

    -

    Annotations are collected whenever an instance is valid against a schema object, and all of that schema object's parent schemas.

    -

    In particular, annotations in a subschema contained within a "not", at any depth, including any number of intervening additional "not" subschemas, MUST be ignored. If the instance was valid against the "not" subschema, then by definition it is not valid against the schema that contains the "not", so the "not" subschema's annotations are not used.

    -

    Similarly, annotations within a failing branch of a "oneOf", "anyOf", "then", or "else" MUST be ignored even when the instance successfully validates against the complete schema document.

    -

    3.3.2. Annotations and Short-Circuit Validation

    -

    Annotation keywords MUST be applied to all possible sub-instances. Even if such application can be short-circuited when only assertion evaluation is needed. For instance, the "contains" keyword need only be checked for assertions until at least one array item proves valid. However, when working with annotations, all items in the array must be evaluated to determine all items with which the annotations should be associated.

    -

    4. Interoperability Considerations

    -

    4.1. Validation of String Instances

    +

    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

    +

    +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

    -

    Two validation keywords, "pattern" and "patternProperties", use regular expressions to express constraints, and the "regex" value for the "format" keyword constrains the instance value to be a regular expression. These regular expressions SHOULD be valid according to the ECMA 262 [ecma262] regular expression dialect.

    -

    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 [RFC7159];
    • -
    • 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".

    -

    5. Meta-Schema

    -

    The current URI for the JSON Schema Validation is <http://json-schema.org/draft-07/schema#>.

    -

    6. Validation Keywords

    -

    Validation keywords in a schema impose requirements for successful validation of an instance.

    -

    6.1. Validation Keywords for Any Instance Type

    -

    6.1.1. type

    +

    +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

    +

    +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 value, including null.

    -

    6.1.3. const

    +

    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.

    -

    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

    +

    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

    +

    +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

    +

    +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

    +

    +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

    +

    +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

    +

    +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 7159 [RFC7159].

    -

    6.3.2. minLength

    +

    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 7159 [RFC7159].

    +

    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

    +

    +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. items

    -

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

    -

    This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.

    -

    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.

    -

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

    -

    6.4.2. additionalItems

    -

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

    -

    This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.

    -

    If "items" is an array of schemas, validation succeeds if every instance element at a position greater than the size of "items" validates against "additionalItems".

    -

    Otherwise, "additionalItems" MUST be ignored, as the "items" schema (possibly the default value of an empty schema) is applied to all elements.

    -

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

    -

    6.4.3. 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.4. minItems

    +

    +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 "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.5. 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.6. 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.

    -

    6.5. Validation Keywords for Objects

    -

    6.5.1. maxProperties

    +

    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

    +

    +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

    +

    +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. properties

    -

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

    -

    This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself.

    -

    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.

    +

    +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.

    -

    6.5.5. 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.

    -

    This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself. Validation of the primitive instance type against this keyword always succeeds.

    -

    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.

    -

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

    -

    6.5.6. additionalProperties

    -

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

    -

    This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself.

    -

    Validation with "additionalProperties" applies only to the child values of instance names that do not match any names in "properties", and do not match any regular expression in "patternProperties".

    -

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

    -

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

    -

    6.5.7. dependencies

    -

    [CREF1]This keyword may be split into two, with the variation that uses an array of property names rather than a subschema getting a new name. The dual behavior is confusing and relatively difficult to implement. In the previous draft, we proposed dropping the keyword altogether, or dropping one of its forms, but we received feedback in support of keeping it. See issues #442 and #528 at <https://github.com/json-schema-org/json-schema-spec/issues> for further discussion. Further feedback is encouraged.

    -

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

    -

    This keyword's value MUST be an object. Each property specifies a dependency. Each dependency value MUST be an array or a valid JSON Schema.

    -

    If the dependency value is a subschema, and the dependency key is a property in the instance, the entire instance must validate against the dependency value.

    -

    If the dependency value is an array, each element in the array, if any, MUST be a string, and MUST be unique. If the dependency key is a property in the instance, each of the items in the dependency value must be a property that exists in the instance.

    -

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

    -

    6.5.8. 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.

    -

    6.6. Keywords for Applying Subschemas Conditionally

    -

    These keywords work together to implement conditional application of a subschema based on the outcome of another subschema.

    -

    These keywords 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 any of these keywords 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.

    -

    6.6.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 [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".

    -

    6.6.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 valiation 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.

    -

    6.6.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 valiation 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.

    -

    6.7. Keywords for Applying Subschemas With Boolean Logic

    -

    6.7.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.

    -

    6.7.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.

    -

    6.7.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.

    -

    6.7.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.

    -

    7. Semantic Validation With "format"

    -

    7.1. Foreword

    -

    Structural validation alone may be insufficient to validate that an instance meets all the requirements of an application. The "format" keyword is defined to allow interoperable semantic validation 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.

    -

    7.2. Implementation Requirements

    -

    The "format" keyword functions as both an annotation (Section 3.3) and as an assertion (Section 3.2). While no special effort is required to implement it as an annotation conveying semantic meaning, implementing validation is non-trivial.

    -

    Implementations MAY support the "format" keyword as a validation assertion. Should they choose to do so:

    +

    +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.

      -
    • they SHOULD implement validation for attributes defined below;
    • -
    • they SHOULD offer an option to disable validation for this keyword.
    • +
    • 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.

    -

    Implementations MAY add custom format attributes. Save for agreement between parties, schema authors SHALL NOT expect a peer implementation to support this keyword and/or custom format attributes.

    -

    7.3. Defined Formats

    -

    7.3.1. Dates and Times

    +

    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 [RFC3339].

    +

    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.
    +
    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. [CREF2]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

    +

    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 [RFC5322].
    -
    idn-email:
    -
    As defined by RFC 6531 [RFC6531]
    +
    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

    +

    +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 1034, section 3.1 [RFC1034], including host names produced using the Punycode algorithm specified in RFC 5891, section 4.4 [RFC5891].
    -
    idn-hostname:
    -
    As defined by either RFC 1034 as for hostname, or an internationalized hostname as defined by RFC 5890, section 2.3.2.3 [RFC5890].
    +
    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

    +

    +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].
    +
    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

    +

    +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].
    +
    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.

    -

    7.3.6. uri-template

    +

    +

    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].

    +

    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

    +

    +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].
    +
    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

    +

    +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 [regexInterop] section of this specification, and SHOULD accept all valid ECMA 262 expressions.

    -

    8. String-Encoding Non-JSON Data

    -

    8.1. Foreword

    -

    Properties defined in this section indicate that an instance contains non-JSON data encoded in a JSON string. They describe the type of content and how it is encoded.

    -

    These properties provide additional information required to interpret JSON data as rich multimedia documents.

    -

    8.2. Implementation Requirements

    -

    The content keywords function as both annotations (Section 3.3) and as assertions (Section 3.2). While no special effort is required to implement them as annotations conveying how applications can interpret the data in the string, implementing validation of conformance to the media type and encoding is non-trivial.

    -

    Implementations MAY support the "contentMediaType" and "contentEncoding" keywords as validation assertions. Should they choose to do so, they SHOULD offer an option to disable validation for 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. RFC 2045, Sec 6.1 [RFC2045] lists the possible values for this property.

    -

    The value of this property MUST be a string.

    -

    The value of this property SHOULD be ignored if the instance described is not a string.

    -

    8.4. contentMediaType

    -

    The value of this property must be a media type, as defined by RFC 2046 [RFC2046]. This property defines the media type of instances which this schema defines.

    -

    The value of this property MUST be a string.

    -

    The value of this property SHOULD be ignored if the instance described is not a string.

    -

    If the "contentEncoding" property is not present, but the instance value is a string, then the value of this property SHOULD specify a text document type, and the character set SHOULD be the character set into which the JSON string value was decoded (for which the default is Unicode).

    -

    8.5. Example

    +

    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":

     
    @@ -964,7 +1003,7 @@ 

    8.5. Example

    }
    -

    Instances described by this schema should be strings, and their values should be interpretable as base64-encoded PNG images.

    +

    Instances described by this schema are expected to be strings, and their values should be interpretable as base64-encoded PNG images.

    Another example:

     
    @@ -974,268 +1013,319 @@ 

    8.5. Example

    }
    -

    Instances described by this schema should be strings containing HTML, using whatever character set the JSON string was decoded into (default is Unicode).

    -

    9. Schema Re-Use With "definitions"

    -

    The "definitions" keywords provides a standardized 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.

    +

    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": "array",
    -    "items": { "$ref": "#/definitions/positiveInteger" },
    -    "definitions": {
    -        "positiveInteger": {
    -            "type": "integer",
    -            "exclusiveMinimum": 0
    -        }
    +    "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"}
    +                }
    +            }
    +        ]
         }
     }
    -
                         
    -

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

    -

    10. Schema Annotations

    -

    Schema validation is a useful mechanism for annotating instance data with additional information. The rules for determining when and how annotations are associated with an instance are outlined in section 3.3.

    -

    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.

    -

    10.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.

    -

    10.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.

    -

    10.3. "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 value MUST be true if any occurrence specifies a true value, and MUST be false 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.

    -

    10.4. "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.

    -

    11. 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.

    -

    12. References

    -

    12.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.
    - [RFC1034] - Mockapetris, P., "Domain names - concepts and facilities", STD 13, RFC 1034, DOI 10.17487/RFC1034, November 1987.
    - [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.
    - [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.
    - [RFC4291] - Hinden, R. and S. Deering, "IP Version 6 Addressing Architecture", RFC 4291, DOI 10.17487/RFC4291, February 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.
    - [RFC6570] - Gregorio, J., Fielding, R., Hadley, M., Nottingham, M. and D. Orchard, "URI Template", RFC 6570, DOI 10.17487/RFC6570, March 2012.
    - [RFC6531] - Yao, J. and W. Mao, "SMTP Extension for Internationalized Email", RFC 6531, DOI 10.17487/RFC6531, February 2012.
    - [RFC6901] - Bryan, P., Zyp, K. and M. Nottingham, "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, April 2013.
    - [RFC7159] - Bray, T., The JavaScript Object Notation (JSON) Data Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March 2014.
    [ecma262]ECMA 262 specification"
    - [relative-json-pointer] - Luff, G. and H. Andrews, "Relative JSON Pointers", Internet-Draft draft-handrews-relative-json-pointer-01, November 2017.
    - [json-schema] - Wright, A. and H. Andrews, "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-handrews-json-schema-01, November 2017.
    -

    12.2. Informative References

    - - - - - - - -
    - [RFC4329] - Hoehrmann, B., "Scripting Media Types", RFC 4329, DOI 10.17487/RFC4329, April 2006.
    -

    Appendix A. 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 B. ChangeLog

    -

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

    -

    +

    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:

    -
    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.
    • -
    -

    -
    +
    "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.

    -

    - Authors' Addresses -

    +

    +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

    @@ -1265,38 +1355,40 @@

    Andrews - Cloudflare, Inc. + - San Francisco, - CA + + - USA + - EMail: henry@cloudflare.com + EMail: andrews_henry@yahoo.com

    - Geraint Luff + Ben Hutton (editor) - + Wellcome Sanger Institute - Cambridge, + - UK + - EMail: luffgd@gmail.com + EMail: bh7@sanger.ac.uk + +URI: https://jsonschema.dev
    diff --git a/latest/relative-json-pointer.html b/latest/relative-json-pointer.html index 7df25f77..5710a004 100644 --- a/latest/relative-json-pointer.html +++ b/latest/relative-json-pointer.html @@ -373,31 +373,31 @@ /*]]>*/ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - + + @@ -409,24 +409,20 @@ - Internet Engineering Task Force - G. Luff +Internet Engineering Task Force +G. Luff - Internet-Draft - +Internet-Draft + - Intended status: Informational - H. Andrews, Ed. +Intended status: Informational +H. Andrews, Ed. - Expires: July 23, 2018 - Cloudflare, Inc. - - - - January 19, 2018 +Expires: March 20, 2020 +September 17, 2019 @@ -434,56 +430,69 @@

    Relative JSON Pointers
    - draft-handrews-relative-json-pointer-01

    + draft-handrews-relative-json-pointer-02

    -

    - Abstract -

    +

    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 -

    +

    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 http://datatracker.ietf.org/drafts/current/.

    +

    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 July 23, 2018.

    -

    - Copyright Notice -

    -

    Copyright (c) 2018 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 (http://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.

    +

    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 [RFC6901]) 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 [RFC2119].

    -

    3. Syntax

    -

    A Relative JSON Pointer is a Unicode string (see RFC 4627, Section 3 [RFC4627]), comprising a non-negative integer, followed by either a '#' (%x23) character or a JSON Pointer (RFC 6901 [RFC6901]).

    +

    +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:

    @@ -494,31 +503,34 @@ 

    3. Syntax

    ; "0", or digits without a leading "0"
    -

    where <json-pointer> follows the production defined in RFC 6901, Section 3 [RFC6901] ("Syntax").

    -

    -

    4. Evaluation

    +

    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 [RFC6901] ("Evaluation"), with the modification that the initial reference being used is the reference currently being held (which may not be root of the document).

    +

    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 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.
    • +
    • 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 [RFC6901].

    -

    5.1. Examples

    +

    +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:

     
    @@ -552,82 +564,81 @@ 

    5.1. Examples

    "1#" "highly"
    -

    6. Non-use in URI Fragment Identifiers

    +

    +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

    +

    +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

    +

    +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.

    +

    +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

    +

    +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

    - - - - - - - -
    - [RFC4627] - Crockford, D., "The application/json Media Type for JavaScript Object Notation (JSON)", RFC 4627, DOI 10.17487/RFC4627, July 2006.
    -

    Appendix A. ChangeLog

    +

    +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-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.
    • -
    -

    -
    +
    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 -

    +

    Authors' Addresses

    @@ -657,17 +668,17 @@

    Andrews - Cloudflare, Inc. + - San Francisco, - CA + + - USA + - EMail: henry@cloudflare.com + EMail: andrews_henry@yahoo.com

    From 44ee36be7503ba34decbe4fd24791867b8860ded Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 17 Sep 2019 14:59:48 -0700 Subject: [PATCH 082/395] Add submodule include for latest draft --- .gitmodules | 3 +++ _includes/draft/2019-09 | 1 + 2 files changed, 4 insertions(+) create mode 160000 _includes/draft/2019-09 diff --git a/.gitmodules b/.gitmodules index 7760d76c..f975f8f1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -23,3 +23,6 @@ path = _includes/draft-07 url = https://github.com/json-schema-org/json-schema-spec.git branch = draft-07 +[submodule "_includes/draft/2019-09"] + path = _includes/draft/2019-09 + url = https://github.com/json-schema-org/json-schema-spec.git diff --git a/_includes/draft/2019-09 b/_includes/draft/2019-09 new file mode 160000 index 00000000..38e1606d --- /dev/null +++ b/_includes/draft/2019-09 @@ -0,0 +1 @@ +Subproject commit 38e1606d71ee848c6cf0490c3457681220c01663 From ce906977452959b2f9625914f8818c9586df34ee Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 17 Sep 2019 17:10:06 -0700 Subject: [PATCH 083/395] Link in 2019-09 JSON documents from submodule --- draft/2019-09/hyper-schema | 1 + draft/2019-09/links | 1 + draft/2019-09/meta/applicator | 1 + draft/2019-09/meta/content | 1 + draft/2019-09/meta/core | 1 + draft/2019-09/meta/format | 1 + draft/2019-09/meta/hyper-schema | 1 + draft/2019-09/meta/meta-data | 1 + draft/2019-09/meta/validation | 1 + draft/2019-09/output/hyper-schema | 1 + draft/2019-09/output/schema | 1 + draft/2019-09/output/verbose-example | 1 + draft/2019-09/schema | 1 + 13 files changed, 13 insertions(+) create mode 120000 draft/2019-09/hyper-schema create mode 120000 draft/2019-09/links create mode 120000 draft/2019-09/meta/applicator create mode 120000 draft/2019-09/meta/content create mode 120000 draft/2019-09/meta/core create mode 120000 draft/2019-09/meta/format create mode 120000 draft/2019-09/meta/hyper-schema create mode 120000 draft/2019-09/meta/meta-data create mode 120000 draft/2019-09/meta/validation create mode 120000 draft/2019-09/output/hyper-schema create mode 120000 draft/2019-09/output/schema create mode 120000 draft/2019-09/output/verbose-example create mode 120000 draft/2019-09/schema diff --git a/draft/2019-09/hyper-schema b/draft/2019-09/hyper-schema new file mode 120000 index 00000000..8a058c65 --- /dev/null +++ b/draft/2019-09/hyper-schema @@ -0,0 +1 @@ +../../_includes/draft/2019-09/hyper-schema.json \ No newline at end of file diff --git a/draft/2019-09/links b/draft/2019-09/links new file mode 120000 index 00000000..aacc1535 --- /dev/null +++ b/draft/2019-09/links @@ -0,0 +1 @@ +../../_includes/draft/2019-09/links.json \ No newline at end of file diff --git a/draft/2019-09/meta/applicator b/draft/2019-09/meta/applicator new file mode 120000 index 00000000..5702a1ae --- /dev/null +++ b/draft/2019-09/meta/applicator @@ -0,0 +1 @@ +../../../_includes/draft/2019-09/meta/applicator.json \ No newline at end of file diff --git a/draft/2019-09/meta/content b/draft/2019-09/meta/content new file mode 120000 index 00000000..04968fb0 --- /dev/null +++ b/draft/2019-09/meta/content @@ -0,0 +1 @@ +../../../_includes/draft/2019-09/meta/content.json \ No newline at end of file diff --git a/draft/2019-09/meta/core b/draft/2019-09/meta/core new file mode 120000 index 00000000..5ca6d983 --- /dev/null +++ b/draft/2019-09/meta/core @@ -0,0 +1 @@ +../../../_includes/draft/2019-09/meta/core.json \ No newline at end of file diff --git a/draft/2019-09/meta/format b/draft/2019-09/meta/format new file mode 120000 index 00000000..be19503e --- /dev/null +++ b/draft/2019-09/meta/format @@ -0,0 +1 @@ +../../../_includes/draft/2019-09/meta/format.json \ No newline at end of file diff --git a/draft/2019-09/meta/hyper-schema b/draft/2019-09/meta/hyper-schema new file mode 120000 index 00000000..72aea96a --- /dev/null +++ b/draft/2019-09/meta/hyper-schema @@ -0,0 +1 @@ +../../../_includes/draft/2019-09/meta/hyper-schema.json \ No newline at end of file diff --git a/draft/2019-09/meta/meta-data b/draft/2019-09/meta/meta-data new file mode 120000 index 00000000..1165b3a3 --- /dev/null +++ b/draft/2019-09/meta/meta-data @@ -0,0 +1 @@ +../../../_includes/draft/2019-09/meta/meta-data.json \ No newline at end of file diff --git a/draft/2019-09/meta/validation b/draft/2019-09/meta/validation new file mode 120000 index 00000000..810c056b --- /dev/null +++ b/draft/2019-09/meta/validation @@ -0,0 +1 @@ +../../../_includes/draft/2019-09/meta/validation.json \ No newline at end of file diff --git a/draft/2019-09/output/hyper-schema b/draft/2019-09/output/hyper-schema new file mode 120000 index 00000000..9a06f839 --- /dev/null +++ b/draft/2019-09/output/hyper-schema @@ -0,0 +1 @@ +../../../_includes/draft/2019-09/output/hyper-schema.json \ No newline at end of file diff --git a/draft/2019-09/output/schema b/draft/2019-09/output/schema new file mode 120000 index 00000000..0c2f2725 --- /dev/null +++ b/draft/2019-09/output/schema @@ -0,0 +1 @@ +../../../_includes/draft/2019-09/output/schema.json \ No newline at end of file diff --git a/draft/2019-09/output/verbose-example b/draft/2019-09/output/verbose-example new file mode 120000 index 00000000..36757e1e --- /dev/null +++ b/draft/2019-09/output/verbose-example @@ -0,0 +1 @@ +../../../_includes/draft/2019-09/output/verbose-example.json \ No newline at end of file diff --git a/draft/2019-09/schema b/draft/2019-09/schema new file mode 120000 index 00000000..7a80adf4 --- /dev/null +++ b/draft/2019-09/schema @@ -0,0 +1 @@ +../../_includes/draft/2019-09/schema.json \ No newline at end of file From c6a2e8cf754a17f330a894c82cd101281d02185d Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 17 Sep 2019 17:11:08 -0700 Subject: [PATCH 084/395] Move release notes from WIP directory --- .../2019-09/release-notes.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename work-in-progress/WIP-json-schema-release-notes.md => draft/2019-09/release-notes.md (100%) diff --git a/work-in-progress/WIP-json-schema-release-notes.md b/draft/2019-09/release-notes.md similarity index 100% rename from work-in-progress/WIP-json-schema-release-notes.md rename to draft/2019-09/release-notes.md From 16a71b1dd89014b1f18a70ba83c438f5029ffc7a Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 17 Sep 2019 18:54:33 -0700 Subject: [PATCH 085/395] Remove WIP docs, no longer needed. Put a note on the page pointing to the published draft. --- work-in-progress/WIP-hyper-schema.json | 26 - work-in-progress/WIP-jsonschema-core.html | 2423 ---------- work-in-progress/WIP-jsonschema-core.txt | 4200 ----------------- .../WIP-jsonschema-hyperschema.html | 2008 -------- .../WIP-jsonschema-hyperschema.txt | 3248 ------------- .../WIP-jsonschema-validation.html | 1397 ------ .../WIP-jsonschema-validation.txt | 1680 ------- work-in-progress/WIP-links.json | 91 - .../WIP-relative-json-pointer.html | 687 --- .../WIP-relative-json-pointer.txt | 392 -- work-in-progress/WIP-schema.json | 42 - work-in-progress/index.md | 111 +- work-in-progress/meta/WIP-applicator.json | 60 - work-in-progress/meta/WIP-content.json | 17 - work-in-progress/meta/WIP-core.json | 58 - work-in-progress/meta/WIP-format.json | 14 - work-in-progress/meta/WIP-hyper-schema.json | 29 - work-in-progress/meta/WIP-meta-data.json | 37 - work-in-progress/meta/WIP-validation.json | 98 - work-in-progress/output/WIP-hyper-schema.json | 62 - work-in-progress/output/WIP-schema.json | 86 - .../output/WIP-verbose-example.json | 130 - 22 files changed, 3 insertions(+), 16893 deletions(-) delete mode 100644 work-in-progress/WIP-hyper-schema.json delete mode 100644 work-in-progress/WIP-jsonschema-core.html delete mode 100644 work-in-progress/WIP-jsonschema-core.txt delete mode 100644 work-in-progress/WIP-jsonschema-hyperschema.html delete mode 100644 work-in-progress/WIP-jsonschema-hyperschema.txt delete mode 100644 work-in-progress/WIP-jsonschema-validation.html delete mode 100644 work-in-progress/WIP-jsonschema-validation.txt delete mode 100644 work-in-progress/WIP-links.json delete mode 100644 work-in-progress/WIP-relative-json-pointer.html delete mode 100644 work-in-progress/WIP-relative-json-pointer.txt delete mode 100644 work-in-progress/WIP-schema.json delete mode 100644 work-in-progress/meta/WIP-applicator.json delete mode 100644 work-in-progress/meta/WIP-content.json delete mode 100644 work-in-progress/meta/WIP-core.json delete mode 100644 work-in-progress/meta/WIP-format.json delete mode 100644 work-in-progress/meta/WIP-hyper-schema.json delete mode 100644 work-in-progress/meta/WIP-meta-data.json delete mode 100644 work-in-progress/meta/WIP-validation.json delete mode 100644 work-in-progress/output/WIP-hyper-schema.json delete mode 100644 work-in-progress/output/WIP-schema.json delete mode 100644 work-in-progress/output/WIP-verbose-example.json diff --git a/work-in-progress/WIP-hyper-schema.json b/work-in-progress/WIP-hyper-schema.json deleted file mode 100644 index 28f9ad4f..00000000 --- a/work-in-progress/WIP-hyper-schema.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/hyper-schema", - "$id": "https://json-schema.org/draft/2019-09/hyper-schema", - "$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://json-schema.org/draft/2019-09/vocab/meta-data": true, - "https://json-schema.org/draft/2019-09/vocab/format": false, - "https://json-schema.org/draft/2019-09/vocab/content": true, - "https://json-schema.org/draft/2019-09/vocab/hyper-schema": true - }, - "$recursiveAnchor": true, - - "title": "JSON Hyper-Schema", - "allOf": [ - {"$ref": "https://json-schema.org/draft/2019-09/schema"}, - {"$ref": "https://json-schema.org/draft/2019-09/meta/hyper-schema"} - ], - "links": [ - { - "rel": "self", - "href": "{+%24id}" - } - ] -} diff --git a/work-in-progress/WIP-jsonschema-core.html b/work-in-progress/WIP-jsonschema-core.html deleted file mode 100644 index 3c3ae48f..00000000 --- a/work-in-progress/WIP-jsonschema-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 17, 2020
    B. Hutton, Ed.
    Wellcome Sanger Institute
    G. Dennis
    September 14, 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 17, 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/work-in-progress/WIP-jsonschema-core.txt b/work-in-progress/WIP-jsonschema-core.txt deleted file mode 100644 index 7a407516..00000000 --- a/work-in-progress/WIP-jsonschema-core.txt +++ /dev/null @@ -1,4200 +0,0 @@ - - - - -Internet Engineering Task Force A. Wright, Ed. -Internet-Draft -Intended status: Informational H. Andrews, Ed. -Expires: March 17, 2020 - B. Hutton, Ed. - Wellcome Sanger Institute - G. Dennis - September 14, 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 . - - For additional information, see . - - 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." - - - - -Wright, et al. Expires March 17, 2020 [Page 1] - -Internet-Draft JSON Schema September 2019 - - - This Internet-Draft will expire on March 17, 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 . . . . . . . . . . . . . . . . . . . . . . . . 4 - 2. Conventions and Terminology . . . . . . . . . . . . . . . . . 4 - 3. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 4 - 4. Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 5 - 4.1. JSON Document . . . . . . . . . . . . . . . . . . . . . . 5 - 4.2. Instance . . . . . . . . . . . . . . . . . . . . . . . . 6 - 4.2.1. Instance Data Model . . . . . . . . . . . . . . . . . 6 - 4.2.2. Instance Media Types . . . . . . . . . . . . . . . . 7 - 4.2.3. Instance Equality . . . . . . . . . . . . . . . . . . 7 - 4.3. JSON Schema Documents . . . . . . . . . . . . . . . . . . 8 - 4.3.1. JSON Schema Objects and Keywords . . . . . . . . . . 8 - 4.3.2. Boolean JSON Schemas . . . . . . . . . . . . . . . . 9 - 4.3.3. Schema Vocabularies . . . . . . . . . . . . . . . . . 9 - 4.3.4. Meta-Schemas . . . . . . . . . . . . . . . . . . . . 9 - 4.3.5. Root Schema and Subschemas and Resources . . . . . . 10 - 5. Fragment Identifiers . . . . . . . . . . . . . . . . . . . . 10 - 6. General Considerations . . . . . . . . . . . . . . . . . . . 11 - 6.1. Range of JSON Values . . . . . . . . . . . . . . . . . . 11 - 6.2. Programming Language Independence . . . . . . . . . . . . 11 - 6.3. Mathematical Integers . . . . . . . . . . . . . . . . . . 11 - 6.4. Regular Expressions . . . . . . . . . . . . . . . . . . . 12 - 6.5. Extending JSON Schema . . . . . . . . . . . . . . . . . . 12 - 7. Keyword Behaviors . . . . . . . . . . . . . . . . . . . . . . 13 - 7.1. Lexical Scope and Dynamic Scope . . . . . . . . . . . . . 13 - 7.2. Keyword Interactions . . . . . . . . . . . . . . . . . . 14 - 7.3. Default Behaviors . . . . . . . . . . . . . . . . . . . . 15 - 7.4. Identifiers . . . . . . . . . . . . . . . . . . . . . . . 15 - 7.5. Applicators . . . . . . . . . . . . . . . . . . . . . . . 15 - 7.5.1. Referenced and Referencing Schemas . . . . . . . . . 16 - - - -Wright, et al. Expires March 17, 2020 [Page 2] - -Internet-Draft JSON Schema September 2019 - - - 7.6. Assertions . . . . . . . . . . . . . . . . . . . . . . . 16 - 7.6.1. Assertions and Instance Primitive Types . . . . . . . 17 - 7.7. Annotations . . . . . . . . . . . . . . . . . . . . . . . 17 - 7.7.1. Collecting Annotations . . . . . . . . . . . . . . . 18 - 7.8. Reserved Locations . . . . . . . . . . . . . . . . . . . 22 - 8. The JSON Schema Core Vocabulary . . . . . . . . . . . . . . . 22 - 8.1. Meta-Schemas and Vocabularies . . . . . . . . . . . . . . 23 - 8.1.1. The "$schema" Keyword . . . . . . . . . . . . . . . . 24 - 8.1.2. The "$vocabulary" Keyword . . . . . . . . . . . . . . 25 - 8.1.3. Updates to Meta-Schema and Vocabulary URIs . . . . . 26 - 8.1.4. Detecting a Meta-Schema . . . . . . . . . . . . . . . 26 - 8.2. Base URI, Anchors, and Dereferencing . . . . . . . . . . 27 - 8.2.1. Initial Base URI . . . . . . . . . . . . . . . . . . 27 - 8.2.2. The "$id" Keyword . . . . . . . . . . . . . . . . . . 28 - 8.2.3. Defining location-independent identifiers with - "$anchor" . . . . . . . . . . . . . . . . . . . . . . 30 - 8.2.4. Schema References . . . . . . . . . . . . . . . . . . 31 - 8.2.5. Schema Re-Use With "$defs" . . . . . . . . . . . . . 36 - 8.3. Comments With "$comment" . . . . . . . . . . . . . . . . 36 - 9. A Vocabulary for Applying Subschemas . . . . . . . . . . . . 37 - 9.1. Keyword Independence . . . . . . . . . . . . . . . . . . 37 - 9.2. Keywords for Applying Subschemas in Place . . . . . . . . 38 - 9.2.1. Keywords for Applying Subschemas With Boolean Logic . 38 - 9.2.2. Keywords for Applying Subschemas Conditionally . . . 39 - 9.3. Keywords for Applying Subschemas to Child Instances . . . 41 - 9.3.1. Keywords for Applying Subschemas to Arrays . . . . . 41 - 9.3.2. Keywords for Applying Subschemas to Objects . . . . . 43 - 10. Output Formatting . . . . . . . . . . . . . . . . . . . . . . 45 - 10.1. Format . . . . . . . . . . . . . . . . . . . . . . . . . 46 - 10.2. Output Formats . . . . . . . . . . . . . . . . . . . . . 46 - 10.3. Minimum Information . . . . . . . . . . . . . . . . . . 46 - 10.3.1. Keyword Relative Location . . . . . . . . . . . . . 47 - 10.3.2. Keyword Absolute Location . . . . . . . . . . . . . 47 - 10.3.3. Instance Location . . . . . . . . . . . . . . . . . 47 - 10.3.4. Error or Annotation . . . . . . . . . . . . . . . . 47 - 10.3.5. Nested Results . . . . . . . . . . . . . . . . . . . 48 - 10.4. Output Structure . . . . . . . . . . . . . . . . . . . . 48 - 10.4.1. Flag . . . . . . . . . . . . . . . . . . . . . . . . 50 - 10.4.2. Basic . . . . . . . . . . . . . . . . . . . . . . . 50 - 10.4.3. Detailed . . . . . . . . . . . . . . . . . . . . . . 51 - 10.4.4. Verbose . . . . . . . . . . . . . . . . . . . . . . 53 - 10.4.5. Output validation schemas . . . . . . . . . . . . . 55 - 11. Usage for Hypermedia . . . . . . . . . . . . . . . . . . . . 55 - 11.1. Linking to a Schema . . . . . . . . . . . . . . . . . . 55 - 11.2. Identifying a Schema via a Media Type Parameter . . . . 55 - 11.3. Usage Over HTTP . . . . . . . . . . . . . . . . . . . . 57 - 12. Security Considerations . . . . . . . . . . . . . . . . . . . 57 - 13. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 58 - - - -Wright, et al. Expires March 17, 2020 [Page 3] - -Internet-Draft JSON Schema September 2019 - - - 13.1. application/schema+json . . . . . . . . . . . . . . . . 58 - 13.2. application/schema-instance+json . . . . . . . . . . . . 59 - 14. References . . . . . . . . . . . . . . . . . . . . . . . . . 59 - 14.1. Normative References . . . . . . . . . . . . . . . . . . 59 - 14.2. Informative References . . . . . . . . . . . . . . . . . 60 - Appendix A. Schema identification examples . . . . . . . . . . . 62 - Appendix B. Manipulating schema documents and references . . . . 64 - B.1. Bundling schema resources into a single document . . . . 64 - B.2. Reference removal is not always safe . . . . . . . . . . 64 - Appendix C. Example of recursive schema extension . . . . . . . 65 - Appendix D. Working with vocabularies . . . . . . . . . . . . . 66 - D.1. Best practices for vocabulary and meta-schema authors . . 66 - D.2. Example meta-schema with vocabulary declarations . . . . 67 - Appendix E. References and generative use cases . . . . . . . . 70 - Appendix F. Acknowledgments . . . . . . . . . . . . . . . . . . 71 - Appendix G. ChangeLog . . . . . . . . . . . . . . . . . . . . . 71 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 74 - -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 [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 - - - -Wright, et al. Expires March 17, 2020 [Page 4] - -Internet-Draft JSON Schema September 2019 - - - 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. - - - - - -Wright, et al. Expires March 17, 2020 [Page 5] - -Internet-Draft JSON Schema September 2019 - - - 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". - -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 - (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. - - - - - -Wright, et al. Expires March 17, 2020 [Page 6] - -Internet-Draft JSON Schema September 2019 - - - 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. - - - -Wright, et al. Expires March 17, 2020 [Page 7] - -Internet-Draft JSON Schema September 2019 - - - 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. - - - -Wright, et al. Expires March 17, 2020 [Page 8] - -Internet-Draft JSON Schema September 2019 - - - 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 - - - -Wright, et al. Expires March 17, 2020 [Page 9] - -Internet-Draft JSON Schema September 2019 - - - 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]. - - 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".) - - - - - -Wright, et al. Expires March 17, 2020 [Page 10] - -Internet-Draft JSON Schema September 2019 - - - 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.3) 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. - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 11] - -Internet-Draft JSON Schema September 2019 - - -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 [ecma262]. - - 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 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. - - - - - - -Wright, et al. Expires March 17, 2020 [Page 12] - -Internet-Draft JSON Schema September 2019 - - -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 - - - -Wright, et al. Expires March 17, 2020 [Page 13] - -Internet-Draft JSON Schema September 2019 - - - 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 (Section 4.3.5) 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 (Section 4.3). - - - - - - -Wright, et al. Expires March 17, 2020 [Page 14] - -Internet-Draft JSON Schema September 2019 - - -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 (Section 8.2.4), 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 (Section 4.3) begins by applying the root - - - -Wright, et al. Expires March 17, 2020 [Page 15] - -Internet-Draft JSON Schema September 2019 - - - 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 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" (Section 8.2.4.1), - 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. - - - -Wright, et al. Expires March 17, 2020 [Page 16] - -Internet-Draft JSON Schema September 2019 - - - 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, annotation - - - -Wright, et al. Expires March 17, 2020 [Page 17] - -Internet-Draft JSON Schema September 2019 - - - 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 [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) - - 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 - (Section 10) described in this specification that include annotation - information meet this requirement. - - - -Wright, et al. Expires March 17, 2020 [Page 18] - -Internet-Draft JSON Schema September 2019 - - -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]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 19] - -Internet-Draft JSON Schema September 2019 - - - 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. - - - -Wright, et al. Expires March 17, 2020 [Page 20] - -Internet-Draft JSON Schema September 2019 - - - 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: - - - - - - - - - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 21] - -Internet-Draft JSON Schema September 2019 - - - { - "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. - - - -Wright, et al. Expires March 17, 2020 [Page 22] - -Internet-Draft JSON Schema September 2019 - - - 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: . - - The current URI for the corresponding meta-schema is: . - - 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. - - - -Wright, et al. Expires March 17, 2020 [Page 23] - -Internet-Draft JSON Schema September 2019 - - - 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 [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 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. - - - - -Wright, et al. Expires March 17, 2020 [Page 24] - -Internet-Draft JSON Schema September 2019 - - -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. - - - - - - -Wright, et al. Expires March 17, 2020 [Page 25] - -Internet-Draft JSON Schema September 2019 - - -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). [[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 - - - -Wright, et al. Expires March 17, 2020 [Page 26] - -Internet-Draft JSON Schema September 2019 - - - 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 [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. 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. - - - - - - -Wright, et al. Expires March 17, 2020 [Page 27] - -Internet-Draft JSON Schema September 2019 - - - 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 - [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). 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 [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 8.2.1) - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 28] - -Internet-Draft JSON Schema September 2019 - - -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 [RFC3986] (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 (Section 8.2.4), 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". - - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 29] - -Internet-Draft JSON Schema September 2019 - - - 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 - - - -Wright, et al. Expires March 17, 2020 [Page 30] - -Internet-Draft JSON Schema September 2019 - - - 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. - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 31] - -Internet-Draft JSON Schema September 2019 - - -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". - - - - - -Wright, et al. Expires March 17, 2020 [Page 32] - -Internet-Draft JSON Schema September 2019 - - - 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 (Section 7.1) 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. - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 33] - -Internet-Draft JSON Schema September 2019 - - -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" (Section 8.2.5) 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 (Section 11). - - 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 - - - - -Wright, et al. Expires March 17, 2020 [Page 34] - -Internet-Draft JSON Schema September 2019 - - - 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 [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 "$id" URI reference against the current base URI to form - . - - When an implementation then looks inside the <#/items> schema, it - encounters the <#item> reference, and resolves this to - , which it has seen defined in - this same document and can therefore use automatically. - - - - -Wright, et al. Expires March 17, 2020 [Page 35] - -Internet-Draft JSON Schema September 2019 - - - When an implementation encounters the reference to "other.json", it - resolves this to , 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. - - 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. - - - -Wright, et al. Expires March 17, 2020 [Page 36] - -Internet-Draft JSON Schema September 2019 - - - 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: . - - The current URI for the corresponding meta-schema is: . - - 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. - - - - -Wright, et al. Expires March 17, 2020 [Page 37] - -Internet-Draft JSON Schema September 2019 - - - 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 - - - - -Wright, et al. Expires March 17, 2020 [Page 38] - -Internet-Draft JSON Schema September 2019 - - - 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. - - - - - -Wright, et al. Expires March 17, 2020 [Page 39] - -Internet-Draft JSON Schema September 2019 - - - 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". - -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. - - - -Wright, et al. Expires March 17, 2020 [Page 40] - -Internet-Draft JSON Schema September 2019 - - -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, - - - -Wright, et al. Expires March 17, 2020 [Page 41] - -Internet-Draft JSON Schema September 2019 - - - 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 (Section 9.2) 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 - - - -Wright, et al. Expires March 17, 2020 [Page 42] - -Internet-Draft JSON Schema September 2019 - - - 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 - - - -Wright, et al. Expires March 17, 2020 [Page 43] - -Internet-Draft JSON Schema September 2019 - - - 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" - - - -Wright, et al. Expires March 17, 2020 [Page 44] - -Internet-Draft JSON Schema September 2019 - - - keyword. Those three annotations, as well as - "unevaluatedProperties", can also result from any and all adjacent - in-place applicator (Section 9.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 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 - - - - -Wright, et al. Expires March 17, 2020 [Page 45] - -Internet-Draft JSON Schema September 2019 - - - 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. - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 46] - -Internet-Draft JSON Schema September 2019 - - -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. - - - - - -Wright, et al. Expires March 17, 2020 [Page 47] - -Internet-Draft JSON Schema September 2019 - - - 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. - - - - - - - - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 48] - -Internet-Draft JSON Schema September 2019 - - - { - "$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 - - - -Wright, et al. Expires March 17, 2020 [Page 49] - -Internet-Draft JSON Schema September 2019 - - - 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. - - - - - - - - - - - - - - - - - - - - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 50] - -Internet-Draft JSON Schema September 2019 - - -{ - "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. - - - - -Wright, et al. Expires March 17, 2020 [Page 51] - -Internet-Draft JSON Schema September 2019 - - - 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. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 52] - -Internet-Draft JSON Schema September 2019 - - -{ - "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 - - - -Wright, et al. Expires March 17, 2020 [Page 53] - -Internet-Draft JSON Schema September 2019 - - - 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: . - - -// 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": "#", - - - -Wright, et al. Expires March 17, 2020 [Page 54] - -Internet-Draft JSON Schema September 2019 - - - "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: . - -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 [RFC8288]. - -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 - [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: ; 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). - - - - - -Wright, et al. Expires March 17, 2020 [Page 55] - -Internet-Draft JSON Schema September 2019 - - - 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. - - - - -Wright, et al. Expires March 17, 2020 [Page 56] - -Internet-Draft JSON Schema September 2019 - - - 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: ;rel="schema", ;rel="schema" - - -11.3. 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. - -12. Security Considerations - - Both schemas and instances are JSON values. As such, all security - considerations defined in RFC 8259 [RFC8259] apply. - - - - -Wright, et al. Expires March 17, 2020 [Page 57] - -Internet-Draft JSON Schema September 2019 - - - 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 - [RFC8259]. - - - - -Wright, et al. Expires March 17, 2020 [Page 58] - -Internet-Draft JSON Schema September 2019 - - - 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 - [RFC8259]. - - 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", . - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 59] - -Internet-Draft JSON Schema September 2019 - - - [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., Ed., Zyp, K., and M. Nottingham, Ed., - "JavaScript Object Notation (JSON) Pointer", RFC 6901, - DOI 10.17487/RFC6901, April 2013, - . - - [RFC8259] Bray, T., Ed., "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", draft- - handrews-json-schema-hyperschema-02 (work in progress), - November 2017. - - [json-schema-validation] - Wright, A., Andrews, H., and G. Luff, "JSON Schema - Validation: A Vocabulary for Structural Validation of - JSON", draft-handrews-json-schema-validation-02 (work in - progress), November 2017. - - [RFC6596] Ohye, M. and J. Kupke, "The Canonical Link Relation", - RFC 6596, DOI 10.17487/RFC6596, April 2012, - . - - - -Wright, et al. Expires March 17, 2020 [Page 60] - -Internet-Draft JSON Schema September 2019 - - - [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object - Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, - October 2013, . - - [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "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, - . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 61] - -Internet-Draft JSON Schema September 2019 - - -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 - 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 - - - - -Wright, et al. Expires March 17, 2020 [Page 62] - -Internet-Draft JSON Schema September 2019 - - - 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# - - - -Wright, et al. Expires March 17, 2020 [Page 63] - -Internet-Draft JSON Schema September 2019 - - - 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. - - - - -Wright, et al. Expires March 17, 2020 [Page 64] - -Internet-Draft JSON Schema September 2019 - - -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 - - - - -Wright, et al. Expires March 17, 2020 [Page 65] - -Internet-Draft JSON Schema September 2019 - - - 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. - - - -Wright, et al. Expires March 17, 2020 [Page 66] - -Internet-Draft JSON Schema September 2019 - - - It is recommended that meta-schema authors reference each - vocabulary's meta-schema using the "allOf" (Section 9.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 "$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. - - - - -Wright, et al. Expires March 17, 2020 [Page 67] - -Internet-Draft JSON Schema September 2019 - - - 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" - } - } - } - - - - - - - - - - - - - - - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 68] - -Internet-Draft JSON Schema September 2019 - - - 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 [json-schema-validation]. - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 69] - -Internet-Draft JSON Schema September 2019 - - -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. - - - - - - -Wright, et al. Expires March 17, 2020 [Page 70] - -Internet-Draft JSON Schema September 2019 - - - 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" - - - - -Wright, et al. Expires March 17, 2020 [Page 71] - -Internet-Draft JSON Schema September 2019 - - - * 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 - - - - -Wright, et al. Expires March 17, 2020 [Page 72] - -Internet-Draft JSON Schema September 2019 - - - * 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 - - - - -Wright, et al. Expires March 17, 2020 [Page 73] - -Internet-Draft JSON Schema September 2019 - - - * 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 - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 74] - -Internet-Draft JSON Schema September 2019 - - - 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 75] diff --git a/work-in-progress/WIP-jsonschema-hyperschema.html b/work-in-progress/WIP-jsonschema-hyperschema.html deleted file mode 100644 index bb8a2c80..00000000 --- a/work-in-progress/WIP-jsonschema-hyperschema.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 17, 2020September 14, 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 17, 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/work-in-progress/WIP-jsonschema-hyperschema.txt b/work-in-progress/WIP-jsonschema-hyperschema.txt deleted file mode 100644 index 89b5b7f0..00000000 --- a/work-in-progress/WIP-jsonschema-hyperschema.txt +++ /dev/null @@ -1,3248 +0,0 @@ - - - - -Internet Engineering Task Force H. Andrews, Ed. -Internet-Draft -Intended status: Informational A. Wright, Ed. -Expires: March 17, 2020 September 14, 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 . - - For additional information, see . - - 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 17, 2020. - - - - - -Andrews & Wright Expires March 17, 2020 [Page 1] - -Internet-Draft JSON Hyper-Schema September 2019 - - -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 . . . . . . . . . . . . . . . . . . . . . . . . 3 - 2. Notational Conventions . . . . . . . . . . . . . . . . . . . 4 - 3. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 4 - 3.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 5 - 3.2. Functionality . . . . . . . . . . . . . . . . . . . . . . 6 - 4. Meta-Schemas and Output Schema . . . . . . . . . . . . . . . 7 - 5. Schema Keywords . . . . . . . . . . . . . . . . . . . . . . . 8 - 5.1. base . . . . . . . . . . . . . . . . . . . . . . . . . . 8 - 5.2. links . . . . . . . . . . . . . . . . . . . . . . . . . . 8 - 6. Link Description Object . . . . . . . . . . . . . . . . . . . 8 - 6.1. Link Context . . . . . . . . . . . . . . . . . . . . . . 9 - 6.1.1. anchor . . . . . . . . . . . . . . . . . . . . . . . 10 - 6.1.2. anchorPointer . . . . . . . . . . . . . . . . . . . . 10 - 6.2. Link Relation Type . . . . . . . . . . . . . . . . . . . 10 - 6.2.1. rel . . . . . . . . . . . . . . . . . . . . . . . . . 11 - 6.2.2. "self" Links . . . . . . . . . . . . . . . . . . . . 11 - 6.2.3. "collection" and "item" Links . . . . . . . . . . . . 11 - 6.2.4. Using Extension Relation Types . . . . . . . . . . . 12 - 6.3. Link Target . . . . . . . . . . . . . . . . . . . . . . . 12 - 6.3.1. href . . . . . . . . . . . . . . . . . . . . . . . . 12 - 6.4. Adjusting URI Template Resolution . . . . . . . . . . . . 12 - 6.4.1. templatePointers . . . . . . . . . . . . . . . . . . 13 - 6.4.2. templateRequired . . . . . . . . . . . . . . . . . . 13 - 6.5. Link Target Attributes . . . . . . . . . . . . . . . . . 13 - 6.5.1. title . . . . . . . . . . . . . . . . . . . . . . . . 13 - 6.5.2. description . . . . . . . . . . . . . . . . . . . . . 13 - 6.5.3. targetMediaType . . . . . . . . . . . . . . . . . . . 14 - 6.5.4. targetSchema . . . . . . . . . . . . . . . . . . . . 14 - 6.5.5. targetHints . . . . . . . . . . . . . . . . . . . . . 14 - 6.6. Link Input . . . . . . . . . . . . . . . . . . . . . . . 15 - 6.6.1. hrefSchema . . . . . . . . . . . . . . . . . . . . . 15 - - - -Andrews & Wright Expires March 17, 2020 [Page 2] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 6.6.2. headerSchema . . . . . . . . . . . . . . . . . . . . 16 - 6.6.3. Manipulating the Target Resource Representation . . . 17 - 6.6.4. Submitting Data for Processing . . . . . . . . . . . 17 - 7. Implementation Requirements . . . . . . . . . . . . . . . . . 18 - 7.1. Link Discovery and Look-Up . . . . . . . . . . . . . . . 19 - 7.2. URI Templating . . . . . . . . . . . . . . . . . . . . . 20 - 7.2.1. Populating Template Data From the Instance . . . . . 21 - 7.2.2. Accepting Input for Template Data . . . . . . . . . . 22 - 7.2.3. Encoding Data as Strings . . . . . . . . . . . . . . 23 - 7.3. Providing Access to LDO Keywords . . . . . . . . . . . . 24 - 7.4. Requests . . . . . . . . . . . . . . . . . . . . . . . . 24 - 7.5. Responses . . . . . . . . . . . . . . . . . . . . . . . . 25 - 7.6. Streaming Parsers . . . . . . . . . . . . . . . . . . . . 26 - 8. JSON Hyper-Schema and HTTP . . . . . . . . . . . . . . . . . 26 - 8.1. One Link Per Target and Relation Type . . . . . . . . . . 27 - 8.2. "targetSchema" and HTTP . . . . . . . . . . . . . . . . . 27 - 8.3. HTTP POST and the "submission*" keywords . . . . . . . . 28 - 8.4. Optimizing HTTP Discoverability With "targetHints" . . . 28 - 8.5. Advertising HTTP Features With "headerSchema" . . . . . . 29 - 8.6. Creating Resources Through Collections . . . . . . . . . 30 - 8.7. Content Negotiation and Schema Evolution . . . . . . . . 30 - 9. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 31 - 9.1. Entry Point Links, No Templates . . . . . . . . . . . . . 31 - 9.2. Individually Identified Resources . . . . . . . . . . . . 33 - 9.3. Submitting a Payload and Accepting URI Input . . . . . . 34 - 9.4. "anchor", "base" and URI Template Resolution . . . . . . 37 - 9.5. Collections . . . . . . . . . . . . . . . . . . . . . . . 40 - 9.5.1. Pagination . . . . . . . . . . . . . . . . . . . . . 45 - 9.5.2. Creating the First Item . . . . . . . . . . . . . . . 48 - 10. Security Considerations . . . . . . . . . . . . . . . . . . . 49 - 10.1. Target Attributes . . . . . . . . . . . . . . . . . . . 49 - 10.2. "self" Links . . . . . . . . . . . . . . . . . . . . . . 50 - 11. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 51 - 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 51 - 12.1. Normative References . . . . . . . . . . . . . . . . . . 51 - 12.2. Informative References . . . . . . . . . . . . . . . . . 52 - Appendix A. Using JSON Hyper-Schema in APIs . . . . . . . . . . 54 - A.1. Resource Evolution With Hyper-Schema . . . . . . . . . . 54 - A.2. Responses and Errors . . . . . . . . . . . . . . . . . . 54 - A.3. Static Analysis of an API's Hyper-Schemas . . . . . . . . 55 - Appendix B. ChangeLog . . . . . . . . . . . . . . . . . . . . . 55 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 58 - -1. Introduction - - JSON Hyper-Schema is a JSON Schema vocabulary for annotating JSON - documents with hyperlinks and instructions for processing and - - - - -Andrews & Wright Expires March 17, 2020 [Page 3] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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 [RFC8288]. - - This specification will use the concepts, syntax, and terminology - defined by the JSON Schema core [json-schema] and JSON Schema - validation [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 [RFC2119]. - -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 - - - -Andrews & Wright Expires March 17, 2020 [Page 4] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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 [RFC3986], 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 - [json-schema]. - - The terms "applicable" and "attached" are to be interpreted as - defined in Section 3.1 of the JSON Schema core specification - [json-schema]. - - 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 [RFC8288]. - - The term "user agent" is to be interpreted as defined in Section 2.1 - of RFC 7230 [RFC7230], 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: - - - -Andrews & Wright Expires March 17, 2020 [Page 5] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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 [RFC8288], a - link consists of a context, a typed relation, a target, and - optionally additional target attributes. - - - - -Andrews & Wright Expires March 17, 2020 [Page 6] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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 - . - - The current URI for this vocabulary, known as the Hyper-Schema - vocabulary, is: . - - 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: . - - The link description format (Section 6) 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: . - - 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" (Section 7), and to show the output - generated by examples (Section 9). 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 . - - - - -Andrews & Wright Expires March 17, 2020 [Page 7] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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 [json-schema], 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 - (Section 7.2), 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 [RFC8288]. 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 - - - -Andrews & Wright Expires March 17, 2020 [Page 8] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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" - (Section 6.3.1) and "rel" (Section 6.2.1) 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 [json-schema]). 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 [RFC6901] in place of - a URI fragment. The process for constructing a URI based on a URI - template is given in the URI Templating (Section 7.2) section. - - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 9] - -Internet-Draft JSON Hyper-Schema September 2019 - - -6.1.1. anchor - - This property sets the context URI of the link. The value of the - property is a URI Template [RFC6570], and the resulting URI-reference - [RFC3986] 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" (Section 6.3.1) property, with the - exception that "hrefSchema" (Section 6.6.1) 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 [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" (Section 6.1.1) 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. - - - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 10] - -Internet-Draft JSON Hyper-Schema September 2019 - - -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 - [RFC4287], 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 [RFC6573] 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. - - - -Andrews & Wright Expires March 17, 2020 [Page 11] - -Internet-Draft JSON Hyper-Schema September 2019 - - - As such a method would correspond to JSON Hyper-Schema's data - submission concept, the "submissionSchema" (Section 6.6.4.2) 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 [RFC8288]. 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 [RFC4151]. - - 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" (Section 6.6.1), 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 7.2) 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 [RFC3986] - 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 7.2) 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 - - - - -Andrews & Wright Expires March 17, 2020 [Page 12] - -Internet-Draft JSON Hyper-Schema September 2019 - - - "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 [RFC6901], or a valid Relative JSON Pointer - [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. - - - - -Andrews & Wright Expires March 17, 2020 [Page 13] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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 - [RFC2046], 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 [RFC7231]. - - 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" (Section 10) 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" (Section 6.6.2). 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 8) 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 - - - -Andrews & Wright Expires March 17, 2020 [Page 14] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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" (Section 8) 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 - - - - -Andrews & Wright Expires March 17, 2020 [Page 15] - -Internet-Draft JSON Hyper-Schema September 2019 - - - other user agent data for filling out the URI Template in "href" - (Section 6.3.1). - - 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 - - - -Andrews & Wright Expires March 17, 2020 [Page 16] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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 8) 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" (Section 6.5.4) 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" (Section 8) for detailed examples. - -6.6.4. Submitting Data for Processing - - The "submissionSchema" (Section 6.6.4.2) and "submissionMediaType" - (Section 6.6.4.1) 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. - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 17] - -Internet-Draft JSON Hyper-Schema September 2019 - - -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" (Section 6.6.4.2). - - 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" (Section 6.5.4) - 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 6.2) 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: - - - - - -Andrews & Wright Expires March 17, 2020 [Page 18] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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" - (Section 5.1) values necessary to resolve each LDO's URI Templates - - - -Andrews & Wright Expires March 17, 2020 [Page 19] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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 [RFC6570]: "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: - - o "ldo.templatePointers" is an empty object if the keyword was not - present and "ldo.templateRequired" is likewise an empty array. - - o "attachmentPointer" is the absolute JSON Pointer for the - attachment location of the LDO. - - o "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: - - - -Andrews & Wright Expires March 17, 2020 [Page 20] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 1. Populate template variable data from the instance - - 2. If input is desired, accept input - - 3. Check that all required variables have a value - - 4. Encode values into strings and fill out the template - - 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. Otherwise, look for a property name matching the variable in the - instance location to which the link is attached - - 3. In either case, if there is a value at the location, put it in - the template resolution data set - - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 21] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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. Pre-populate the input data set if the template resolution data - set has a value - - 3. Accept input (present a web form, make a callback, etc.) - - 4. Validate the input data set, (not the template resolution data - set) - - 5. Put the input in the template resolution data set, overriding any - existing values - - - - - - - - - - - - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 22] - -Internet-Draft JSON Hyper-Schema September 2019 - - - "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. - - - - - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 23] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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. - - - - - -Andrews & Wright Expires March 17, 2020 [Page 24] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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 - - - -Andrews & Wright Expires March 17, 2020 [Page 25] - -Internet-Draft JSON Hyper-Schema September 2019 - - - schemas and use appropriate media types (e.g. "application/ - problem+json" [RFC7807] 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 [json-schema] - 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 - - - - -Andrews & Wright Expires March 17, 2020 [Page 26] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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 - (Section 6.2.1) 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" [RFC7231]. - - - - -Andrews & Wright Expires March 17, 2020 [Page 27] - -Internet-Draft JSON Hyper-Schema September 2019 - - - Per RFC 5789 [RFC5789], 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" [I-D.reschke-http-jfv]. 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 - - - -Andrews & Wright Expires March 17, 2020 [Page 28] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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: - - o Method allowance - - o Method-specific request media types - - o 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" [I-D.reschke-http-jfv] 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: - - o Content negotiation - - o Authentication and authorization - - - -Andrews & Wright Expires March 17, 2020 [Page 29] - -Internet-Draft JSON Hyper-Schema September 2019 - - - o Range requests - - o 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. - - - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 30] - -Internet-Draft JSON Hyper-Schema September 2019 - - -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 (Section 8). - -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: ; 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" - } - ] - } - - - -Andrews & Wright Expires March 17, 2020 [Page 31] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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. - - - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 32] - -Internet-Draft JSON Hyper-Schema September 2019 - - -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, - - - - -Andrews & Wright Expires March 17, 2020 [Page 33] - -Internet-Draft JSON Hyper-Schema September 2019 - - - so an extension relationship is defined using the "tag:" URI scheme - [RFC4151]: - - { - "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 - (Section 8). - - In this case, we use a "mailto:" URI, which, per RFC 6068, Section 3" - [RFC6068], 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". - - - - - -Andrews & Wright Expires March 17, 2020 [Page 34] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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" - }, - - - -Andrews & Wright Expires March 17, 2020 [Page 35] - -Internet-Draft JSON Hyper-Schema September 2019 - - - "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": - - - - -Andrews & Wright Expires March 17, 2020 [Page 36] - -Internet-Draft JSON Hyper-Schema September 2019 - - - { - "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=y - our%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. - - - - - -Andrews & Wright Expires March 17, 2020 [Page 37] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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: ; rel="self" - Link: ; rel="up"; - anchor="https://example.com/api/trees/1/nodes/456" - Link: ; 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. - - - - - - - - - - - - - - - - - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 38] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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. - - - - -Andrews & Wright Expires March 17, 2020 [Page 39] - -Internet-Draft JSON Hyper-Schema September 2019 - - -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. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 40] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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. - - - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 41] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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"} - } - ] - } - - - - - - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 42] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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" - }, - - - -Andrews & Wright Expires March 17, 2020 [Page 43] - -Internet-Draft JSON Hyper-Schema September 2019 - - - { - "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. - - - - -Andrews & Wright Expires March 17, 2020 [Page 44] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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": "#"} - - - -Andrews & Wright Expires March 17, 2020 [Page 45] - -Internet-Draft JSON Hyper-Schema September 2019 - - - }, { - "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. - - - - - - - - - - - - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 46] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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. - - - - - -Andrews & Wright Expires March 17, 2020 [Page 47] - -Internet-Draft JSON Hyper-Schema September 2019 - - - [[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. - - - - -Andrews & Wright Expires March 17, 2020 [Page 48] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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 [RFC8288] 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 - - - - -Andrews & Wright Expires March 17, 2020 [Page 49] - -Internet-Draft JSON Hyper-Schema September 2019 - - - 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. - ]] - - - - - -Andrews & Wright Expires March 17, 2020 [Page 50] - -Internet-Draft JSON Hyper-Schema September 2019 - - -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", draft-handrews-json-schema-02 - (work in progress), November 2017. - - [json-schema-validation] - Wright, A., Andrews, H., and G. Luff, "JSON Schema - Validation: A Vocabulary for Structural Validation of - JSON", draft-handrews-json-schema-validation-02 (work in - progress), November 2017. - - [relative-json-pointer] - Luff, G. and H. Andrews, "Relative JSON Pointers", draft- - handrews-relative-json-pointer-02 (work in progress), - 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., Ed. and R. Sayre, Ed., "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, - . - - - -Andrews & Wright Expires March 17, 2020 [Page 51] - -Internet-Draft JSON Hyper-Schema September 2019 - - - [RFC6573] Amundsen, M., "The Item and Collection Link Relations", - RFC 6573, DOI 10.17487/RFC6573, April 2012, - . - - [RFC6901] Bryan, P., Ed., Zyp, K., and M. Nottingham, Ed., - "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", draft-reschke-http-jfv-06 (work in progress), - 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., Ed. and J. Reschke, Ed., "Hypertext Transfer - Protocol (HTTP/1.1): Message Syntax and Routing", - RFC 7230, DOI 10.17487/RFC7230, June 2014, - . - - [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer - Protocol (HTTP/1.1): Semantics and Content", RFC 7231, - DOI 10.17487/RFC7231, June 2014, - . - - - - - -Andrews & Wright Expires March 17, 2020 [Page 52] - -Internet-Draft JSON Hyper-Schema September 2019 - - - [RFC7807] Nottingham, M. and E. Wilde, "Problem Details for HTTP - APIs", RFC 7807, DOI 10.17487/RFC7807, March 2016, - . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 53] - -Internet-Draft JSON Hyper-Schema September 2019 - - -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" - - - -Andrews & Wright Expires March 17, 2020 [Page 54] - -Internet-Draft JSON Hyper-Schema September 2019 - - - [RFC7807], 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) - - - - - -Andrews & Wright Expires March 17, 2020 [Page 55] - -Internet-Draft JSON Hyper-Schema September 2019 - - - * 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" - - - -Andrews & Wright Expires March 17, 2020 [Page 56] - -Internet-Draft JSON Hyper-Schema September 2019 - - - * 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 - - - -Andrews & Wright Expires March 17, 2020 [Page 57] - -Internet-Draft JSON Hyper-Schema September 2019 - - - * 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Andrews & Wright Expires March 17, 2020 [Page 58] diff --git a/work-in-progress/WIP-jsonschema-validation.html b/work-in-progress/WIP-jsonschema-validation.html deleted file mode 100644 index cd921cc5..00000000 --- a/work-in-progress/WIP-jsonschema-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 17, 2020
    B. Hutton, Ed.
    Wellcome Sanger Institute
    September 14, 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 17, 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/work-in-progress/WIP-jsonschema-validation.txt b/work-in-progress/WIP-jsonschema-validation.txt deleted file mode 100644 index 46be7345..00000000 --- a/work-in-progress/WIP-jsonschema-validation.txt +++ /dev/null @@ -1,1680 +0,0 @@ - - - - -Internet Engineering Task Force A. Wright, Ed. -Internet-Draft -Intended status: Informational H. Andrews, Ed. -Expires: March 17, 2020 - B. Hutton, Ed. - Wellcome Sanger Institute - September 14, 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 . - - For additional information, see . - - 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 17, 2020. - - - - - -Wright, et al. Expires March 17, 2020 [Page 1] - -Internet-Draft JSON Schema Validation September 2019 - - -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 . . . . . . . . . . . . . . . . . . . . . . . . 3 - 2. Conventions and Terminology . . . . . . . . . . . . . . . . . 4 - 3. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 4 - 4. Interoperability Considerations . . . . . . . . . . . . . . . 4 - 4.1. Validation of String Instances . . . . . . . . . . . . . 4 - 4.2. Validation of Numeric Instances . . . . . . . . . . . . . 5 - 4.3. Regular Expressions . . . . . . . . . . . . . . . . . . . 5 - 5. Meta-Schema . . . . . . . . . . . . . . . . . . . . . . . . . 5 - 6. A Vocabulary for Structural Validation . . . . . . . . . . . 5 - 6.1. Validation Keywords for Any Instance Type . . . . . . . . 6 - 6.1.1. type . . . . . . . . . . . . . . . . . . . . . . . . 6 - 6.1.2. enum . . . . . . . . . . . . . . . . . . . . . . . . 6 - 6.1.3. const . . . . . . . . . . . . . . . . . . . . . . . . 6 - 6.2. Validation Keywords for Numeric Instances (number and - integer) . . . . . . . . . . . . . . . . . . . . . . . . 6 - 6.2.1. multipleOf . . . . . . . . . . . . . . . . . . . . . 6 - 6.2.2. maximum . . . . . . . . . . . . . . . . . . . . . . . 7 - 6.2.3. exclusiveMaximum . . . . . . . . . . . . . . . . . . 7 - 6.2.4. minimum . . . . . . . . . . . . . . . . . . . . . . . 7 - 6.2.5. exclusiveMinimum . . . . . . . . . . . . . . . . . . 7 - 6.3. Validation Keywords for Strings . . . . . . . . . . . . . 7 - 6.3.1. maxLength . . . . . . . . . . . . . . . . . . . . . . 7 - 6.3.2. minLength . . . . . . . . . . . . . . . . . . . . . . 8 - 6.3.3. pattern . . . . . . . . . . . . . . . . . . . . . . . 8 - 6.4. Validation Keywords for Arrays . . . . . . . . . . . . . 8 - 6.4.1. maxItems . . . . . . . . . . . . . . . . . . . . . . 8 - 6.4.2. minItems . . . . . . . . . . . . . . . . . . . . . . 8 - 6.4.3. uniqueItems . . . . . . . . . . . . . . . . . . . . . 8 - 6.4.4. maxContains . . . . . . . . . . . . . . . . . . . . . 9 - 6.4.5. minContains . . . . . . . . . . . . . . . . . . . . . 9 - 6.5. Validation Keywords for Objects . . . . . . . . . . . . . 9 - - - -Wright, et al. Expires March 17, 2020 [Page 2] - -Internet-Draft JSON Schema Validation September 2019 - - - 6.5.1. maxProperties . . . . . . . . . . . . . . . . . . . . 9 - 6.5.2. minProperties . . . . . . . . . . . . . . . . . . . . 9 - 6.5.3. required . . . . . . . . . . . . . . . . . . . . . . 10 - 6.5.4. dependentRequired . . . . . . . . . . . . . . . . . . 10 - 7. A Vocabulary for Semantic Content With "format" . . . . . . . 10 - 7.1. Foreword . . . . . . . . . . . . . . . . . . . . . . . . 10 - 7.2. Implementation Requirements . . . . . . . . . . . . . . . 11 - 7.2.1. As an annotation . . . . . . . . . . . . . . . . . . 11 - 7.2.2. As an assertion . . . . . . . . . . . . . . . . . . . 12 - 7.2.3. Custom format attributes . . . . . . . . . . . . . . 13 - 7.3. Defined Formats . . . . . . . . . . . . . . . . . . . . . 13 - 7.3.1. Dates, Times, and Duration . . . . . . . . . . . . . 14 - 7.3.2. Email Addresses . . . . . . . . . . . . . . . . . . . 14 - 7.3.3. Hostnames . . . . . . . . . . . . . . . . . . . . . . 15 - 7.3.4. IP Addresses . . . . . . . . . . . . . . . . . . . . 15 - 7.3.5. Resource Identifiers . . . . . . . . . . . . . . . . 15 - 7.3.6. uri-template . . . . . . . . . . . . . . . . . . . . 16 - 7.3.7. JSON Pointers . . . . . . . . . . . . . . . . . . . . 16 - 7.3.8. regex . . . . . . . . . . . . . . . . . . . . . . . . 16 - 8. A Vocabulary for the Contents of String-Encoded Data . . . . 17 - 8.1. Foreword . . . . . . . . . . . . . . . . . . . . . . . . 17 - 8.2. Implementation Requirements . . . . . . . . . . . . . . . 17 - 8.3. contentEncoding . . . . . . . . . . . . . . . . . . . . . 18 - 8.4. contentMediaType . . . . . . . . . . . . . . . . . . . . 18 - 8.5. contentSchema . . . . . . . . . . . . . . . . . . . . . . 18 - 8.6. Example . . . . . . . . . . . . . . . . . . . . . . . . . 19 - 9. A Vocabulary for Basic Meta-Data Annotations . . . . . . . . 20 - 9.1. "title" and "description" . . . . . . . . . . . . . . . . 21 - 9.2. "default" . . . . . . . . . . . . . . . . . . . . . . . . 21 - 9.3. "deprecated" . . . . . . . . . . . . . . . . . . . . . . 21 - 9.4. "readOnly" and "writeOnly" . . . . . . . . . . . . . . . 22 - 9.5. "examples" . . . . . . . . . . . . . . . . . . . . . . . 22 - 10. Security Considerations . . . . . . . . . . . . . . . . . . . 23 - 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 23 - 11.1. Normative References . . . . . . . . . . . . . . . . . . 23 - 11.2. Informative References . . . . . . . . . . . . . . . . . 25 - Appendix A. Keywords Moved from Validation to Core . . . . . . . 26 - Appendix B. Acknowledgments . . . . . . . . . . . . . . . . . . 26 - Appendix C. ChangeLog . . . . . . . . . . . . . . . . . . . . . 27 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 30 - -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. - - - -Wright, et al. Expires March 17, 2020 [Page 3] - -Internet-Draft JSON Schema Validation September 2019 - - - 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. - - - - -Wright, et al. Expires March 17, 2020 [Page 4] - -Internet-Draft JSON Schema Validation September 2019 - - -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 meta-schema is - . 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: . - - The current URI for the corresponding meta-schema is: . - - - -Wright, et al. Expires March 17, 2020 [Page 5] - -Internet-Draft JSON Schema Validation September 2019 - - -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" - (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. - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 6] - -Internet-Draft JSON Schema Validation September 2019 - - -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 [RFC8259]. - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 7] - -Internet-Draft JSON Schema Validation September 2019 - - -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. - - - - -Wright, et al. Expires March 17, 2020 [Page 8] - -Internet-Draft JSON Schema Validation September 2019 - - - 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" - [json-schema] 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" - [json-schema] 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. - - - -Wright, et al. Expires March 17, 2020 [Page 9] - -Internet-Draft JSON Schema Validation September 2019 - - -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 - - - -Wright, et al. Expires March 17, 2020 [Page 10] - -Internet-Draft JSON Schema Validation September 2019 - - - instance types defined in the data model defined in the core JSON - Schema. [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: . - - The current URI for the corresponding meta-schema is: . - -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. ]] - - - -Wright, et al. Expires March 17, 2020 [Page 11] - -Internet-Draft JSON Schema Validation September 2019 - - -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: - - 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. - - [[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. ]] - - When the vocabulary is declared with a value of true, an - implementation that supports this form of the vocabulary: - - 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 - - - -Wright, et al. Expires March 17, 2020 [Page 12] - -Internet-Draft JSON Schema Validation September 2019 - - - implementation would send an email, attempt to connect to a URL, or - otherwise check the existence of an entity identified by a format - instance. [[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. ]] - - 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 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 - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 13] - -Internet-Draft JSON Schema Validation September 2019 - - -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" 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 [RFC5322]. - - idn-email: As defined by RFC 6531 [RFC6531] - - - - -Wright, et al. Expires March 17, 2020 [Page 14] - -Internet-Draft JSON Schema Validation September 2019 - - - 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]. - - - - - -Wright, et al. Expires March 17, 2020 [Page 15] - -Internet-Draft JSON Schema Validation September 2019 - - - 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. - - - - -Wright, et al. Expires March 17, 2020 [Page 16] - -Internet-Draft JSON Schema Validation September 2019 - - - 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: . - - The current URI for the corresponding meta-schema is: . - -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 - - - -Wright, et al. Expires March 17, 2020 [Page 17] - -Internet-Draft JSON Schema Validation September 2019 - - - 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 (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 binary data and decoded using the - encoding named by this property. - - Possible values for this property are listed in RFC 2045, Sec 6.1 - [RFC2045] and RFC 4648 [RFC4648]. 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" (Section 6.3.3) 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 [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. - - - - - -Wright, et al. Expires March 17, 2020 [Page 18] - -Internet-Draft JSON Schema Validation September 2019 - - - 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 [RFC8259], outside of an - entirely closed system, this MUST be UTF-8. - - - - - - - - - - - - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 19] - -Internet-Draft JSON Schema Validation September 2019 - - - 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. - - - -Wright, et al. Expires March 17, 2020 [Page 20] - -Internet-Draft JSON Schema Validation September 2019 - - - The current URI for this vocabulary, known as the Meta-Data - vocabulary, is: . - - The current URI for the corresponding meta-schema is: . - -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. - - - - -Wright, et al. Expires March 17, 2020 [Page 21] - -Internet-Draft JSON Schema Validation September 2019 - - - 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. - - - -Wright, et al. Expires March 17, 2020 [Page 22] - -Internet-Draft JSON Schema Validation September 2019 - - - 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 - - [ecma262] "ECMA 262 specification", . - - [json-schema] - Wright, A. and H. Andrews, "JSON Schema: A Media Type for - Describing JSON Documents", draft-handrews-json-schema-02 - (work in progress), November 2017. - - - -Wright, et al. Expires March 17, 2020 [Page 23] - -Internet-Draft JSON Schema Validation September 2019 - - - [relative-json-pointer] - Luff, G. and H. Andrews, "Relative JSON Pointers", draft- - handrews-relative-json-pointer-01 (work in progress), - November 2017. - - [RFC1123] Braden, R., Ed., "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, - . - - - - - -Wright, et al. Expires March 17, 2020 [Page 24] - -Internet-Draft JSON Schema Validation September 2019 - - - [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., Ed., "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., Ed., Zyp, K., and M. Nottingham, Ed., - "JavaScript Object Notation (JSON) Pointer", RFC 6901, - DOI 10.17487/RFC6901, April 2013, - . - - [RFC8259] Bray, T., Ed., "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, - . - - - - - -Wright, et al. Expires March 17, 2020 [Page 25] - -Internet-Draft JSON Schema Validation September 2019 - - -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, Ben Hutton, - Evgeny Poberezkin, Brad Bowman, Gowry Sankar, Donald Pipowitch, Dave - - - - -Wright, et al. Expires March 17, 2020 [Page 26] - -Internet-Draft JSON Schema Validation September 2019 - - - 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 - - - -Wright, et al. Expires March 17, 2020 [Page 27] - -Internet-Draft JSON Schema Validation September 2019 - - - * 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" - - - -Wright, et al. Expires March 17, 2020 [Page 28] - -Internet-Draft JSON Schema Validation September 2019 - - - * 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. - - - - -Wright, et al. Expires March 17, 2020 [Page 29] - -Internet-Draft JSON Schema Validation September 2019 - - - * 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 - - - - - - - - - - - - - - - - - - - -Wright, et al. Expires March 17, 2020 [Page 30] diff --git a/work-in-progress/WIP-links.json b/work-in-progress/WIP-links.json deleted file mode 100644 index 7b1a578f..00000000 --- a/work-in-progress/WIP-links.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/hyper-schema", - "$id": "https://json-schema.org/draft/2019-09/links", - "title": "Link Description Object", - "allOf": [ - { "required": [ "rel", "href" ] }, - { "$ref": "#/$defs/noRequiredFields" } - ], - "$defs": { - "noRequiredFields": { - "type": "object", - "properties": { - "anchor": { - "type": "string", - "format": "uri-template" - }, - "anchorPointer": { - "type": "string", - "anyOf": [ - { "format": "json-pointer" }, - { "format": "relative-json-pointer" } - ] - }, - "rel": { - "anyOf": [ - { "type": "string" }, - { - "type": "array", - "items": { "type": "string" }, - "minItems": 1 - } - ] - }, - "href": { - "type": "string", - "format": "uri-template" - }, - "hrefSchema": { - "$recursiveRef": "https://json-schema.org/draft/2019-09/hyper-schema", - "default": false - }, - "templatePointers": { - "type": "object", - "additionalProperties": { - "type": "string", - "anyOf": [ - { "format": "json-pointer" }, - { "format": "relative-json-pointer" } - ] - } - }, - "templateRequired": { - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "title": { - "type": "string" - }, - "description": { - "type": "string" - }, - "targetSchema": { - "$recursiveRef": "https://json-schema.org/draft/2019-09/hyper-schema", - "default": true - }, - "targetMediaType": { - "type": "string" - }, - "targetHints": { }, - "headerSchema": { - "$recursiveRef": "https://json-schema.org/draft/2019-09/hyper-schema", - "default": true - }, - "submissionMediaType": { - "type": "string", - "default": "application/json" - }, - "submissionSchema": { - "$recursiveRef": "https://json-schema.org/draft/2019-09/hyper-schema", - "default": true - }, - "$comment": { - "type": "string" - } - } - } - } -} diff --git a/work-in-progress/WIP-relative-json-pointer.html b/work-in-progress/WIP-relative-json-pointer.html deleted file mode 100644 index ea7f3025..00000000 --- a/work-in-progress/WIP-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 17, 2020September 14, 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 17, 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/work-in-progress/WIP-relative-json-pointer.txt b/work-in-progress/WIP-relative-json-pointer.txt deleted file mode 100644 index f952342c..00000000 --- a/work-in-progress/WIP-relative-json-pointer.txt +++ /dev/null @@ -1,392 +0,0 @@ - - - - -Internet Engineering Task Force G. Luff -Internet-Draft -Intended status: Informational H. Andrews, Ed. -Expires: March 17, 2020 September 14, 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 17, 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. - - - - -Luff & Andrews Expires March 17, 2020 [Page 1] - -Internet-Draft Relative JSON Pointers September 2019 - - -Table of Contents - - 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 - 2. Conventions and Terminology . . . . . . . . . . . . . . . . . 2 - 3. Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 - 4. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . 3 - 5. JSON String Representation . . . . . . . . . . . . . . . . . 4 - 5.1. Examples . . . . . . . . . . . . . . . . . . . . . . . . 4 - 6. Non-use in URI Fragment Identifiers . . . . . . . . . . . . . 5 - 7. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 5 - 8. Relationship to JSON Pointer . . . . . . . . . . . . . . . . 5 - 9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 5 - 10. Security Considerations . . . . . . . . . . . . . . . . . . . 5 - 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 6 - 11.1. Normative References . . . . . . . . . . . . . . . . . . 6 - 11.2. Informative References . . . . . . . . . . . . . . . . . 6 - Appendix A. ChangeLog . . . . . . . . . . . . . . . . . . . . . 7 - Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 7 - -1. Introduction - - JSON Pointer (RFC 6901 [RFC6901]) 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 [RFC2119]. - -3. Syntax - - A Relative JSON Pointer is a Unicode string in UTF-8 encoding (see - RFC 8259, Section 8 [RFC8259]), comprising a non-negative integer, - followed by either a '#' (%x23) character or a JSON Pointer (RFC 6901 - [RFC6901]). - - 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 '#'. - - - - - - - - -Luff & Andrews Expires March 17, 2020 [Page 2] - -Internet-Draft Relative JSON Pointers September 2019 - - - 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 follows the production defined in RFC 6901, - Section 3 [RFC6901] ("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 remainder of the Relative JSON Pointer is a JSON Pointer, then - evaluation proceeds as per RFC 6901, Section 4 [RFC6901] - ("Evaluation"), 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. - - - -Luff & Andrews Expires March 17, 2020 [Page 3] - -Internet-Draft Relative JSON Pointers September 2019 - - - 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 - [RFC6901]. - -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" - - - - - - -Luff & Andrews Expires March 17, 2020 [Page 4] - -Internet-Draft Relative JSON Pointers September 2019 - - -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. - - - -Luff & Andrews Expires March 17, 2020 [Page 5] - -Internet-Draft Relative JSON Pointers September 2019 - - -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., Ed., Zyp, K., and M. Nottingham, Ed., - "JavaScript Object Notation (JSON) Pointer", RFC 6901, - DOI 10.17487/RFC6901, April 2013, - . - -11.2. Informative References - - [RFC8259] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data - Interchange Format", STD 90, RFC 8259, - DOI 10.17487/RFC8259, December 2017, - . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Luff & Andrews Expires March 17, 2020 [Page 6] - -Internet-Draft Relative JSON Pointers September 2019 - - -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 - - - - - - - - - - - - - - - - -Luff & Andrews Expires March 17, 2020 [Page 7] diff --git a/work-in-progress/WIP-schema.json b/work-in-progress/WIP-schema.json deleted file mode 100644 index 2248a0c8..00000000 --- a/work-in-progress/WIP-schema.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://json-schema.org/draft/2019-09/schema", - "$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://json-schema.org/draft/2019-09/vocab/meta-data": true, - "https://json-schema.org/draft/2019-09/vocab/format": false, - "https://json-schema.org/draft/2019-09/vocab/content": true - }, - "$recursiveAnchor": true, - - "title": "Core and Validation specifications meta-schema", - "allOf": [ - {"$ref": "meta/core"}, - {"$ref": "meta/applicator"}, - {"$ref": "meta/validation"}, - {"$ref": "meta/meta-data"}, - {"$ref": "meta/format"}, - {"$ref": "meta/content"} - ], - "type": ["object", "boolean"], - "properties": { - "definitions": { - "$comment": "While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.", - "type": "object", - "additionalProperties": { "$recursiveRef": "#" }, - "default": {} - }, - "dependencies": { - "$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"", - "type": "object", - "additionalProperties": { - "anyOf": [ - { "$recursiveRef": "#" }, - { "$ref": "meta/validation#/$defs/stringArray" } - ] - } - } - } -} diff --git a/work-in-progress/index.md b/work-in-progress/index.md index 36c8a2fa..4455aec4 100644 --- a/work-in-progress/index.md +++ b/work-in-progress/index.md @@ -7,113 +7,8 @@ permalink: /work-in-progress * TOC {:toc} -## The Next Draft (by whatever name) Is Ready for Final Pre-Publication Review! +Draft 2019-09 has been [published](/specification.html)! -The forthcoming draft is now feature-frozen and has gone through the initial four-week pre-publication review period. - -_**UPDATE: Sept 8th, 2019** All PRs have been posted, and we are waiting on final reviews from one team member. The WIP documents here incorporate the PRs as they are currently posted._ - -Once we have completed reviews within the core JSON Schema team, we will publish this draft. - -Learn more about the [changes](/work-in-progress/WIP-json-schema-release-notes.html) in this draft. - -## What Is This Draft Called, Anyway? - -We have typically referred to this as `draft-08`, following our own convention of just -incrementing the draft number for meta-schemas regardless of the IETF identifier. - -However, this is frowned upon by the IETF and has in fact been a source of confusion. -It worked well up to and including `draft-04`, as even after the split into multiple -documents, `draft-zyp-json-schema-04` (the core spec) at least ended in `-04`! -Unfortunately, after that point, the numbers stopped matching in any way. - -Assuming this new draft gets published more or less as presented in this WIP, -and by the end of June, it will be: - -* IETF identifiers: `draft-handrews-*-02` -* Meta-schema identifiers: `draft/2019-08` - -Meta-schemas will now be identified with dates, which can be correlated with the publication -and expiration dates of the IETF documents. This will make it more clear when a bugfix -meta-schema is produced, and also make it more obvious that the IETF and meta-schema identifiers -are not expected to match exactly. - -## Pre-Built Review Documents - -To encourage as many reviewers as possible, pre-built documents are available. These may -slightly lag those in the GitHub repository, although all efforts will be made to keep them -in sync during the review period. After the review period, these will be removed. In particular, -using "WORK IN PROGRESS" meta-schemas **is not allowed** and **will break** as soon as the files -are moved to their permanent homes. - -### Specifications: - -As always, these are the actual normative documents: - -_**NOTE:** Links to meta-schemas and among the drafts will not work correctly in these review copies._ - -* [WIP: JSON Schema (core)](/work-in-progress/WIP-jsonschema-core.html) -* [WIP: JSON Schema Validation](/work-in-progress/WIP-jsonschema-validation.html) -* [WIP: JSON Schema Hyper-Schema](/work-in-progress/WIP-jsonschema-hyperschema.html) -* [WIP: Relative JSON Pointer](/work-in-progress/WIP-relative-json-pointer.html) - -### Change Log / Release Notes: - -Learn more about the [changes](/work-in-progress/WIP-json-schema-release-notes.html) in this draft. - -### General use meta-schemas: - -These are the traditional non-normative meta-schemas, which serve the same purpose as -in previous drafts, although their internal structure is different. - -_**NOTE:** when published, the `.json` will be removed from the final URI_ - -* [WIP: schema.json](/work-in-progress/WIP-schema.json) (core and validation) -* [WIP: links.json](/work-in-progress/WIP-links.json) (individual link description object) -* [WIP: hyper-schema.json](/work-in-progress/WIP-hyper-schema.json) (hyper-schema, references schema and links) - -### Single-vocabulary meta-schemas: - -The new draft introduces the concept of modular vocabularies. Most schema authors will not directly -reference these meta-schemas. Instead, they are combined in useful ways by the general use meta-schemas. -However, those wishing to build custom meta-schemas may find it useful to choose different subsets of -the standard keywords depending on the custom meta-schema's intended purpose. - -_**NOTE:** when published, the `.json` will be removed from the final URI_ - -* [WIP: meta/core.json](/work-in-progress/meta/WIP-core.json) (core keywords, from the core spec) -* [WIP: meta/applicator.json](/work-in-progress/meta/WIP-applicator.json) (applicator keywords, from the core spec) -* [WIP: meta/validation.json](/work-in-progress/meta/WIP-validation.json) (validation assertions, from the validation spec) -* [WIP: meta/meta-data.json](/work-in-progress/meta/WIP-meta-data.json) (meta-data annotations, from the validation spec) -* [WIP: meta/format.json](/work-in-progress/meta/WIP-format.json) (the format keyword, from the validation spec) -* [WIP: meta/content.json](/work-in-progress/meta/WIP-content.json) (content keywords, from the validation spec) -* [WIP: meta/hyper-schema.json](/work-in-progress/meta/WIP-hyper-schema.json) (hyper-schema keywords, from the hyper-shema spec) - -### Output schema: - -The new draft also introduces recommended output formats for reporting errors and annotations. - -_**NOTE:** when published, the `.json` will be removed from the final URI_ - -* [WIP: schema.json](/work-in-progress/output/WIP-schema.json) (schema for recommended output formats) -* [WIP: verbose-example.json](/work-in-progress/output/WIP-verbose-example.json) (example of the most verbose output format) -* [WIP: hyper-schema.json](/work-in-progress/output/WIP-hyper-schema.json) (format used by the proposed hyper-schema test suite, and used in examples in the specification) - -## Providing Feedback and Tracking Progress in GitHub - -We are **particularly interested** in feedback on whether the wording and concepts is an -improvement in terms of how easy it is to understand and learn the specifications. - -Note that _all drafts have Changelog appendicies_, for a concise list of notable changes. - -* The active sources are on the -["master" branch of json-schema-org/json-schema-spec](https://github.com/json-schema-org/json-schema-spec) -* The [draft-08 milestone](https://github.com/json-schema-org/json-schema-spec/milestone/6) - tracks all issues and PRs for this draft - _(yes, it's still called draft-08 here because GitHub doesn't handle milestone renames well)_ -* Check the [open PRs](https://github.com/json-schema-org/json-schema-spec/pulls) - to see what is already being changed from other feedback -* [file an issue](https://github.com/json-schema-org/json-schema-spec/issues/new?milestone=draft-08) - or [join us on Slack](https://join.slack.com/t/json-schema/shared_invite/enQtMjk1NDcyNDI2NTAwLTcyYmYwMjdmMmUxNzZjYzIxNGU2YjdkNzdlOGZiNjIwNDI2M2Y3NmRkYjA4YmMwODMwYjgyOTFlNWZjZjAyNjg) to submit feedback - _(technically there is also a [mailing list](https://groups.google.com/forum/#!forum/json-schema) but it gets very little traffic and is not closely monitored)_ +This page will remain blank until the next draft nears completion. +See the [GitHub repository](https://github.com/json-schema-org/json-schema-spec) for ongoing spec work. diff --git a/work-in-progress/meta/WIP-applicator.json b/work-in-progress/meta/WIP-applicator.json deleted file mode 100644 index b17d35c5..00000000 --- a/work-in-progress/meta/WIP-applicator.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://json-schema.org/draft/2019-09/meta/applicator", - "$vocabulary": { - "https://json-schema.org/draft/2019-09/vocab/applicator": true - }, - "$recursiveAnchor": true, - - "title": "Applicator vocabulary meta-schema", - "properties": { - "additionalItems": { "$recursiveRef": "#" }, - "unevaluatedItems": { "$recursiveRef": "#" }, - "items": { - "anyOf": [ - { "$recursiveRef": "#" }, - { "$ref": "#/$defs/schemaArray" } - ] - }, - "contains": { "$recursiveRef": "#" }, - "additionalProperties": { "$recursiveRef": "#" }, - "unevaluatedProperties": { - "type": "object", - "additionalProperties": { - "$recursiveRef": "#" - } - }, - "properties": { - "type": "object", - "additionalProperties": { "$recursiveRef": "#" }, - "default": {} - }, - "patternProperties": { - "type": "object", - "additionalProperties": { "$recursiveRef": "#" }, - "propertyNames": { "format": "regex" }, - "default": {} - }, - "dependentSchemas": { - "type": "object", - "additionalProperties": { - "$recursiveRef": "#" - } - }, - "propertyNames": { "$recursiveRef": "#" }, - "if": { "$recursiveRef": "#" }, - "then": { "$recursiveRef": "#" }, - "else": { "$recursiveRef": "#" }, - "allOf": { "$ref": "#/$defs/schemaArray" }, - "anyOf": { "$ref": "#/$defs/schemaArray" }, - "oneOf": { "$ref": "#/$defs/schemaArray" }, - "not": { "$recursiveRef": "#" } - }, - "$defs": { - "schemaArray": { - "type": "array", - "minItems": 1, - "items": { "$recursiveRef": "#" } - } - } -} diff --git a/work-in-progress/meta/WIP-content.json b/work-in-progress/meta/WIP-content.json deleted file mode 100644 index f6752a8e..00000000 --- a/work-in-progress/meta/WIP-content.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://json-schema.org/draft/2019-09/meta/content", - "$vocabulary": { - "https://json-schema.org/draft/2019-09/vocab/content": true - }, - "$recursiveAnchor": true, - - "title": "Content vocabulary meta-schema", - - "type": ["object", "boolean"], - "properties": { - "contentMediaType": { "type": "string" }, - "contentEncoding": { "type": "string" }, - "contentSchema": { "$recursiveRef": "#" } - } -} diff --git a/work-in-progress/meta/WIP-core.json b/work-in-progress/meta/WIP-core.json deleted file mode 100644 index 0a1fc68a..00000000 --- a/work-in-progress/meta/WIP-core.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://json-schema.org/draft/2019-09/meta/core", - "$vocabulary": { - "https://json-schema.org/draft/2019-09/vocab/core": true - }, - "$recursiveAnchor": true, - - "title": "Core vocabulary meta-schema", - "type": ["object", "boolean"], - "properties": { - "$id": { - "type": "string", - "format": "uri-reference", - "$comment": "Non-empty fragments not allowed.", - "pattern": "^[^#]#?$" - }, - "$schema": { - "type": "string", - "format": "uri" - }, - "$anchor": { - "type": "string", - "pattern": "^[A-Za-z][-A-Za-z0-9.:_]*$" - }, - "$ref": { - "type": "string", - "format": "uri-reference" - }, - "$recursiveRef": { - "type": "string", - "format": "uri-reference" - }, - "$recursiveAnchor": { - "type": "boolean", - "const": true, - "default": false - }, - "$vocabulary": { - "type": "object", - "propertyNames": { - "type": "string", - "format": "uri" - }, - "additionalProperties": { - "type": "boolean" - } - }, - "$comment": { - "type": "string" - }, - "$defs": { - "type": "object", - "additionalProperties": { "$recursiveRef": "#" }, - "default": {} - } - } -} diff --git a/work-in-progress/meta/WIP-format.json b/work-in-progress/meta/WIP-format.json deleted file mode 100644 index 09bbfdda..00000000 --- a/work-in-progress/meta/WIP-format.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://json-schema.org/draft/2019-09/meta/format", - "$vocabulary": { - "https://json-schema.org/draft/2019-09/vocab/format": true - }, - "$recursiveAnchor": true, - - "title": "Format vocabulary meta-schema", - "type": ["object", "boolean"], - "properties": { - "format": { "type": "string" } - } -} diff --git a/work-in-progress/meta/WIP-hyper-schema.json b/work-in-progress/meta/WIP-hyper-schema.json deleted file mode 100644 index 3d230589..00000000 --- a/work-in-progress/meta/WIP-hyper-schema.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/hyper-schema", - "$id": "https://json-schema.org/draft/2019-09/meta/hyper-schema", - "$vocabulary": { - "https://json-schema.org/draft/2019-09/vocab/hyper-schema": true - }, - "$recursiveAnchor": true, - - "title": "JSON Hyper-Schema Vocabulary Schema", - "type": ["object", "boolean"], - "properties": { - "base": { - "type": "string", - "format": "uri-template" - }, - "links": { - "type": "array", - "items": { - "$ref": "https://json-schema.org/draft/2019-09/links" - } - } - }, - "links": [ - { - "rel": "self", - "href": "{+%24id}" - } - ] -} diff --git a/work-in-progress/meta/WIP-meta-data.json b/work-in-progress/meta/WIP-meta-data.json deleted file mode 100644 index da04cff6..00000000 --- a/work-in-progress/meta/WIP-meta-data.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://json-schema.org/draft/2019-09/meta/meta-data", - "$vocabulary": { - "https://json-schema.org/draft/2019-09/vocab/meta-data": true - }, - "$recursiveAnchor": true, - - "title": "Meta-data vocabulary meta-schema", - - "type": ["object", "boolean"], - "properties": { - "title": { - "type": "string" - }, - "description": { - "type": "string" - }, - "default": true, - "deprecated": { - "type": "boolean", - "default": false - }, - "readOnly": { - "type": "boolean", - "default": false - }, - "writeOnly": { - "type": "boolean", - "default": false - }, - "examples": { - "type": "array", - "items": true - } - } -} diff --git a/work-in-progress/meta/WIP-validation.json b/work-in-progress/meta/WIP-validation.json deleted file mode 100644 index 9f59677b..00000000 --- a/work-in-progress/meta/WIP-validation.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://json-schema.org/draft/2019-09/meta/validation", - "$vocabulary": { - "https://json-schema.org/draft/2019-09/vocab/validation": true - }, - "$recursiveAnchor": true, - - "title": "Validation vocabulary meta-schema", - "type": ["object", "boolean"], - "properties": { - "multipleOf": { - "type": "number", - "exclusiveMinimum": 0 - }, - "maximum": { - "type": "number" - }, - "exclusiveMaximum": { - "type": "number" - }, - "minimum": { - "type": "number" - }, - "exclusiveMinimum": { - "type": "number" - }, - "maxLength": { "$ref": "#/$defs/nonNegativeInteger" }, - "minLength": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, - "pattern": { - "type": "string", - "format": "regex" - }, - "maxItems": { "$ref": "#/$defs/nonNegativeInteger" }, - "minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, - "uniqueItems": { - "type": "boolean", - "default": false - }, - "maxContains": { "$ref": "#/$defs/nonNegativeInteger" }, - "minContains": { - "$ref": "#/$defs/nonNegativeInteger", - "default": 1 - }, - "maxProperties": { "$ref": "#/$defs/nonNegativeInteger" }, - "minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, - "required": { "$ref": "#/$defs/stringArray" }, - "dependentRequired": { - "type": "object", - "additionalProperties": { - "$ref": "#/$defs/stringArray" - } - }, - "const": true, - "enum": { - "type": "array", - "items": true - }, - "type": { - "anyOf": [ - { "$ref": "#/$defs/simpleTypes" }, - { - "type": "array", - "items": { "$ref": "#/$defs/simpleTypes" }, - "minItems": 1, - "uniqueItems": true - } - ] - } - }, - "$defs": { - "nonNegativeInteger": { - "type": "integer", - "minimum": 0 - }, - "nonNegativeIntegerDefault0": { - "$ref": "#/$defs/nonNegativeInteger", - "default": 0 - }, - "simpleTypes": { - "enum": [ - "array", - "boolean", - "integer", - "null", - "number", - "object", - "string" - ] - }, - "stringArray": { - "type": "array", - "items": { "type": "string" }, - "uniqueItems": true, - "default": [] - } - } -} diff --git a/work-in-progress/output/WIP-hyper-schema.json b/work-in-progress/output/WIP-hyper-schema.json deleted file mode 100644 index 34e67303..00000000 --- a/work-in-progress/output/WIP-hyper-schema.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://json-schema.org/draft/2019-09/output/hyper-schema", - "title": "JSON Hyper-Schema Output", - "type": "array", - "items": { - "allOf": [ - {"$ref": "https://json-schema.org/draft/2019-09/links#/$defs/noRequiredFields" } - ], - "type": "object", - "required": [ - "contextUri", - "contextPointer", - "rel", - "attachmentPointer" - ], - "if": { "required": [ "hrefSchema" ] }, - "then": { "required": [ "hrefInputTemplates", "hrefPrepopulatedInput" ] }, - "else": { "required": [ "targetUri" ] }, - "properties": { - "contextUri": { - "$comment": "The fully resolved URI of the link context, including a fragment if it is possible to construct one for the given media type and instance", - "type": "string", - "format": "uri" - }, - "contextPointer": { - "$comment": "The absolute JSON Pointer to the location in the instance that is the context of the link. If the context resource supports JSON Pointer fragments, this will the string form of the identical JSON Pointer", - "type": "string", - "format": "json-pointer" - }, - "rel": { - "type": "string" - }, - "targetUri": { - "$comment": "The fully resolved target URI", - "type": "string", - "format": "uri" - }, - "hrefInputTemplates": { - "$comment": "The list of partially resolved URI Templates, starting with \"href\", followed by applicable \"base\" values from nearest to furthest.", - "type": "array", - "items": { - "type": "string", - "format": "uri-template" - } - }, - "hrefPrepopulatedInput": { - "$comment": "The initial data set to be presented with the input form when URI Template input is accepted.", - "type": "object", - "propertyNames": { - "$comment": "These are all URI Template variable names, specifically the 'varname' production from RFC 6570, Section 2.3", - "pattern": "^(?:\\w|(?:%[a-f\\d]{2}))+(?:\\.(?:\\w|(?:%[a-f\\d]{2})))*$" - } - }, - "attachmentPointer": { - "$comment": "The absolute JSON Pointer, in string form, of the position to which this resolved link applies", - "type": "string", - "format": "json-pointer" - } - } - } -} diff --git a/work-in-progress/output/WIP-schema.json b/work-in-progress/output/WIP-schema.json deleted file mode 100644 index 7cf4c4ac..00000000 --- a/work-in-progress/output/WIP-schema.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://json-schema.org/draft/2019-09/output/schema", - "description": "A schema that validates the minimum requirements for validation output", - - "oneOf": [ - { "$ref": "#/$defs/flag" }, - { "$ref": "#/$defs/basic" }, - { "$ref": "#/$defs/detailed" }, - { "$ref": "#/$defs/verbose" } - ], - "$defs": { - "outputUnit":{ - "properties": { - "valid": { "type": "boolean" }, - "keywordLocation": { - "type": "string", - "format": "uri-reference" - }, - "absoluteKeywordLocation": { - "type": "string", - "format": "uri" - }, - "instanceLocation": { - "type": "string", - "format": "uri-reference" - }, - "errors": { - "$ref": "#/$defs/outputUnitArray" - }, - "annotations": { - "$ref": "#/$defs/outputUnitArray" - } - }, - "required": [ "valid", "keywordLocation", "instanceLocation" ], - "allOf": [ - { - "if": { - "properties": { - "valid": { "const": false } - } - }, - "then": { - "required": [ "errors" ] - } - }, - { - "if": { - "oneOf": [ - { - "properties": { - "keywordLocation": { - "pattern": ".*/$ref/.*" - } - } - }, - { - "properties": { - "keywordLocation": { - "pattern": ".*/$recursiveRef/.*" - } - } - } - ] - }, - "then": { - "required": [ "absoluteKeywordLocation" ] - } - } - ] - }, - "outputUnitArray": { - "type": "array", - "items": { "$ref": "#/$defs/outputUnit" } - }, - "flag": { - "properties": { - "valid": { "type": "boolean" } - }, - "required": [ "valid" ] - }, - "basic": { "$ref": "#/outputUnit" }, - "detailed": { "$ref": "#/outputUnit" }, - "verbose": { "$ref": "#/outputUnit" } - } -} diff --git a/work-in-progress/output/WIP-verbose-example.json b/work-in-progress/output/WIP-verbose-example.json deleted file mode 100644 index 37acb2d5..00000000 --- a/work-in-progress/output/WIP-verbose-example.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "valid": false, - "keywordLocation": "#", - "instanceLocation": "#", - "errors": [ - { - "valid": true, - "keywordLocation": "#/$defs", - "instanceLocation": "#" - }, - { - "valid": true, - "keywordLocation": "#/type", - "instanceLocation": "#" - }, - { - "valid": false, - "keywordLocation": "#/items", - "instanceLocation": "#", - "errors": [ - { - "valid": true, - "keywordLocation": "#/items/$ref", - "absoluteKeywordLocation": - "https://example.com/polygon#/items/$ref", - "instanceLocation": "#/0", - "annotations": [ - { - "valid": true, - "keywordLocation": "#/items/$ref", - "absoluteKeywordLocation": - "https://example.com/polygon#/$defs/point", - "instanceLocation": "#/0", - "annotations": [ - { - "valid": true, - "keywordLocation": "#/items/$ref/type", - "absoluteKeywordLocation": - "https://example.com/polygon#/$defs/point/type", - "instanceLocation": "#/0" - }, - { - "valid": true, - "keywordLocation": "#/items/$ref/properties", - "absoluteKeywordLocation": - "https://example.com/polygon#/$defs/point/properties", - "instanceLocation": "#/0" - }, - { - "valid": true, - "keywordLocation": "#/items/$ref/required", - "absoluteKeywordLocation": - "https://example.com/polygon#/$defs/point/required", - "instanceLocation": "#/0" - }, - { - "valid": true, - "keywordLocation": "#/items/$ref/additionalProperties", - "absoluteKeywordLocation": - "https://example.com/polygon#/$defs/point/additionalProperties", - "instanceLocation": "#/0" - } - ] - } - ] - }, - { - "valid": false, - "keywordLocation": "#/items/$ref", - "absoluteKeywordLocation": - "https://example.com/polygon#/items/$ref", - "instanceLocation": "#/1", - "errors": [ - { - "valid": false, - "keywordLocation": "#/items/$ref", - "absoluteKeywordLocation": - "https://example.com/polygon#/$defs/point", - "instanceLocation": "#/1", - "errors": [ - { - "valid": true, - "keywordLocation": "#/items/$ref/type", - "absoluteKeywordLocation": - "https://example.com/polygon#/$defs/point/type", - "instanceLocation": "#/1" - }, - { - "valid": true, - "keywordLocation": "#/items/$ref/properties", - "absoluteKeywordLocation": - "https://example.com/polygon#/$defs/point/properties", - "instanceLocation": "#/1" - }, - { - "valid": false, - "keywordLocation": "#/items/$ref/required", - "absoluteKeywordLocation": - "https://example.com/polygon#/$defs/point/required", - "instanceLocation": "#/1" - }, - { - "valid": false, - "keywordLocation": "#/items/$ref/additionalProperties", - "absoluteKeywordLocation": - "https://example.com/polygon#/$defs/point/additionalProperties", - "instanceLocation": "#/1", - "errors": [ - { - "valid": false, - "keywordLocation": "#/items/$ref/additionalProperties", - "absoluteKeywordLocation": - "https://example.com/polygon#/$defs/point/additionalProperties", - "instanceLocation": "#/1/z" - } - ] - } - ] - } - ] - } - ] - }, - { - "valid": false, - "keywordLocation": "#/minItems", - "instanceLocation": "#" - } - ] -} From 5083344dee5b38867d6f9a83668ba0222ec7b5c8 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 17 Sep 2019 18:55:03 -0700 Subject: [PATCH 086/395] Update various pages for newly published draft. --- draft/2019-09/release-notes.md | 66 ++++---- index.md | 22 +-- specification-links.md | 279 ++++++++++++++++++++++++++++++--- specification.md | 56 +++++-- 4 files changed, 339 insertions(+), 84 deletions(-) diff --git a/draft/2019-09/release-notes.md b/draft/2019-09/release-notes.md index 7a79bf73..45972a5b 100644 --- a/draft/2019-09/release-notes.md +++ b/draft/2019-09/release-notes.md @@ -3,6 +3,8 @@ title: JSON Schema Draft-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. @@ -13,9 +15,9 @@ For implementors, there is a lot more to consider, and further guidance on imple {:toc} For a basic list of changes to each document, see their change logs: -* [Core](/work-in-progress/WIP-jsonschema-core.html#rfc.appendix.G) -* [Validation](/work-in-progress/WIP-jsonschema-validation.html#rfc.appendix.C) -* [Hyper-Schema](/work-in-progress/WIP-jsonschema-hyperschema.html#rfc.appendix.B) +* [Core](/draft/2019-09/json-schema-core.html#rfc.appendix.G) +* [Validation](/draft/2019-09/json-schema-validation.html#rfc.appendix.C) +* [Hyper-Schema](/draft/2019-09/json-schema-hypermedia.html#rfc.appendix.B) ### Incompatible Changes @@ -33,60 +35,60 @@ The old syntax for these keywords is not an error (and the default meta-schema s ### Annotations, Errors, and Outputs -[Annotation keywords](/work-in-progress/WIP-jsonschema-core.html#rfc.section.7.7) such as `title`, `readOnly`, and `default` have always been a part of JSON Schema, but without any guidance on how to make use of them. This draft formalizes how implementations can make annotation information available to applications. +[Annotation keywords](/draft/2019-09/json-schema-core.html#rfc.section.7.7) such as `title`, `readOnly`, and `default` have always been a part of JSON Schema, but without any guidance on how to make use of them. This draft formalizes how implementations can make annotation information available to applications. Similarly, there has not previously been guidance on what constitutes useful error reporting when validation fails. -To solve both of these problems, we now recommend that implementations support one or more of standardized [output formats](/work-in-progress/WIP-jsonschema-core.html#rfc.section.10). +To solve both of these problems, we now recommend that implementations support one or more of standardized [output formats](/draft/2019-09/json-schema-core.html#rfc.section.10). ### Keyword Changes -All keywords have now been organized into [vocabularies](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.1), with the Core and Validation specifications containing multiple vocabularies. In this process, some keywords have moved from Validation into Core. +All keywords have now been organized into [vocabularies](/draft/2019-09/json-schema-core.html#rfc.section.8.1), with the Core and Validation specifications containing multiple vocabularies. In this process, some keywords have moved from Validation into Core. #### Core Vocabulary -[Core Specification, Section 8](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8) +[Core Specification, Section 8](/draft/2019-09/json-schema-core.html#rfc.section.8) keyword | change | notes ---- | ---- | ---- -[`$anchor`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.2.3) | **new** | Replaces the `#plain-name` form of `$id`, with a different syntax and approach -[`$defs` (renamed from `definitions`)](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.2.5) | **renamed** | Note that the standard meta-schema still reserves `definitions` for backwards compatibility -[`$id`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.2.2) | **changed** | Only URI-references without fragments are allowed; see `$anchor` for a replacement for plain-name fragments; all other fragments in `$id` had undefined behavior previously -[`$recursiveAnchor` and `$recursiveRef`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.2.4.2) | **new** | Used for extending recursive schemas such as meta-schemas -[`$ref`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.2.4) | **changed** | Other keywords are now allowed alongside of it -[`$vocabulary`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.8.1) | **new** | Has effects only in meta-schemas, and is used to control what keywords an implementation must or can support in order to process a schema using that meta-schema +[`$anchor`](/draft/2019-09/json-schema-core.html#rfc.section.8.2.3) | **new** | Replaces the `#plain-name` form of `$id`, with a different syntax and approach +[`$defs` (renamed from `definitions`)](/draft/2019-09/json-schema-core.html#rfc.section.8.2.5) | **renamed** | Note that the standard meta-schema still reserves `definitions` for backwards compatibility +[`$id`](/draft/2019-09/json-schema-core.html#rfc.section.8.2.2) | **changed** | Only URI-references without fragments are allowed; see `$anchor` for a replacement for plain-name fragments; all other fragments in `$id` had undefined behavior previously +[`$recursiveAnchor` and `$recursiveRef`](/draft/2019-09/json-schema-core.html#rfc.section.8.2.4.2) | **new** | Used for extending recursive schemas such as meta-schemas +[`$ref`](/draft/2019-09/json-schema-core.html#rfc.section.8.2.4) | **changed** | Other keywords are now allowed alongside of it +[`$vocabulary`](/draft/2019-09/json-schema-core.html#rfc.section.8.1) | **new** | Has effects only in meta-schemas, and is used to control what keywords an implementation must or can support in order to process a schema using that meta-schema #### Applicator Vocabulary -[Core Specification, Section 9](/work-in-progress/WIP-jsonschema-core.html#rfc.section.9) +[Core Specification, Section 9](/draft/2019-09/json-schema-core.html#rfc.section.9) These keywords were formerly found in the Validation Specification. keyword | change | notes ---- | ---- | ---- -[`dependentSchemas` (split from `dependencies`)](/work-in-progress/WIP-jsonschema-core.html#rfc.section.9.2.2.4) | **split** | This is the schema form of `dependencies`; note that the standard meta-schema still reserves `dependencies` for backwards compatibility -[`unevaluatedItems`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.9.3.1.3) | **new** | Similar to `additionalItems`, but can "see" into subschemas and across references -[`unevaluatedProperties`](/work-in-progress/WIP-jsonschema-core.html#rfc.section.9.3.2.4) | **new** | Similar to `additionalProperties`, but can "see" into subschemas and across references +[`dependentSchemas` (split from `dependencies`)](/draft/2019-09/json-schema-core.html#rfc.section.9.2.2.4) | **split** | This is the schema form of `dependencies`; note that the standard meta-schema still reserves `dependencies` for backwards compatibility +[`unevaluatedItems`](/draft/2019-09/json-schema-core.html#rfc.section.9.3.1.3) | **new** | Similar to `additionalItems`, but can "see" into subschemas and across references +[`unevaluatedProperties`](/draft/2019-09/json-schema-core.html#rfc.section.9.3.2.4) | **new** | Similar to `additionalProperties`, but can "see" into subschemas and across references The other applicator vocabulary keywords are `items`, `additionalItems`, `properties`, `patternProperties`, `additionalProperties`, `anyOf`, `allOf`, `oneOf`, `not`, `if`, `then`, `else`. #### Validation Vocabulary -[Validation Specification, Section 6](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.6) +[Validation Specification, Section 6](/draft/2019-09/json-schema-validation.html#rfc.section.6) keyword | change | notes ---- | ---- | ---- -[`dependentRequired` (split from `dependencies`)](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.6.5.4) | **split** | This is the string array form of `dependencies`; note that the standard meta-schema still reserves `dependencies` for backwards compatibility -[`maxContains` and `minContains`](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.6.4.4) | **new** | Assertion for controlling how many times a subschema must be matched within an array +[`dependentRequired` (split from `dependencies`)](/draft/2019-09/json-schema-validation.html#rfc.section.6.5.4) | **split** | This is the string array form of `dependencies`; note that the standard meta-schema still reserves `dependencies` for backwards compatibility +[`maxContains` and `minContains`](/draft/2019-09/json-schema-validation.html#rfc.section.6.4.4) | **new** | Assertion for controlling how many times a subschema must be matched within an array #### Format Vocabulary -[Validation Specification, Section 7](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.7) +[Validation Specification, Section 7](/draft/2019-09/json-schema-validation.html#rfc.section.7) The `format` keywords has always been problematic due to its optional nature. There has never been a way to ensure that the implementation processing your schema supports `format` at all, or if it does, to what degree it validates each type of format. In theory, since each format references a standard specification, if a format is supported, it should behave consistently. In practice, this is not the case. -There are two ways for an application to validate formats: It can rely on a JSON Schema implementation to validate them (which may or may not have the expected results), or it can note where the `format` keyword has been used and perform its own validation based on that. This second approach is supported by treating `format` as an [annotation keyword](/work-in-progress/WIP-jsonschema-core.html#rfc.section.7.7) and supporting the [basic, detailed, or verbose output formats](/work-in-progress/WIP-jsonschema-core.html#rfc.section.10.4.2). +There are two ways for an application to validate formats: It can rely on a JSON Schema implementation to validate them (which may or may not have the expected results), or it can note where the `format` keyword has been used and perform its own validation based on that. This second approach is supported by treating `format` as an [annotation keyword](/draft/2019-09/json-schema-core.html#rfc.section.7.7) and supporting the [basic, detailed, or verbose output formats](/draft/2019-09/json-schema-core.html#rfc.section.10.4.2). To impose some predictability on this system, the behavior has changed in several ways, as illustrated below. The key difference here is that `format` validation is now predictably off by default, but can be configured to be turned on. In draft-07, it was on (but possibly unimplemented) by default and could be configured to be turned off. @@ -131,34 +133,34 @@ Additionally, two new formats were added, and a specification reference was upda format | change | notes ---- | ---- | ---- -[`"duration"`](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.7.3.1) | **added** | The duration format is from the ISO 8601 ABNF as given in Appendix A of RFC 3339 -[`"hostname"` and `"idn-hostname"`](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.7.3.3) | **updated** | Use RFC 1123 instead of RFC 1034; this allows for a leading digit -[`"uuid"`](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.7.3.5) | **added** | A string instance is valid against this attribute if it is a valid string representation of a UUID, according to RFC4122 +[`"duration"`](/draft/2019-09/json-schema-validation.html#rfc.section.7.3.1) | **added** | The duration format is from the ISO 8601 ABNF as given in Appendix A of RFC 3339 +[`"hostname"` and `"idn-hostname"`](/draft/2019-09/json-schema-validation.html#rfc.section.7.3.3) | **updated** | Use RFC 1123 instead of RFC 1034; this allows for a leading digit +[`"uuid"`](/draft/2019-09/json-schema-validation.html#rfc.section.7.3.5) | **added** | A string instance is valid against this attribute if it is a valid string representation of a UUID, according to RFC4122 #### Content Vocabulary -[Validation Specification, Section 8](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.8) +[Validation Specification, Section 8](/draft/2019-09/json-schema-validation.html#rfc.section.8) These keywords are now specified purely as annotations, and never assertions. Some guidance is provided around how an implementation can optionally offer further automatic processing of this information outside of the validation process. keyword | change | notes ---- | ---- | ---- -[`contentEncoding`](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.8.3) | **updated** | Encodings from RFC 4648 are now allowed, and take precedence over RFC 2045 when there is a difference -[`contentSchema`](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.8.5) | **added** | Schema for use with the decoded content string; note that it is _not_ automatically applied as not all content media types can be understood in advance +[`contentEncoding`](/draft/2019-09/json-schema-validation.html#rfc.section.8.3) | **updated** | Encodings from RFC 4648 are now allowed, and take precedence over RFC 2045 when there is a difference +[`contentSchema`](/draft/2019-09/json-schema-validation.html#rfc.section.8.5) | **added** | Schema for use with the decoded content string; note that it is _not_ automatically applied as not all content media types can be understood in advance #### Meta-Data Vocabulary -[Validation Specification, Section 9](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.9) +[Validation Specification, Section 9](/draft/2019-09/json-schema-validation.html#rfc.section.9) keyword | change | notes ---- | ---- | ---- -[`deprecated`](/work-in-progress/WIP-jsonschema-validation.html#rfc.section.9.3) | **added** | Used to indicate that a field is deprecated in some application-specific manner +[`deprecated`](/draft/2019-09/json-schema-validation.html#rfc.section.9.3) | **added** | Used to indicate that a field is deprecated in some application-specific manner #### Hyper-Schema Vocabulary -[Hyper-Schema Specification, Sections 5 and 6](/work-in-progress/WIP-jsonschema-hyperschema.html#rfc.section.5) +[Hyper-Schema Specification, Sections 5 and 6](/draft/2019-09/json-schema-hypermedia.html#rfc.section.5) keyword | change | notes ---- | ---- | ---- -[`rel`](/work-in-progress/WIP-jsonschema-hyperschema.html#rfc.section.6.2.1) | **changed** | Can now be an array of values instead of just a string +[`rel`](/draft/2019-09/json-schema-hypermedia.html#rfc.section.6.2.1) | **changed** | Can now be an array of values instead of just a string diff --git a/index.md b/index.md index eafbc63d..efe5fd9d 100644 --- a/index.md +++ b/index.md @@ -4,11 +4,11 @@ title: JSON Schema permalink: / --- -***The current version is [draft-07](specification.html)!*** -{: style="color:gray; font-size: 150%; text-align: center;"} +**NEW DRAFT PUBLISHED!** +{: style="color:red; font-size: 200%; text-align: center;"} -***The next draft work-in-progress is [in final review](work-in-progress)!*** -{: style="color:red; font-size: 150%; text-align: center;"} +The current version is [draft/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. @@ -40,19 +40,9 @@ permalink: / ## Project Status -### Update as of 8 September 2019 - -***All PRs from our final review feedback for the next draft have been posted!*** - -_The draft will be published as soon as we have sufficient reviews from the spec team and/or implementation owners. As this is summer vacation season, that may still take a few weeks. As of September 8th, all but one team member have completed their reviews, and the last team member is now looking at the remaining PRs._ - -This draft has also taken more time than expected because it tackles deep, long-term issues that have long been a challenge for JSON Schema. This includes building in a formal extensibility mechanism so that we can more easily draw a line to finalize the contents of the Core and Validation specifications. - -Additionally, numerous life issues reduced the availability of key contributors during the process. - -And finally, the feedback process demonstrated that our first attempt at a publishable draft needed substantial additional work, adding another few months to the timeline. +16 September 2019: Draft 2019-09 (formerly known as draft-08) has been published! -Since the most intractable problems are all addressed to one degree or another in this draft, we do not anticipate future drafts taking so long. +See the [Specification page](specification.html) for details. ### The Path to Standardization diff --git a/specification-links.md b/specification-links.md index f86d822e..6cc24ed7 100644 --- a/specification-links.md +++ b/specification-links.md @@ -5,29 +5,250 @@ layout: page -You can find the latest released draft on the [Specification](/specification.html) page. Older drafts are expired, but may be of historical interest. +You can find the latest released draft on the [Specification](/specification.html) page. Older drafts are expired, but may be of historical interest. The complex numbering and naming system for drafts and meta-schemas is fully explained here as well. -**A note on draft naming and numbering:** -IETF Internet-Drafts (I-Ds) are named with the editor's name and a sequential number which resets with each new editor. Meta-schemas are numbered sequentially. Additionally, drafts 00-03 used one document for all three current specs. Most people find it easier to remember the sequential meta-schema numbers, so those are used throughout the site. - -IETF draft documents do not correspond directly with meta-schema draft numbers, as a new IETF draft may be published to fix bugs in a previous document without changing implementation requirements or moving to a new meta-schema. This is because it is not possible to edit drafts once they are published, it is only possible to replace them with a new corrected draft. * TOC {:toc} -## Latest Snapshot (work in progress) +## Understanding draft names and numbers -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). +IETF Internet-Drafts (I-Ds) are named with the editor's name and a sequential number which resets with each new editor. Meta-schemas were more-or-less numbered sequentially up through Draft 7, but the increasingly confusing mismatch between "draft-nn" versions on the meta-schemas and the IETF documents has made that unsustainable. The practice of fixing meta-schema bugs in place to preserve the sequential numbering has also been controversial. - - 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) -- [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) +Starting with what had been called "Draft 8" while it was being written, meta-schemas are identified by the year and month of publication. This allows for bug fixes to be published with new URIs (as long as it is not more than once a month). + +### Table of All Versions of Everything + +The specification links here go to the IETF-hosted documents. + +For links to the somewhat more readably formatted versions on this web site, and for links to the various meta-schemas and other supplemental documents, see the the following sections. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    IETF identifiersmeta‑schema identifierscommon namenotes
    + + draft‑zyp‑json‑schema‑00 + + draft‑00 + Draft 0 + + due to a markup error, this draft was replaced by + draft‑01 on the same day +
    + + draft‑zyp‑json‑schema‑01 + + draft‑01 + + Draft 1 +
    + + draft‑zyp‑json‑schema‑02 + + draft‑02 + + Draft 2 +
    + + draft‑zyp‑json‑schema‑03 + + draft‑03 + + Draft 3 +
    + + draft‑zyp‑json‑schema‑04 +
    + + draft‑fge‑json‑schema‑validation‑00 +
    + + draft‑luff‑json‑hyper‑schema‑00 +
    + + draft‑pbryan‑zyp‑json‑ref‑03 +
    +
    + draft‑04 + + Draft 4 + + json‑ref drafts + 00‑02 were all published between + json‑schema‑03 and + json‑schema‑04 +
    + + draft‑wright‑json‑schema‑00 +
    + + draft‑wright‑json‑schema‑validation‑00 +
    + + draft‑wright‑json‑schema‑hyperschema‑00 +
    +
    + Draft 5 + + the meta‑schema was not changed, so + "draft‑05" has no formal meaning
    + + draft‑wright‑json‑schema‑01 +
    + + draft‑wright‑json‑schema‑validation‑01 +
    + + draft‑wright‑json‑schema‑hyperschema‑01 +
    +
    + draft‑06 + + Draft 6 +
    + + draft‑handrews‑json‑schema‑00 +
    + + draft‑handrews‑json‑schema‑validation‑00 +
    + + draft‑handrews‑json‑schema‑hyperschema‑00 +
    + + draft‑handrews‑relative‑json‑pointer‑00 +
    +
    + draft‑07 + Draft 7 + + the draft‑handrews‑*‑01 drafts were + bugfixes and/or clarifications without meta‑schema or functional changes +
    + + draft‑handrews‑json‑schema‑01 +
    + + draft‑handrews‑json‑schema‑validation‑01 +
    + + draft‑handrews‑json‑schema‑hyperschema‑01 +
    + + draft‑handrews‑relative‑json‑pointer‑01 +
    +
    + + draft‑handrews‑json‑schema‑02 +
    + + draft‑handrews‑json‑schema‑validation‑02 +
    + + draft‑handrews‑json‑schema‑hyperschema‑02 +
    + + draft‑handrews‑relative‑json‑pointer‑02 +
    +
    + draft/2019‑09 + + 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) -## Draft 7 +_**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)) + - 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)) +- 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) + - [JSON Hyper-Schema Link Description Object meta-schema](https://json-schema.org/draft/2019-09/links) +- Individual vocablary 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) + - [Format Vocabulary meta-schema](https://json-schema.org/draft/2019-09/meta/format) + - [Content Vocabulary meta-schema](https://json-schema.org/draft/2019-09/meta/content) + - [Meta-Data Vocabulary meta-schema](https://json-schema.org/draft/2019-09/meta/meta-data) + - [Hyper-Schema Vocabulary meta-schema](https://json-schema.org/draft/2019-09/meta/hyper-schema) +- Output schemas + - [JSON Schema recommended output schema](https://json-schema.org/draft/2019-09/output/schema) + - [JSON Hyper-Schema recommended output schema](https://json-schema.org/draft/2019-09/output/hyper-schema) +- Output examples + - [JSON Schema verbose output example](https://json-schema.org/draft/2019-09/output/verbose-example) + +### Draft 7 - Core: [draft-handrews-json-schema-01](https://tools.ietf.org/html/draft-handrews-json-schema-01) ([changes](https://tools.ietf.org/html/draft-handrews-json-schema-01#appendix-B)) - Validation: [draft-handrews-json-schema-validation-01](https://tools.ietf.org/html/draft-handrews-json-schema-validation-01) ([changes](https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#appendix-B)) @@ -38,7 +259,7 @@ The next unreleased draft is a work in progress. You can [give feedback and get - [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)) -### Obsolete Draft 7 Documents +#### Obsolete Draft 7 Documents Play "spot the bugs"! @@ -47,7 +268,7 @@ Play "spot the bugs"! - 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)) -## Draft 6 +### Draft 6 - Core: [draft-wright-json-schema-01](https://tools.ietf.org/html/draft-wright-json-schema-01) ([changes](https://tools.ietf.org/html/draft-wright-json-schema-01#appendix-B)) - Validation: [draft-wright-json-schema-validation-01](https://tools.ietf.org/html/draft-wright-json-schema-validation-01) ([changes](https://tools.ietf.org/html/draft-wright-json-schema-validation-01#appendix-B)) ([schema migration FAQ](draft-06/json-schema-migration-faq.html)) @@ -55,14 +276,14 @@ Play "spot the bugs"! - [JSON Schema meta-schema](http://json-schema.org/draft-06/schema) - [JSON Hyper-Schema meta-schema](http://json-schema.org/draft-06/hyper-schema) -## Draft 5 +### Draft 5 - Core: [draft-wright-json-schema-00](https://tools.ietf.org/html/draft-wright-json-schema-00) ([changes](https://tools.ietf.org/html/draft-wright-json-schema-00#appendix-B)) - Validation: [draft-wright-json-schema-validation-00](https://tools.ietf.org/html/draft-wright-json-schema-validation-00) ([changes](https://tools.ietf.org/html/draft-wright-json-schema-validation-00#appendix-B)) - Hyper-Schema: [draft-wright-json-schema-hyperschema-00](https://tools.ietf.org/html/draft-wright-json-schema-hyperschema-00) ([changes](https://tools.ietf.org/html/draft-wright-json-schema-hyperschema-00#appendix-B)) - Draft 5 was primarily a cleanup of Draft 4 and continued to use the Draft 4 meta-schemas. -## Draft 4 +### Draft 4 - 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)) @@ -70,7 +291,7 @@ Play "spot the bugs"! * [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 +### 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) @@ -78,5 +299,19 @@ Play "spot the bugs"! * [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 +### 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) + +## 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). + + - 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) +- [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) + diff --git a/specification.md b/specification.md index 6f97a600..a697b3b7 100644 --- a/specification.md +++ b/specification.md @@ -11,38 +11,64 @@ title: Specification Draft numbering --------------- -The latest Internet-Drafts at the IETF are the **draft-handrews-json-schema\*-01** documents, which correspond to the **draft-07** meta-schemas. These were published on **2018-03-19** (Core and Validation) and **2018-01-19** (Hyper-Schema and Relative JSON Pointer). +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**. -Due to a change in author/editorship the I-D numbering was reset to -00 again. Due to bugs in the draft-handrews-\*-00 specifications, they have been replaced with -01, but are still considered draft-07 as there is no functional change. +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. Specification documents ----------------------- +See also the [release notes / change log](draft/2019-09/release-notes.html). + The specification is split into three parts, Core, Validation, and Hyper-Schema, along with a related specification, Relative JSON Pointers: |--------------------------------------------------------------|-------------------------------------------------------| -| [JSON Schema Core](latest/json-schema-core.html) | defines the basic foundation of JSON Schema | -| [JSON Schema Validation](latest/json-schema-validation.html) | defines the validation keywords of JSON Schema | -| [JSON Hyper-Schema](latest/json-schema-hypermedia.html) ([errata](https://github.com/json-schema-org/json-schema-spec/issues?q=label%3Aerrata+label%3Ahypermedia)) | defines the hyper-media keywords of JSON Schema | -| [Relative JSON Pointers](latest/relative-json-pointer.html) | extends the JSON Pointer syntax for relative 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 | They are also available on the IETF main site: -* [draft-handrews-json-schema-01 (core)](https://tools.ietf.org/html/draft-handrews-json-schema-01) -* [draft-handrews-json-schema-validation-01](https://tools.ietf.org/html/draft-handrews-json-schema-validation-01) -* [draft-handrews-json-schema-hyperschema-01](https://tools.ietf.org/html/draft-handrews-json-schema-hyperschema-01) ([errata](https://github.com/json-schema-org/json-schema-spec/issues?q=label%3Aerrata+label%3Ahypermedia)) -* [draft-handrews-relative-json-pointer-01](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01) +* [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) + +_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 ------------ 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-07**. + +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. + +_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 + +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. |--------------------------------------------------------------|------------------------------------------------------------| -| [Core/Validation meta-schema](https://json-schema.org/draft-07/schema) | Used for schemas written for pure validation. | -| [Hyper meta-schema](https://json-schema.org/draft-07/hyper-schema) | Used for schemas written for validation and hyper-linking. | +| [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. | + +## 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) -_If you are accessing the above meta-schema links **from a web browser**, you will need to **save the file** then open it as a JSON document._ +## 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) Migrating from older drafts ------------- @@ -50,9 +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-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-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 a51c9b2413d9504f26923fb4e2ee799828f54b9a Mon Sep 17 00:00:00 2001 From: Ondrej Kokes Date: Wed, 18 Sep 2019 09:04:58 +0200 Subject: [PATCH 087/395] 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 088/395] 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 089/395] 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 090/395] 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 091/395] 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 092/395] 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 093/395] 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 094/395] 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 095/395] 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 096/395] 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 097/395] 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 098/395] 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 099/395] 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 100/395] 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 101/395] 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 102/395] 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 103/395] 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 104/395] 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 105/395] 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 106/395] 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 107/395] 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 108/395] 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 109/395] 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 110/395] 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 111/395] 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 112/395] 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 113/395] 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 114/395] 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 115/395] 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 116/395] 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 117/395] 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 118/395] 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 119/395] 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 120/395] 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 121/395] 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 122/395] 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 123/395] 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 124/395] 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 125/395] 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 126/395] 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 127/395] 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 128/395] 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 129/395] 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 130/395] 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 131/395] 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 132/395] 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 133/395] 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 134/395] @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 135/395] 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 136/395] 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 137/395] 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 138/395] 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 139/395] 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 140/395] 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 141/395] 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 142/395] 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 143/395] 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 144/395] 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 145/395] 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 146/395] 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 147/395] 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 148/395] 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 149/395] 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 150/395] 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 151/395] 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 152/395] 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 153/395] 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 154/395] 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 155/395] 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 156/395] 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 157/395] 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 158/395] 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 159/395] 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 160/395] 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 161/395] 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 162/395] 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 163/395] 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 164/395] 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 165/395] 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 166/395] 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 167/395] 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 168/395] 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 169/395] 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 170/395] 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 171/395] 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 172/395] 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 173/395] 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 174/395] 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"
  • +

    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 175/395] 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 176/395] 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 177/395] 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 178/395] 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 179/395] 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 180/395] 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 181/395] 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 182/395] 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 183/395] 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 184/395] 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 185/395] 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 186/395] 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 187/395] 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 188/395] 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 189/395] 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 190/395] 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 191/395] 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 192/395] 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 193/395] 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 194/395] 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 195/395] 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 196/395] 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 197/395] 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 198/395] 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 199/395] 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 200/395] 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 201/395] 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 202/395] 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 203/395] 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 204/395] 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 205/395] 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 206/395] 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 207/395] 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 208/395] 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 209/395] 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 210/395] 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 211/395] 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 212/395] 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 213/395] 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 214/395] 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 215/395] 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 216/395] 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 217/395] 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 218/395] 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 219/395] 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 220/395] 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 221/395] 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 222/395] 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 223/395] 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 224/395] 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 225/395] 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 226/395] 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 227/395] 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 228/395] 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 229/395] 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 230/395] 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 231/395] 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 232/395] 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 233/395] 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 234/395] 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 235/395] 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 236/395] 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 237/395] 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 238/395] 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 239/395] 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 240/395] 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 241/395] 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 242/395] 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 243/395] 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 244/395] 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 245/395] 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 246/395] 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 247/395] 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 248/395] 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 249/395] 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 250/395] 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 251/395] 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 252/395] 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 253/395] 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 254/395] 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 255/395] 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 256/395] 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 257/395] 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 258/395] 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 259/395] 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 260/395] 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 261/395] 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 262/395] 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 263/395] 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 264/395] 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 265/395] 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 266/395] 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 267/395] 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 268/395] 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 269/395] 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 270/395] 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 271/395] 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 272/395] 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 273/395] 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 274/395] 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 275/395] 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 276/395] 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 277/395] 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 278/395] 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 279/395] 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 280/395] 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 281/395] 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 282/395] 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 283/395] 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 284/395] 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 285/395] 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 286/395] 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 287/395] 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 288/395] 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 289/395] 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 290/395] 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 291/395] 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 292/395] 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 293/395] 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 294/395] 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 295/395] 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 296/395] 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 297/395] 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 298/395] 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 299/395] 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 300/395] 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 301/395] 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 302/395] 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 303/395] 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 304/395] 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 305/395] 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 306/395] 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 307/395] 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 308/395] 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 309/395] 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 310/395] 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 311/395] 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 312/395] 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 313/395] 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 314/395] 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 315/395] 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 316/395] 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 317/395] 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 318/395] 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 324/395] 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 325/395] 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 326/395] 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 327/395] 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 328/395] 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 329/395] 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 330/395] 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 331/395] 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 332/395] 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 333/395] 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 334/395] 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 335/395] 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 336/395] 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 337/395] 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 338/395] 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 339/395] 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 340/395] 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 341/395] 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 342/395] 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 343/395] 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 344/395] 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 345/395] 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 346/395] 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 347/395] 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 348/395] 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 349/395] 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 350/395] 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 351/395] 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 352/395] 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 353/395] 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 354/395] 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 355/395] 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 356/395] 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 357/395] 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 358/395] 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 359/395] 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 360/395] 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 361/395] 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 362/395] 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 363/395] 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 364/395] 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 365/395] 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 366/395] 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 367/395] 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 368/395] 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 369/395] 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 370/395] 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 371/395] 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 372/395] 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 373/395] 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 374/395] 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 375/395] 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 376/395] 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 377/395] 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 378/395] 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 379/395] 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 380/395] 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 381/395] 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 382/395] 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 383/395] 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 384/395] 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 385/395] 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 386/395] 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 387/395] 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 388/395] 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 389/395] 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 390/395] 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 391/395] 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 392/395] 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 393/395] 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 394/395] 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 395/395] 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).