diff --git a/documentation.html b/documentation.html index 9c6e36fe..91086ab3 100644 --- a/documentation.html +++ b/documentation.html @@ -4,7 +4,8 @@

Specification

-

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:

@@ -22,7 +23,7 @@

Specification

-

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.

Meta-schemas

diff --git a/draft-wright-00/hyper-schema b/draft-wright-00/hyper-schema new file mode 100644 index 00000000..f8b13447 --- /dev/null +++ b/draft-wright-00/hyper-schema @@ -0,0 +1,131 @@ +{ + "$schema": "http://json-schema.org/draft-wright-00/hyper-schema#", + "id": "http://json-schema.org/draft-wright-00/hyper-schema#", + "title": "JSON Hyper-Schema", + "allOf": [ + {"$ref": "http://json-schema.org/draft-wright-00/schema#"} + ], + "properties": { + "additionalItems": { + "anyOf": [ + {"type": "boolean"}, + {"$ref": "#"} + ] + }, + "additionalProperties": { + "anyOf": [ + {"type": "boolean"}, + {"$ref": "#"} + ] + }, + "dependencies": { + "additionalProperties": { + "anyOf": [ + {"$ref": "#"}, + {"type": "array"} + ] + } + }, + "items": { + "anyOf": [ + {"$ref": "#"}, + {"$ref": "#/definitions/schemaArray"} + ] + }, + "definitions": { + "additionalProperties": {"$ref": "#"} + }, + "patternProperties": { + "additionalProperties": {"$ref": "#"} + }, + "properties": { + "additionalProperties": {"$ref": "#"} + }, + "allOf": {"$ref": "#/definitions/schemaArray"}, + "anyOf": {"$ref": "#/definitions/schemaArray"}, + "oneOf": {"$ref": "#/definitions/schemaArray"}, + "not": { "$ref": "#" }, + + "links": { + "type": "array", + "items": {"$ref": "#/definitions/linkDescription"} + }, + "fragmentResolution": { + "type": "string" + }, + "media": { + "type": "object", + "properties": { + "type": { + "description": "A media type, as described in RFC 2046", + "type": "string" + }, + "binaryEncoding": { + "description": "A content encoding scheme, as described in RFC 2045", + "type": "string" + } + } + }, + "pathStart": { + "description": "Instances' URIs must start with this value for this schema to apply to them", + "type": "string", + "format": "uri" + } + }, + "definitions": { + "schemaArray": { + "type": "array", + "items": {"$ref": "#"} + }, + "linkDescription": { + "title": "Link Description Object", + "type": "object", + "required": ["href", "rel"], + "properties": { + "href": { + "description": "a URI template, as defined by RFC 6570, with the addition of the $, ( and ) characters for pre-processing", + "type": "string" + }, + "rel": { + "description": "relation to the target resource of the link", + "type": "string" + }, + "title": { + "description": "a title for the link", + "type": "string" + }, + "targetSchema": { + "description": "JSON Schema describing the link target", + "$ref": "#" + }, + "mediaType": { + "description": "media type (as defined by RFC 2046) describing the link target", + "type": "string" + }, + "method": { + "description": "method for requesting the target of the link (e.g. for HTTP this might be \"GET\" or \"DELETE\")", + "type": "string" + }, + "encType": { + "description": "The media type in which to submit data along with the request", + "type": "string", + "default": "application/json" + }, + "schema": { + "description": "Schema describing the data to submit along with the request", + "$ref": "#" + } + } + } + }, + "links": [ + { + "rel": "self", + "href": "{+id}" + }, + { + "rel": "full", + "href": "{+($ref)}" + } + ] +} diff --git a/draft-wright-00/schema b/draft-wright-00/schema new file mode 100644 index 00000000..cff8e562 --- /dev/null +++ b/draft-wright-00/schema @@ -0,0 +1,151 @@ +{ + "id": "http://json-schema.org/draft-wright-00/schema#", + "$schema": "http://json-schema.org/draft-wright-00/schema#", + "description": "Core schema meta-schema", + "definitions": { + "schemaArray": { + "type": "array", + "minItems": 1, + "items": { "$ref": "#" } + }, + "positiveInteger": { + "type": "integer", + "minimum": 0 + }, + "positiveIntegerDefault0": { + "allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ] + }, + "simpleTypes": { + "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ] + }, + "stringArray": { + "type": "array", + "items": { "type": "string" }, + "minItems": 1, + "uniqueItems": true + } + }, + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uri" + }, + "$schema": { + "type": "string", + "format": "uri" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "default": {}, + "multipleOf": { + "type": "number", + "minimum": 0, + "exclusiveMinimum": true + }, + "maximum": { + "type": "number" + }, + "exclusiveMaximum": { + "type": "boolean", + "default": false + }, + "minimum": { + "type": "number" + }, + "exclusiveMinimum": { + "type": "boolean", + "default": false + }, + "maxLength": { "$ref": "#/definitions/positiveInteger" }, + "minLength": { "$ref": "#/definitions/positiveIntegerDefault0" }, + "pattern": { + "type": "string", + "format": "regex" + }, + "additionalItems": { + "anyOf": [ + { "type": "boolean" }, + { "$ref": "#" } + ], + "default": {} + }, + "items": { + "anyOf": [ + { "$ref": "#" }, + { "$ref": "#/definitions/schemaArray" } + ], + "default": {} + }, + "maxItems": { "$ref": "#/definitions/positiveInteger" }, + "minItems": { "$ref": "#/definitions/positiveIntegerDefault0" }, + "uniqueItems": { + "type": "boolean", + "default": false + }, + "maxProperties": { "$ref": "#/definitions/positiveInteger" }, + "minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" }, + "required": { "$ref": "#/definitions/stringArray" }, + "additionalProperties": { + "anyOf": [ + { "type": "boolean" }, + { "$ref": "#" } + ], + "default": {} + }, + "definitions": { + "type": "object", + "additionalProperties": { "$ref": "#" }, + "default": {} + }, + "properties": { + "type": "object", + "additionalProperties": { "$ref": "#" }, + "default": {} + }, + "patternProperties": { + "type": "object", + "additionalProperties": { "$ref": "#" }, + "default": {} + }, + "dependencies": { + "type": "object", + "additionalProperties": { + "anyOf": [ + { "$ref": "#" }, + { "$ref": "#/definitions/stringArray" } + ] + } + }, + "enum": { + "type": "array", + "minItems": 1, + "uniqueItems": true + }, + "type": { + "anyOf": [ + { "$ref": "#/definitions/simpleTypes" }, + { + "type": "array", + "items": { "$ref": "#/definitions/simpleTypes" }, + "minItems": 1, + "uniqueItems": true + } + ] + }, + "format": { "type": "string" }, + "allOf": { "$ref": "#/definitions/schemaArray" }, + "anyOf": { "$ref": "#/definitions/schemaArray" }, + "oneOf": { "$ref": "#/definitions/schemaArray" }, + "not": { "$ref": "#" } + }, + "dependencies": { + "exclusiveMaximum": [ "maximum" ], + "exclusiveMinimum": [ "minimum" ] + }, + "default": {} +} diff --git a/hyper-schema b/hyper-schema index 853bd35f..f8b13447 100644 --- a/hyper-schema +++ b/hyper-schema @@ -1,88 +1,54 @@ { - "$schema": "http://json-schema.org/draft-04/hyper-schema#", - "id": "http://json-schema.org/draft-04/hyper-schema#", + "$schema": "http://json-schema.org/draft-wright-00/hyper-schema#", + "id": "http://json-schema.org/draft-wright-00/hyper-schema#", "title": "JSON Hyper-Schema", "allOf": [ - { - "$ref": "http://json-schema.org/draft-04/schema#" - } + {"$ref": "http://json-schema.org/draft-wright-00/schema#"} ], "properties": { "additionalItems": { "anyOf": [ - { - "type": "boolean" - }, - { - "$ref": "#" - } + {"type": "boolean"}, + {"$ref": "#"} ] }, "additionalProperties": { "anyOf": [ - { - "type": "boolean" - }, - { - "$ref": "#" - } + {"type": "boolean"}, + {"$ref": "#"} ] }, "dependencies": { "additionalProperties": { "anyOf": [ - { - "$ref": "#" - }, - { - "type": "array" - } + {"$ref": "#"}, + {"type": "array"} ] } }, "items": { "anyOf": [ - { - "$ref": "#" - }, - { - "$ref": "#/definitions/schemaArray" - } + {"$ref": "#"}, + {"$ref": "#/definitions/schemaArray"} ] }, "definitions": { - "additionalProperties": { - "$ref": "#" - } + "additionalProperties": {"$ref": "#"} }, "patternProperties": { - "additionalProperties": { - "$ref": "#" - } + "additionalProperties": {"$ref": "#"} }, "properties": { - "additionalProperties": { - "$ref": "#" - } - }, - "allOf": { - "$ref": "#/definitions/schemaArray" - }, - "anyOf": { - "$ref": "#/definitions/schemaArray" - }, - "oneOf": { - "$ref": "#/definitions/schemaArray" - }, - "not": { - "$ref": "#" + "additionalProperties": {"$ref": "#"} }, + "allOf": {"$ref": "#/definitions/schemaArray"}, + "anyOf": {"$ref": "#/definitions/schemaArray"}, + "oneOf": {"$ref": "#/definitions/schemaArray"}, + "not": { "$ref": "#" }, "links": { "type": "array", - "items": { - "$ref": "#/definitions/linkDescription" - } + "items": {"$ref": "#/definitions/linkDescription"} }, "fragmentResolution": { "type": "string" @@ -109,14 +75,12 @@ "definitions": { "schemaArray": { "type": "array", - "items": { - "$ref": "#" - } + "items": {"$ref": "#"} }, "linkDescription": { "title": "Link Description Object", "type": "object", - "required": [ "href", "rel" ], + "required": ["href", "rel"], "properties": { "href": { "description": "a URI template, as defined by RFC 6570, with the addition of the $, ( and ) characters for pre-processing", @@ -165,4 +129,3 @@ } ] } - diff --git a/latest/json-schema-core.html b/latest/json-schema-core.html index c1735b9f..70d697a4 100644 --- a/latest/json-schema-core.html +++ b/latest/json-schema-core.html @@ -1,1091 +1,898 @@ - -JSON Schema: core definitions and terminology - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - ol.text { margin-left: 2em; margin-right: 2em; } - ul.text { margin-left: 2em; margin-right: 2em; } - li { margin-left: 3em; } - - /* RFC-2629 s and s. */ - em { font-style: italic; } - strong { font-weight: bold; } - dfn { font-weight: bold; font-style: normal; } - cite { font-weight: normal; font-style: normal; } - tt { color: #036; } - tt, pre, pre dfn, pre em, pre cite, pre span { - font-family: "Courier New", Courier, monospace; font-size: small; - } - pre { - text-align: left; padding: 4px; - color: #000; background-color: #CCC; - } - pre dfn { color: #900; } - pre em { color: #66F; background-color: #FFC; font-weight: normal; } - pre .key { color: #33C; font-weight: bold; } - pre .id { color: #900; } - pre .str { color: #000; background-color: #CFF; } - pre .val { color: #066; } - pre .rep { color: #909; } - pre .oth { color: #000; background-color: #FCF; } - pre .err { background-color: #FCC; } - - /* RFC-2629 s. */ - table.all, table.full, table.headers, table.none { - font-size: small; text-align: center; border-width: 2px; - vertical-align: top; border-collapse: collapse; - } - table.all, table.full { border-style: solid; border-color: black; } - table.headers, table.none { border-style: none; } - th { - font-weight: bold; border-color: black; - border-width: 2px 2px 3px 2px; - } - table.all th, table.full th { border-style: solid; } - table.headers th { border-style: none none solid none; } - table.none th { border-style: none; } - table.all td { - border-style: solid; border-color: #333; - border-width: 1px 2px; - } - table.full td, table.headers td, table.none td { border-style: none; } - - hr { height: 1px; } - hr.insert { - width: 80%; border-style: none; border-width: 0; - color: #CCC; background-color: #CCC; - } ---> - -
 TOC 
-
- - - - - - -
Internet Engineering Task Forcefge. Galiegue
Internet-Draft 
Intended status: InformationalK. Zyp, Ed.
Expires: August 3, 2013SitePen (USA)
 G. Court
 January 30, 2013
-


JSON Schema: core definitions and terminology
json-schema-core

- -

Abstract

- -

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

-

Status of This Memo

-

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

-

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

-

-Internet-Drafts are 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 Notice

-

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

-

-

Table of Contents

-

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

1.  -Introduction

- -

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

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

3.  -Core terminology

- -

-
 TOC 
-

3.1.  -Property, item

- -

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

3.2.  -JSON Schema, keywords

- -

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

3.3.  -Empty schema

- -

- An empty schema is a JSON Schema with no properties, or with properties which - are not schema keywords. - -

-

-
 TOC 
-

3.4.  -Root schema, subschema

- -

- This example of a JSON Schema has no subschemas: - -

+
 
-{
-    "title": "root"
-}
+  
+    
+    
+    	
+  
+  
+
+
+  
+  
+
+
+  
+  
+
+
+  
+  
+
+
+    	
+    
+  
Internet Engineering Task ForceA. Wright, Ed.
Internet-DraftNovember 3, 2016
Intended status: Informational
Expires: May 7, 2017
+ +

JSON Schema: A Media Type for Describing JSON Documents
+ draft-wright-json-schema-00

+ +

+ Abstract +

+

JSON Schema defines the media type "application/schema+json", a JSON based format for describing the structure of JSON data. JSON Schema asserts what a JSON document must look like, ways to extract information from it, and how to interact with it, ideal for annotating existing JSON APIs that would not otherwise have hypermedia controls or be machine-readable.

+

+ Note to Readers +

+

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

+

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

+

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

+

+ Status of This Memo +

+

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

+

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at 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 Notice +

+

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.

+ + +
+

Table of Contents

+ + +

1. Introduction

+

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

+

This specification defines JSON Schema core terminology and mechanisms, including pointing to another JSON Schema by reference, dereferencing a JSON Schema reference, specifying the vocabulary being used, and 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.

+

2. Conventions and Terminology

+

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

+

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

+

3. Overview

+

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.

+

3.1. Validation

+

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

+

Validation behaviour and keywords are specified in a separate document [json-schema-validation].

+

3.2. Hypermedia and linking

+

JSON Hyper-Schema describes the hypertext structure of a JSON document. This includes link relations from the instance to other resources, interpretation of instances as multimedia data, and submission data required to use an API.

+

Hyper-schema behaviour and keywords are specified in a separate document [json-hyper-schema].

+

4. Definitions

+

4.1. JSON document

+

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.

+

4.2. instance

+

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:

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

+

4.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 an equal key the other, and that other property has an equal value.
  • +
