+ 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.
+
+
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
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/work-in-progress/WIP-jsonschema-core.html b/draft/2019-09/json-schema-core.html
similarity index 71%
rename from work-in-progress/WIP-jsonschema-core.html
rename to draft/2019-09/json-schema-core.html
index d5e562f0..80fb2685 100644
--- a/work-in-progress/WIP-jsonschema-core.html
+++ b/draft/2019-09/json-schema-core.html
@@ -388,7 +388,7 @@
-
+
@@ -400,25 +400,26 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
+
-
-
+
+
+
@@ -454,8 +455,17 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -463,8 +473,8 @@
-
-
+
+
@@ -488,7 +498,7 @@
H. Andrews, Ed.
-
Expires: February 17, 2020
+
Expires: March 20, 2020
@@ -505,7 +515,7 @@
-
August 16, 2019
+
September 17, 2019
@@ -513,7 +523,7 @@
JSON Schema: A Media Type for Describing JSON Documents
- draft-handrews-json-schema-WIP
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.
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 20, 2020.
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.
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
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.
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.
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.
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.
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".
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.
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.
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.
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.
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.
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.
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:
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.
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.
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.
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.
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.
+
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.
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,40 +1006,39 @@
-
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.
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. The output formats described in this specification that include annotation information meet this requirement.
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:
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.
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.
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 +1077,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.
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.
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.
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.
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.
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.
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.
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.
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 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 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 +1134,7 @@
For example, an implementation that is a validator SHOULD assume the use of all vocabularies in this specification and the companion Validation specification.
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.
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 +1143,131 @@
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.
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").
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.
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.
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.
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.
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.
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.
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 (".").
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:
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:
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.
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":
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:
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#".
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.
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.
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.
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.
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.
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.
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.
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.
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 "$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.
+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 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.
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.
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.
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.
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.
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.
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.
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.
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 +1308,21 @@
}
-
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":
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.
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.
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".
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.
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".
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.
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.
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:
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.
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.
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.
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.
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
+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.
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.
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.
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.
+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.
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.
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.
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.
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.
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.
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.
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 20, 2020.
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.
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 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.
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:
@@ -734,7 +1189,7 @@
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.
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 20, 2020.
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.
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.
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.
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.
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.
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 "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.
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.
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 value of both of these keywords MUST be a string.
@@ -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.
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.
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.
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.
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 +1227,7 @@
-
draft-handrews-json-schema-validation-WIP
+
draft-handrews-json-schema-validation-02
Grouped keywords into formal vocabuarlies
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/work-in-progress/WIP-relative-json-pointer.html b/draft/2019-09/relative-json-pointer.html
similarity index 99%
rename from work-in-progress/WIP-relative-json-pointer.html
rename to draft/2019-09/relative-json-pointer.html
index 8d5dfa42..5710a004 100644
--- a/work-in-progress/WIP-relative-json-pointer.html
+++ b/draft/2019-09/relative-json-pointer.html
@@ -397,7 +397,7 @@
-
+
@@ -421,8 +421,8 @@
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 20, 2020.
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/draft/2019-09/release-notes.md b/draft/2019-09/release-notes.md
new file mode 100644
index 00000000..0f5c933d
--- /dev/null
+++ b/draft/2019-09/release-notes.md
@@ -0,0 +1,166 @@
+---
+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.
+
+For implementors, there is a lot more to consider, and further guidance on implementation topics will be forthcoming.
+
+* TOC
+{:toc}
+
+For a basic list of changes to each document, see their change logs:
+* [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
+
+* 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](/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](/draft/2019-09/json-schema-core.html#rfc.section.10).
+
+### Keyword Changes
+
+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](/draft/2019-09/json-schema-core.html#rfc.section.8)
+
+keyword | change | notes
+---- | ---- | ----
+[`$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](/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`)](/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](/draft/2019-09/json-schema-validation.html#rfc.section.6)
+
+keyword | change | notes
+---- | ---- | ----
+[`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](/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](/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.
+
+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 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
+---- | ---- | ----
+[`"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](/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`](/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](/draft/2019-09/json-schema-validation.html#rfc.section.9)
+
+keyword | change | notes
+---- | ---- | ----
+[`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](/draft/2019-09/json-schema-hypermedia.html#rfc.section.5)
+
+keyword | change | notes
+---- | ---- | ----
+[`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/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
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
+---
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/implementations.md b/implementations.md
index 7ee033e6..9ee00aaa 100644
--- a/implementations.md
+++ b/implementations.md
@@ -43,9 +43,14 @@ Validators
'}}
@@ -183,12 +188,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*
+- 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
- [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*
@@ -214,7 +223,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
---------
@@ -239,8 +249,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
@@ -257,8 +266,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
diff --git a/index.md b/index.md
index fe9771cf..a67a09bb 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 [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,13 @@ permalink: /
## Project Status
-### Update as of 26 Aug 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._
-
-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.
+16 September 2019: Draft 2019-09 (formerly known as draft-08) has been published!
-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.
+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.
-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 about naming and numbering.
### The Path to Standardization
diff --git a/latest/json-schema-core.html b/latest/json-schema-core.html
deleted file mode 100644
index 23e22842..00000000
--- a/latest/json-schema-core.html
+++ /dev/null
@@ -1,1145 +0,0 @@
-
-
-
-
-
-
- JSON Schema: A Media Type for Describing JSON Documents
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Internet Engineering Task Force
-
A. Wright, Ed.
-
-
-
Internet-Draft
-
-
-
-
Intended status: Informational
-
H. Andrews, Ed.
-
-
-
Expires: September 20, 2018
-
Cloudflare, Inc.
-
-
-
-
March 19, 2018
-
-
-
-
-
-
-
JSON Schema: A Media Type for Describing JSON Documents
- draft-handrews-json-schema-01
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.
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 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 (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.
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.
-
Other specifications define the vocabularies that perform assertions about validation, linking, annotation, navigation, and interaction.
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].
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 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].
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].
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].
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].
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 [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.
-
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.
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.
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.
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".
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:
-
-
-
assertions:
-
produce a boolean result when applied to an instance
-
annotations:
-
attach information to an instance for application use
-
-
-
-
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:
-
-
-
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 <>.
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.
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.
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 (".").
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:
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 "$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.
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.
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.
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.
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.
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].
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:
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:
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:
-
Clients SHOULD be able to make requests with a "From" header so that server operators can contact the owner of a potentially misbehaving script.
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.
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].
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.
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.
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 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."
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.
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.
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].
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":
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.
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:
-
-
-
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.
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.
-
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.
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#>.
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.
-
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.
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.
-
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.
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.
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.
-
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.
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.
-
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.
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.
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.
-
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.
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.
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.
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.
-
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.
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.
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.
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.
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.
-
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.
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.
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.
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.
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.
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.
-
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".
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.
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.
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.
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].
-
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.
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.
-
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.
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.
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].
-
Omitting this keyword has the same behavior as a value of application/json.
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.
-
Omitting "submissionSchema" has the same behavior as a value of "true".
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.
-
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.
-
-
-
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.
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.
-
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.
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:
-
-
-
"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:
-
-
-
Populate template variable data from the instance
-
If input is desired, accept input
-
Check that all required variables have a value
-
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)
-
-
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.
-
-
-
-
Determine which variables can accept input
-
Pre-populate the input data set if the template resolution data set has a value
-
Accept input (present a web form, make a callback, etc.)
-
Validate the input data set, (not the template resolution data set)
-
Put the input in the template resolution data set, overriding any existing values
-
-
-
-
"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:
-
-
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.
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.
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.
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.
-
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).
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.
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.
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.
-
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.
"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.
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.
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"
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 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".
-
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:
-
-
-
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.
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.
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.
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].
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:
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 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.
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.
-
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]:
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.
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".
-
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.
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://api.example.com/stuff":
-
-{
- "title": "The Awesome Thing",
- "stuffWorthEmailingAbout": "Lots of text here...",
- "email": "someone@exapmle.com"
-}
-
-
We can partially resolve the link as follows, before asking the client application for input.
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:
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).
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".
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.
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.
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.
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.
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.
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.
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.
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:
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.
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.
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).
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.
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.
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.
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.
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.
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.
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.
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.
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 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 (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.
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.
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].
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.
-
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.
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.
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.
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.
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.
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.
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.
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.
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.
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".
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.
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.
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.
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.
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.
-
Omitting this keyword has the same behavior as an empty object.
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.
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.
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.
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.
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.
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".
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.
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.
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.
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:
-
-
-
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.
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.
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.
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.
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.
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.
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).
Instances described by this schema should be strings containing HTML, using whatever character set the JSON string was decoded into (default is Unicode).
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 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."
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.
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.
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].
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]).
-
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 [RFC6901] ("Syntax").
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).
-
-
-
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.
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.
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.
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.
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.
-
-
- Henry Andrews (editor)
-
- Andrews
-
-
- Cloudflare, Inc.
-
-
-
- San Francisco,
- CA
-
-
- USA
-
- EMail: henry@cloudflare.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"
+---
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
+---
diff --git a/specification-links.md b/specification-links.md
index f86d822e..7f4253ed 100644
--- a/specification-links.md
+++ b/specification-links.md
@@ -5,29 +5,300 @@ 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).
-## Draft 7
+### 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.
+
+
+
+## Published Drafts
+
+### 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-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 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)
+ - [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))
@@ -36,18 +307,18 @@ The next unreleased draft is a work in progress. You can [give feedback and get
- [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
+#### 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
+### 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,28 +326,61 @@ 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))
- 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
+### 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 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 6f97a600..469da8a0 100644
--- a/specification.md
+++ b/specification.md
@@ -5,44 +5,74 @@ 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\*-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 **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 `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)
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 **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._
+
+## 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 +80,11 @@ Migrating from older drafts
The release notes discuss the changes impacting users and implementers:
- JSON Schema Core and Validation
+ - [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 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)
diff --git a/work-in-progress/WIP-hyper-schema.json b/work-in-progress/WIP-hyper-schema.json
deleted file mode 100644
index 406455d3..00000000
--- a/work-in-progress/WIP-hyper-schema.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "$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-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-WIP/schema"},
- {"$ref": "http://json-schema.org/draft/2019-WIP/meta/hyper-schema"}
- ],
- "links": [
- {
- "rel": "self",
- "href": "{+%24id}"
- }
- ]
-}
diff --git a/work-in-progress/WIP-json-schema-release-notes.md b/work-in-progress/WIP-json-schema-release-notes.md
deleted file mode 100644
index 30589b61..00000000
--- a/work-in-progress/WIP-json-schema-release-notes.md
+++ /dev/null
@@ -1,52 +0,0 @@
----
-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.
-
-* 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) | **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.
-
-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
diff --git a/work-in-progress/WIP-jsonschema-core.txt b/work-in-progress/WIP-jsonschema-core.txt
deleted file mode 100644
index 103d1164..00000000
--- a/work-in-progress/WIP-jsonschema-core.txt
+++ /dev/null
@@ -1,3752 +0,0 @@
-
-
-
-
-Internet Engineering Task Force A. Wright, Ed.
-Internet-Draft
-Intended status: Informational H. Andrews, Ed.
-Expires: February 17, 2020
- B. Hutton, Ed.
- Wellcome Sanger Institute
- G. Dennis
- August 16, 2019
-
-
- JSON Schema: A Media Type for Describing JSON Documents
- 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.
-
-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 February 17, 2020 [Page 1]
-
-Internet-Draft JSON Schema August 2019
-
-
- 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.
-
-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 . . . . . . . . . . . . . . . . 8
- 4.3.3. Schema Vocabularies . . . . . . . . . . . . . . . . . 9
- 4.3.4. Meta-Schemas . . . . . . . . . . . . . . . . . . . . 9
- 4.3.5. Root Schema and Subschemas . . . . . . . . . . . . . 9
- 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 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
- 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
-
- 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
- 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.
-
-
-
-
-
-
-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.
-
- 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].
-
-
-
-
-
-
-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
- "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.
-
- 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
-
-
-
-
-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.
-
-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.
-
-
-
-
-
-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
- 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 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
-
-
-
-
-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).
-
- 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 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:
-
-
-
-Wright, et al. Expires February 17, 2020 [Page 9]
-
-Internet-Draft JSON Schema August 2019
-
-
- {
- "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.
-
-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.2) section.
-
-
-
-
-
-
-
-
-Wright, et al. Expires February 17, 2020 [Page 10]
-
-Internet-Draft JSON Schema August 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 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;
-
-
-
-
-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 ("|").
-
- 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
-
-
-
-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
- 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
- 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
-
-
-
-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.
-
- 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).
-
-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.
-
-
-
-
-
-
-
-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
- 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.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.6) results are combined according to the rules
- specified by each annotation keyword.
-
-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" (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 17, 2020 [Page 15]
-
-Internet-Draft JSON Schema August 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
-
- 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.
-
-
-
-
-
-
-
-Wright, et al. Expires February 17, 2020 [Page 16]
-
-Internet-Draft JSON Schema August 2019
-
-
-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)
-
-
-
-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
- 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 17, 2020 [Page 18]
-
-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 17, 2020 [Page 19]
-
-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 17, 2020 [Page 20]
-
-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. 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-
- 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.
-
-
-
-
-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
- 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 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.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.
-
-
-
-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. ]]
-
- 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.
-
-
-
-
-
-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
- 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 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.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.
-
-
-
-
-
-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-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.
-
-
-
-
-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
-
- 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.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.
-
-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]
-
-Internet-Draft JSON Schema August 2019
-
-
-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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Wright, et al. Expires February 17, 2020 [Page 29]
-
-Internet-Draft JSON Schema August 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": "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"
- }
- }
- }
-
-
- 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)
-
- 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
-
-
-
-Wright, et al. Expires February 17, 2020 [Page 30]
-
-Internet-Draft JSON Schema August 2019
-
-
- 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.
-
-
-
-
-Wright, et al. Expires February 17, 2020 [Page 31]
-
-Internet-Draft JSON Schema August 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.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 February 17, 2020 [Page 32]
-
-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
- recursive references. It also repeats the description of "r" from
- the original schema.
-
-
- {
- "$schema": "https://json-schema.org/draft/2019-WIP/schema#",
- "$id": "https://example.com/original",
-
- "properties": {
- "name": {
- "type": "string"
- },
- "r": {
- "$ref": "#"
- }
- }
- }
-
- {
- "$schema": "https://json-schema.org/draft/2019-WIP/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 February 17, 2020 [Page 33]
-
-Internet-Draft JSON Schema August 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"
-
- 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".
-
-
-
-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-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
-
-
-
-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" }
- }
- }
- }
-
-
- 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.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.
-
-
-
-
-
-
-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":
-
-
- {
- "type": "array",
- "items": { "$ref": "#/$defs/positiveInteger" },
- "$defs": {
- "positiveInteger": {
- "type": "integer",
- "exclusiveMinimum": 0
- }
- }
- }
-
-
-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.
-
-
-
-
-Wright, et al. Expires February 17, 2020 [Page 39]
-
-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: .
-
- 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
-
-
-
-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.
-
-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
-
-
-
-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.
-
- 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 (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".
-
-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.
-
-
-
-
-
-
-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.
-
- 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.
-
-
-
-
-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
- 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 (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.
-
- 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
-
-
-
-
-
-
-
-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
- 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".
-
-
-
-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.
-
- 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 (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
-
-
-
-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.
-
- 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.
-
-
-
-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.
-
- 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/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".
-
-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-WIP/schema#/$defs/nonNegativeInteger/minimum
-
-
-
-
-
-
-Wright, et al. Expires February 17, 2020 [Page 49]
-
-Internet-Draft JSON Schema August 2019
-
-
- 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
-
- "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 February 17, 2020 [Page 50]
-
-Internet-Draft JSON Schema August 2019
-
-
- {
- "$id": "https://example.com/polygon#",
- "$schema": "https://json-schema.org/draft/2019-WIP/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 February 17, 2020 [Page 51]
-
-Internet-Draft JSON Schema August 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 February 17, 2020 [Page 52]
-
-Internet-Draft JSON Schema August 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 correllation is more easily identified.
-
-
-
-
-Wright, et al. Expires February 17, 2020 [Page 53]
-
-Internet-Draft JSON Schema August 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 February 17, 2020 [Page 54]
-
-Internet-Draft JSON Schema August 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 February 17, 2020 [Page 55]
-
-Internet-Draft JSON Schema August 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-WIP/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 February 17, 2020 [Page 56]
-
-Internet-Draft JSON Schema August 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 February 17, 2020 [Page 57]
-
-Internet-Draft JSON Schema August 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 February 17, 2020 [Page 58]
-
-Internet-Draft JSON Schema August 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.
-
- [[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: ;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 February 17, 2020 [Page 59]
-
-Internet-Draft JSON Schema August 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 February 17, 2020 [Page 60]
-
-Internet-Draft JSON Schema August 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 February 17, 2020 [Page 61]
-
-Internet-Draft JSON Schema August 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-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-WIP (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 February 17, 2020 [Page 63]
-
-Internet-Draft JSON Schema August 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
-
- [[CREF8: This section to be removed before leaving Internet-Draft
- status.]]
-
- draft-handrews-json-schema-WIP
-
- * 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
-
-
-
-Wright, et al. Expires February 17, 2020 [Page 64]
-
-Internet-Draft JSON Schema August 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 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
- "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 February 17, 2020 [Page 66]
-
-Internet-Draft JSON Schema August 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)
-
- 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 February 17, 2020 [Page 67]
diff --git a/work-in-progress/WIP-jsonschema-hyperschema.txt b/work-in-progress/WIP-jsonschema-hyperschema.txt
deleted file mode 100644
index 431525a8..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: February 17, 2020 August 16, 2019
-
-
- JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON
- 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.
-
-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 February 17, 2020.
-
-
-
-
-
-Andrews & Wright Expires February 17, 2020 [Page 1]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 2]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 3]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 4]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 5]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 6]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 7]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 8]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 9]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 10]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 11]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 12]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 13]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 14]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 15]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 16]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 17]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 18]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 19]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 20]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 21]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 22]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 23]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 24]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 25]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 26]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 27]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 28]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 29]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 30]
-
-Internet-Draft JSON Hyper-Schema August 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-WIP/hyper-schema#",
- "base": "https://example.com/api/",
- "links": [
- {
- "rel": "self",
- "href": "../api",
- }, {
- "rel": "about",
- "href": "docs"
- }
- ]
- }
-
-
-
-Andrews & Wright Expires February 17, 2020 [Page 31]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 32]
-
-Internet-Draft JSON Hyper-Schema August 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-WIP/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 February 17, 2020 [Page 33]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 34]
-
-Internet-Draft JSON Hyper-Schema August 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-WIP/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 February 17, 2020 [Page 35]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 36]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 37]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 38]
-
-Internet-Draft JSON Hyper-Schema August 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-WIP/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 February 17, 2020 [Page 39]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 40]
-
-Internet-Draft JSON Hyper-Schema August 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-WIP/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 February 17, 2020 [Page 41]
-
-Internet-Draft JSON Hyper-Schema August 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-WIP/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 February 17, 2020 [Page 42]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 43]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 44]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 45]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 46]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 47]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 48]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 49]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 50]
-
-Internet-Draft JSON Hyper-Schema August 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-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-WIP (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 February 17, 2020 [Page 51]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 52]
-
-Internet-Draft JSON Hyper-Schema August 2019
-
-
- [RFC7807] Nottingham, M. and E. Wilde, "Problem Details for HTTP
- APIs", RFC 7807, DOI 10.17487/RFC7807, March 2016,
- .
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Andrews & Wright Expires February 17, 2020 [Page 53]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 54]
-
-Internet-Draft JSON Hyper-Schema August 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-WIP
-
- * 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 February 17, 2020 [Page 55]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 56]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 57]
-
-Internet-Draft JSON Hyper-Schema August 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 February 17, 2020 [Page 58]
diff --git a/work-in-progress/WIP-jsonschema-validation.txt b/work-in-progress/WIP-jsonschema-validation.txt
deleted file mode 100644
index bf6bb7d9..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: February 17, 2020
- B. Hutton, Ed.
- Wellcome Sanger Institute
- August 16, 2019
-
-
- JSON Schema Validation: A Vocabulary for Structural Validation of JSON
- 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.
-
-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 February 17, 2020.
-
-
-
-
-
-Wright, et al. Expires February 17, 2020 [Page 1]
-
-Internet-Draft JSON Schema Validation August 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 February 17, 2020 [Page 2]
-
-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 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" . . . . . . . . . . . . . . . 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
-
- 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 February 17, 2020 [Page 3]
-
-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",
- "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 February 17, 2020 [Page 4]
-
-Internet-Draft JSON Schema Validation August 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. 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 February 17, 2020 [Page 5]
-
-Internet-Draft JSON Schema Validation August 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 February 17, 2020 [Page 6]
-
-Internet-Draft JSON Schema Validation August 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 February 17, 2020 [Page 7]
-
-Internet-Draft JSON Schema Validation August 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 February 17, 2020 [Page 8]
-
-Internet-Draft JSON Schema Validation August 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 February 17, 2020 [Page 9]
-
-Internet-Draft JSON Schema Validation August 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 February 17, 2020 [Page 10]
-
-Internet-Draft JSON Schema Validation August 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 February 17, 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 17, 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 17, 2020 [Page 13]
-
-Internet-Draft JSON Schema Validation August 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 February 17, 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.
-
-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 February 17, 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].
-
- 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 February 17, 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
- 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 February 17, 2020 [Page 17]
-
-Internet-Draft JSON Schema Validation August 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 February 17, 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
-
- 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 February 17, 2020 [Page 19]
-
-Internet-Draft JSON Schema Validation August 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 February 17, 2020 [Page 20]
-
-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: .
-
-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 February 17, 2020 [Page 21]
-
-Internet-Draft JSON Schema Validation August 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 February 17, 2020 [Page 22]
-
-Internet-Draft JSON Schema Validation August 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-WIP
- (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]
-
-Internet-Draft JSON Schema Validation August 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 February 17, 2020 [Page 24]
-
-Internet-Draft JSON Schema Validation August 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 February 17, 2020 [Page 25]
-
-Internet-Draft JSON Schema Validation August 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 (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.
-
-
-
-
-
-
-Wright, et al. Expires February 17, 2020 [Page 26]
-
-Internet-Draft JSON Schema Validation August 2019
-
-
-Appendix C. ChangeLog
-
- [[CREF8: This section to be removed before leaving Internet-Draft
- status.]]
-
- draft-handrews-json-schema-validation-WIP
-
- * 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
-
-
-
-
-Wright, et al. Expires February 17, 2020 [Page 27]
-
-Internet-Draft JSON Schema Validation August 2019
-
-
- * 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 February 17, 2020 [Page 28]
-
-Internet-Draft JSON Schema Validation August 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 February 17, 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
- 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 February 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 c5b3a20c..00000000
--- a/work-in-progress/WIP-links.json
+++ /dev/null
@@ -1,91 +0,0 @@
-{
- "$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" ] },
- { "$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-WIP/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-WIP/hyper-schema",
- "default": true
- },
- "targetMediaType": {
- "type": "string"
- },
- "targetHints": { },
- "headerSchema": {
- "$recursiveRef": "http://json-schema.org/draft/2019-WIP/hyper-schema",
- "default": true
- },
- "submissionMediaType": {
- "type": "string",
- "default": "application/json"
- },
- "submissionSchema": {
- "$recursiveRef": "http://json-schema.org/draft/2019-WIP/hyper-schema",
- "default": true
- },
- "$comment": {
- "type": "string"
- }
- }
- }
- }
-}
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 7c23f8ff..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: February 17, 2020 August 16, 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 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.
-
-
-
-
-Luff & Andrews Expires February 17, 2020 [Page 1]
-
-Internet-Draft Relative JSON Pointers August 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 February 17, 2020 [Page 2]
-
-Internet-Draft Relative JSON Pointers August 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 February 17, 2020 [Page 3]
-
-Internet-Draft Relative JSON Pointers August 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 February 17, 2020 [Page 4]
-
-Internet-Draft Relative JSON Pointers August 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 February 17, 2020 [Page 5]
-
-Internet-Draft Relative JSON Pointers August 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 February 17, 2020 [Page 6]
-
-Internet-Draft Relative JSON Pointers August 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 February 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 6765ac43..00000000
--- a/work-in-progress/WIP-schema.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
- "$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-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
- },
- "$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 c8d5a464..4455aec4 100644
--- a/work-in-progress/index.md
+++ b/work-in-progress/index.md
@@ -7,115 +7,8 @@ permalink: /work-in-progress
* TOC
{:toc}
-## The Next Draft (by whatever name) Is Approaching Publication!
+Draft 2019-09 has been [published](/specification.html)!
-The draft is feature-complete, including late additions based on our first try at a final review period several months ago.
-
-We will be working on a more user-friendly and extensive guide to the new draft shortly.
-
-### 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._
-
-## 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.
-
-## 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
-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 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 73788361..00000000
--- a/work-in-progress/meta/WIP-applicator.json
+++ /dev/null
@@ -1,60 +0,0 @@
-{
- "$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-WIP/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 79882081..00000000
--- a/work-in-progress/meta/WIP-content.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "$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-WIP/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 82ad7e25..00000000
--- a/work-in-progress/meta/WIP-core.json
+++ /dev/null
@@ -1,52 +0,0 @@
-{
- "$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-WIP/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
deleted file mode 100644
index 7a2bd28f..00000000
--- a/work-in-progress/meta/WIP-format.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "$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-WIP/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 357747c6..00000000
--- a/work-in-progress/meta/WIP-hyper-schema.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "$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-WIP/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-WIP/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 0bbbdeaf..00000000
--- a/work-in-progress/meta/WIP-meta-data.json
+++ /dev/null
@@ -1,37 +0,0 @@
-{
- "$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-WIP/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 4d5fcc96..00000000
--- a/work-in-progress/meta/WIP-validation.json
+++ /dev/null
@@ -1,98 +0,0 @@
-{
- "$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-WIP/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 ebb53d46..00000000
--- a/work-in-progress/output/WIP-hyper-schema.json
+++ /dev/null
@@ -1,62 +0,0 @@
-{
- "$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-WIP/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
deleted file mode 100644
index 45187ee0..00000000
--- a/work-in-progress/output/WIP-schema.json
+++ /dev/null
@@ -1,86 +0,0 @@
-{
- "$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": [
- { "$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 ef50444f..00000000
--- a/work-in-progress/output/WIP-verbose-example.json
+++ /dev/null
@@ -1,130 +0,0 @@
-{
- "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": "#"
- }
- ]
-}