diff --git a/documentation.html b/documentation.html index 9c6e36fe..91086ab3 100644 --- a/documentation.html +++ b/documentation.html @@ -4,7 +4,8 @@
The latest IETF published draft is v4. The specification is split into three parts: +
The latest IETF published draft is v5, although due to a change in authorship + the I-D numbering has been reset to 00. The specification is split into three parts:
They are also available on the IETF main site: core, validation and hyper-schema. +
They are also available on the IETF main site: core, validation and hyper-schema.
TOC |
|
- JSON Schema defines the media type "application/schema+json", a JSON based format - for defining the structure of JSON data. JSON Schema provides a contract for what - JSON data is required for a given application and how to interact with it. JSON - Schema is intended to define validation, documentation, hyperlink navigation, and - interaction control of JSON data. - -
--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 August 3, 2013.
- --Copyright (c) 2013 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.
-
-1.
-Introduction
-2.
-Conventions and Terminology
-3.
-Core terminology
- 3.1.
-Property, item
- 3.2.
-JSON Schema, keywords
- 3.3.
-Empty schema
- 3.4.
-Root schema, subschema
- 3.5.
-JSON Schema primitive types
- 3.6.
-JSON value equality
- 3.7.
-Instance
-4.
-Overview
- 4.1.
-Validation
- 4.2.
-Hypermedia and linking
-5.
-General considerations
- 5.1.
-Applicability to all JSON values
- 5.2.
-Programming language independence
- 5.3.
-JSON Schema and HTTP
- 5.4.
-JSON Schema and other protocols
- 5.5.
-Mathematical integers
- 5.6.
-Extending JSON Schema
- 5.7.
-Security considerations
-6.
-The "$schema" keyword
- 6.1.
-Purpose
- 6.2.
-Customization
-7.
-URI resolution scopes and dereferencing
- 7.1.
-Definition
- 7.2.
-URI resolution scope alteration with the "id" keyword
- 7.2.1.
-Valid values
- 7.2.2.
-Usage
- 7.2.3.
-Canonical dereferencing and inline dereferencing
- 7.2.4.
-Inline dereferencing and fragments
- 7.3.
-Security considerations
-8.
-Recommended correlation mechanisms for use with the HTTP protocol
- 8.1.
-Correlation by means of the "Content-Type" header
- 8.2.
-Correlation by means of the "Link" header
-9.
-IANA Considerations
-10.
-References
- 10.1.
-Normative References
- 10.2.
-Informative References
-Appendix A.
-ChangeLog
-
TOC |
- JSON Schema is a JSON media type for defining the structure of JSON data. JSON - Schema provides a contract for what JSON data is required for a given application - and how to interact with it. 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; related - specifications build upon this specification and define different applications of - JSON Schema. - -
-TOC |
- - 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 (Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels,” March 1997.) [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 4627 (Crockford, D., “The application/json Media Type for JavaScript Object Notation (JSON),” July 2006.) [RFC4627]. - -
-TOC |
TOC |
- When refering to a JSON Object, as defined by [RFC4627] (Crockford, D., “The application/json Media Type for JavaScript Object Notation (JSON),” July 2006.), the - terms "member" and "property" may be used interchangeably. - -
-- When refering to a JSON Array, as defined by [RFC4627] (Crockford, D., “The application/json Media Type for JavaScript Object Notation (JSON),” July 2006.), the terms - "element" and "item" may be used interchangeably. - -
-TOC |
- A JSON Schema is a JSON document, and that document MUST be an object. Object - members (or properties) defined by JSON Schema (this specification, or related - specifications) are called keywords, or schema keywords. - -
-- A JSON Schema MAY contain properties which are not schema keywords. - -
-TOC |
- An empty schema is a JSON Schema with no properties, or with properties which - are not schema keywords. - -
-TOC |
- This example of a JSON Schema has no subschemas: - -
+ -{ - "title": "root" -} +
Internet Engineering Task Force | +A. Wright, Ed. | +
Internet-Draft | +November 3, 2016 | +
Intended status: Informational | ++ |
Expires: May 7, 2017 | ++ |
JSON Schema: A Media Type for Describing JSON Documents
+ draft-wright-json-schema-00
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, ideal for annotating existing JSON APIs that would not otherwise have hypermedia controls or be machine-readable.
+The issues list for this draft can be found at <https://github.com/json-schema-org/json-schema-spec/issues>.
+For additional information, see <http://json-schema.org/>.
+To provide feedback, use this issue tracker, the communication methods listed on the homepage, or email the document editors.
+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 May 7, 2017.
+Copyright (c) 2016 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, specifying the vocabulary being used, and declaring the minimum functionality necessary for processing an instance against a schema.
+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 JSON Schema for describing JSON data. JSON Schemas are themselves written in JSON. This, and related specifications, define keywords allowing to describe this data in terms of allowable values, textual descriptions and interpreting relations with other resources. The following sections are a summary of features defined by related specifications.
+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 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 interchangable because of the data model it defines.
+JSON Schema interperts documents according to a data model. A JSON value interperted 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:
+ ++
Whitespace and formatting conserns are thus outside the scope of JSON Schema.
+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.
+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:
+ +- JSON Schemas can also be nested, as in this example: - -
++
Implied in this definition is that arrays must be the same length, objects must have the same number of members, properties in objects are unordered, there is no way to define multiple properties with the same key, and mere formatting differences (indentation, placement of commas, trailing zeros) are insignificant.
+4.4. JSON Schema document
+A JSON Schema document, or simply a schema, is a JSON document used to describe an instance. A schema is itself interperted as an instance. A JSON schema MUST be an object.
+Properties that are used to describe the instance are called keywords, or schema keywords. The meaning of properties is specified by the vocabulary that the schema is using.
+A JSON Schema MAY contain properties which are not schema keywords. Unknown keywords SHOULD be ignored.
+A schema that itself describes a schema is called a meta-schema. Meta-schemas are used to validate JSON Schemas and specify which vocabulary it is using.
+An empty schema is a JSON Schema with no properties, or only unknown properties.
+4.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:
+{ "title": "root", - "otherSchema": { - "title": "nested", - "anotherSchema": { - "title": "alsoNested" - } + "items": { + "title": "array item" } } -
- In this example, "nested" and "alsoNested" are subschemas, and "root" is a root - schema. - -
-TOC |
- JSON Schema defines seven primitive types for JSON values: -
--
- array
-- A JSON array. -
-- boolean
-- A JSON boolean. -
-- integer
-- A JSON number without a fraction or exponent part. -
-- number
-- Any JSON number. Number includes integer. -
-- null
-- The JSON null value. -
-- object
-- A JSON object. -
-- string
-- A JSON string. -
-
- -
-TOC |
- Two JSON values are said to be equal if and only if: - -
--both are nulls; or -
-both are booleans, and have the same value; or -
-both are strings, and have the same value; or -
-both are numbers, and have the same mathematical value; or -
-both are arrays, and: -
--- - -have the same number of items; and -
-items at the same index are equal according to this definition; - or -
-both are objects, and: -
--- - -have the same set of property names; and -
-values for a same property name are equal according to this - definition. -
-
- -
-TOC |
- An instance is any JSON value. An instance may be described by one or more - schemas. - -
-- An instance may also be referred to as "JSON instance", or "JSON data". - -
-TOC |
- This document proposes a new media type "application/schema+json" to identify JSON - Schema for describing JSON data. JSON Schemas are themselves written in JSON. This, - and related specifications, define keywords allowing to describe this data in terms - of allowable values, textual descriptions and interpreting relations with other - resources. The following sections are a summary of features defined by related - specifications. - -
-TOC |
- JSON Schema allows applications to validate instances, either non interactively - or interactively. For instance, an application may collect JSON data and check - that this data matches a given set of constraints; another application may use a - JSON Schema to build an interactive interface in order to collect user input - according to constraints described by JSON Schema. - -
-TOC |
- JSON Schema provides a method for extracting link relations from instances to - other resources, as well as describing interpretations of instances as - multimedia data. This allows JSON data to be interpreted as rich hypermedia - documents, placed in the context of a larger set of related resources. - -
-TOC |
TOC |
- It is acknowledged that an instance may be any valid JSON value as defined - by [RFC4627] (Crockford, D., “The application/json Media Type for JavaScript Object Notation (JSON),” July 2006.). As such, JSON Schema does not mandate that an - instance be of a particular type: JSON Schema can describe any JSON value, - including null. - -
-TOC |
- JSON Schema is programming language agnostic. The only limitations are the ones - expressed by [RFC4627] (Crockford, D., “The application/json Media Type for JavaScript Object Notation (JSON),” July 2006.) and those of the host programming - language. - -
-TOC |
- This specification acknowledges the role of HTTP (Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, “Hypertext Transfer Protocol -- HTTP/1.1,” June 1999.) [RFC2616] - as the dominant protocol in use on the Internet, and the wealth of - official specifications related to it. - -
-- This specification uses a subset of these specifications to recommend a set of - mechanisms, usable by this protocol, to associate JSON instances to one or more - schemas. - -
-TOC |
- JSON Schema does not define any semantics for the client-server interface for - any other protocols than HTTP. These semantics are application dependent, or - subject to agreement between the parties involved in the use of JSON Schema for - their own needs. - -
-TOC |
- It is acknowledged by this specification that some programming languages, and - their associated parsers, use different internal representations for floating - point numbers and integers, while others do not. - -
-- As a consequence, for interoperability reasons, JSON values used in the context - of JSON Schema, whether that JSON be a JSON Schema or an instance, SHOULD ensure - that mathematical integers be represented as integers as defined by this - specification. - -
-TOC |
- Implementations MAY choose to 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. - -
-TOC |
- Both schemas and instances are JSON values. As such, all security considerations - defined in RFC 4627 (Crockford, D., “The application/json Media Type for JavaScript Object Notation (JSON),” July 2006.) [RFC4627] apply. - -
-TOC |
TOC |
- 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. - -
-- This keyword MUST be located at the root of a JSON Schema. The value of this - keyword MUST be a URI (Berners-Lee, T., Fielding, R., and L. Masinter, “Uniform Resource Identifier (URI): Generic Syntax,” January 2005.) [RFC3986] and a valid JSON Reference (Bryan, P. and K. Zyp, “JSON Reference (work in progress),” September 2012.) [json‑reference]; this URI MUST be both absolute - and normalized. The resource located at this URI MUST successfully describe - itself. It is RECOMMENDED that schema authors include this keyword in their - schemas. - -
-- The following values are predefined: - -
--
- http://json-schema.org/schema#
-- JSON Schema written against - the current version of the specification. -
-- http://json-schema.org/hyper-schema#
-- JSON Schema written - against the current version of the specification. -
-- http://json-schema.org/draft-04/schema#
-- JSON Schema written - against this version. -
-- http://json-schema.org/draft-04/hyper-schema#
-- JSON Schema hyperschema - written against this version. -
-- http://json-schema.org/draft-03/schema#
-- JSON Schema written - against JSON Schema, draft v3 (Court, G. and K. Zyp, “JSON Schema, draft 3,” September 2012.) [json‑schema‑03]. -
-- http://json-schema.org/draft-03/hyper-schema#
-- JSON Schema hyperschema - written against JSON Schema, draft - v3 (Court, G. and K. Zyp, “JSON Schema, draft 3,” September 2012.) [json‑schema‑03]. -
-
- -
-TOC |
- When extending JSON Schema with custom keywords, schema authors SHOULD define a - custom URI for "$schema". This custom URI MUST NOT be one of the predefined - values. - -
-TOC |
TOC |
- JSON Schema uses JSON Reference (Bryan, P. and K. Zyp, “JSON Reference (work in progress),” September 2012.) [json‑reference] as a - mechanism for schema addressing. It extends this specification in two ways: - -
--JSON Schema offers facilities to alter the base URI against which a - reference must resolve by the means of the "id" keyword; -
-it defines a specific dereferencing mechanism extending JSON Reference to - accept arbitrary fragment parts. -
-
- - -
-- Altering the URI within a schema is called defining a new resolution scope. The - initial resolution scope of a schema is the URI of the schema itself, if any, or - the empty URI if the schema was not loaded from a URI. - -
-TOC |
TOC |
- The value for this keyword MUST be a string, and MUST be a valid URI. This - URI MUST be normalized, and SHOULD NOT be an empty fragment (#) or the empty - URI. - -
-TOC |
- The "id" keyword (or "id", for short) is used to alter the resolution scope. - When an id is encountered, an implementation MUST resolve this id against - the most immediate parent scope. The resolved URI will be the new resolution - scope for this subschema and all its children, until another id is - encountered. - -
-- When using "id" to alter resolution scopes, schema authors SHOULD ensure - that resolution scopes are unique within the schema. - -
-- This schema will be taken as an example: - -
++
In this example document, the schema titled "array item" is a subschema, and the schema titled "root" is the root schema.
+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.
+Some programming languages and parsers use different internal representations for floating point numbers than they do for integers.
+For constistency, integer JSON numbers SHOULD NOT be encoded with a fractional part.
+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.
+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 root schema of a JSON Schema document SHOULD use this keyword. The value of this keyword MUST be a URI [RFC3986] (an "absolute" URI), and this URI MUST be normalized. The current schema MUST be valid against the meta-schema identified by this URI.
+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.
+Any time a subschema is expected, a schema may instead use an object containing a "$ref" property. The value of the $ref is 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-addressible URL, and implementations SHOULD NOT assume they should perform a network operation when they encounter a network-addressible 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.
+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 it was found at, or a suitable substitute URI if none is known.
+The "id" keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. The "id" keyword itself is resolved against the base URI that the object as a whole appears in.
+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 (containing a scheme, but no fragment).
+To name subschemas in a JSON Schema document, subschemas can use "id" to give themselves a document-local identifier. This form of "id" keyword MUST begin with a hash ("#") to identify it as a fragment URI reference, followed by a letter ([A-Za-z]), followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), or periods (".").
+{ - "id": "http://x.y.z/rootschema.json#", - "schema1": { - "id": "#foo" - }, - "schema2": { - "id": "otherschema.json", - "nested": { - "id": "#bar" + "id": "http://example.com/root.json", + "definitions": { + "A": { "id": "#foo" }, + "B": { + "id": "other.json", + "definitions": { + "X": { "id": "#bar" }, + "Y": { "id": "t/inner.json" } + } }, - "alsonested": { - "id": "t/inner.json#a" + "C": { + "id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f" } - }, - "schema3": { - "id": "some://where.else/completely#" } } -
- Subschemas at the following URI-encoded JSON - Pointer (Bryan, P. and K. Zyp, “JSON Pointer (work in progress),” September 2012.) [json‑pointer]s (starting from the root schema) define the following - resolution scopes: - -
--
- # (document root)
-- http://x.y.z/rootschema.json# -
-- #/schema1
-- http://x.y.z/rootschema.json#foo -
-- #/schema2
-- http://x.y.z/otherschema.json# -
-- #/schema2/nested
-- http://x.y.z/otherschema.json#bar -
-- #/schema2/alsonested
-- http://x.y.z/t/inner.json#a -
-- #/schema3
-- some://where.else/completely# -
-
- -
-TOC |
- When resolving a URI against a resolution scope, an implementation may - choose two modes of operation: - -
--
- canonical dereferencing
-- The implementation dereferences - all resolved URIs. -
-- inline dereferencing
-- The implementation chooses to - dereference URIs within the schema. -
-
- -
-- Implementations MUST support canonical dereferencing, and MAY support inline - dereferencing. - -
-- For example, consider this schema: - -
++
For example:
+The schemas at the following URI-encoded JSON Pointers [RFC6901] (relative to the root schema) have the following base URIs, and are identifiable by either URI:
+ + ++
Schemas can be identified by any URI that has been given to them, including a JSON Pointer or their URI given directly by "id".
+Tools SHOULD take note of the URIs that schemas, including subschemas, provide for themselves using "id". This is known as "Internal referencing".
+For example, consider this schema:
+{ - "id": "http://my.site/myschema#", + "id": "http://example.net/root.json", + "items": { + "type": "array", + "items": { "$ref": "#item" } + }, "definitions": { - "schema1": { - "id": "schema1", + "single": { + "id": "#item", "type": "integer" }, - "schema2", { - "type": "array", - "items": { "$ref": "schema1" } - } } } -
- When an implementation encounters the "schema1" reference, it resolves it - against the most immediate parent scope, leading to URI - "http://my.site/schema1#". The way to process this URI will differ - according to the chosen dereferencing mode: - -
--if canonical dereferencing is used, the implementation will - dereference this URI, and fetch the content at this URI; -
-if inline dereferencing is used, the implementation will notice that - URI scope "http://my.site/schema1#" is already defined within the - schema, and choose to use the appropriate subschema. -
-
- -
-TOC |
- When using inline dereferencing, a resolution scope may lead to a URI which - has a non empty fragment part which is not a JSON Pointer, as in this - example: - -
- -{ - "id": "http://some.site/schema#", - "not": { "$ref": "#inner" }, - "definitions": { - "schema1": { - "id": "#inner", - "type": "boolean" - } - } -} - -
- An implementation choosing to support inline dereferencing SHOULD be able to - use this kind of reference. Implementations choosing to use canonical - dereferencing, however, are not required to support it. - -
-TOC |
- Inline dereferencing can produce canonical URIs which differ from the canonical URI - of the root schema. Schema authors SHOULD ensure that implementations using - canonical dereferencing obtain the same content as implementations using inline - dereferencing. - -
-- Extended JSON References using fragments which are not JSON Pointers are not - dereferenceable by implementations choosing not to support inline dereferencing. - This kind of reference is defined for backwards compatibility, and SHOULD NOT be - used in new schemas. - -
-TOC |
- It is acknowledged by this specification that the majority of interactive JSON - Schema processing will be over HTTP. This section therefore gives recommendations - for materializing an instance/schema correlation using mechanisms currently - available for this protocol. An instance is said to be described by one (or more) - schema(s). - -
-TOC |
- It is RECOMMENDED that a MIME type parameter by the name of "profile" be - appended to the "Content-Type" header of the instance being processed. If - present, the value of this parameter MUST be a valid URI, and this URI SHOULD - resolve to a valid JSON Schema. The MIME type MUST be "application/json", or any - other subtype. - -
-- An example of such a header would be: - -
- -Content-Type: application/my-media-type+json; - profile=http://example.com/my-hyper-schema# - -
TOC |
- When using the "Link" header, the relation type used MUST be "describedBy", as - defined by RFC 5988, section 5.3 (Nottingham, M., “Web Linking,” October 2010.) [RFC5988]. The target URI - of the "Link" header MUST be a valid JSON Schema. - -
-- An example of such a header would be: - -
- -Link: <http://example.com/my-hyper-schema#>; rel="describedBy" - -
TOC |
- The proposed MIME media type for JSON Schema is defined as follows: - -
--type name: application; -
-subtype name: schema+json. -
-
- -
-TOC |
TOC |
[RFC2119] | -Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels,” BCP 14, RFC 2119, March 1997 (TXT, HTML, XML). |
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 is understood as the schema defined elsewhere in the same document.
+To differentiate schemas between each other in a vast ecosystem, schemas are identified by URI. As specified above, this does not necessarially mean anything is downloaded, but instead JSON Schema implementations SHOULD already understand the schemas they will be using, including the URIs that identify them.
+Implementations SHOULD be able to associate arbritrary URIs with an arbritrary schema and/or automatically associate a schema's "id"-given URI, depending on the trust that the the validator has in the schema.
+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 with the same URI, validators SHOULD raise an error condition.
+One of the largest adoptors of JSON has been 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 [RFC5988].
+It is RECOMMENDED that instances described by a schema/profile 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 [RFC5988]. An example of such a header would be:
++ +Link: <http://example.com/my-hyper-schema#>; rel="describedby" + ++
Instances MAY specify a "profile" as described in The 'profile' Link Relation [RFC6906]. When used as a media-type parameter, HTTP servers gain the ability to perform Content-Type Negotiation based on profile. The media-type parameter MUST be a whitespace-separated list of URIs (i.e. relative references are invalid).
+The profile URI is opaque and SHOULD NOT automatically be dereferenced. If the implementation does not understand the semantics of the provided profile, the implementation can instead follow the "describedby" links, if any, which may provide information on how to handle the profile. Since "profile" 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; + profile="http://example.com/my-hyper-schema#" + ++
Multiple profiles are whitespace seperated:
++ +Content-Type: application/json; + profile="http://example.com/alice http://example.com/bob" + ++
HTTP can also send the "profile" in a Link, though this may impact media-type semantics and Content-Type negotiation if this replaces the media-type parameter entirely:
++ +Link: </alice>;rel="profile", </bob>;rel="profile" + ++
When used for hypermedia systems over a network, HTTP [RFC7231] is frequently the protocol of choice for distributing schemas. Misbehaved clients can pose problems for server maintainers if they pull a schema over the network more frequently than necessary, when it's instead possible to cache a schema for a long period of time.
+HTTP servers SHOULD set long-lived caching headers on JSON Schemas. HTTP clients SHOULD observe caching headers and not re-request documents within their freshness period. Distributed systems SHOULD make use of a shared cache and/or caching proxy.
++ +User-Agent: so-cool-json-schema/1.0.2 curl/7.43.0 + ++
Clients SHOULD set or prepend a User-Agent header specific to the JSON Schema implementation or software product. Since symbols are listed in decreasing order of significance, the JSON Schema library name/version goes first, then 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 witten by untrusted third parties, to be deployed on public Internet servers. Validators should take care that the parsing of schemas doesn't consume excessive system resources. Validators MUST NOT fall into an infinite loop.
+Servers need to take care 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.
+The proposed MIME media type for JSON Schema is defined as follows:
+ +TOC |
[RFC2616] | -Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, “Hypertext Transfer Protocol -- HTTP/1.1,” RFC 2616, June 1999 (TXT, PS, PDF, HTML, XML). |
[RFC3986] | -Berners-Lee, T., Fielding, R., and L. Masinter, “Uniform Resource Identifier (URI): Generic Syntax,” STD 66, RFC 3986, January 2005 (TXT, HTML, XML). |
[RFC4627] | -Crockford, D., “The application/json Media Type for JavaScript Object Notation (JSON),” RFC 4627, July 2006 (TXT). |
[RFC5988] | -Nottingham, M., “Web Linking,” RFC 5988, October 2010 (TXT). |
[json-reference] | -Bryan, P. and K. Zyp, “JSON Reference (work in progress),” September 2012. |
[json-pointer] | -Bryan, P. and K. Zyp, “JSON Pointer (work in progress),” September 2012. |
[json-schema-03] | -Court, G. and K. Zyp, “JSON Schema, draft 3,” September 2012. |
+ [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. | +
+ [RFC7159] + | +Bray, T., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March 2014. | +
+ [W3C.REC-ldp-20150226] + | +Speicher, S., Arwe, J. and A. Malhotra, "Linked Data Platform 1.0", World Wide Web Consortium Recommendation REC-ldp-20150226, February 2015. | +
TOC |
-
--
- draft-00
-- - -
--
- -- Initial draft. -
-- Salvaged from draft v3. -
-- Mandate the use of JSON Reference, JSON Pointer. -
-- Define the role of "id". Define URI resolution scope. -
-- Add interoperability considerations. -
-
- -
-TOC |
- | Francis Galiegue |
EMail: | -fgaliegue@gmail.com |
- | Kris Zyp (editor) |
- | SitePen (USA) |
- | 530 Lytton Avenue |
- | Palo Alto, CA 94301 |
- | USA |
Phone: | -+1 650 968 8787 |
EMail: | -kris@sitepen.com |
- | Gary Court |
- | Calgary, AB |
- | Canada |
EMail: | -gary.court@gmail.com |
+ [RFC5988] + | +Nottingham, M., "Web Linking", RFC 5988, DOI 10.17487/RFC5988, October 2010. | +
+ [RFC6901] + | +Bryan, P., Zyp, K. and M. Nottingham, "JavaScript Object Notation (JSON) Pointer", RFC 6901, DOI 10.17487/RFC6901, April 2013. | +
+ [RFC6906] + | +Wilde, E., "The 'profile' Link Relation Type", RFC 6906, DOI 10.17487/RFC6906, March 2013. | +
+ [RFC7231] + | +Fielding, R. and J. Reschke, "Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content", RFC 7231, DOI 10.17487/RFC7231, June 2014. | +
+ [json-schema-validation] + | +Wright, A. and G. Luff, "JSON Schema Validation: A Vocabulary for Structural Validation of JSON", Internet-Draft draft-wright-json-schema-validation-00, October 2016. | +
+ [json-hyper-schema] + | +Wright, A. and G. Luff, "JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON", Internet-Draft draft-wright-json-schema-hyperschema-00, October 2016. | +
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, and Henry H. Andrews for their submissions and patches to the document.
+[CREF1]This section to be removed before leaving Internet-Draft status.
+ + ++
+
+
+