-
-

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

3.5.  -JSON Schema primitive types

- -

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

3.6.  -JSON value equality

- -

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

3.7.  -Instance

- -

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

4.  -Overview

- -

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

4.1.  -Validation

- -

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

4.2.  -Hypermedia and linking

- -

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

5.  -General considerations

- -

-
 TOC 
-

5.1.  -Applicability to all JSON values

- -

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

5.2.  -Programming language independence

- -

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

5.3.  -JSON Schema and HTTP

- -

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

5.4.  -JSON Schema and other protocols

- -

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

5.5.  -Mathematical integers

- -

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

5.6.  -Extending JSON Schema

- -

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

5.7.  -Security considerations

- -

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

6.  -The "$schema" keyword

- -

-
 TOC 
-

6.1.  -Purpose

- -

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

6.2.  -Customization

- -

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

7.  -URI resolution scopes and dereferencing

- -

-
 TOC 
-

7.1.  -Definition

- -

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

7.2.  -URI resolution scope alteration with the "id" keyword

- -

-
 TOC 
-

7.2.1.  -Valid values

- -

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

7.2.2.  -Usage

- -

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

+

5. General considerations

+

5.1. Range of JSON values

+

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

+

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

+

5.3. Mathematical integers

+

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.

+

5.4. Extending JSON Schema

+

Implementations MAY define additional keywords to JSON Schema. Save for explicit agreement, schema authors SHALL NOT expect these additional keywords to be supported by peer implementations. Implementations SHOULD ignore keywords they do not support.

+

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

+

6. The "$schema" keyword

+

6.1. Purpose

+

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.

+

7. Schema references with $ref

+

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.

+

8. Base URI and dereferencing

+

8.1. Initial base URI

+

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

+

Informatively, the initial base URI of a schema is the URI it was found at, or a suitable substitute URI if none is known.

+

8.2. The "id" keyword

+

The "id" keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. 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 
-

7.2.3.  -Canonical dereferencing and inline dereferencing

- -

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

+

+ +

+
# (document root)
+
http://example.com/root.json#
+
#/definitions/A
+
http://example.com/root.json#foo
+
#/definitions/B
+
http://example.com/other.json
+
#/definitions/B/definitions/X
+
http://example.com/other.json#bar
+
#/definitions/B/definitions/Y
+
http://example.com/t/inner.json
+
#/definitions/C
+
urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f
+
+ +

+

8.2.1. Internal references

+

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 
-

7.2.4.  -Inline dereferencing and fragments

- -

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

7.3.  -Security considerations

- -

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

8.  -Recommended correlation mechanisms for use with the HTTP protocol

- -

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

8.1.  -Correlation by means of the "Content-Type" header

- -

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

8.2.  -Correlation by means of the "Link" header

- -

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

9.  -IANA Considerations

- -

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

-
-

type name: application; -

-

subtype name: schema+json. -

-

- -

-

-
 TOC 
-

10.  -References

- -

-
 TOC 
-

10.1. Normative References

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

+

8.2.2. External references

+

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.

+

9. Usage for hypermedia

+

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

+

9.1. Linking to a schema

+

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

9.2. Describing a profile of JSON

+

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

9.3. Usage over HTTP

+

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.

+

10. Security considerations

+

Both schemas and instances are JSON values. As such, all security considerations defined in RFC 7159 [RFC7159] apply.

+

Instances and schemas are both frequently 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.

+

11. IANA Considerations

+

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

+ +
    +
  • type name: application;
  • +
  • subtype name: schema+json.
  • +
-

-
 TOC 
-

10.2. Informative References

- - - - - - - - - - - - - - - +

+

12. References

+

12.1. Normative References

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

Appendix A.  -ChangeLog

- -

-

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

Authors' Addresses

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - +

12.2. Informative References

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

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, and Henry H. Andrews for their submissions and patches to the document.

+

Appendix B. ChangeLog

+

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

+

+ +

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

+
+
draft-zyp-json-schema-04
+
+
    +
  • Split validation keywords into separate document
  • +
+

+
+
draft-zyp-json-schema-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.
  • +
+

+
+
+ +

+

+ Author's Address +

+
+
+ + Austin Wright (editor) + + + + + + + + + + + + + EMail: aaa@bzfx.net + +
+
+ + + diff --git a/latest/json-schema-hypermedia.html b/latest/json-schema-hypermedia.html index a2905b24..86b9e272 100644 --- a/latest/json-schema-hypermedia.html +++ b/latest/json-schema-hypermedia.html @@ -1,321 +1,525 @@ - -JSON Hyper-Schema: Hypertext definitions for JSON Schema - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - ol.text { margin-left: 2em; margin-right: 2em; } - ul.text { margin-left: 2em; margin-right: 2em; } - li { margin-left: 3em; } - - /* RFC-2629 s and s. */ - em { font-style: italic; } - strong { font-weight: bold; } - dfn { font-weight: bold; font-style: normal; } - cite { font-weight: normal; font-style: normal; } - tt { color: #036; } - tt, pre, pre dfn, pre em, pre cite, pre span { - font-family: "Courier New", Courier, monospace; font-size: small; - } - pre { - text-align: left; padding: 4px; - color: #000; background-color: #CCC; - } - pre dfn { color: #900; } - pre em { color: #66F; background-color: #FFC; font-weight: normal; } - pre .key { color: #33C; font-weight: bold; } - pre .id { color: #900; } - pre .str { color: #000; background-color: #CFF; } - pre .val { color: #066; } - pre .rep { color: #909; } - pre .oth { color: #000; background-color: #FCF; } - pre .err { background-color: #FCC; } - - /* RFC-2629 s. */ - table.all, table.full, table.headers, table.none { - font-size: small; text-align: center; border-width: 2px; - vertical-align: top; border-collapse: collapse; - } - table.all, table.full { border-style: solid; border-color: black; } - table.headers, table.none { border-style: none; } - th { - font-weight: bold; border-color: black; - border-width: 2px 2px 3px 2px; - } - table.all th, table.full th { border-style: solid; } - table.headers th { border-style: none none solid none; } - table.none th { border-style: none; } - table.all td { - border-style: solid; border-color: #333; - border-width: 1px 2px; - } - table.full td, table.headers td, table.none td { border-style: none; } - - hr { height: 1px; } - hr.insert { - width: 80%; border-style: none; border-width: 0; - color: #CCC; background-color: #CCC; - } ---> - -
 TOC 
-
- - - - - - -
Internet Engineering Task ForceG. Luff, Ed.
Internet-Draft 
Intended status: InformationalK. Zyp
Expires: August 4, 2013SitePen (USA)
 G. Court
 January 31, 2013
-


JSON Hyper-Schema: Hypertext definitions for JSON Schema
json-schema-hypermedia

- -

Abstract

- -

- JSON Schema is a JSON based format for defining the structure of JSON data. - This document specifies hyperlink- and hypermedia-related keywords of JSON Schema. - -

-

Status of This Memo

-

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

-

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

-

-Internet-Drafts are 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 4, 2013.

- -

Copyright Notice

-

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

-

-

Table of Contents

-

-1.  -Introduction
-2.  -Conventions and Terminology
-3.  -Overview
-    3.1.  -Design Considerations
-4.  -Schema keywords
-    4.1.  -links
-        4.1.1.  -Multiple links per URI
-    4.2.  -fragmentResolution
-        4.2.1.  -json-pointer fragment resolution
-    4.3.  -media
-        4.3.1.  -Properties of "media"
-        4.3.2.  -Example
-    4.4.  -readOnly
-    4.5.  -pathStart
-5.  -Link Description Object
-    5.1.  -href
-        5.1.1.  -URI Templating
-    5.2.  -rel
-        5.2.1.  -Fragment resolution with "root" links
-        5.2.2.  -Security Considerations for "self" links
-    5.3.  -title
-    5.4.  -targetSchema
-        5.4.1.  -Security Considerations for "targetSchema"
-    5.5.  -mediaType
-        5.5.1.  -Security concerns for "mediaType"
-    5.6.  -Submission Link Properties
-        5.6.1.  -method
-        5.6.2.  -encType
-        5.6.3.  -schema
-6.  -IANA Considerations
-    6.1.  -Registry of Link Relations
-7.  -References
-    7.1.  -Normative References
-    7.2.  -Informative References
-Appendix A.  -Change Log
-

-
- -

-
 TOC 
-

1.  -Introduction

- -

- JSON Schema is a JSON based format for defining the structure of JSON data. - This document specifies hyperlink- and hypermedia-related keywords of JSON Schema. - -

-

- The term JSON Hyper-Schema is used to refer to a JSON Schema that uses these keywords. - -

-

- This specification will use the terminology defined by the JSON Schema core - specification. It is advised that readers have a copy of this specification. - -

-

-
 TOC 
-

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 (Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels,” March 1997.) [RFC2119]. - -

-

- The terms "schema", "instance", "property" and "item" are to be interpreted as defined in the JSON Schema core definition [FIXME_LINK]. - -

-

-
 TOC 
-

3.  -Overview

+ -

- This document describes how JSON Schema can be used to define hyperlinks on instance data. It also defines how to provide additional information required to interpret JSON data as rich multimedia documents. - -

-

- Just as with the core JSON schema keywords, all the keywords described in the "Schema Keywords" section are optional. - -

-

Here is an example JSON Schema defining hyperlinks, and providing a multimedia interpretation for the "imgData" property: -

+  
+    
+    
+    	
+  
+  
+
+
+  
+  
+
+
+  
+  
+
+
+  
+  
+
+
+    	
+    
+  
Internet Engineering Task ForceA. Wright, Ed.
Internet-Draft
Intended status: InformationalG. Luff
Expires: May 7, 2017November 3, 2016
+ +

JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON
+ draft-wright-json-schema-hyperschema-00

+ +

+ Abstract +

+

JSON Schema is a JSON based format for defining the structure of JSON data. This document specifies hyperlink- and hypermedia-related keywords of JSON Schema for annotating JSON documents with hyperlinks and instructions for processing and manipulating remote JSON resources through hypermedia environments like HTTP.

+

+ Note to Readers +

+

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

+

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

+

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

+

+ Status of This Memo +

+

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

+

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at 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 Notice +

+

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.

+ + +
+

Table of Contents

+ + +

1. Introduction

+

JSON Schema is a JSON based format for defining the structure of JSON data. This document specifies hyperlink- and hypermedia-related keywords of JSON Schema.

+

The term JSON Hyper-Schema is used to refer to a JSON Schema that uses these keywords.

+

This specification will use the terminology defined by the JSON Schema core specification [json-schema]. It is advised that readers have a copy of this 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].

+

The terms "schema", "instance", "property" and "item" are to be interpreted as defined in the JSON Schema core specification [json-schema].

+

3. Overview

+

This document describes how JSON Schema can be used to define hyperlinks on instance data. It also defines how to provide additional information required to interpret JSON data as rich multimedia documents.

+

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

+

Here is an example JSON Schema defining hyperlinks, and providing a multimedia interpretation for the "imgData" property:

+
 
 {
     "title": "Written Article",
@@ -323,7 +527,8 @@ 

Table of Contents

"properties": { "id": { "title": "Article Identifier", - "type": "number" + "type": "number", + "readOnly": true }, "title": { "title": "Article Title", @@ -332,8 +537,8 @@

Table of Contents

"authorId": { "type": "integer" }, - "imgData": { - "title": "Article Illustration (small)", + "imgDataPng": { + "title": "Article Illustration (thumbnail)", "type": "string", "media": { "binaryEncoding": "base64", @@ -344,8 +549,8 @@

Table of Contents

"required" : ["id", "title", "authorId"], "links": [ { - "rel": "full", - "href": "{id}" + "rel": "self", + "href": "/article{?id}" }, { "rel": "author", @@ -354,15 +559,10 @@

Table of Contents

] } -
-

- This example schema defines the properties of the instance. - For the "imgData" property, it specifies that that it should be base64-decoded and the resulting binary data treated as a PNG image. - It also defines link relations for the instance, with URIs incorporating values from the instance. - -

-

An example of a JSON instance described by the above schema might be: -

+                
+

This example schema defines the properties of the instance. For the "imgData" property, it specifies that that it should be base64-decoded and the resulting binary data treated as a PNG image. It also defines link relations for the instance, with URIs incorporating values from the instance. [CREF1]"id" probably should not normally be a required keyword, since new instances will have an unknown "id" property until is it assigned by the server. However, this property is used in a link, and without it, multiple different instances would be given the same rel=self URI!

+

An example of a JSON instance described by the above schema might be:

+
 
 {
     "id": 15,
@@ -371,203 +571,79 @@ 

Table of Contents

"imgData": "iVBORw...kJggg==" } -
-

The base-64 data has been abbreviated for readability. -

-

-
 TOC 
-

3.1.  -Design Considerations

- -

- The purpose of this document is to define keywords for the JSON Schema that allow JSON data to be understood as hyper-text. - -

-

- JSON data on its own requires special knowledge from the client about the format in order to be interpretable as hyper-text. - This document proposes a way to describe the hyper-text and hyper-media interpretation of such JSON formats, without defining reserved keywords or otherwise restricting the structure of the JSON data. - -

-

-
 TOC 
-

4.  -Schema keywords

- -

-
 TOC 
-

4.1.  -links

+ +

The base-64 data has been abbreviated for readability.

+

4. Schema keywords

+

4.1. base

+

If present, this keyword is resolved against the current URI base that the entire instance is found within, and sets the new URI base for URI references within the instance. It is therefore the first URI Reference resolved, regardless of which order it was found in.

+

The URI is computed from the provided URI template using the same process described for the "href" [href] property of a Link Description Object.

+

An example of a JSON schema using "base":

+
 
-

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

-

An example schema using the "links" keyword could be: -

 {
-    "title": "Schema defining links",
+    "base": "/object/{id}",
     "links": [
         {
-            "rel": "full",
-            "href": "{id}"
+            "rel": "self",
+            "href": ""
         },
         {
-            "rel": "parent",
-            "href": "{parent}"
+            "rel": "next",
+            "href": "{next_id}"
         }
     ]
 }
-
-

-
 TOC 
-

4.1.1.  -Multiple links per URI

-

- A single URI might have more than one role with relation to an instance. This is not a problem - the same URI can be used in more than one Link Description Object. - -

-

- For example, this schema describes a format for blog posts, accessed via HTTP. - The links describe how to access the comments for the post, how to search the comments, and how to submit new comments, all with the same URI: -

+                    
+

An example of a JSON instance using this schema to produce rel="self" and rel="next" links:

+
+
+{
+    "id": "41",
+    "next_id": "42"
+}
+
+                    
+

If the document URI is <http://example.com/?id=41>, then the new URI base becomes <http://example.com/object/41>

+

Resolving the two Link Description Objects against this URI base creates two links exactly equivelant to these absolute-form HTTP Link headers:

+ +
    +
  • Link: <http://example.com/object/41>;rel=self
  • +
  • Link: <http://example.com/object/42>;rel=next
  • +
+ +

+

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

+

An example schema using the "links" keyword could be:

+
 {
-    "title": "News post",
-    ...
+    "title": "Schema defining links",
     "links": [
         {
-            "rel": "comments",
-            "href": "/{id}/comments"
-        },
-        {
-            "rel": "search",
-            "href": "/{id}/comments",
-            "schema": {
-                "type": "object",
-                "properties": {
-                    "searchTerm": {
-                        "type": "string"
-                    },
-                    "itemsPerPage": {
-                        "type": "integer",
-                        "minimum": 10,
-                        "multipleOf": 10,
-                        "default": 20
-                    }
-                },
-                "required": ["searchTerm"]
-            }
+            "rel": "self",
+            "href": "{id}"
         },
         {
-            "title": "Post a comment",
-            "rel": "create",
-            "href": "/{id}/comments",
-            "method": "POST",
-            "schema": {
-                "type": "object",
-                "properties": {
-                    "message": {
-                        "type": "string"
-                    }
-                },
-                "required": ["message"]
-            }
+            "rel": "parent",
+            "href": "{parent}"
         }
     ]
 }
-
-

- If the client follows the first link, the URI might be expanded to "/15/comments". - For the second link, the method is "GET" (the default for HTTP) so a client following this link would add the parameters to the URL to produce something like: "/15/comments?searchTerm=JSON&itemsPerPage=50". - The third link defines a possible interaction where a client would POST to a URI (such as "/15/comments"), where the post-data was a JSON representation of the new comment, for example: - -

-{
-    "message": "This is an example comment"
-}
-
-

-
 TOC 
-

4.2.  -fragmentResolution

- -

- When addressing a JSON document, the fragment part of the URI may be used to refer to a particular instance within the document. - -

-

- This keyword indicates the method to use for finding the appropriate instance within a document, given the fragment part. - The default fragment resolution protocol is "json-pointer", which is defined below. - Other fragment resolution protocols MAY be used, but are not defined in this document. - -

-

- If the instance is described by a schema providing the a link with "root" relation, or such a link is provided in using the HTTP Link header (Nottingham, M., “Web Linking,” October 2010.) [RFC5988], then the target of the "root" link should be considered the document root for the purposes of all fragment resolution methods that use the document structure (such as "json-pointer"). - The only exception to this is the resolution of "root" links themselves. - -

-

-
 TOC 
-

4.2.1.  -json-pointer fragment resolution

- -

- The "json-pointer" fragment resolution protocol uses a JSON Pointer (Bryan, P. and K. Zyp, “JSON Pointer,” October 2011.) [json‑pointer] to resolve fragment identifiers in URIs within instance representations. - -

-

-
 TOC 
-

4.3.  -media

- -

- The "media" property indicates that this instance contains non-JSON data encoded in a JSON string. It describes the type of content and how it is encoded. - -

-

- The value of this property MUST be an object, and SHOULD be ignored for any instance that is not a string. - -

-

-
 TOC 
-

4.3.1.  -Properties of "media"

- -

- The value of the "media" keyword MAY contain any of the following properties: - -

-

-
 TOC 
-

4.3.1.1.  -binaryEncoding

- -

- 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 (Freed, N. and N. Borenstein, “Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies,” November 1996.) [RFC2045] lists the possible values for this property. - -

-

-
 TOC 
-

4.3.1.2.  -type

- -

- The value of this property must be a media type, as defined by RFC 2046 (Freed, N. and N. Borenstein, “Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types,” November 1996.) [RFC2046]. - This property defines the media type of instances which this schema defines. - -

-

- If the "binaryEncoding" property is not set, 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). - -

-

-
 TOC 
-

4.3.2.  -Example

- -

Here is an example schema, illustrating the use of "media": -

+                    
+

4.3. media

+

The "media" property indicates that this instance contains non-JSON data encoded in a JSON string. It describes the type of content and how it is encoded.

+

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

+

4.3.1. Properties of "media"

+

The value of the "media" keyword MAY contain any of the following properties:

+

4.3.1.1. binaryEncoding

+

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.

+

4.3.1.2. type

+

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.

+

If the "binaryEncoding" property is not set, 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).

+

4.3.2. Example

+

Here is an example schema, illustrating the use of "media":

+
 
 {
     "type": "string",
@@ -577,11 +653,10 @@ 

Table of Contents

} } -
-

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

-

Another example: -

+                        
+

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

+

Another example:

+
 
 {
     "type": "string",
@@ -590,343 +665,143 @@ 

Table of Contents

} } -
-

Instances described by this schema should be strings containing HTML, using whatever character set the JSON string was decoded into (default is Unicode). -

-

-
 TOC 
-

4.4.  -readOnly

- -

- If it has a value of boolean true, this keyword indicates that the instance property SHOULD NOT be changed, and attempts by a user agent to modify the value of this property are expected to be rejected by a server. - -

-

- The value of this keyword MUST be a boolean. - The default value is false. - -

-

-
 TOC 
-

4.5.  -pathStart

- -

- This property is a URI that defines what the instance's URI MUST start with in order to validate. - The value of the "pathStart" property MUST be resolved relative to the closest URI Resolution Scope (as defined in the core specification [FIXME link]), using the rules from RFC 3986, Sec 5 (Berners-Lee, T., Fielding, R., and L. Masinter, “Uniform Resource Identifier (URI): Generic Syntax,” January 2005.) [RFC3986]. - -

-

- When multiple schemas have been referenced for an instance, the user agent can determine if this schema is applicable for a particular instance by determining if the URI of the instance begins with the the value of the "pathStart" property. - If the URI of the instance does not start with this URI, or if another schema specifies a starting URI that is longer and also matches the instance, this schema SHOULD NOT be considered to describe the instance. - Any schema that does not have a pathStart property SHOULD be considered applicable to all the instances for which it is referenced. - -

-

-
 TOC 
-

5.  -Link Description Object

- -

- A Link Description Object (LDO) is used to describe a single link relation. - In the context of a schema, it defines the link relations of the instances of the schema, and can be parameterized by the instance values. - A Link Description Object (LDO) must be an object. - -

-

- The link description format can be used without JSON Schema, and use of this format can be declared by referencing the normative link description schema as the schema for the data structure that uses the links. - The URI of the normative link description schema is: http://json-schema.org/links (latest version) or http://json-schema.org/draft-04/links (draft-04 version). - -

-

- "Form"-like functionality can be defined by use of the "schema" keyword, which supplies a schema describing the data to supply to the server. - -

-

-
 TOC 
-

5.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 SHOULD be resolved as a URI-Reference per RFC 3986 (Berners-Lee, T., Fielding, R., and L. Masinter, “Uniform Resource Identifier (URI): Generic Syntax,” January 2005.) [RFC3986] and MAY be a relative reference to a URI. - The base URI to be used for relative URI resolution SHOULD be the URI used to retrieve the instance object (not the schema). - -

-

- The base URI to be used for relative URI resolution SHOULD is defined as follows: -

-
-

if the data has a link defined, with a relation of "self", then the "href" value of that link is used, unless the relation of the link being resolved is also "self" -

-

otherwise, the URI should be resolved against the link with relation "self" belonging to the closest parent node in the JSON document, if it exists -

-

otherwise, the URI used to fetch the document should be used. -

-

- -

-

This property is not optional. -

-

-
 TOC 
-

5.1.1.  -URI Templating

- -

- The value of "href" is to be used as a URI Template, as defined in RFC 6570 (Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, “URI Template,” March 2012.) [RFC6570]. However, some special considerations apply: - -

-

-
 TOC 
-

5.1.1.1.  -Pre-processing

- -

- The URI Template specification (Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, “URI Template,” March 2012.) [RFC6570] restricts the set of characters available for variable names. - Property names in JSON, however, can be any UTF-8 string. - -

-

- To allow the use of any JSON property name in the template, before using the value of "href" as a URI Template, the following pre-processing rules MUST be applied, in order: - -

-

-
 TOC 
-

5.1.1.1.1.  -Bracket escaping

- -

- The purpose of this step is to allow the use of brackets to percent-encode variable names inside curly brackets. - Variable names to be escaped are enclosed within rounded brackets, with the close-rounded-bracket character ")" being escaped as a pair of close-rounded-brackets "))". - Since the empty string is not a valid variable name in RFC 6570, an empty pair of brackets is replaced with "%65mpty". - -

-

- The rules are as follows: - -

-

- Find the largest possible sections of the text such that: -

-
-

do not contain an odd number of close-rounded-bracket characters ")" in sequence in that section of the text -

-

are surrounded by a pair of rounded brackets: ( ), where -

-

the surrounding rounded brackets are themselves contained within a pair of curly brackets: { } -

-

- -

-

- Each of these sections of the text (including the surrounding rounded brackets) MUST be replaced, according to the following rules: -

-
-

If the brackets contained no text (the empty string), then they are replaced with "%65mpty" (which is "empty" with a percent-encoded "e") -

-

Otherwise, the enclosing brackets are removed, and the inner text used after the following modifications -

-
-

all pairs of close-brackets "))" are replaced with a single close bracket -

-

after that, the text is replaced with its percent-encoded equivalent, such that the result is a valid RFC 6570 variable name (note that this requires encoding characters such as "*" and "!") -

-
- - -

- -

-

-
 TOC 
-

5.1.1.1.2.  -Replacing $

- -

- After the above substitutions, if the character "$" (dollar sign) appears within a pair of curly brackets, then it MUST be replaced with the text "%73elf" (which is "self" with a percent-encoded "s"). - -

-

- The purpose of this stage is to allow the use of the instance value itself (instead of its object properties or array items) in the URI Template, by the special value "%73elf". - -

-

-
 TOC 
-

5.1.1.1.3.  -Choice of special-case values

- -

- The special-case values of "%73elf" and "%65mpty" were chosen because they are unlikely to be accidentally generated by either a human or automated escaping. - -

-

-
 TOC 
-

5.1.1.1.4.  -Examples

- -

- -

For example, here are some possible values for "href", followed by the results after pre-processing: -

-
-Input                    Output
------------------------------------------
-"no change"              "no change"
-"(no change)"            "(no change)"
-"{(escape space)}"       "{escape%20space}"
-"{(escape+plus)}"        "{escape%2Bplus}"
-"{(escape*asterisk)}"    "{escape%2Aasterisk}"
-"{(escape(bracket)}"     "{escape%28bracket}"
-"{(escape))bracket)}"    "{escape%29bracket}"
-"{(a))b)}"             "{a%29b}
-"{(a (b)))}"             "{a%20%28b%29}
-"{()}"                   "{%65mpty}
-"{+$*}"                   "{+%73elf*}
-"{+($)*}"                 "{+%24*}
-
-
-

- Note that in the final example, because the "+" was outside the brackets, it remained unescaped, whereas in the fourth example the "+" was escaped. - -

- - -

-
 TOC 
-

5.1.1.2.  -Values for substitution

+
+

Instances described by this schema should be strings containing HTML, using whatever character set the JSON string was decoded into (default is Unicode).

+

4.4. readOnly

+

If it has a value of boolean true, this keyword indicates that the value of the instance is managed exclusively by the server or the owning authority, and attempts by a user agent to modify the value of this property are expected to be ignored or rejected by a server.

+

For example, this property would be used to mark a server-generated serial number as read-only.

+

The value of this keyword MUST be a boolean. The default value is false.

+

5. Link Description Object

+

A Link Description Object (LDO) is used to describe a single link relation from the instance to another resource. A Link Description Object must be an object.

+

The link description format can be used without JSON Schema, and use of this format can be declared by referencing the normative link description schema as the schema for the data structure that uses the links. The URI of the normative link description schema is: http://json-schema.org/draft-04/links (draft-04 version).

+

"Form"-like functionality can be defined by use of the "method" and "schema" keywords, which supplies a schema describing the data to supply to the server.

+

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

+

5.1.1. URI Templating

+

The value of "href" is to be used as a URI Template, as defined in RFC 6570 [RFC6570]. However, some special considerations apply:

+

5.1.1.1. Pre-processing

+

[CREF2]This pre-processing section is subject to significant change in upcoming drafts.

+

The URI Template specification [RFC6570] restricts the set of characters available for variable names. Property names in JSON, however, can be any UTF-8 string.

+

To allow the use of any JSON property name in the template, before using the value of "href" as a URI Template, the following pre-processing rules MUST be applied, in order:

+

5.1.1.1.1. Bracket escaping

+

The purpose of this step is to allow the use of brackets to percent-encode variable names inside curly brackets. Variable names to be escaped are enclosed within rounded brackets, with the close-rounded-bracket character ")" being escaped as a pair of close-rounded-brackets "))". Since the empty string is not a valid variable name in RFC 6570, an empty pair of brackets is replaced with "%65mpty".

+

The rules are as follows:

+

Find the largest possible sections of the text such that:

+ +
    +
  • do not contain an odd number of close-rounded-bracket characters ")" in sequence in that section of the text
  • +
  • are surrounded by a pair of rounded brackets: ( ), where
  • +
  • the surrounding rounded brackets are themselves contained within a pair of curly brackets: { }
  • +
-

- After pre-processing, the URI Template is filled out using data from the instance. - To allow the use of any object property (including the empty string), array index, or the instance value itself, the following rules are defined: - -

-

- For a given variable name in the URI Template, the value to use is determined as follows: -

-
-

If the variable name is "%73elf", then the instance value itself MUST be used. -

-

If the variable name is "%65mpty", then the instances's empty-string ("") property MUST be used (if it exists). -

-

If the instance is an array, and the variable name is a representation of a non-negative integer, then the value at the corresponding array index MUST be used (if it exists). -

-

Otherwise, the variable name should be percent-decoded, and the corresponding object property MUST be used (if it exists). -

-

- -

-

-
 TOC 
-

5.1.1.2.1.  -Converting to strings

+

+

Each of these sections of the text (including the surrounding rounded brackets) MUST be replaced, according to the following rules:

-

- When any value referenced by the URI template is null, a boolean or a number, then it should first be converted into a string as follows: -

-
-

null values SHOULD be replaced by the text "null" -

-

boolean values SHOULD be replaced by their lower-case equivalents: "true" or "false" -

-

numbers SHOULD be replaced with their original JSON representation. -

-

- -

-

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

-

-
 TOC 
-

5.1.1.3.  -Missing values

+
    +
  • If the brackets contained no text (the empty string), then they are replaced with "%65mpty" (which is "empty" with a percent-encoded "e")
  • +
  • Otherwise, the enclosing brackets are removed, and the inner text used after the following modifications
    • all pairs of close-brackets "))" are replaced with a single close bracket
    • after that, the text is replaced with its percent-encoded equivalent, such that the result is a valid RFC 6570 variable name (note that this requires encoding characters such as "*" and "!")

  • +
-

- Sometimes, the appropriate values will not be available. - For example, the template might specify the use of object properties, but the instance is an array or a string. - -

-

- If any of the values required for the template are not present in the JSON instance, then substitute values MAY be provided from another source (such as default values). - Otherwise, the link definition SHOULD be considered not to apply to the instance. - -

-

-
 TOC 
-

5.2.  -rel

+

+

5.1.1.1.2. Replacing $

+

After the above substitutions, if the character "$" (dollar sign) appears within a pair of curly brackets, then it MUST be replaced with the text "%73elf" (which is "self" with a percent-encoded "s").

+

The purpose of this stage is to allow the use of the instance value itself (instead of its object properties or array items) in the URI Template, by the special value "%73elf".

+

5.1.1.1.3. Choice of special-case values

+

The special-case values of "%73elf" and "%65mpty" were chosen because they are unlikely to be accidentally generated by either a human or automated escaping.

+

5.1.1.1.4. Examples

+

For example, here are some possible values for "href", followed by the results after pre-processing:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
InputOutput
"no change""no change"
"(no change)""(no change)"
"{(escape space)}""{escape%20space}"
"{(escape+plus)}""{escape%2Bplus}"
"{(escape*asterisk)}""{escape%2Aasterisk}"
"{(escape(bracket)}""{escape%28bracket}"
"{(escape))bracket)}""{escape%29bracket}"
"{(a))b)}""{a%29b}
"{(a (b)))}""{a%20%28b%29}
"{()}""{%65mpty}
"{+$*}""{+%73elf*}
"{+($)*}""{+%24*}
+

Note that in the final example, because the "+" was outside the brackets, it remained unescaped, whereas in the fourth example the "+" was escaped.

+

5.1.1.2. Values for substitution

+

After pre-processing, the URI Template is filled out using data from the instance. To allow the use of any object property (including the empty string), array index, or the instance value itself, the following rules are defined:

+

For a given variable name in the URI Template, the value to use is determined as follows:

+ +
    +
  • If the variable name is "%73elf", then the instance value itself MUST be used.
  • +
  • If the variable name is "%65mpty", then the instances's empty-string ("") property MUST be used (if it exists).
  • +
  • If the instance is an array, and the variable name is a representation of a non-negative integer, then the value at the corresponding array index MUST be used (if it exists).
  • +
  • Otherwise, the variable name should be percent-decoded, and the corresponding object property MUST be used (if it exists).
  • +
-

- The value of the "rel" property indicates the name of the relation to the target resource. - This property is not optional. - -

-

- The relation to the target SHOULD be interpreted as specifically from the instance object that the schema (or sub-schema) applies to, not just the top level resource that contains the object within its hierarchy. - A link relation from the top level resource to a target MUST be indicated with the schema describing the top level JSON representation. - -

-

- Relationship definitions SHOULD NOT be media type dependent, and users are encouraged to utilize existing accepted relation definitions, including those in existing relation registries (see RFC 4287 (Nottingham, M., Ed. and R. Sayre, Ed., “The Atom Syndication Format,” December 2005.) [RFC4287]). - However, we define these relations here for clarity of normative interpretation within the context of JSON Schema defined relations: +

+

5.1.1.2.1. Converting to strings

+

When any value referenced by the URI template is null, a boolean or a number, then it should first be converted into a string as follows:

-

-
-
self
-
- If the relation value is "self", when this property is encountered in the instance object, the object represents a resource and the instance object is treated as a full representation of the target resource identified by the specified URI. - -
-
full
-
- This indicates that the target of the link is the full representation for the instance object. - The instance that contains this link may not be the full representation. - -
-
describedBy
-
- This indicates the target of the link is a schema describing the instance object. - This MAY be used to specifically denote the schemas of objects within a JSON object hierarchy, facilitating polymorphic type data structures. - -
-
root
-
- This relation indicates that the target of the link SHOULD be treated as the root or the body of the representation for the purposes of user agent interaction or fragment resolution. - All other data in the document can be regarded as meta-data for the document. - The URI of this link MUST refer to a location within the instance document, otherwise the link MUST be ignored. - -
-

- -

-

- The following relations are applicable for schemas (the schema as the "from" resource in the relation): +

    +
  • null values SHOULD be replaced by the text "null"
  • +
  • boolean values SHOULD be replaced by their lower-case equivalents: "true" or "false"
  • +
  • numbers SHOULD be replaced with their original JSON representation.
  • +
-

-
-
instances
-
- This indicates the target resource that represents a collection of instances of a schema. - -
-
create
-
- This indicates a target to use for creating new instances of a schema. - This link definition SHOULD be a submission link with a non-safe method (like POST). - -
-

- - Links defined in the schema using these relation values SHOULD not require parameterization with data from the instance, as they describe a link for the schema, not the instances. - -

-

For example, if a schema is defined: -

+

+

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.

+

5.1.1.3. Missing values

+

Sometimes, the appropriate values will not be available. For example, the template might specify the use of object properties, but the instance is an array or a string.

+

If any of the values required for the template are not present in the JSON instance, then substitute values MAY be provided from another source (such as default values). Otherwise, the link definition SHOULD be considered not to apply to the instance.

+

5.2. rel

+

The value of the "rel" property indicates the name of the relation to the target resource. The value MUST be a registered link relation from the IANA Link Relation Type Registry established in RFC 5988 [RFC5988], or a normalized URI following the URI production of RFC 3986 [RFC3986].

+

The relation to the target is interpreted as from the instance that the schema (or sub-schema) applies to, not any larger document that the instance may have been found in.

+

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

+

For example, if a schema is defined:

+
 {
     "links": [{
         "rel": "self",
@@ -934,14 +809,11 @@ 

Table of Contents

}, { "rel": "up", "href": "{upId}" - }, { - "rel": "children", - "href": "?upId={id}" }] } -
-

And if a collection of instance resources were retrieved with JSON representation: -

+                    
+

And if a collection of instance resources were retrieved with JSON representation:

+
 GET /Resource/
 
 [{
@@ -951,164 +823,60 @@ 

Table of Contents

"id": "thing2", "upId": "parent" }] -
-

- This would indicate that for the first item in the collection, its own (self) URI would resolve to "/Resource/thing" and the first item's "up" relation SHOULD be resolved to the resource at "/Resource/parent". - The "children" collection would be located at "/Resource/?upId=thing". - -

-

- Note that these relationship values are case-insensitive, consistent with their use in HTML and the HTTP Link header (Nottingham, M., “Web Linking,” October 2010.) [RFC5988]. - -

-

-
 TOC 
-

5.2.1.  -Fragment resolution with "root" links

- -

- The presence of a link with relation "root" alters what the root of the document is considered to be. - For fragment resolution methods (such as JSON Pointer fragments) that navigate through the document, the target of the "root" link should be the starting point for such methods. - -

-

- The only exception is "root" links themselves. - When calculating the target of links with relation "root", existing "root" links MUST NOT be taken into consideration. - -

-

- -

For example, say we have the following schema: -

-{
-    "links": [{
-        "rel": "root",
-        "href": "#/myRootData"
-    }]
-}
-
- - -

- -

And the following data, returned from the URI: "http://example.com/data/12345": -

-{
-    "myRootData": {
-        "title": "Document title"
-    },
-    "metaData": {
-        ...
-    }
-}
-
- - -

- To correctly resolve the URL "http://example.com/data/12345", we must take the "root" link into account. Here are some example URIs, along with the data they would resolve to: -

-
-
-URI                                         Data
------------------------------------------------------------------------
-http://example.com/data/12345               {"title": "Document title"}
-http://example.com/data/12345#/title        "Document title"
-
-

- - -

-

-
 TOC 
-

5.2.2.  -Security Considerations for "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 the URI used to request the resource representation which contains the target URI with the "self" link. - - -

For example, if a hyper schema was defined: -

+                    
+

This would indicate that for the first item in the collection, its own (self) URI would resolve to "/Resource/thing" and the first item's "up" relation SHOULD be resolved to the resource at "/Resource/parent".

+

Note that these relationship values are case-insensitive, consistent with their use in HTML and the HTTP Link header [RFC5988].

+

5.2.1. Security Considerations for "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 the URI used to request the resource representation which contains the target URI with the "self" link.

+ +

For example, if a hyper schema was defined:

+
 {
     "links": [{
         "rel": "self",
         "href": "{id}"
     }]
 }
-
- - -

And a resource was requested from somesite.com: -

+                            
+

And a resource was requested from somesite.com:

+
 
 GET /foo/
 
-
- - -

With a response of: -

-Content-Type: application/json; profile=/schema-for-this-data
+                            
+

With a response of (with newlines and whitespace added):

+
+Content-Type: application/json; profile="http://example.com/alpha"
 
 [{
     "id": "bar",
-    "name": "This representation can be safely treated \
-        as authoritative "
+    "name": "This representation can be safely treated
+             as authoritative "
 }, {
     "id": "/baz",
-    "name": "This representation should not be treated as \
-        authoritative the user agent should make request the resource\
-        from '/baz' to ensure it has the authoritative representation"
+    "name": "This representation should not be treated as
+             authoritative the user agent should make request the
+             resource from '/baz' to ensure it has the authoritative
+             representation"
 }, {
     "id": "http://othersite.com/something",
-    "name": "This representation\
-        should also not be treated as authoritative and the target\
-        resource representation should be retrieved for the\
-        authoritative representation"
+    "name": "This representation
+             should also not be treated as authoritative and the
+             target resource representation should be retrieved
+             for the authoritative representation"
 }]
-
- - -

-
 TOC 
-

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

-

-
 TOC 
-

5.4.  -targetSchema

- -

- This property value is advisory only, and is a schema that defines the expected structure of the JSON representation of the target of the link, if the target of the link is returned using JSON representation. - -

-

-
 TOC 
-

5.4.1.  -Security Considerations for "targetSchema"

- -

- This property has similar security concerns to that of "mediaType". - Clients MUST NOT use the value of this property to aid in the interpretation of the data received in response to following the link, as this leaves "safe" data open to re-interpretation. - -

-

- -

- For example, suppose two programmers are having a discussion about web security using a text-only message board. - Here is some data from that conversation, with a URI of: http://forum.example.com/topics/152/comments/13 - -

+                            
+

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

+

5.4. targetSchema

+

This property provides a schema that is expected to describe the link target, including what a client can expect if it makes an HTTP GET request, and what it should send if it replaces the resource in an HTTP PUT request. This property is advisory only.

+

5.4.1. Security Considerations for "targetSchema"

+

This property has similar security concerns to that of "mediaType". Clients MUST NOT use the value of this property to aid in the interpretation of the data received in response to following the link, as this leaves "safe" data open to re-interpretation.

+

+ +

For example, suppose two programmers are having a discussion about web security using a text-only message board. Here is some data from that conversation, with a URI of: http://forum.example.com/topics/152/comments/13

+
 {
     "topicId": 152,
     "commentId": 13,
@@ -1120,22 +888,19 @@ 

Table of Contents

"name": "Jason", "id": 8 }, - "message": "It's easy, you just add some HTML like this: <script>doSomethingEvil()</script>" + "message": "It's easy, just add some HTML like + this: <script>doSomethingEvil()</script>" } -
- - -

- A third party might then write provide the following Link Description Object at another location: -

-
+                            
+

The message string was split over two lines for readability.

+
 {
     "rel": "evil-attack",
     "href": "http://forum.example.com/topics/152/comments/13",
     "targetSchema": {
         "properties": {
             "message": {
-                "description": "Re-interpret the message text as HTML",
+                "description": "Re-interpret `message` as HTML",
                 "media": {
                     "type": "text/html"
                 }
@@ -1143,41 +908,17 @@ 

Table of Contents

} } } -

- -

- If the client used this "targetSchema" value when interpreting the above data, then it might display the contents of "message" as HTML. - At this point, the JavaScript embedded in the message might be executed (in the context of the "forum.example.com" domain). - -

- - -

-
 TOC 
-

5.5.  -mediaType

- -

- The value of this property is advisory only, and represents the media type RFC 2046 (Freed, N. and N. Borenstein, “Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types,” November 1996.) [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 2161, section 14.1 - HTTP "Accept" header (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]. - -

-

- This property is analogous to the "type" property of <a> elements in HTML (advisory content type), or the "type" parameter in the HTTP Link header (Nottingham, M., “Web Linking,” October 2010.) [RFC5988]. - User agents MAY use this information to inform the interface they present to the user before the link is followed, but this information MUST NOT use this information in the interpretation of the resulting data. - When deciding how to interpret data obtained through following this link, the behaviour of user agents MUST be identical regardless of the value of the this property. - -

-

- If this property's value is specified, and the link's target is to be obtained using any protocol that supports the HTTP/1.1 "Accept" header RFC 2616, section 14.1 (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], then user agents MAY use the value of this property to aid in the assembly of that header when making the request to the server. - -

-

- If this property's value is not specified, then the value should be taken to be "application/json". - -

-

For example, if a schema is defined: -

+                            
+

A third party might then write provide the following Link Description Object at another location:

+ +

If the client used this "targetSchema" value when interpreting the above data, then it might display the contents of "message" as HTML. At this point, the JavaScript embedded in the message might be executed (in the context of the "forum.example.com" domain).

+

5.5. mediaType

+

The value of this property is advisory only, and 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.1 - HTTP "Accept" header [RFC7231].

+

This property is analogous to the "type" property of <a> elements in HTML (advisory content type), or the "type" parameter in the HTTP Link header [RFC5988]. User agents MAY use this information to inform the interface they present to the user before the link is followed, but this information MUST NOT use this information in the interpretation of the resulting data. When deciding how to interpret data obtained through following this link, the behaviour of user agents MUST be identical regardless of the value of the this property.

+

If this property's value is specified, and the link's target is to be obtained using any protocol that supports the HTTP/1.1 "Accept" header RFC 7231, section 5.3.1 [RFC7231], then user agents MAY use the value of this property to aid in the assembly of that header when making the request to the server.

+

If this property's value is not specified, then the value should be taken to be "application/json".

+

For example, if a schema is defined:

+
 
 {
     "links": [{
@@ -1198,84 +939,30 @@ 

Table of Contents

}] } -
-

- A suitable instance described by this schema would have four links defined. - The link with a "rel" value of "self" would have an expected MIME type of "application/json" (the default). - The two links with a "rel" value of "alternate" specify the locations of HTML and RSS versions of the current item. - The link with a "rel" value of "icon" links to an image, but does not specify the exact format. - -

-

- A visual user agent displaying the item from the above example might present a button representing an RSS feed, which when pressed passes the target URI (calculated "href" value) to an view more suited to displaying it, such as a news feed aggregator tab. - -

-

- Note that presenting the link in the above manner, or passing the URI to a news feed aggregator view does not constitute interpretation of the data, but an interpretation of the link. - The interpretation of the data itself is performed by the news feed aggregator, which SHOULD reject any data that would not have also been interpreted as a news feed, had it been displayed in the main view. - -

-

-
 TOC 
-

5.5.1.  -Security concerns for "mediaType"

- -

- The "mediaType" property in link definitions defines the expected format of the link's target. - However, this is advisory only, and MUST NOT be considered authoritative. - -

-

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

-

-
 TOC 
-

5.6.  -Submission Link Properties

- -

- The following properties also apply to Link Description Objects, and provide functionality analogous to HTML forms, in providing a means for submitting extra (often user supplied) information to send to a server. - -

-

-
 TOC 
-

5.6.1.  -method

- -

- This property defines which method can be used to access the target resource. - In an HTTP environment, this might be "GET" or "POST" (or other HTTP methods). - -

-

- Some link relation values imply a set of appropriate HTTP methods to be used for the link. - For example, a client might assume that a link with a relation of "edit" can be used in conjuction with the "PUT" HTTP method. - If the client does not know which methods might be appropriate, then this SHOULD default to "GET". - -

-

-
 TOC 
-

5.6.2.  -encType

- -

- If present, this property indicates a query media type format that the server supports for querying or posting to the collection of instances at the target resource. - The query can be suffixed to the target URI to query the collection with property-based constraints on the resources that SHOULD be returned from the server or used to post data to the resource (depending on the method). - - -

For example, with the following schema: -

+                    
+

A suitable instance described by this schema would have four links defined. The link with a "rel" value of "self" would have an expected MIME type of "application/json" (the default). The two links with a "rel" value of "alternate" specify the locations of HTML and RSS versions of the current item. The link with a "rel" value of "icon" links to an image, but does not specify the exact format.

+

A visual user agent displaying the item from the above example might present a button representing an RSS feed, which when pressed passes the target URI (calculated "href" value) to an view more suited to displaying it, such as a news feed aggregator tab.

+

Note that presenting the link in the above manner, or passing the URI to a news feed aggregator view does not constitute interpretation of the data, but an interpretation of the link. The interpretation of the data itself is performed by the news feed aggregator, which SHOULD reject any data that would not have also been interpreted as a news feed, had it been displayed in the main view.

+

5.5.1. Security concerns for "mediaType"

+

The "mediaType" property in link definitions defines the expected format of the link's target. However, this is advisory only, and MUST NOT be considered authoritative.

+

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

+

5.6. Submission Form Properties

+

The following properties also apply to Link Description Objects, and provide functionality analogous to HTMLforms [W3C.CR-html5-20140731], by providing a means for making a request with client- or user-selected information.

+

5.6.1. method

+

This property specifies that the client can construct a templated query or non-idempotent request to a resource.

+

If "method" is "get", the link identifies how a user can compute the URI of an arbritrary resource. For example, how compute a link to a page of search results relating to the instance, for a user-selected query term. Despite being named after GET, there is no constraint on the method or protocol used to interact with the remote resource.

+

If "method" is "post", the link specifies how a user can construct a document to submit to the link target for evaluation.

+

Values for this property SHOULD be lowercase, and SHOULD be compared case-insensitive. Use of other values not defined here SHOULD be ignored.

+

5.6.2. encType

+

If present, this property indicates the media type format the client should use to encode a query parameter or send to the server. posting to the collection of instances at the target resource. If the method is "get", this will indicate how to encode the query-string that is appended to the "href" link target. If the method is "post", this indicates which media type to send to the server and how to encode it.

+ +

For example, with the following schema:

+
 {
     "links": [{
         "encType": "application/x-www-form-urlencoded",
-        "method": "GET",
+        "method": "get",
         "href": "/Product/",
         "properties": {
             "name": {
@@ -1284,258 +971,164 @@ 

Table of Contents

} }] } -
-

This indicates that the client can query the server for instances that have a specific name. -

- - -

For example: -

+                            
+

This indicates that the client can query the server for instances that have a specific name.

+

For example:

+
 
 /Product/?name=Slinky
 
-
- - If no encType or method is specified, only the single URI specified by the href property is defined. - If the method is POST, "application/json" is the default media type. - - -

-
 TOC 
-

5.6.3.  -schema

- -

- This property contains a schema which defines the acceptable structure of the submitted request. - For a GET request, this schema would define the properties for the query string and for a POST request, this would define the body. - -

-

- Note that this is separate from the URI templating of "href" (which uses data from the instance, not submitted by the user). - It is also separate from the "targetSchema" property, which provides a schema for the data that the client should expect to be returned when they follow the link. - -

-

-
 TOC 
-

6.  -IANA Considerations

- -

-
 TOC 
-

6.1.  -Registry of Link Relations

- -

- This registry is maintained by IANA per RFC 4287 (Nottingham, M., Ed. and R. Sayre, Ed., “The Atom Syndication Format,” December 2005.) [RFC4287] and this specification adds four values: "full", "create", "instances", "root". - New assignments are subject to IESG Approval, as outlined in RFC 5226 (Narten, T. and H. Alvestrand, “Guidelines for Writing an IANA Considerations Section in RFCs,” May 2008.) [RFC5226]. - Requests should be made by email to IANA, which will then forward the request to the IESG, requesting approval. - -

-

-
 TOC 
-

7.  -References

- -

-
 TOC 
-

7.1. Normative References

- - - - - - - - - - - - - -
[RFC2045]Freed, N. and N. Borenstein, “Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies,” RFC 2045, November 1996 (TXT).
[RFC2119]Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels,” BCP 14, RFC 2119, March 1997 (TXT, 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).
[RFC4287]Nottingham, M., Ed. and R. Sayre, Ed., “The Atom Syndication Format,” RFC 4287, December 2005 (TXT, HTML, XML).
[RFC6570]Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., and D. Orchard, “URI Template,” RFC 6570, March 2012 (TXT).
[json-pointer]Bryan, P. and K. Zyp, “JSON Pointer,” October 2011.
- -

-
 TOC 
-

7.2. Informative References

- - - - - - - - - - - - - + +

5.6.3. schema

+

This property contains a schema which defines the acceptable structure of the document being encoded according to the "encType" property.

+

Note that this does not provide data for any URI templates. This is a separate concept from the "targetSchema" property, which is describing the target information resource (including for replacing the contents of the resource in a PUT request), unlike "schema" which describes the user-submitted request data to be evaluated by the resource.

+

6. References

+

6.1. Normative References

+
[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).
[RFC4627]Crockford, D., “The application/json Media Type for JavaScript Object Notation (JSON),” RFC 4627, July 2006 (TXT).
[RFC5226]Narten, T. and H. Alvestrand, “Guidelines for Writing an IANA Considerations Section in RFCs,” BCP 26, RFC 5226, May 2008 (TXT).
[RFC2046]Freed, N. and N. Borenstein, “Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types,” RFC 2046, November 1996 (TXT).
[RFC5988]Nottingham, M., “Web Linking,” RFC 5988, October 2010 (TXT).
[W3C.REC-html401-19991224]Hors, A., Raggett, D., and I. Jacobs, “HTML 4.01 Specification,” World Wide Web Consortium Recommendation REC-html401-19991224, December 1999 (HTML).
+ + + + + + + + + + + + + + + + + + + + + +
+ [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.
+ [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.
+ [RFC6570] + Gregorio, J., Fielding, R., Hadley, M., Nottingham, M. and D. Orchard, "URI Template", RFC 6570, DOI 10.17487/RFC6570, March 2012.
+ [json-schema] + Wright, A., "JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-wright-json-schema-00, October 2016.
- -

-
 TOC 
-

Appendix A.  -Change Log

- -

-

-
-
draft-04
-
- -
    -
  • Resolution of link URIs ("href") is now affected by rel="self" links on the instance -
  • -
  • Define "title" for LDOs -
  • -
  • Use URI Templates for the "href" property -
  • -
  • Split hyper-schema definition out from main schema. -
  • -
  • Removed "readonly" -
  • -
  • Capitalised the T in "encType" -
  • -
  • Moved "mediaType" and "contentEncoding" to the new "media" property (renamed "type" and "binaryEncoding") -
  • -
  • Added "mediaType" property to LDOs -
  • -
  • Replaced "slash-delimited" fragment resolution with - "json-pointer". -
  • -
  • Added "template" LDO attribute. -
  • -
  • Improved wording of sections. -
  • -
- -
-
draft-03
-
- -
    -
  • Added example and verbiage to "extends" attribute. -
  • -
  • Defined slash-delimited to use a leading slash. -
  • -
  • Made "root" a relation instead of an attribute. -
  • -
  • Removed address values, and MIME media type from format to reduce - confusion (mediaType already exists, so it can be used for MIME - types). -
  • -
  • Added more explanation of nullability. -
  • -
  • Removed "alternate" attribute. -
  • -
  • Upper cased many normative usages of must, may, and should. -
  • -
  • Replaced the link submission "properties" attribute to "schema" - attribute. -
  • -
  • Replaced "optional" attribute with "required" attribute. -
  • -
  • Replaced "maximumCanEqual" attribute with "exclusiveMaximum" - attribute. -
  • -
  • Replaced "minimumCanEqual" attribute with "exclusiveMinimum" - attribute. -
  • -
  • Replaced "requires" attribute with "dependencies" attribute. -
  • -
  • Moved "contentEncoding" attribute to hyper schema. -
  • -
  • Added "additionalItems" attribute. -
  • -
  • Added "id" attribute. -
  • -
  • Switched self-referencing variable substitution from "-this" to "@" - to align with reserved characters in URI template. -
  • -
  • Added "patternProperties" attribute. -
  • -
  • Schema URIs are now namespace versioned. -
  • -
  • Added "$ref" and "$schema" attributes. -
  • -
- -
-
draft-02
-
- -
    -
  • Replaced "maxDecimal" attribute with "divisibleBy" attribute. -
  • -
  • Added slash-delimited fragment resolution protocol and made it the - default. -
  • -
  • Added language about using links outside of schemas by referencing - its normative URI. -
  • -
  • Added "uniqueItems" attribute. -
  • -
  • Added "targetSchema" attribute to link description object. -
  • -
- -
-
draft-01
-
- -
    -
  • Fixed category and updates from template. -
  • -
- -
-
draft-00
-
- -
    -
  • Initial draft. -
  • -
- -
-

- -

-

-
 TOC 
-

Authors' Addresses

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +

6.2. Informative References

+
 Geraint Luff (editor)
 Cambridge
 UK
EMail: luffgd@gmail.com
  
 Kris Zyp
 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
+ + + + + + + + + + + + + + + + + +
+ [RFC2046] + Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types", RFC 2046, DOI 10.17487/RFC2046, November 1996.
+ [RFC5988] + Nottingham, M., "Web Linking", RFC 5988, DOI 10.17487/RFC5988, October 2010.
+ [RFC7231] + Fielding, R. and J. Reschke, "Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content", RFC 7231, DOI 10.17487/RFC7231, June 2014.
+ [W3C.CR-html5-20140731] + Berjon, R., Faulkner, S., Leithead, T., Navara, E., O&#039;Connor, E. and S. Pfeiffer, "HTML5", World Wide Web Consortium CR CR-html5-20140731, July 2014.
- +

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, and Henry H. Andrews for their submissions and patches to the document.

+

Appendix B. Change Log

+

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

+

+ +

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

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

+
+
+ +

+

+ Authors' Addresses +

+
+
+ + Austin Wright (editor) + + + + + + + + + + + + + EMail: aaa@bzfx.net + +
+
+
+ + Geraint Luff + + + + + + + Cambridge, + + + + UK + + EMail: luffgd@gmail.com + +
+
+ + + diff --git a/latest/json-schema-validation.html b/latest/json-schema-validation.html index e7ccf207..4bca4c49 100644 --- a/latest/json-schema-validation.html +++ b/latest/json-schema-validation.html @@ -1,1517 +1,724 @@ - -JSON Schema: interactive and non interactive validation - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - ol.text { margin-left: 2em; margin-right: 2em; } - ul.text { margin-left: 2em; margin-right: 2em; } - li { margin-left: 3em; } - - /* RFC-2629 s and s. */ - em { font-style: italic; } - strong { font-weight: bold; } - dfn { font-weight: bold; font-style: normal; } - cite { font-weight: normal; font-style: normal; } - tt { color: #036; } - tt, pre, pre dfn, pre em, pre cite, pre span { - font-family: "Courier New", Courier, monospace; font-size: small; - } - pre { - text-align: left; padding: 4px; - color: #000; background-color: #CCC; - } - pre dfn { color: #900; } - pre em { color: #66F; background-color: #FFC; font-weight: normal; } - pre .key { color: #33C; font-weight: bold; } - pre .id { color: #900; } - pre .str { color: #000; background-color: #CFF; } - pre .val { color: #066; } - pre .rep { color: #909; } - pre .oth { color: #000; background-color: #FCF; } - pre .err { background-color: #FCC; } - - /* RFC-2629 s. */ - table.all, table.full, table.headers, table.none { - font-size: small; text-align: center; border-width: 2px; - vertical-align: top; border-collapse: collapse; - } - table.all, table.full { border-style: solid; border-color: black; } - table.headers, table.none { border-style: none; } - th { - font-weight: bold; border-color: black; - border-width: 2px 2px 3px 2px; - } - table.all th, table.full th { border-style: solid; } - table.headers th { border-style: none none solid none; } - table.none th { border-style: none; } - table.all td { - border-style: solid; border-color: #333; - border-width: 1px 2px; - } - table.full td, table.headers td, table.none td { border-style: none; } - - hr { height: 1px; } - hr.insert { - width: 80%; border-style: none; border-width: 0; - color: #CCC; background-color: #CCC; - } ---> - -
 TOC 
-
- - - - - - -
Internet Engineering Task Forcefge. Galiegue
Internet-Draft 
Intended status: InformationalK. Zyp, Ed.
Expires: August 3, 2013SitePen (USA)
 G. Court
 January 30, 2013
-


JSON Schema: interactive and non interactive validation
json-schema-validation

- -

Abstract

- -

- JSON Schema (application/schema+json) has several purposes, one of which is instance - validation. The validation process may be interactive or non interactive. For - instance, applications may use JSON Schema to build a user interface enabling - interactive content generation in addition to user input checking, or validate data - retrieved from various sources. This specification describes schema keywords - dedicated to validation purposes. - -

-

Status of This Memo

-

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

-

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

-

-Internet-Drafts are 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 Notice

-

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

-

-

Table of Contents

-

-1.  -Introduction
-2.  -Conventions and Terminology
-3.  -Interoperability considerations
-    3.1.  -Validation of string instances
-    3.2.  -Validation of numeric instances
-    3.3.  -Regular expressions
-4.  -General validation considerations
-    4.1.  -Keywords and instance primitive types
-    4.2.  -Inter-dependent keywords
-    4.3.  -Default values for missing keywords
-    4.4.  -Validation of container instances
-5.  -Validation keywords sorted by instance types
-    5.1.  -Validation keywords for numeric instances (number and integer)
-        5.1.1.  -multipleOf
-        5.1.2.  -maximum and exclusiveMaximum
-        5.1.3.  -minimum and exclusiveMinimum
-    5.2.  -Validation keywords for strings
-        5.2.1.  -maxLength
-        5.2.2.  -minLength
-        5.2.3.  -pattern
-    5.3.  -Validation keywords for arrays
-        5.3.1.  -additionalItems and items
-        5.3.2.  -maxItems
-        5.3.3.  -minItems
-        5.3.4.  -uniqueItems
-    5.4.  -Validation keywords for objects
-        5.4.1.  -maxProperties
-        5.4.2.  -minProperties
-        5.4.3.  -required
-        5.4.4.  -additionalProperties, properties and patternProperties
-        5.4.5.  -dependencies
-    5.5.  -Validation keywords for any instance type
-        5.5.1.  -enum
-        5.5.2.  -type
-        5.5.3.  -allOf
-        5.5.4.  -anyOf
-        5.5.5.  -oneOf
-        5.5.6.  -not
-        5.5.7.  -definitions
-6.  -Metadata keywords
-    6.1.  -"title" and "description"
-        6.1.1.  -Valid values
-        6.1.2.  -Purpose
-    6.2.  -"default"
-        6.2.1.  -Valid values
-        6.2.2.  -Purpose
-7.  -Semantic validation with "format"
-    7.1.  -Foreword
-    7.2.  -Implementation requirements
-    7.3.  -Defined attributes
-        7.3.1.  -date-time
-        7.3.2.  -email
-        7.3.3.  -hostname
-        7.3.4.  -ipv4
-        7.3.5.  -ipv6
-        7.3.6.  -uri
-8.  -Reference algorithms for calculating children schemas
-    8.1.  -Foreword
-    8.2.  -Array elements
-        8.2.1.  -Defining characteristic
-        8.2.2.  -Implied keywords and default values.
-        8.2.3.  -Calculation
-    8.3.  -Object members
-        8.3.1.  -Defining characteristic
-        8.3.2.  -Implied keywords
-        8.3.3.  -Calculation
-9.  -IANA Considerations
-10.  -References
-    10.1.  -Normative References
-    10.2.  -Informative References
-Appendix A.  -ChangeLog
-

-
- -

-
 TOC 
-

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 materialized by a set of - keywords which are described in this specification. In addition, a set of keywords - is defined to assist in interactive instance generation. Those are also described in - this specification. - -

-

- This specification will use the terminology defined by the JSON Schema core - specification. It is advised that readers have a copy of this specification. - -

-

-
 TOC 
-

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 (Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels,” March 1997.) [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. - -

-

- This specification uses the term "property set" to refer to the set of an object's - member names; for instance, the property set of JSON Object { "a": 1, "b": 2 } is [ - "a", "b" ]. - -

-

- Elements in an array value are said to be unique if no two elements of this array - are equal, as defined by the core specification. - -

-

-
 TOC 
-

3.  -Interoperability considerations

- -

-
 TOC 
-

3.1.  -Validation of string instances

- -

- It should be noted that the nul character (\x00) 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. - -

-

-
 TOC 
-

3.2.  -Validation of numeric instances

- -

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

-

-
 TOC 
-

3.3.  -Regular expressions

- -

- Two validation keywords, "pattern" and "patternProperties", use regular - expressions to express constraints. These regular expressions SHOULD - be valid according to the ECMA 262 (, “ECMA 262 specification,” .) [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 (Crockford, D., “The application/json Media Type for JavaScript Object Notation (JSON),” July 2006.) [RFC4627]; -

-

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 consider that regular expressions are - anchored, neither at the beginning nor at the end. This means, for instance, - that "es" matches "expression". - -

-

-
 TOC 
-

4.  -General validation considerations

- -

-
 TOC 
-

4.1.  -Keywords and instance primitive types

- -

- Some validation keywords only apply to one or more primitive types. When the - primitive type of the instance cannot be validated by a given keyword, - validation for this keyword and instance SHOULD succeed. - -

-

- This specification groups keywords in different sections, according to the - primitive type, or types, these keywords validate. Note that some keywords - validate all instance types. - -

-

-
 TOC 
-

4.2.  -Inter-dependent keywords

- -

- In order to validate an instance, some keywords are influenced by the presence - (or absence) of other keywords. In this case, all these keywords will be grouped - in the same section. - -

-

-
 TOC 
-

4.3.  -Default values for missing keywords

- -

- Some keywords, if absent, MAY be regarded by implementations as having - a default value. In this case, the default value will be mentioned. - -

-

-
 TOC 
-

4.4.  -Validation of container instances

- -

- Keywords with the possibility to validate container instances (arrays or - objects) only validate the instances themselves and not their children (array - items or object properties). Some of these keywords do, however, contain - information which is necessary for calculating which schema(s) a child must be - valid against. The algorithms to calculate a child instance's relevant schema(s) - are explained in a separate section. - -

-

- It should be noted that while an array element will only have to validate - against one schema, object member values may have to validate against more than - one schema. - -

-

-
 TOC 
-

5.  -Validation keywords sorted by instance types

- -

-
 TOC 
-

5.1.  -Validation keywords for numeric instances (number and integer)

- -

-
 TOC 
-

5.1.1.  -multipleOf

- -

-
 TOC 
-

5.1.1.1.  -Valid values

- -

- The value of "multipleOf" MUST be a JSON number. This number MUST be - strictly greater than 0. - -

-

-
 TOC 
-

5.1.1.2.  -Conditions for successful validation

- -

- A numeric instance is valid against "multipleOf" if the - result of the division of the instance by this keyword's value is - an integer. - -

-

-
 TOC 
-

5.1.2.  -maximum and exclusiveMaximum

- -

-
 TOC 
-

5.1.2.1.  -Valid values

- -

- The value of "maximum" MUST be a JSON number. The value of - "exclusiveMaximum" MUST be a boolean. - -

-

- If "exclusiveMaximum" is present, "maximum" MUST also be present. - -

-

-
 TOC 
-

5.1.2.2.  -Conditions for successful validation

- -

- Successful validation depends on the presence and value of - "exclusiveMaximum": - -

-
-

if "exclusiveMaximum" is not present, or has boolean value false, - then the instance is valid if it is lower than, or equal to, the - value of "maximum"; -

-

if "exclusiveMaximum" has boolean value true, the instance is - valid if it is strictly lower than the value of "maximum". -

-

- -

-

-
 TOC 
-

5.1.2.3.  -Default value

- -

- "exclusiveMaximum", if absent, may be considered as being present with - boolean value false. - -

-

-
 TOC 
-

5.1.3.  -minimum and exclusiveMinimum

- -

-
 TOC 
-

5.1.3.1.  -Valid values

- -

- The value of "minimum" MUST be a JSON number. The value of - "exclusiveMinimum" MUST be a boolean. - -

-

- If "exclusiveMinimum" is present, "minimum" MUST also be present. - -

-

-
 TOC 
-

5.1.3.2.  -Conditions for successful validation

- -

- Successful validation depends on the presence and value of - "exclusiveMinimum": - -

-
-

if "exclusiveMinimum" is not present, or has boolean value false, - then the instance is valid if it is greater than, or equal to, the - value of "minimum"; -

-

if "exclusiveMinimum" is present and has boolean value true, the - instance is valid if it is strictly greater than the value of - "minimum". -

-

- -

-

-
 TOC 
-

5.1.3.3.  -Default value

- -

- "exclusiveMinimum", if absent, may be considered as being present with - boolean value false. - -

-

-
 TOC 
-

5.2.  -Validation keywords for strings

- -

-
 TOC 
-

5.2.1.  -maxLength

- -

-
 TOC 
-

5.2.1.1.  -Valid values

- -

- The value of this keyword MUST be an integer. This integer MUST be - greater than, or equal to, 0. - -

-

-
 TOC 
-

5.2.1.2.  -Conditions for successful validation

- -

- 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 4627 (Crockford, D., “The application/json Media Type for JavaScript Object Notation (JSON),” July 2006.) [RFC4627]. - -

-

-
 TOC 
-

5.2.2.  -minLength

- -

-
 TOC 
-

5.2.2.1.  -Valid values

- -

- The value of this keyword MUST be an integer. This integer MUST be - greater than, or equal to, 0. - -

-

-
 TOC 
-

5.2.2.2.  -Conditions for successful validation

- -

- 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 4627 (Crockford, D., “The application/json Media Type for JavaScript Object Notation (JSON),” July 2006.) [RFC4627]. - -

-

-
 TOC 
-

5.2.2.3.  -Default value

- -

- "minLength", if absent, may be considered as being present with integer - value 0. - -

-

-
 TOC 
-

5.2.3.  -pattern

- -

-
 TOC 
-

5.2.3.1.  -Valid values

- -

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

-

-
 TOC 
-

5.2.3.2.  -Conditions for successful validation

- -

- A string instance is considered valid if the regular - expression matches the instance successfully. Recall: regular - expressions are not implicitly anchored. - -

-

-
 TOC 
-

5.3.  -Validation keywords for arrays

- -

-
 TOC 
-

5.3.1.  -additionalItems and items

- -

-
 TOC 
-

5.3.1.1.  -Valid values

- -

- The value of "additionalItems" MUST be either a boolean or an object. If - it is an object, this object MUST be a valid JSON Schema. - -

-

- The value of "items" MUST be either an object or an array. If it is an - object, this object MUST be a valid JSON Schema. If it is an array, - items of this array MUST be objects, and each of these objects MUST be a - valid JSON Schema. - -

-

-
 TOC 
-

5.3.1.2.  -Conditions for successful validation

- -

- Successful validation of an array instance with regards to these two - keywords is determined as follows: - -

-
-

if "items" is not present, or its value is an object, validation - of the instance always succeeds, regardless of the value of - "additionalItems"; -

-

if the value of "additionalItems" is boolean value true or an - object, validation of the instance always succeeds; -

-

if the value of "additionalItems" is boolean value false and the - value of "items" is an array, the instance is valid if - its size is less than, or equal to, the size of "items". -

-

- -

-

-
 TOC 
-

5.3.1.3.  -Example

- -

- The following example covers the case where "additionalItems" has - boolean value false and "items" is an array, since this is the only - situation under which an instance may fail to validate successfully. - -

-

This is an example schema: -

-
-{
-    "items": [ {}, {}, {} ],
-    "additionalItems": false
-}
-
-
-

- With this schema, the following instances are valid: - -

-
-

[] (an empty array), -

-

[ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ], -

-

[ 1, 2, 3 ]; -

-

- -

-

- the following instances are invalid: - -

-
-

[ 1, 2, 3, 4 ], -

-

[ null, { "a": "b" }, true, 31.000002020013 ] -

-

- -

-

-
 TOC 
-

5.3.1.4.  -Default values

- -

- If either keyword is absent, it may be considered present with an empty - schema. - -

-

-
 TOC 
-

5.3.2.  -maxItems

- -

-
 TOC 
-

5.3.2.1.  -Valid values

- -

- The value of this keyword MUST be an integer. This integer MUST be - greater than, or equal to, 0. - -

-

-
 TOC 
-

5.3.2.2.  -Conditions for successful validation

- -

- An array instance is valid against "maxItems" if its size is - less than, or equal to, the value of this keyword. - -

-

-
 TOC 
-

5.3.3.  -minItems

- -

-
 TOC 
-

5.3.3.1.  -Valid values

- -

- The value of this keyword MUST be an integer. This integer MUST be - greater than, or equal to, 0. - -

-

-
 TOC 
-

5.3.3.2.  -Conditions for successful validation

- -

- An array instance is valid against "minItems" if its size is - greater than, or equal to, the value of this keyword. - -

-

-
 TOC 
-

5.3.3.3.  -Default value

- -

- If this keyword is not present, it may be considered present with a - value of 0. - -

-

-
 TOC 
-

5.3.4.  -uniqueItems

- -

-
 TOC 
-

5.3.4.1.  -Valid values

- -

- The value of this keyword MUST be a boolean. - -

-

-
 TOC 
-

5.3.4.2.  -Conditions for successful validation

- -

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

-

-
 TOC 
-

5.3.4.3.  -Default value

- -

- If not present, this keyword may be considered present with boolean - value false. - -

-

-
 TOC 
-

5.4.  -Validation keywords for objects

- -

-
 TOC 
-

5.4.1.  -maxProperties

- -

-
 TOC 
-

5.4.1.1.  -Valid values

- -

- The value of this keyword MUST be an integer. This integer MUST be - greater than, or equal to, 0. - -

-

-
 TOC 
-

5.4.1.2.  -Conditions for successful validation

- -

- An object instance is valid against "maxProperties" if its - number of properties is less than, or equal to, the value of this - keyword. - -

-

-
 TOC 
-

5.4.2.  -minProperties

- -

-
 TOC 
-

5.4.2.1.  -Valid values

- -

- The value of this keyword MUST be an integer. This integer MUST be - greater than, or equal to, 0. - -

-

-
 TOC 
-

5.4.2.2.  -Conditions for successful validation

- -

- An object instance is valid against "minProperties" if its - number of properties is greater than, or equal to, the value of this - keyword. - -

-

-
 TOC 
-

5.4.2.3.  -Default value

- -

- If this keyword is not present, it may be considered present with a - value of 0. - -

-

-
 TOC 
-

5.4.3.  -required

- -

-
 TOC 
-

5.4.3.1.  -Valid values

- -

- The value of this keyword MUST be an array. This array MUST have at - least one element. Elements of this array MUST be strings, and MUST be - unique. - -

-

-
 TOC 
-

5.4.3.2.  -Conditions for successful validation

-

- An object instance is valid against this keyword if its - property set contains all elements in this keyword's array value. - -

-

-
 TOC 
-

5.4.4.  -additionalProperties, properties and patternProperties

- -

-
 TOC 
-

5.4.4.1.  -Valid values

- -

- The value of "additionalProperties" MUST be a boolean or an object. If - it is an object, it MUST also be a valid JSON Schema. - -

-

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

-

- 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 an object, and each object MUST be a valid JSON Schema. - -

-

-
 TOC 
-

5.4.4.2.  -Conditions for successful validation

- -

- Successful validation of an object instance against these three keywords - depends on the value of "additionalProperties": - -

-
-

if its value is boolean true or a schema, validation - succeeds; -

-

if its value is boolean false, the algorithm to determine - validation success is described below. -

-

- -

-

-
 TOC 
-

5.4.4.3.  -Default values

- -

- If either "properties" or "patternProperties" are absent, they can be - considered present with an empty object as a value. - -

-

- If "additionalProperties" is absent, it may be considered present with - an empty schema as a value. - -

-

-
 TOC 
-

5.4.4.4.  -If "additionalProperties" has boolean value false

- -

- In this case, validation of the instance depends on the property set of - "properties" and "patternProperties". In this section, the property - names of "patternProperties" will be called regexes for convenience. - -

-

- The first step is to collect the following sets: - -

-
-
s
-
The property set of the instance to validate. -
-
p
-
The property set from "properties". -
-
pp
-
The property set from "patternProperties". -
-

- -

-

- Having collected these three sets, the process is as follows: - -

-
-

remove from "s" all elements of "p", if any; -

-

for each regex in "pp", remove all elements of "s" which this - regex matches. -

-

- -

-

- Validation of the instance succeeds if, after these two - steps, set "s" is empty. - -

-

-
 TOC 
-

5.4.4.5.  -Example

- -

- This schema will be used as an example: - -

-
-{
-    "properties": {
-        "p1": {}
-    },
-    "patternProperties": {
-        "p": {},
-        "[0-9]": {}
-    }
-}
-
-
-

- This is the instance to validate: - -

-
-{
-    "p1": true,
-    "p2": null,
-    "a32&o": "foobar",
-    "": [],
-    "fiddle": 42,
-    "apple": "pie"
-}
-
-
-

- The three property sets are: - -

-
-
s
-
[ "p1", "p2", "a32&o", "", "fiddle", "apple" - ] -
-
p
-
[ "p1" ] -
-
pp
-
[ "p", "[0-9]" ] -
-

- -

-

- Applying the two steps of the algorithm: - -

-
-

after the first step, "p1" is removed from "s"; -

-

after the second step, "p2" (matched by "p"), "a32&o" - (matched by "[0-9]") and "apple" (matched by "p") are removed from - "s". -

-

- -

-

- The set "s" still contains two elements, "" and "fiddle". Validation - therefore fails. - -

-

-
 TOC 
-

5.4.5.  -dependencies

- -

-
 TOC 
-

5.4.5.1.  -Valid values

- -

- This keyword's value MUST be an object. Each value of this object MUST - be either an object or an array. - -

-

- If the value is an object, it MUST be a valid JSON Schema. This is - called a schema dependency. - -

-

- If the value is an array, it MUST have at least one element. Each - element MUST be a string, and elements in the array MUST be unique. This - is called a property dependency. - -

-

-
 TOC 
-

5.4.5.2.  -Conditions for successful validation

- -

-
 TOC 
-

5.4.5.2.1.  -Schema dependencies

- -

- For all (name, schema) pair of schema dependencies, if the instance - has a property by this name, then it must also validate successfully - against the schema. - -

-

- Note that this is the instance itself which must validate - successfully, not the value associated with the property name. - -

-

-
 TOC 
-

5.4.5.2.2.  -Property dependencies

- -

- For each (name, propertyset) pair of property dependencies, if the - instance has a property by this name, then it must also have - properties with the same names as propertyset. - -

-

-
 TOC 
-

5.5.  -Validation keywords for any instance type

- -

-
 TOC 
-

5.5.1.  -enum

- -

-
 TOC 
-

5.5.1.1.  -Valid values

- -

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

-

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

-

-
 TOC 
-

5.5.1.2.  -Conditions for successful validation

- -

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

-

-
 TOC 
-

5.5.2.  -type

- -

-
 TOC 
-

5.5.2.1.  -Valid values

- -

- 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 seven primitive types defined by - the core specification. - -

-

-
 TOC 
-

5.5.2.2.  -Conditions for successful validation

- -

- An instance matches successfully if its primitive type is one of the - types defined by keyword. Recall: "number" includes "integer". - -

-

-
 TOC 
-

5.5.3.  -allOf

- -

-
 TOC 
-

5.5.3.1.  -Valid values

- -

- This keyword's value MUST be an array. This array MUST have at least one - element. - -

-

- Elements of the array MUST be objects. Each object MUST be a valid JSON - Schema. - -

-

-
 TOC 
-

5.5.3.2.  -Conditions for successful validation

- -

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

-

-
 TOC 
-

5.5.4.  -anyOf

- -

-
 TOC 
-

5.5.4.1.  -Valid values

- -

- This keyword's value MUST be an array. This array MUST have at least one - element. - -

-

- Elements of the array MUST be objects. Each object MUST be a valid JSON - Schema. - -

-

-
 TOC 
-

5.5.4.2.  -Conditions for successful validation

- -

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

-

-
 TOC 
-

5.5.5.  -oneOf

- -

-
 TOC 
-

5.5.5.1.  -Valid values

- -

- This keyword's value MUST be an array. This array MUST have at least one - element. - -

-

- Elements of the array MUST be objects. Each object MUST be a valid JSON - Schema. - -

-

-
 TOC 
-

5.5.5.2.  -Conditions for successful validation

- -

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

-

-
 TOC 
-

5.5.6.  -not

- -

-
 TOC 
-

5.5.6.1.  -Valid values

- -

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

-

-
 TOC 
-

5.5.6.2.  -Conditions for successful validation

- -

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

-

-
 TOC 
-

5.5.7.  -definitions

+ -

-
 TOC 
-

5.5.7.1.  -Valid values

+ + + + + + + + + + + + + + + + + + + + + + +
Internet Engineering Task ForceA. Wright, Ed.
Internet-Draft
Intended status: InformationalG. Luff
Expires: May 7, 2017November 3, 2016
+ +

JSON Schema Validation: A Vocabulary for Structural Validation of JSON
+ draft-wright-json-schema-validation-00

+ +

+ Abstract +

+

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

+

+ Note to Readers +

+

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

+

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

+

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

+

+ Status of This Memo +

+

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

+

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at 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 Notice +

+

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.

+ + +
+

Table of Contents

+ + +

1. Introduction

+

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

+

This specification will use the 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.

+

This specification uses the term "property set" to refer to the set of an object's member names; for instance, the property set of JSON Object { "a": 1, "b": 2 } is [ "a", "b" ].

+

Elements in an array value are said to be unique if no two elements of this array are equal [json-schema].

+

3. Interoperability considerations

+

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

+

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

+

3.3. Regular expressions

+

Two validation keywords, "pattern" and "patternProperties", use regular expressions to express constraints. 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 ("|").
  • +
-

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

-

-
 TOC 
-

5.5.7.2.  -Conditions for successful validation

+

+

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

+

4. General validation considerations

+

4.1. Keywords and instance primitive types

+

Most validation keywords only limit the range of values within a certain primitive type. When the primitive type of the instance is not of the type targeted by the keyword, the validation succeeds.

+

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, the keyword passes validation.

+

4.2. Missing keywords

+

Validation keywords that are missing 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.

+

4.3. Linearity

+

Validation keywords typically operate independent of each other, without affecting each other.

+

For author convienence, there are some exceptions:

+ +
    +
  • "additionalProperties", whose behavior is defined in terms of "properties" and "patternProperties"; and
  • +
  • "additionalItems", whose behavior is defined in terms of "items"
  • +
-

- This keyword plays no role in validation per se. Its role is to provide - a standardized location for schema authors to inline JSON Schemas into a - more general schema. - -

-

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

+

5. Validation keywords

+

Validation keywords in a schema impose requirements for successfully validating an instance.

+

5.1. multipleOf

+

The value of "multipleOf" MUST be a number, strictly greater than 0.

+

A numeric instance is only valid if division by this keyword's value results in an integer.

+

5.2. maximum

+

The value of "maximum" MUST be a number, representing an upper limit for a numeric instance.

+

If the instance is a number, then this keyword validates if "exclusiveMaximum" is true and instance is less than the provided value, or else if the instance is less than or exactly equal to the provided value.

+

5.3. exclusiveMaximum

+

The value of "exclusiveMaximum" MUST be a boolean, representing whether the limit in "maximum" is exclusive or not. An undefined value is the same as false.

+

If "exclusiveMaximum" is true, then a numeric instance SHOULD NOT be equal to the value specified in "maximum". If "exclusiveMaximum" is false (or not specified), then a numeric instance MAY be equal to the value of "maximum".

+

5.4. minimum

+

The value of "minimum" MUST be a number, representing a lower limit for a numeric instance.

+

If the instance is a number, then this keyword validates if "exclusiveMinimum" is true and instance is greater than the provided value, or else if the instance is greater than or exactly equal to the provided value.

+

5.5. exclusiveMinimum

+

The value of "exclusiveMinimum" MUST be a boolean, representing whether the limit in "minimum" is exclusive or not. An undefined value is the same as false.

+

If "exclusiveMinimum" is true, then a numeric instance SHOULD NOT be equal to the value specified in "minimum". If "exclusiveMinimum" is false (or not specified), then a numeric instance MAY be equal to the value of "minimum".

+

5.6. maxLength

+

The value of this keyword MUST be a non-negative integer.

+

The value of this keyword MUST be an integer. This integer MUST be greater than, or equal to, 0.

+

A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.

+

The length of a string instance is defined as the number of its characters as defined by RFC 7159 [RFC7159].

+

5.7. minLength

+

A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.

+

The length of a string instance is defined as the number of its characters as defined by RFC 7159 [RFC7159].

+

The value of this keyword MUST be an integer. This integer MUST be greater than, or equal to, 0.

+

"minLength", if absent, may be considered as being present with integer value 0.

+

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

+

5.9. additionalItems and items

+

The value of "additionalItems" MUST be either a boolean or an object. If it is an object, this object MUST be a valid JSON Schema.

+

The value of "items" MUST be either a schema or array of schemas.

+

Successful validation of an array instance with regards to these two keywords is determined as follows:

+ +
    +
  • if "items" is not present, or its value is an object, validation of the instance always succeeds, regardless of the value of "additionalItems";
  • +
  • if the value of "additionalItems" is boolean value true or an object, validation of the instance always succeeds;
  • +
  • if the value of "additionalItems" is boolean value false and the value of "items" is an array, the instance is valid if its size is less than, or equal to, the size of "items".
  • +
-

-
+

+

If either keyword is absent, it may be considered present with an empty schema.

+

5.10. maxItems

+

The value of this keyword MUST be an integer. This integer MUST be greater than, or equal to, 0.

+

An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword.

+

5.11. minItems

+

The value of this keyword MUST be an integer. This integer MUST be greater than, or equal to, 0.

+

An array instance is valid against "minItems" if its size is greater than, or equal to, the value of this keyword.

+

If this keyword is not present, it may be considered present with a value of 0.

+

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

+

If not present, this keyword may be considered present with boolean value false.

+

5.13. maxProperties

+

The value of this keyword MUST be an integer. This integer MUST be greater than, or equal to, 0.

+

An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword.

+

5.14. minProperties

+

The value of this keyword MUST be an integer. This integer MUST be greater than, or equal to, 0.

+

An object instance is valid against "minProperties" if its number of properties is greater than, or equal to, the value of this keyword.

+

If this keyword is not present, it may be considered present with a value of 0.

+

5.15. required

+

The value of this keyword MUST be an array. This array MUST have at least one element. Elements of this array MUST be strings, and MUST be unique.

+

An object instance is valid against this keyword if its property set contains all elements in this keyword's array value.

+

5.16. properties

+

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

+

If absent, it can be considered the same as an empty object.

+

5.17. 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 an object, and each object MUST be a valid JSON Schema.

+

If absent, it can be considered the same as an empty object.

+

5.18. additionalProperties

+

The value of "additionalProperties" MUST be a boolean or a schema.

+

If "additionalProperties" is absent, it may be considered present with an empty schema as a value.

+

If "additionalProperties" is true, validation always succeeds.

+

If "additionalProperties" is false, validation succeeds only if the instance is an object and all properties on the instance were covered by "properties" and/or "patternProperties".

+

If "additionalProperties" is an object, validate the value as a schema to all of the properties that weren't validated by "properties" nor "patternProperties".

+

5.19. dependencies

+

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 object or an array.

+

If the dependency value is an object, it MUST be a valid JSON Schema. If the dependency key is a property in the instance, the dependency value must validate against the entire instance.

+

If the dependency value is an array, it MUST have at least one element, each element MUST be a string, and elements in the array 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.

+

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

+

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

+

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

+

5.21. 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 seven primitive types defined by the core specification.

+

An instance matches successfully if its primitive type is one of the types defined by keyword. Recall: "number" includes "integer".

+

5.22. allOf

+

This keyword's value MUST be an array. This array MUST have at least one element.

+

Elements of the array MUST be objects. Each object 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.

+

5.23. anyOf

+

This keyword's value MUST be an array. This array MUST have at least one element.

+

Elements of the array MUST be objects. Each object 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.

+

5.24. oneOf

+

This keyword's value MUST be an array. This array MUST have at least one element.

+

Elements of the array MUST be objects. Each object 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.

+

5.25. not

+

This keyword's value MUST be an object. This object 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.

+

5.26. definitions

+

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

+

This keyword plays no role in validation per se. Its role is to provide a standardized location for schema authors to inline JSON Schemas into a more general schema.

+
 
 {
     "type": "array",
@@ -1525,593 +732,206 @@ 

Table of Contents

} } -

- - -

-

-
 TOC 
-

6.  -Metadata keywords

- -

-
 TOC 
-

6.1.  -"title" and "description"

- -

-
 TOC 
-

6.1.1.  -Valid values

- -

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

-

-
 TOC 
-

6.1.2.  -Purpose

- -

- 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 - preferrably be short, whereas a description will provide explanation about - the purpose of the instance described by this schema. - -

-

- Both of these keywords MAY be used in root schemas, and in any subschemas. - -

-

-
 TOC 
-

6.2.  -"default"

- -

-
 TOC 
-

6.2.1.  -Valid values

- -

- There are no restrictions placed on the value of this keyword. - -

-

-
 TOC 
-

6.2.2.  -Purpose

- -

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

-

- This keyword MAY be used in root schemas, and in any subschemas. - -

-

-
 TOC 
-

7.  -Semantic validation with "format"

- -

-
 TOC 
-

7.1.  -Foreword

- -

- Structural validation alone may be insufficient to validate that an instance - meets all the requirements of an application. The "format" keyword is defined to - allow interoperable semantic validation for a fixed subset of values which are - accurately described by authoritative resources, be they RFCs or other external - specifications. - -

-

- The value of this keyword is called a format attribute. It MUST be a string. A - format attribute can generally only validate a given set of instance types. If - the type of the instance to validate is not in this set, validation for this - format attribute and instance SHOULD succeed. - -

-

-
 TOC 
-

7.2.  -Implementation requirements

- -

- Implementations MAY support the "format" keyword. 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. - -

-

-
 TOC 
-

7.3.  -Defined attributes

- -

-
 TOC 
-

7.3.1.  -date-time

- -

-
 TOC 
-

7.3.1.1.  -Applicability

- -

- This attribute applies to string instances. - -

-

-
 TOC 
-

7.3.1.2.  -Validation

- -

- A string instance is valid against this attribute if it is a valid date - representation as defined by RFC 3339, section - 5.6 (Klyne, G., Ed. and C. Newman, “Date and Time on the Internet: Timestamps,” July 2002.) [RFC3339]. - -

-

-
 TOC 
-

7.3.2.  -email

- -

-
 TOC 
-

7.3.2.1.  -Applicability

- -

- This attribute applies to string instances. - -

-

-
 TOC 
-

7.3.2.2.  -Validation

- -

- A string instance is valid against this attribute if it is a valid - Internet email address as defined by RFC 5322, - section 3.4.1 (Resnick, P., Ed., “Internet Message Format,” October 2008.) [RFC5322]. - -

-

-
 TOC 
-

7.3.3.  -hostname

- -

-
 TOC 
-

7.3.3.1.  -Applicability

- -

- This attribute applies to string instances. - -

-

-
 TOC 
-

7.3.3.2.  -Validation

- -

- A string instance is valid against this attribute if it is a valid - representation for an Internet host name, as defined by RFC 1034, section 3.1 (Mockapetris, P., “Domain names - concepts and facilities,” November 1987.) [RFC1034]. - -

-

-
 TOC 
-

7.3.4.  -ipv4

- -

-
 TOC 
-

7.3.4.1.  -Applicability

- -

- This attribute applies to string instances. - -

-

-
 TOC 
-

7.3.4.2.  -Validation

- -

- A string instance is valid against this attribute if it is a valid - representation of an IPv4 address according to the "dotted-quad" ABNF - syntax as defined in RFC 2673, section - 3.2 (Crawford, M., “Binary Labels in the Domain Name System,” August 1999.) [RFC2673]. - -

-

-
 TOC 
-

7.3.5.  -ipv6

- -

-
 TOC 
-

7.3.5.1.  -Applicability

- -

- This attribute applies to string instances. - -

-

-
 TOC 
-

7.3.5.2.  -Validation

- -

- A string instance is valid against this attribute if it is a valid - representation of an IPv6 address as defined in RFC 2373, section 2.2 (Hinden, R. and S. Deering, “IP Version 6 Addressing Architecture,” July 1998.) [RFC2373]. - -

-

-
 TOC 
-

7.3.6.  -uri

- -

-
 TOC 
-

7.3.6.1.  -Applicability

- -

- This attribute applies to string instances. - -

-

-
 TOC 
-

7.3.6.2.  -Validation

- -

- A string instance is valid against this attribute if it is a valid URI, - according to [RFC3986] (Berners-Lee, T., Fielding, R., and L. Masinter, “Uniform Resource Identifier (URI): Generic Syntax,” January 2005.). - -

-

-
 TOC 
-

8.  -Reference algorithms for calculating children schemas

- -

-
 TOC 
-

8.1.  -Foreword

- -

- Calculating the schema, or schemas, a child instance must validate against is - influenced by the following: - -

-
-

the container instance type; -

-

the child instance's defining characteristic in the container - instance; -

-

the value of keywords implied in the calculation. -

-

- -

-

- In addition, it is important that if one or more keyword(s) implied in the - calculation are not defined, they be considered present with their default - value, which will be recalled in this section. - -

-

-
 TOC 
-

8.2.  -Array elements

- -

-
 TOC 
-

8.2.1.  -Defining characteristic

- -

- The defining characteristic of the child instance is its index within the - array. Recall: array indices start at 0. - -

-

-
 TOC 
-

8.2.2.  -Implied keywords and default values.

- -

- The two implied keywords in this calculation are "items" and - "additionalItems". - -

-

- If either keyword is absent, it is considered present with an empty schema as a - value. In addition, boolean value true for "additionalItems" is considered - equivalent to an empty schema. - -

-

-
 TOC 
-

8.2.3.  -Calculation

- -

-
 TOC 
-

8.2.3.1.  -If "items" is a schema

- -

- If items is a schema, then the child instance must be valid against this - schema, regardless of its index, and regardless of the value of - "additionalItems". - -

-

-
 TOC 
-

8.2.3.2.  -If "items" is an array

- -

- In this situation, the schema depends on the index: - -

-
-

if the index is less than, or equal to, the size of "items", the - child instance must be valid against the corresponding schema in the - "items" array; -

-

otherwise, it must be valid against the schema defined by - "additionalItems". -

-

- -

-

-
 TOC 
-

8.3.  -Object members

- -

-
 TOC 
-

8.3.1.  -Defining characteristic

- -

- The defining characteristic is the property name of the child. - -

-

-
 TOC 
-

8.3.2.  -Implied keywords

- -

- The three keywords implied in this calculation are "properties", - "patternProperties" and "additionalProperties". - -

-

- If "properties" or "patternProperties" are absent, they are considered - present with an empty object as a value. - -

-

- If "additionalProperties" is absent, it is considered present with an empty - schema as a value. In addition, boolean value true is considered equivalent - to an empty schema. - -

-

-
 TOC 
-

8.3.3.  -Calculation

- -

-
 TOC 
-

8.3.3.1.  -Names used in this calculation

- -

- The calculation below uses the following names: - -

-
-
m
-
The property name of the child. -
-
p
-
The property set from "properties". -
-
pp
-
The property set from "patternProperties". Elements - of this set will be called regexes for convenience. -
-
s
-
The set of schemas for the child instance. -
-

- -

-

-
 TOC 
-

8.3.3.2.  -First step: schemas in "properties"

- -

- If set "p" contains value "m", then the corresponding schema in - "properties" is added to "s". - -

-

-
 TOC 
-

8.3.3.3.  -Second step: schemas in "patternProperties"

- -

- For each regex in "pp", if it matches "m" successfully, the - corresponding schema in "patternProperties" is added to "s". - -

-

-
 TOC 
-

8.3.3.4.  -Third step: "additionalProperties"

- -

- The schema defined by "additionalProperties" is added to "s" if and only - if, at this stage, "s" is empty. - -

-

-
 TOC 
-

9.  -IANA Considerations

- -

- This specification does not have any influence with regards to IANA. - -

-

-
 TOC 
-

10.  -References

- -

-
 TOC 
-

10.1. Normative References

- - - -
[RFC2119]Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels,” BCP 14, RFC 2119, March 1997 (TXT, HTML, XML).
+ +

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

+

6. Metadata keywords

+

6.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 preferrably be short, whereas a description will provide explanation about the purpose of the instance described by this schema.

+

Both of these keywords MAY be used in root schemas, and in any subschemas.

+

6.2. "default"

+

There are no restrictions placed on the value of this keyword.

+

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.

+

This keyword MAY be used in root schemas, and in any subschemas.

+

7. Semantic validation with "format"

+

7.1. Foreword

+

Structural validation alone may be insufficient to validate that an instance meets all the requirements of an application. The "format" keyword is defined to allow interoperable semantic validation for a fixed subset of values which are accurately described by authoritative resources, be they RFCs or other external specifications.

+

The value of this keyword is called a format attribute. It MUST be a string. A format attribute can generally only validate a given set of instance types. If the type of the instance to validate is not in this set, validation for this format attribute and instance SHOULD succeed.

+

7.2. Implementation requirements

+

Implementations MAY support the "format" keyword. 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.
  • +
-

-
 TOC 
-

10.2. Informative References

- - - - - - - - - - - - - - - - - +

+

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

+

7.3. Defined formats

+

7.3.1. date-time

+

This attribute applies to string instances.

+

A string instance is valid against this attribute if it is a valid date representation as defined by RFC 3339, section 5.6 [RFC3339].

+

7.3.2. email

+

This attribute applies to string instances.

+

A string instance is valid against this attribute if it is a valid Internet email address as defined by RFC 5322, section 3.4.1 [RFC5322].

+

7.3.3. hostname

+

7.3.3.1. Applicability

+

This attribute applies to string instances.

+

7.3.3.2. Validation

+

A string instance is valid against this attribute if it is a valid representation for an Internet host name, as defined by RFC 1034, section 3.1 [RFC1034].

+

7.3.4. ipv4

+

This attribute applies to string instances.

+

A string instance is valid against this attribute if it is a valid representation of an IPv4 address according to the "dotted-quad" ABNF syntax as defined in RFC 2673, section 3.2 [RFC2673].

+

7.3.5. ipv6

+

This attribute applies to string instances.

+

A string instance is valid against this attribute if it is a valid representation of an IPv6 address as defined in RFC 2373, section 2.2 [RFC2373].

+

7.3.6. uri

+

This attribute applies to string instances.

+

A string instance is valid against this attribute if it is a valid URI, according to [RFC3986].

+

7.3.7. uriref

+

This attribute applies to string instances.

+

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

+

8. Security considerations

+

JSON Schema validation defines a vocabulary for JSON Schema core and conserns 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 arbritrary 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.

+

9. IANA Considerations

+

This specification does not have any influence with regards to IANA.

+

10. References

+

10.1. Normative References

+
[RFC1034]Mockapetris, P., “Domain names - concepts and facilities,” STD 13, RFC 1034, November 1987 (TXT).
[RFC2373]Hinden, R. and S. Deering, “IP Version 6 Addressing Architecture,” RFC 2373, July 1998 (TXT, XML).
[RFC2673]Crawford, M., “Binary Labels in the Domain Name System,” RFC 2673, August 1999 (TXT).
[RFC3339]Klyne, G., Ed. and C. Newman, “Date and Time on the Internet: Timestamps,” RFC 3339, July 2002 (TXT, 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).
[RFC5322]Resnick, P., Ed., “Internet Message Format,” RFC 5322, October 2008 (TXT, HTML, XML).
[ecma262]ECMA 262 specification.”
+ + + + + + , " +
+ [RFC2119] + Bradner, S., Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.
[json-schema]JSON Schema: A Media Type for Describing JSON Documents", Internet-Draft draft-wright-json-schema-00, October 2016.
- -

-
 TOC 
-

Appendix A.  -ChangeLog

- -

-

-
-
draft-00
-
- -
    -
  • Initial draft. -
  • -
  • Salvaged from draft v3. -
  • -
  • Redefine the "required" keyword. -
  • -
  • Remove "extends", "disallow" -
  • -
  • Add "anyOf", "allOf", "oneOf", "not", "definitions", "minProperties", - "maxProperties". -
  • -
  • "dependencies" member values can no longer be single strings; at - least one element is required in a property dependency array. -
  • -
  • Rename "divisibleBy" to "multipleOf". -
  • -
  • "type" arrays can no longer have schemas; remove "any" as a possible - value. -
  • -
  • Rework the "format" section; make support optional. -
  • -
  • "format": remove attributes "phone", "style", "color"; rename - "ip-address" to "ipv4"; add references for all attributes. -
  • -
  • Provide algorithms to calculate schema(s) for array/object - instances. -
  • -
  • Add interoperability considerations. -
  • -
- -
-

- -

-

-
 TOC 
-

Authors' Addresses

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - +

10.2. Informative References

+
 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
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + , " +
+ [RFC1034] + Mockapetris, P., "Domain names - concepts and facilities", STD 13, RFC 1034, DOI 10.17487/RFC1034, November 1987.
+ [RFC2373] + Hinden, R. and S. Deering, "IP Version 6 Addressing Architecture", RFC 2373, DOI 10.17487/RFC2373, July 1998.
+ [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.
+ [RFC7159] + Bray, T., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March 2014.
+ [RFC5322] + Resnick, P., Internet Message Format", RFC 5322, DOI 10.17487/RFC5322, October 2008.
[ecma262]ECMA 262 specification"
- +

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, and Henry H. Andrews for their submissions and patches to the document.

+

Appendix B. ChangeLog

+

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

+

+ +

+
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-01
+
+
    +
  • Initial draft.
  • +
  • Salvaged from draft v3.
  • +
  • Redefine the "required" keyword.
  • +
  • Remove "extends", "disallow"
  • +
  • Add "anyOf", "allOf", "oneOf", "not", "definitions", "minProperties", "maxProperties".
  • +
  • "dependencies" member values can no longer be single strings; at least one element is required in a property dependency array.
  • +
  • Rename "divisibleBy" to "multipleOf".
  • +
  • "type" arrays can no longer have schemas; remove "any" as a possible value.
  • +
  • Rework the "format" section; make support optional.
  • +
  • "format": remove attributes "phone", "style", "color"; rename "ip-address" to "ipv4"; add references for all attributes.
  • +
  • Provide algorithms to calculate schema(s) for array/object instances.
  • +
  • Add interoperability considerations.
  • +
+

+
+
+ +

+

+ Authors' Addresses +

+
+
+ + Austin Wright (editor) + + + + + + + + + + + + + EMail: aaa@bzfx.net + +
+
+
+ + Geraint Luff + + + + + + + + + + + + + EMail: luffgd@gmail.com + +
+
+ + + diff --git a/links b/links deleted file mode 100644 index da815919..00000000 --- a/links +++ /dev/null @@ -1,42 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/hyper-schema#", - "id": "http://json-schema.org/draft-04/links#", - "title": "Link Description Object", - "type": "object", - "required": [ "href", "rel" ], - "properties": { - "href": { - "description": "a URI template, as defined by RFC 6570, with the addition of the $, ( and ) characters for pre-processing", - "type": "string" - }, - "rel": { - "description": "relation to the target resource of the link", - "type": "string" - }, - "title": { - "description": "a title for the link", - "type": "string" - }, - "targetSchema": { - "description": "JSON Schema describing the link target", - "$ref": "hyper-schema#" - }, - "mediaType": { - "description": "media type (as defined by RFC 2046) describing the link target", - "type": "string" - }, - "method": { - "description": "method for requesting the target of the link (e.g. for HTTP this might be \"GET\" or \"DELETE\")", - "type": "string" - }, - "encType": { - "description": "The media type in which to submit data along with the request", - "type": "string", - "default": "application/json" - }, - "schema": { - "description": "Schema describing the data to submit along with the request", - "$ref": "hyper-schema#" - } - } -} diff --git a/schema b/schema index 85eb502a..cff8e562 100644 --- a/schema +++ b/schema @@ -1,6 +1,6 @@ { - "id": "http://json-schema.org/draft-04/schema#", - "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://json-schema.org/draft-wright-00/schema#", + "$schema": "http://json-schema.org/draft-wright-00/schema#", "description": "Core schema meta-schema", "definitions": { "schemaArray": { @@ -137,6 +137,7 @@ } ] }, + "format": { "type": "string" }, "allOf": { "$ref": "#/definitions/schemaArray" }, "anyOf": { "$ref": "#/definitions/schemaArray" }, "oneOf": { "$ref": "#/definitions/schemaArray" },