Blame doc/draft-zyp-json-schema-02.txt

Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Internet Engineering Task Force                              K. Zyp, Ed.
Packit 4c4d6b
Internet-Draft                                             SitePen (USA)
Packit 4c4d6b
Intended status: Informational                            March 23, 2010
Packit 4c4d6b
Expires: September 24, 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   A JSON Media Type for Describing the Structure and Meaning of JSON
Packit 4c4d6b
                               Documents
Packit 4c4d6b
                        draft-zyp-json-schema-02
Packit 4c4d6b
Packit 4c4d6b
Abstract
Packit 4c4d6b
Packit 4c4d6b
   JSON (JavaScript Object Notation) Schema defines the media type
Packit 4c4d6b
   application/schema+json, a JSON based format for defining the
Packit 4c4d6b
   structure of JSON data.  JSON Schema provides a contract for what
Packit 4c4d6b
   JSON data is required for a given application and how to interact
Packit 4c4d6b
   with it.  JSON Schema is intended to define validation,
Packit 4c4d6b
   documentation, hyperlink navigation, and interaction control of JSON
Packit 4c4d6b
   data.
Packit 4c4d6b
Packit 4c4d6b
Status of This Memo
Packit 4c4d6b
Packit 4c4d6b
   This Internet-Draft is submitted to IETF in full conformance with the
Packit 4c4d6b
   provisions of BCP 78 and BCP 79.
Packit 4c4d6b
Packit 4c4d6b
   Internet-Drafts are working documents of the Internet Engineering
Packit 4c4d6b
   Task Force (IETF), its areas, and its working groups.  Note that
Packit 4c4d6b
   other groups may also distribute working documents as Internet-
Packit 4c4d6b
   Drafts.
Packit 4c4d6b
Packit 4c4d6b
   Internet-Drafts are draft documents valid for a maximum of six months
Packit 4c4d6b
   and may be updated, replaced, or obsoleted by other documents at any
Packit 4c4d6b
   time.  It is inappropriate to use Internet-Drafts as reference
Packit 4c4d6b
   material or to cite them other than as "work in progress."
Packit 4c4d6b
Packit 4c4d6b
   The list of current Internet-Drafts can be accessed at
Packit 4c4d6b
   http://www.ietf.org/ietf/1id-abstracts.txt.
Packit 4c4d6b
Packit 4c4d6b
   The list of Internet-Draft Shadow Directories can be accessed at
Packit 4c4d6b
   http://www.ietf.org/shadow.html.
Packit 4c4d6b
Packit 4c4d6b
   This Internet-Draft will expire on September 24, 2010.
Packit 4c4d6b
Packit 4c4d6b
Copyright Notice
Packit 4c4d6b
Packit 4c4d6b
   Copyright (c) 2010 IETF Trust and the persons identified as the
Packit 4c4d6b
   document authors.  All rights reserved.
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010               [Page 1]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   This document is subject to BCP 78 and the IETF Trust's Legal
Packit 4c4d6b
   Provisions Relating to IETF Documents
Packit 4c4d6b
   (http://trustee.ietf.org/license-info) in effect on the date of
Packit 4c4d6b
   publication of this document.  Please review these documents
Packit 4c4d6b
   carefully, as they describe your rights and restrictions with respect
Packit 4c4d6b
   to this document.  Code Components extracted from this document must
Packit 4c4d6b
   include Simplified BSD License text as described in Section 4.e of
Packit 4c4d6b
   the Trust Legal Provisions and are provided without warranty as
Packit 4c4d6b
   described in the BSD License.
Packit 4c4d6b
Packit 4c4d6b
Table of Contents
Packit 4c4d6b
Packit 4c4d6b
   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  4
Packit 4c4d6b
   2.  Conventions  . . . . . . . . . . . . . . . . . . . . . . . . .  4
Packit 4c4d6b
   3.  Overview . . . . . . . . . . . . . . . . . . . . . . . . . . .  4
Packit 4c4d6b
     3.1.  Terminology  . . . . . . . . . . . . . . . . . . . . . . .  5
Packit 4c4d6b
     3.2.  Design Considerations  . . . . . . . . . . . . . . . . . .  6
Packit 4c4d6b
   4.  Schema/Instance Association  . . . . . . . . . . . . . . . . .  6
Packit 4c4d6b
     4.1.  Self-Descriptive Schema  . . . . . . . . . . . . . . . . .  7
Packit 4c4d6b
   5.  Core Schema Definition . . . . . . . . . . . . . . . . . . . .  7
Packit 4c4d6b
     5.1.  type . . . . . . . . . . . . . . . . . . . . . . . . . . .  8
Packit 4c4d6b
     5.2.  properties . . . . . . . . . . . . . . . . . . . . . . . .  8
Packit 4c4d6b
     5.3.  items  . . . . . . . . . . . . . . . . . . . . . . . . . .  9
Packit 4c4d6b
     5.4.  optional . . . . . . . . . . . . . . . . . . . . . . . . .  9
Packit 4c4d6b
     5.5.  additionalProperties . . . . . . . . . . . . . . . . . . .  9
Packit 4c4d6b
     5.6.  requires . . . . . . . . . . . . . . . . . . . . . . . . .  9
Packit 4c4d6b
     5.7.  minimum  . . . . . . . . . . . . . . . . . . . . . . . . . 10
Packit 4c4d6b
     5.8.  maximum  . . . . . . . . . . . . . . . . . . . . . . . . . 10
Packit 4c4d6b
     5.9.  minimumCanEqual  . . . . . . . . . . . . . . . . . . . . . 10
Packit 4c4d6b
     5.10. maximumCanEqual  . . . . . . . . . . . . . . . . . . . . . 10
Packit 4c4d6b
     5.11. minItems . . . . . . . . . . . . . . . . . . . . . . . . . 10
Packit 4c4d6b
     5.12. maxItems . . . . . . . . . . . . . . . . . . . . . . . . . 10
Packit 4c4d6b
     5.13. uniqueItems  . . . . . . . . . . . . . . . . . . . . . . . 10
Packit 4c4d6b
     5.14. pattern  . . . . . . . . . . . . . . . . . . . . . . . . . 10
Packit 4c4d6b
     5.15. maxLength  . . . . . . . . . . . . . . . . . . . . . . . . 11
Packit 4c4d6b
     5.16. minLength  . . . . . . . . . . . . . . . . . . . . . . . . 11
Packit 4c4d6b
     5.17. enum . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Packit 4c4d6b
     5.18. title  . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Packit 4c4d6b
     5.19. description  . . . . . . . . . . . . . . . . . . . . . . . 11
Packit 4c4d6b
     5.20. format . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Packit 4c4d6b
     5.21. contentEncoding  . . . . . . . . . . . . . . . . . . . . . 12
Packit 4c4d6b
     5.22. default  . . . . . . . . . . . . . . . . . . . . . . . . . 13
Packit 4c4d6b
     5.23. divisibleBy  . . . . . . . . . . . . . . . . . . . . . . . 13
Packit 4c4d6b
     5.24. disallow . . . . . . . . . . . . . . . . . . . . . . . . . 13
Packit 4c4d6b
     5.25. extends  . . . . . . . . . . . . . . . . . . . . . . . . . 13
Packit 4c4d6b
   6.  Hyper Schema . . . . . . . . . . . . . . . . . . . . . . . . . 13
Packit 4c4d6b
     6.1.  links  . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Packit 4c4d6b
       6.1.1.  Link Description Object  . . . . . . . . . . . . . . . 14
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010               [Page 2]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
     6.2.  fragmentResolution . . . . . . . . . . . . . . . . . . . . 18
Packit 4c4d6b
       6.2.1.  dot-delimited fragment resolution  . . . . . . . . . . 18
Packit 4c4d6b
       6.2.2.  slash-delimited fragment resolution  . . . . . . . . . 19
Packit 4c4d6b
     6.3.  root . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Packit 4c4d6b
     6.4.  readonly . . . . . . . . . . . . . . . . . . . . . . . . . 19
Packit 4c4d6b
     6.5.  pathStart  . . . . . . . . . . . . . . . . . . . . . . . . 20
Packit 4c4d6b
     6.6.  mediaType  . . . . . . . . . . . . . . . . . . . . . . . . 20
Packit 4c4d6b
     6.7.  alternate  . . . . . . . . . . . . . . . . . . . . . . . . 20
Packit 4c4d6b
   7.  Security Considerations  . . . . . . . . . . . . . . . . . . . 20
Packit 4c4d6b
   8.  IANA Considerations  . . . . . . . . . . . . . . . . . . . . . 21
Packit 4c4d6b
     8.1.  Registry of Link Relations . . . . . . . . . . . . . . . . 21
Packit 4c4d6b
   9.  References . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Packit 4c4d6b
     9.1.  Normative References . . . . . . . . . . . . . . . . . . . 22
Packit 4c4d6b
     9.2.  Informative References . . . . . . . . . . . . . . . . . . 22
Packit 4c4d6b
   Appendix A.  Change Log  . . . . . . . . . . . . . . . . . . . . . 23
Packit 4c4d6b
   Appendix B.  Open Issues . . . . . . . . . . . . . . . . . . . . . 24
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010               [Page 3]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
1.  Introduction
Packit 4c4d6b
Packit 4c4d6b
   JSON (JavaScript Object Notation) Schema is a JSON media type for
Packit 4c4d6b
   defining the structure of JSON data.  JSON Schema provides a contract
Packit 4c4d6b
   for what JSON data is required for a given application and how to
Packit 4c4d6b
   interact with it.  JSON Schema is intended to define validation,
Packit 4c4d6b
   documentation, hyperlink navigation, and interaction control of JSON
Packit 4c4d6b
   data.
Packit 4c4d6b
Packit 4c4d6b
2.  Conventions
Packit 4c4d6b
Packit 4c4d6b
   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
Packit 4c4d6b
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
Packit 4c4d6b
   document are to be interpreted as described in RFC 2119.
Packit 4c4d6b
Packit 4c4d6b
3.  Overview
Packit 4c4d6b
Packit 4c4d6b
   JSON Schema defines the media type application/schema+json for
Packit 4c4d6b
   describing the structure of other JSON documents.  JSON Schema is
Packit 4c4d6b
   JSON-based and includes facilities for describing the structure of
Packit 4c4d6b
   JSON documents in terms of allowable values, descriptions, and
Packit 4c4d6b
   interpreting relations with other resources.
Packit 4c4d6b
Packit 4c4d6b
   JSON Schema format is organized into several separate definitions.
Packit 4c4d6b
   The first definition is the core schema specification.  This
Packit 4c4d6b
   definition is primary concerned with describing a JSON structure and
Packit 4c4d6b
   specifying valid elements in the structure.  The second definition is
Packit 4c4d6b
   the Hyper Schema specification which is intended define elements in a
Packit 4c4d6b
   structure that can be interpreted as hyperlinks.  Hyper Schema builds
Packit 4c4d6b
   on JSON Schema to describe the hyperlink structure of other JSON
Packit 4c4d6b
   documents.  This allows user agents to be able to successfully
Packit 4c4d6b
   navigate JSON documents based on their schemas.
Packit 4c4d6b
Packit 4c4d6b
   Cumulatively JSON Schema acts as a meta-document that can be used to
Packit 4c4d6b
   define the required type and constraints on property values, as well
Packit 4c4d6b
   as define the meaning of the property values for the purpose of
Packit 4c4d6b
   describing a resource and determining hyperlinks within the
Packit 4c4d6b
   representation.
Packit 4c4d6b
Packit 4c4d6b
   An example JSON Schema that describes products might look like:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010               [Page 4]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   {
Packit 4c4d6b
     "name":"Product",
Packit 4c4d6b
     "properties":{
Packit 4c4d6b
       "id":{
Packit 4c4d6b
         "type":"number",
Packit 4c4d6b
         "description":"Product identifier"
Packit 4c4d6b
       },
Packit 4c4d6b
       "name":{
Packit 4c4d6b
         "description":"Name of the product",
Packit 4c4d6b
         "type":"string"
Packit 4c4d6b
       },
Packit 4c4d6b
       "price":{
Packit 4c4d6b
         "type": "number",
Packit 4c4d6b
         "minimum":0
Packit 4c4d6b
       },
Packit 4c4d6b
       "tags":{
Packit 4c4d6b
         "optional":true,
Packit 4c4d6b
         "type":"array",
Packit 4c4d6b
         "items":{
Packit 4c4d6b
            "type":"string"
Packit 4c4d6b
         }
Packit 4c4d6b
       }
Packit 4c4d6b
     },
Packit 4c4d6b
     "links":[
Packit 4c4d6b
       {
Packit 4c4d6b
         "rel":"full",
Packit 4c4d6b
         "href":"{id}"
Packit 4c4d6b
       },
Packit 4c4d6b
       {
Packit 4c4d6b
         "rel":"comments",
Packit 4c4d6b
         "href":"comments/?id={id}"
Packit 4c4d6b
       }
Packit 4c4d6b
     ]
Packit 4c4d6b
   }
Packit 4c4d6b
Packit 4c4d6b
   This schema defines the properties of the instance JSON documents and
Packit 4c4d6b
   their required properties (id, name, and price) as well as an
Packit 4c4d6b
   optional property (tags).  This also defines the link relations of
Packit 4c4d6b
   the instance JSON documents.
Packit 4c4d6b
Packit 4c4d6b
3.1.  Terminology
Packit 4c4d6b
Packit 4c4d6b
   For this specification, a schema will be used to denote a JSON Schema
Packit 4c4d6b
   definition, and an instance refers to the JSON object or array that
Packit 4c4d6b
   the schema will be describing and validating
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010               [Page 5]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
3.2.  Design Considerations
Packit 4c4d6b
Packit 4c4d6b
   The JSON Schema media type does not attempt to dictate the structure
Packit 4c4d6b
   of JSON representations that contain data, but rather provides a
Packit 4c4d6b
   separate format for flexibly communicating how a JSON representation
Packit 4c4d6b
   should be interpreted and validated, such that user agents can
Packit 4c4d6b
   properly understand acceptable structures and extrapolate hyperlink
Packit 4c4d6b
   information with the JSON document.  It is acknowledged that JSON
Packit 4c4d6b
   documents come in a variety of structures, and JSON is unique in that
Packit 4c4d6b
   the structure of stored data structures often prescribes a non-
Packit 4c4d6b
   ambiguous definite JSON representation.  Attempting to force a
Packit 4c4d6b
   specific structure is generally not viable, and therefore JSON Schema
Packit 4c4d6b
   allows for great flexibility in the structure of JSON data that it
Packit 4c4d6b
   describes.
Packit 4c4d6b
Packit 4c4d6b
   This specification is protocol agnostic.  The underlying protocol
Packit 4c4d6b
   (such as HTTP) should sufficiently define the semantics of the
Packit 4c4d6b
   client-server interface, the retrieval of resource representations
Packit 4c4d6b
   linked to by JSON representations, and modification of those
Packit 4c4d6b
   resources.  The goal of this format is to sufficiently describe JSON
Packit 4c4d6b
   structures such that one can utilize existing information available
Packit 4c4d6b
   in existing JSON representations from a large variety of services
Packit 4c4d6b
   that leverage a representational state transfer architecture using
Packit 4c4d6b
   existing protocols.
Packit 4c4d6b
Packit 4c4d6b
4.  Schema/Instance Association
Packit 4c4d6b
Packit 4c4d6b
   JSON Schema instances are correlated to their schema by the
Packit 4c4d6b
   "describedby" relation, where the schema is defined to be the target
Packit 4c4d6b
   of the relation.  Instance representations may be of the application/
Packit 4c4d6b
   json media type or any other subtype.  Consequently, dictating how an
Packit 4c4d6b
   instance representation should specify the relation to the schema is
Packit 4c4d6b
   beyond the normative scope of this document (since this document
Packit 4c4d6b
   specifically defines the JSON Schema media type, and no other), but
Packit 4c4d6b
   it is recommended that instances specify their schema so that user
Packit 4c4d6b
   agents can interpret the instance representation and messages may
Packit 4c4d6b
   retain the self-descriptive characteristic, avoiding the need for
Packit 4c4d6b
   out-of-band information about instance data.  Two approaches are
Packit 4c4d6b
   recommended for declaring the relation to the schema that describes
Packit 4c4d6b
   the meaning of a JSON instance's (or collection of instances)
Packit 4c4d6b
   structure.  A MIME type parameter named "profile" or a Link header
Packit 4c4d6b
   with a relation of "describedby" SHOULD be used:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   Content-Type: application/json;
Packit 4c4d6b
                 profile=http://json.com/my-hyper-schema
Packit 4c4d6b
Packit 4c4d6b
   or if the content is being transferred by a protocol (such as HTTP)
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010               [Page 6]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   that provides headers, a Link header can be used:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   Link: <http://json.com/my-hyper-schema>; rel="describedby"
Packit 4c4d6b
Packit 4c4d6b
   Instances MAY specify multiple schemas, to indicate all the schemas
Packit 4c4d6b
   that are applicable to the data.  The instance data may have multiple
Packit 4c4d6b
   schemas that it is defined by (the instance data should be valid for
Packit 4c4d6b
   those schemas).  Or if the document is a collection of instances, the
Packit 4c4d6b
   collection may contain instances from different schemas.  When
Packit 4c4d6b
   collections contain heterogeneous instances, the pathStart attribute
Packit 4c4d6b
   MAY be specified in the schema to disambiguate which schema should be
Packit 4c4d6b
   applied for each item in the collection.
Packit 4c4d6b
Packit 4c4d6b
4.1.  Self-Descriptive Schema
Packit 4c4d6b
Packit 4c4d6b
   JSON Schemas are themselves instances for the schema schemas.  A
Packit 4c4d6b
   self-describing JSON Schema for the core JSON Schema can be found at
Packit 4c4d6b
   http://json-schema.org/schema and the hyper schema self-description
Packit 4c4d6b
   can be found at: http://json-schema.org/hyper-schema.  All schemas
Packit 4c4d6b
   used within a protocol with media type definitions SHOULD include a
Packit 4c4d6b
   MIME parameter that refers to the self-descriptive hyper schema or
Packit 4c4d6b
   another schema that extends this hyper schema:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   Content-Type: application/json;
Packit 4c4d6b
                 profile=http://www.json-schema.org/hyper-schema
Packit 4c4d6b
Packit 4c4d6b
5.  Core Schema Definition
Packit 4c4d6b
Packit 4c4d6b
   A JSON Schema is a JSON Object that defines various attributes of the
Packit 4c4d6b
   instance and defines it's usage and valid values.  A JSON Schema is a
Packit 4c4d6b
   JSON Object with schema attribute properties.  The following is the
Packit 4c4d6b
   grammar of a JSON Schema:
Packit 4c4d6b
Packit 4c4d6b
   And an example JSON Schema definition could look like:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   {"description":"A person",
Packit 4c4d6b
    "type":"object",
Packit 4c4d6b
Packit 4c4d6b
    "properties":
Packit 4c4d6b
     {"name": {"type":"string"},
Packit 4c4d6b
      "age" : {"type":"integer",
Packit 4c4d6b
        "maximum":125}}
Packit 4c4d6b
   }
Packit 4c4d6b
Packit 4c4d6b
   A JSON Schema object may have any of the following properties, called
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010               [Page 7]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   schema attributes (all attributes are optional):
Packit 4c4d6b
Packit 4c4d6b
5.1.  type
Packit 4c4d6b
Packit 4c4d6b
      Union type definition - An array with two or more items which
Packit 4c4d6b
      indicates a union of type definitions.  Each item in the array may
Packit 4c4d6b
      be a simple type definition or a schema.  The instance value is
Packit 4c4d6b
      valid if it is of the same type as one the type definitions in the
Packit 4c4d6b
      array or if it is valid by one of the schemas in the array.  For
Packit 4c4d6b
      example to indicate that a string or number is a valid: {"type":
Packit 4c4d6b
      ["string","number"]}
Packit 4c4d6b
Packit 4c4d6b
      Simple type definition - A string indicating a primitive or simple
Packit 4c4d6b
      type.  The following are acceptable strings:
Packit 4c4d6b
Packit 4c4d6b
         string - Value must be a string.
Packit 4c4d6b
Packit 4c4d6b
         number - Value must be a number, floating point numbers are
Packit 4c4d6b
         allowed.
Packit 4c4d6b
Packit 4c4d6b
         integer - Value must be an integer, no floating point numbers
Packit 4c4d6b
         are allowed.  This is a subset of the number type.
Packit 4c4d6b
Packit 4c4d6b
         boolean - Value must be a boolean.
Packit 4c4d6b
Packit 4c4d6b
         object - Value must be an object.
Packit 4c4d6b
Packit 4c4d6b
         array - Value must be an array.
Packit 4c4d6b
Packit 4c4d6b
         null - Value must be null.  Note this is mainly for purpose of
Packit 4c4d6b
         being able use union types to define nullability.
Packit 4c4d6b
Packit 4c4d6b
         any - Value may be of any type including null.  If the property
Packit 4c4d6b
         is not defined or is not in this list, than any type of value
Packit 4c4d6b
         is acceptable.  Other type values may be used for custom
Packit 4c4d6b
         purposes, but minimal validators of the specification
Packit 4c4d6b
         implementation can allow any instance value on unknown type
Packit 4c4d6b
         values.
Packit 4c4d6b
Packit 4c4d6b
5.2.  properties
Packit 4c4d6b
Packit 4c4d6b
   This should be an object type definition, which is an object with
Packit 4c4d6b
   property definitions that correspond to instance object properties.
Packit 4c4d6b
   When the instance value is an object, the property values of the
Packit 4c4d6b
   instance object must conform to the property definitions in this
Packit 4c4d6b
   object.  In this object, each property definition's value should be a
Packit 4c4d6b
   schema, and the property's name should be the name of the instance
Packit 4c4d6b
   property that it defines.
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010               [Page 8]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
5.3.  items
Packit 4c4d6b
Packit 4c4d6b
   This should be a schema or an array of schemas.  When this is an
Packit 4c4d6b
   object/schema and the instance value is an array, all the items in
Packit 4c4d6b
   the array must conform to this schema.  When this is an array of
Packit 4c4d6b
   schemas and the instance value is an array, each position in the
Packit 4c4d6b
   instance array must conform to the schema in the corresponding
Packit 4c4d6b
   position for this array.  This called tuple typing.  When tuple
Packit 4c4d6b
   typing is used, additional items are allowed, disallowed, or
Packit 4c4d6b
   constrained by the additionalProperties attribute using the same
Packit 4c4d6b
   rules as extra properties for objects.  The default value is an empty
Packit 4c4d6b
   schema which allows any value for items in the instance array.
Packit 4c4d6b
Packit 4c4d6b
5.4.  optional
Packit 4c4d6b
Packit 4c4d6b
   This indicates that the instance property in the instance object is
Packit 4c4d6b
   optional.  This is false by default.
Packit 4c4d6b
Packit 4c4d6b
5.5.  additionalProperties
Packit 4c4d6b
Packit 4c4d6b
   This provides a default property definition for all properties that
Packit 4c4d6b
   are not explicitly defined in an object type definition.  The value
Packit 4c4d6b
   must be a schema.  If false is provided, no additional properties are
Packit 4c4d6b
   allowed, and the schema can not be extended.  The default value is an
Packit 4c4d6b
   empty schema which allows any value for additional properties.
Packit 4c4d6b
Packit 4c4d6b
5.6.  requires
Packit 4c4d6b
Packit 4c4d6b
   This indicates that if this property is present in the containing
Packit 4c4d6b
   instance object, the property given by requires attribute must also
Packit 4c4d6b
   be present in the containing instance object.  The value of this
Packit 4c4d6b
   property may be a string, indicating the require property name.  Or
Packit 4c4d6b
   the value may be a schema, in which case the containing instance must
Packit 4c4d6b
   be valid by the schema if the property is present.  For example if a
Packit 4c4d6b
   object type definition is defined:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   {
Packit 4c4d6b
     "state":
Packit 4c4d6b
     {
Packit 4c4d6b
       "optional":true
Packit 4c4d6b
     },
Packit 4c4d6b
     "town":
Packit 4c4d6b
     {
Packit 4c4d6b
       "requires":"state",
Packit 4c4d6b
       "optional":true
Packit 4c4d6b
     }
Packit 4c4d6b
   }
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010               [Page 9]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   An instance must include a state property if a town property is
Packit 4c4d6b
   included.  If a town property is not included, the state property is
Packit 4c4d6b
   optional.
Packit 4c4d6b
Packit 4c4d6b
5.7.  minimum
Packit 4c4d6b
Packit 4c4d6b
   This indicates the minimum value for the instance property when the
Packit 4c4d6b
   type of the instance value is a number.
Packit 4c4d6b
Packit 4c4d6b
5.8.  maximum
Packit 4c4d6b
Packit 4c4d6b
   This indicates the minimum value for the instance property when the
Packit 4c4d6b
   type of the instance value is a number.
Packit 4c4d6b
Packit 4c4d6b
5.9.  minimumCanEqual
Packit 4c4d6b
Packit 4c4d6b
   If the minimum is defined, this indicates whether or not the instance
Packit 4c4d6b
   property value can equal the minimum.
Packit 4c4d6b
Packit 4c4d6b
5.10.  maximumCanEqual
Packit 4c4d6b
Packit 4c4d6b
   If the maximum is defined, this indicates whether or not the instance
Packit 4c4d6b
   property value can equal the maximum.
Packit 4c4d6b
Packit 4c4d6b
5.11.  minItems
Packit 4c4d6b
Packit 4c4d6b
   This indicates the minimum number of values in an array when an array
Packit 4c4d6b
   is the instance value.
Packit 4c4d6b
Packit 4c4d6b
5.12.  maxItems
Packit 4c4d6b
Packit 4c4d6b
   This indicates the maximum number of values in an array when an array
Packit 4c4d6b
   is the instance value.
Packit 4c4d6b
Packit 4c4d6b
5.13.  uniqueItems
Packit 4c4d6b
Packit 4c4d6b
   This indicates that all the items in an array must be unique (no two
Packit 4c4d6b
   identical values) within that array when an array is the instance
Packit 4c4d6b
   value.
Packit 4c4d6b
Packit 4c4d6b
5.14.  pattern
Packit 4c4d6b
Packit 4c4d6b
   When the instance value is a string, this provides a regular
Packit 4c4d6b
   expression that a instance string value should match in order to be
Packit 4c4d6b
   valid.  Regular expressions should follow the regular expression
Packit 4c4d6b
   specification from ECMA 262/Perl 5
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 10]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
5.15.  maxLength
Packit 4c4d6b
Packit 4c4d6b
   When the instance value is a string, this indicates maximum length of
Packit 4c4d6b
   the string.
Packit 4c4d6b
Packit 4c4d6b
5.16.  minLength
Packit 4c4d6b
Packit 4c4d6b
   When the instance value is a string, this indicates minimum length of
Packit 4c4d6b
   the string.
Packit 4c4d6b
Packit 4c4d6b
5.17.  enum
Packit 4c4d6b
Packit 4c4d6b
   This provides an enumeration of possible values that are valid for
Packit 4c4d6b
   the instance property.  This should be an array, and each item in the
Packit 4c4d6b
   array represents a possible value for the instance value.  If "enum"
Packit 4c4d6b
   is included, the instance value must be one of the values in enum
Packit 4c4d6b
   array in order for the schema to be valid.
Packit 4c4d6b
Packit 4c4d6b
5.18.  title
Packit 4c4d6b
Packit 4c4d6b
   This provides a short description of the instance property.  The
Packit 4c4d6b
   value must be a string.
Packit 4c4d6b
Packit 4c4d6b
5.19.  description
Packit 4c4d6b
Packit 4c4d6b
   This provides a full description of the of purpose the instance
Packit 4c4d6b
   property.  The value must be a string.
Packit 4c4d6b
Packit 4c4d6b
5.20.  format
Packit 4c4d6b
Packit 4c4d6b
   This property indicates the type of data, content type, or
Packit 4c4d6b
   microformat to be expected in the instance property values.  A format
Packit 4c4d6b
   attribute may be one of the values listed below, and if so, should
Packit 4c4d6b
   adhere to the semantics describing for the format.  A format should
Packit 4c4d6b
   only be used give meaning to primitive types (string, integer,
Packit 4c4d6b
   number, or boolean).  Validators are not required to validate that
Packit 4c4d6b
   the instance values conform to a format.  The following formats are
Packit 4c4d6b
   defined:
Packit 4c4d6b
Packit 4c4d6b
      Any valid MIME media type may be used as a format value, in which
Packit 4c4d6b
      case the instance property value must be a string, representing
Packit 4c4d6b
      the contents of the MIME file.
Packit 4c4d6b
Packit 4c4d6b
      date-time - This should be a date in ISO 8601 format of YYYY-MM-
Packit 4c4d6b
      DDThh:mm:ssZ in UTC time.  This is the recommended form of date/
Packit 4c4d6b
      timestamp.
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 11]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
      date - This should be a date in the format of YYYY-MM-DD.  It is
Packit 4c4d6b
      recommended that you use the "date-time" format instead of "date"
Packit 4c4d6b
      unless you need to transfer only the date part.
Packit 4c4d6b
Packit 4c4d6b
      time - This should be a time in the format of hh:mm:ss.  It is
Packit 4c4d6b
      recommended that you use the "date-time" format instead of "time"
Packit 4c4d6b
      unless you need to transfer only the time part.
Packit 4c4d6b
Packit 4c4d6b
      utc-millisec - This should be the difference, measured in
Packit 4c4d6b
      milliseconds, between the specified time and midnight, January 1,
Packit 4c4d6b
      1970 UTC.  The value should be a number (integer or float).
Packit 4c4d6b
Packit 4c4d6b
      regex - A regular expression.
Packit 4c4d6b
Packit 4c4d6b
      color - This is a CSS color (like "#FF0000" or "red").
Packit 4c4d6b
Packit 4c4d6b
      style - This is a CSS style definition (like "color: red;
Packit 4c4d6b
      background-color:#FFF").
Packit 4c4d6b
Packit 4c4d6b
      phone - This should be a phone number (format may follow E.123).
Packit 4c4d6b
Packit 4c4d6b
      uri - This value should be a URI..
Packit 4c4d6b
Packit 4c4d6b
      email - This should be an email address.
Packit 4c4d6b
Packit 4c4d6b
      ip-address - This should be an ip version 4 address.
Packit 4c4d6b
Packit 4c4d6b
      ipv6 - This should be an ip version 6 address.
Packit 4c4d6b
Packit 4c4d6b
      street-address - This should be a street address.
Packit 4c4d6b
Packit 4c4d6b
      locality - This should be a city or town.
Packit 4c4d6b
Packit 4c4d6b
      region - This should be a region (a state in the US, province in
Packit 4c4d6b
      Canada, etc.)
Packit 4c4d6b
Packit 4c4d6b
      postal-code - This should be a postal code (AKA zip code).
Packit 4c4d6b
Packit 4c4d6b
      country - This should be the name of a country.
Packit 4c4d6b
Packit 4c4d6b
      Additional custom formats may be defined with a URL to a
Packit 4c4d6b
      definition of the format.
Packit 4c4d6b
Packit 4c4d6b
5.21.  contentEncoding
Packit 4c4d6b
Packit 4c4d6b
   If the instance property value is a string, this indicates that the
Packit 4c4d6b
   string should be interpreted as binary data and decoded using the
Packit 4c4d6b
   encoding named by this schema property.  RFC 2045, Sec 6.1 lists
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 12]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   possible values.
Packit 4c4d6b
Packit 4c4d6b
5.22.  default
Packit 4c4d6b
Packit 4c4d6b
   This indicates the default for the instance property.
Packit 4c4d6b
Packit 4c4d6b
5.23.  divisibleBy
Packit 4c4d6b
Packit 4c4d6b
   This indicates that the instance property value must be divisible by
Packit 4c4d6b
   the given schema value when the instance property value is a number.
Packit 4c4d6b
Packit 4c4d6b
5.24.  disallow
Packit 4c4d6b
Packit 4c4d6b
   This attribute may take the same values as the "type" attribute,
Packit 4c4d6b
   however if the instance matches the type or if this value is an array
Packit 4c4d6b
   and the instance matches any type or schema in the array, than this
Packit 4c4d6b
   instance is not valid.
Packit 4c4d6b
Packit 4c4d6b
5.25.  extends
Packit 4c4d6b
Packit 4c4d6b
   The value of this property should be another schema which will
Packit 4c4d6b
   provide a base schema which the current schema will inherit from.
Packit 4c4d6b
   The inheritance rules are such that any instance that is valid
Packit 4c4d6b
   according to the current schema must be valid according to the
Packit 4c4d6b
   referenced schema.  This may also be an array, in which case, the
Packit 4c4d6b
   instance must be valid for all the schemas in the array.
Packit 4c4d6b
Packit 4c4d6b
6.  Hyper Schema
Packit 4c4d6b
Packit 4c4d6b
   This section defines hypermedia definitions of JSON schema.  The
Packit 4c4d6b
   following attributes are specified in addition to those attributes
Packit 4c4d6b
   that already provided by JSON schema with the specific purpose of
Packit 4c4d6b
   informing user agents of relations between resources based on JSON
Packit 4c4d6b
   data.  Just as with JSON schema attributes, all the attributes in
Packit 4c4d6b
   hyper-schema are optional.  Therefore an empty object is a valid
Packit 4c4d6b
   (non-informative) schema, and essentially describes plain JSON (no
Packit 4c4d6b
   constraints on the structures).  Addition of attributes provides
Packit 4c4d6b
   additive information for user agents.
Packit 4c4d6b
Packit 4c4d6b
6.1.  links
Packit 4c4d6b
Packit 4c4d6b
   The value of the links property should be an array, where each item
Packit 4c4d6b
   in the array is a link description object which describes the link
Packit 4c4d6b
   relations of the instances.
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 13]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
6.1.1.  Link Description Object
Packit 4c4d6b
Packit 4c4d6b
   A link description object is used to describe the link relations.  In
Packit 4c4d6b
   the context of a schema, it defines the link relations of the
Packit 4c4d6b
   instances of the schema, and can be parameterized by the instance
Packit 4c4d6b
   values.  The link description format can be used on its own in
Packit 4c4d6b
   regular (non-schema documents), and use of this format can be
Packit 4c4d6b
   declared by referencing the normative link description schema as the
Packit 4c4d6b
   the schema for the data structure that uses the links.  The URI of
Packit 4c4d6b
   the normative link description schema is:
Packit 4c4d6b
   http://json-schema.org/links.
Packit 4c4d6b
Packit 4c4d6b
6.1.1.1.  href
Packit 4c4d6b
Packit 4c4d6b
   The value of the "href" link description property indicates the
Packit 4c4d6b
   target URI of the related resource.  The value of the instance
Packit 4c4d6b
   property should be resolved as a URI-Reference per [RFC3986] and may
Packit 4c4d6b
   be a relative URI.  The base URI to be used for relative resolution
Packit 4c4d6b
   should be the URI used to retrieve the instance object (not the
Packit 4c4d6b
   schema) when used in the context of a schema.  Also, the URI may be
Packit 4c4d6b
   parametrized by the property values of the instance object.
Packit 4c4d6b
Packit 4c4d6b
   Instance property values should be substituted into the URIs where
Packit 4c4d6b
   matching braces ('{', '}') are found surrounding zero or more
Packit 4c4d6b
   characters, creating an expanded URI.  Instance property value
Packit 4c4d6b
   substitutions are resolved by using the text between the braces to
Packit 4c4d6b
   denote the property name from the instance to get the value to
Packit 4c4d6b
   substitute.  For example, if an href value is defined:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   http://somesite.com/{id}
Packit 4c4d6b
Packit 4c4d6b
   Then it would be resolved by replace the value of the "id" property
Packit 4c4d6b
   value from the instance object.  If the value of the "id" property
Packit 4c4d6b
   was "45", the expanded URI would be:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   http://somesite.com/45
Packit 4c4d6b
Packit 4c4d6b
   If matching braces are found with the string "-this" (no quotes)
Packit 4c4d6b
   between the braces, than the actual instance value should be used to
Packit 4c4d6b
   replace the braces, rather than a property value.  This should only
Packit 4c4d6b
   be used in situations where the instance is a scalar (string,
Packit 4c4d6b
   boolean, or number), and not for objects or arrays.
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 14]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
6.1.1.2.  rel
Packit 4c4d6b
Packit 4c4d6b
   The value of the "rel" property indicates the name of the relation to
Packit 4c4d6b
   the target resource.  The relation to the target should be
Packit 4c4d6b
   interpreted as specifically from the instance object that the schema
Packit 4c4d6b
   (or sub-schema) applies to, not just the top level resource that
Packit 4c4d6b
   contains the object within its hierarchy.  If a resource JSON
Packit 4c4d6b
   representation contains a sub object with a property interpreted as a
Packit 4c4d6b
   link, that sub-object holds the relation with the target.  A relation
Packit 4c4d6b
   to target from the top level resource must be indicated with the
Packit 4c4d6b
   schema describing the top level JSON representation.
Packit 4c4d6b
Packit 4c4d6b
   Relationship definitions SHOULD NOT be media type dependent, and
Packit 4c4d6b
   users are encouraged to utilize existing accepted relation
Packit 4c4d6b
   definitions, including those in existing relation registries (see
Packit 4c4d6b
   &rfc4287).  However, we define these relation here for clarity of
Packit 4c4d6b
   normative interpretation within the context of JSON hyper schema
Packit 4c4d6b
   defined relations:
Packit 4c4d6b
Packit 4c4d6b
      self - If the relation value is "self", when this property is
Packit 4c4d6b
      encountered in the instance object, the object represents a
Packit 4c4d6b
      resource and the instance object is treated as a full
Packit 4c4d6b
      representation of the target resource identified by the specified
Packit 4c4d6b
      URI.
Packit 4c4d6b
Packit 4c4d6b
      full - This indicates that the target of the link is the full
Packit 4c4d6b
      representation for the instance object.  The object that contains
Packit 4c4d6b
      this link may not be the full representation.
Packit 4c4d6b
Packit 4c4d6b
      describedby - This indicates the target of the link is the schema
Packit 4c4d6b
      for the instance object.  This may be used to specifically denote
Packit 4c4d6b
      the schemas of objects within a JSON object hierarchy,
Packit 4c4d6b
      facilitating polymorphic type data structures.
Packit 4c4d6b
Packit 4c4d6b
      The following relations are applicable for schemas (the schema as
Packit 4c4d6b
      the "from" resource in the relation).
Packit 4c4d6b
Packit 4c4d6b
      instances - This indicates the target resource that represents
Packit 4c4d6b
      collection of instances of a schema.
Packit 4c4d6b
Packit 4c4d6b
      create - This indicates a target to use for creating new instances
Packit 4c4d6b
      of a schema.  This link definition SHOULD be a submission link
Packit 4c4d6b
      with a non-safe method (like POST).
Packit 4c4d6b
Packit 4c4d6b
   For example, if a schema is defined:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 15]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   {
Packit 4c4d6b
       "links": [
Packit 4c4d6b
           {
Packit 4c4d6b
                   "rel": "self"
Packit 4c4d6b
                   "href": "{id}"
Packit 4c4d6b
           },
Packit 4c4d6b
           {
Packit 4c4d6b
                   "rel": "up"
Packit 4c4d6b
                   "href": "{upId}"
Packit 4c4d6b
           },
Packit 4c4d6b
           {
Packit 4c4d6b
                   "rel": "children"
Packit 4c4d6b
                   "href": "?upId={id}"
Packit 4c4d6b
           }
Packit 4c4d6b
       ]
Packit 4c4d6b
   }
Packit 4c4d6b
Packit 4c4d6b
   And if a collection of instance resource's JSON representation was
Packit 4c4d6b
   retrieved:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   GET /Resource/
Packit 4c4d6b
Packit 4c4d6b
   [
Packit 4c4d6b
       {
Packit 4c4d6b
           "id": "thing",
Packit 4c4d6b
           "upId": "parent"
Packit 4c4d6b
       },
Packit 4c4d6b
       {
Packit 4c4d6b
           "id": "thing2",
Packit 4c4d6b
           "upId": "parent"
Packit 4c4d6b
       }
Packit 4c4d6b
   ]
Packit 4c4d6b
Packit 4c4d6b
   This would indicate that for the first item in the collection, it's
Packit 4c4d6b
   own (self) URI would resolve to "/Resource/thing" and the first
Packit 4c4d6b
   item's "up" relation should be resolved to the resource at
Packit 4c4d6b
   "/Resource/parent".  The "children" collection would be located at
Packit 4c4d6b
   "/Resource/?upId=thing".
Packit 4c4d6b
Packit 4c4d6b
6.1.1.2.1.  targetSchema
Packit 4c4d6b
Packit 4c4d6b
   This property value can be a schema that defines the expected
Packit 4c4d6b
   structure of the JSON representation of the target of the link.
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 16]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
6.1.1.3.  Submission Link Properties
Packit 4c4d6b
Packit 4c4d6b
   The following properties also apply to link definition objects, and
Packit 4c4d6b
   provide functionality analogous to HTML forms, in providing a means
Packit 4c4d6b
   for submitting extra (often user supplied) information to send to a
Packit 4c4d6b
   server.
Packit 4c4d6b
Packit 4c4d6b
6.1.1.3.1.  method
Packit 4c4d6b
Packit 4c4d6b
   This indicates which method should be used to access the target
Packit 4c4d6b
   resource.  In an HTTP environment, this would be "GET" or "POST"
Packit 4c4d6b
   (other HTTP methods such as "PUT" and "DELETE" have semantics that
Packit 4c4d6b
   are clearly implied by accessed resources, and do not need to be
Packit 4c4d6b
   defined here).  This defaults to "GET".
Packit 4c4d6b
Packit 4c4d6b
6.1.1.3.2.  enctype
Packit 4c4d6b
Packit 4c4d6b
   If present, this property indicates a query media type format that
Packit 4c4d6b
   the server supports for querying or posting to the collection of
Packit 4c4d6b
   instances at the target resource.  The query can be suffixed to the
Packit 4c4d6b
   target URI to query the collection with property-based constraints on
Packit 4c4d6b
   the resources that SHOULD be returned from the server or used to post
Packit 4c4d6b
   data to the resource (depending on the method).  For example, with
Packit 4c4d6b
   the following schema:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   {
Packit 4c4d6b
    "links":[
Packit 4c4d6b
       {
Packit 4c4d6b
         "enctype": "application/x-www-form-urlencoded",
Packit 4c4d6b
         "method": "GET",
Packit 4c4d6b
         "href": "/Product/",
Packit 4c4d6b
         "properties":{
Packit 4c4d6b
            "name":{"description":"name of the product"}
Packit 4c4d6b
         }
Packit 4c4d6b
       }
Packit 4c4d6b
     ]
Packit 4c4d6b
   }
Packit 4c4d6b
Packit 4c4d6b
   This indicates that the client can query the server for instances
Packit 4c4d6b
   that have a specific name:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   /Product/?name=Slinky
Packit 4c4d6b
Packit 4c4d6b
   If no enctype or method is specified, only the single URI specified
Packit 4c4d6b
   by the href property is defined.  If the method is POST, application/
Packit 4c4d6b
   json is the default media type.
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 17]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
6.1.1.3.3.  properties
Packit 4c4d6b
Packit 4c4d6b
   This is inherited from the base JSON schema definition, and can
Packit 4c4d6b
   follow the same structure, but its meaning should be used to define
Packit 4c4d6b
   the acceptable property names and values for the action (whether it
Packit 4c4d6b
   be for the GET query or POST body).  If properties are omitted, and
Packit 4c4d6b
   this form is the child of a schema, the properties from the parent
Packit 4c4d6b
   schema should be used as the basis for the form action.
Packit 4c4d6b
Packit 4c4d6b
6.2.  fragmentResolution
Packit 4c4d6b
Packit 4c4d6b
   This property indicates the fragment resolution protocol to use for
Packit 4c4d6b
   resolving fragment identifiers in URIs within the instance
Packit 4c4d6b
   representations.  This applies to the instance object URIs and all
Packit 4c4d6b
   children of the instance object's URIs.  The default fragment
Packit 4c4d6b
   resolution protocol is "slash-delimited", which is defined below.
Packit 4c4d6b
   Other fragment resolution protocols may be used, but are not defined
Packit 4c4d6b
   in this document.
Packit 4c4d6b
Packit 4c4d6b
   The fragment identifier is based on RFC 2396 Sec 5, and defines the
Packit 4c4d6b
   mechanism for resolving references to entities within a document.
Packit 4c4d6b
Packit 4c4d6b
6.2.1.  dot-delimited fragment resolution
Packit 4c4d6b
Packit 4c4d6b
   With the dot-delimited fragment resolution protocol, the fragment
Packit 4c4d6b
   identifier is interpreted as a series of property reference tokens
Packit 4c4d6b
   that are delimited by the "." character (\x2E).  Each property
Packit 4c4d6b
   reference token is a series of any legal URI component characters
Packit 4c4d6b
   except the "." character.  Each property reference token should be
Packit 4c4d6b
   interpreted, starting from the beginning of the fragment identifier,
Packit 4c4d6b
   as a path reference in the target JSON structure.  The final target
Packit 4c4d6b
   value of the fragment can be determined by starting with the root of
Packit 4c4d6b
   the JSON structure from the representation of the resource identified
Packit 4c4d6b
   by the pre-fragment URI.  If the target is a JSON object, than the
Packit 4c4d6b
   new target is the value of the property with the name identified by
Packit 4c4d6b
   the next property reference token in the fragment.  If the target is
Packit 4c4d6b
   a JSON array, than the target is determined by finding the item in
Packit 4c4d6b
   array the array with the index defined by the next property reference
Packit 4c4d6b
   token (which MUST be a number).  The target is successively updated
Packit 4c4d6b
   for each property reference token, until the entire fragment has been
Packit 4c4d6b
   traversed.
Packit 4c4d6b
Packit 4c4d6b
   Property names SHOULD be URI-encoded.  In particular, any "." in a
Packit 4c4d6b
   property name MUST be encoded to avoid being interpreted as a
Packit 4c4d6b
   property delimiter.
Packit 4c4d6b
Packit 4c4d6b
   For example, for the following JSON representation:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 18]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   {
Packit 4c4d6b
      "foo":{
Packit 4c4d6b
         "anArray":[
Packit 4c4d6b
           {"prop":44}
Packit 4c4d6b
         ],
Packit 4c4d6b
         "another prop":{
Packit 4c4d6b
             "baz":"A string"
Packit 4c4d6b
         }
Packit 4c4d6b
      }
Packit 4c4d6b
   }
Packit 4c4d6b
Packit 4c4d6b
   The following fragment identifiers would be resolved:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   fragment identifier    resolution
Packit 4c4d6b
   -------------------    ----------
Packit 4c4d6b
   #                      self, the root of the resource itself
Packit 4c4d6b
   #foo                   the object referred to by the foo property
Packit 4c4d6b
   #foo.another prop      the object referred to by the "another prop"
Packit 4c4d6b
                          property of the object referred to by the
Packit 4c4d6b
                          "foo" property
Packit 4c4d6b
   #foo.another prop.baz  the string referred to by the value of "baz"
Packit 4c4d6b
                          property of the "another prop" property of
Packit 4c4d6b
                          the object referred to by the "foo" property
Packit 4c4d6b
   #foo.anArray.0         the first object in the "anArray" array
Packit 4c4d6b
Packit 4c4d6b
6.2.2.  slash-delimited fragment resolution
Packit 4c4d6b
Packit 4c4d6b
   The slash-delimited fragment resolution protocol is exactly the same
Packit 4c4d6b
   as dot-delimited fragment resolution protocol except that the "/"
Packit 4c4d6b
   character (\x2F) is used as the delimiter between property names
Packit 4c4d6b
   (instead of ".").
Packit 4c4d6b
Packit 4c4d6b
6.3.  root
Packit 4c4d6b
Packit 4c4d6b
   This attribute indicates that the value of the instance property
Packit 4c4d6b
   value SHOULD be treated as the root or the body of the representation
Packit 4c4d6b
   for the purposes of user agent interaction and fragment resolution
Packit 4c4d6b
   (all other properties of the instance objects are can be regarded as
Packit 4c4d6b
   meta-data descriptions for the data).
Packit 4c4d6b
Packit 4c4d6b
6.4.  readonly
Packit 4c4d6b
Packit 4c4d6b
   This indicates that the instance property should not be changed.
Packit 4c4d6b
   Attempts by a user agent to modify the value of this property are
Packit 4c4d6b
   expected to be rejected by a server.
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 19]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
6.5.  pathStart
Packit 4c4d6b
Packit 4c4d6b
   This property value is a URI-Reference that indicates the URI that
Packit 4c4d6b
   all the URIs for the instances of the schema should start with.  When
Packit 4c4d6b
   multiple schemas have been referenced for an instance, the user agent
Packit 4c4d6b
   can determine if this schema is applicable for a particular instance
Packit 4c4d6b
   by determining if URI of the instance begins with the pathStart's
Packit 4c4d6b
   referenced URI. pathStart MUST be resolved as per [RFC3986] section
Packit 4c4d6b
   5.  If the URI of the instance does not start with URI indicated by
Packit 4c4d6b
   pathStart, or if another schema specifies a starting URI that is
Packit 4c4d6b
   longer and also matches the instance, this schema should not be
Packit 4c4d6b
   applied to the instance.  Any schema that does not have a pathStart
Packit 4c4d6b
   attribute should be considered applicable to all the instances for
Packit 4c4d6b
   which it is referenced.
Packit 4c4d6b
Packit 4c4d6b
6.6.  mediaType
Packit 4c4d6b
Packit 4c4d6b
   This indicates the media type of the instance representations that
Packit 4c4d6b
   this schema is defining.
Packit 4c4d6b
Packit 4c4d6b
6.7.  alternate
Packit 4c4d6b
Packit 4c4d6b
   This is an array of JSON schema definitions that define any other
Packit 4c4d6b
   schemas for alternate JSON-based representations of the instance
Packit 4c4d6b
   resources.
Packit 4c4d6b
Packit 4c4d6b
7.  Security Considerations
Packit 4c4d6b
Packit 4c4d6b
   This specification is a sub-type of the JSON format, and consequently
Packit 4c4d6b
   the security considerations are generally the same as RFC 4627.
Packit 4c4d6b
   However, an additional issue is that when link relation of "self" is
Packit 4c4d6b
   used to denote a full representation of an object, the user agent
Packit 4c4d6b
   SHOULD NOT consider the representation to be the authoritative
Packit 4c4d6b
   representation of the resource denoted by the target URI if the
Packit 4c4d6b
   target URI is not equivalent to or a sub-path of the the URI used to
Packit 4c4d6b
   request the resource representation which contains the target URI
Packit 4c4d6b
   with the "self" link.  For example, if a hyper schema was defined:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   {
Packit 4c4d6b
     "links":[
Packit 4c4d6b
           {
Packit 4c4d6b
                   "rel":"self",
Packit 4c4d6b
                   "href":"{id}"
Packit 4c4d6b
           }
Packit 4c4d6b
     ]
Packit 4c4d6b
   }
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 20]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   And a resource was requested from somesite.com:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   GET /foo/
Packit 4c4d6b
Packit 4c4d6b
   With a response of:
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Content-Type: application/json; profile=/schema-for-this-data
Packit 4c4d6b
[
Packit 4c4d6b
  {"id":"bar", "name":"This representation can be safely treated \
Packit 4c4d6b
        as authoritative "},
Packit 4c4d6b
  {"id":"/baz", "name":"This representation should not be treated as \
Packit 4c4d6b
        authoritative the user agent should make request the resource\
Packit 4c4d6b
        from "/baz" to ensure it has the authoritative representation"},
Packit 4c4d6b
  {"id":"http://othersite.com/something", "name":"This representation\
Packit 4c4d6b
        should also not be treated as authoritative and the target\
Packit 4c4d6b
        resource representation should be retrieved for the\
Packit 4c4d6b
        authoritative representation"}
Packit 4c4d6b
]
Packit 4c4d6b
Packit 4c4d6b
8.  IANA Considerations
Packit 4c4d6b
Packit 4c4d6b
   The proposed MIME media type for JSON Schema is application/
Packit 4c4d6b
   schema+json
Packit 4c4d6b
Packit 4c4d6b
   Type name: application
Packit 4c4d6b
Packit 4c4d6b
   Subtype name: schema+json
Packit 4c4d6b
Packit 4c4d6b
   Required parameters: profile
Packit 4c4d6b
Packit 4c4d6b
   The value of the profile parameter should be a URI (relative or
Packit 4c4d6b
   absolute) that refers to the schema used to define the structure of
Packit 4c4d6b
   this structure (the meta-schema).  Normally the value would be
Packit 4c4d6b
   http://json-schema.org/hyper-schema, but it is allowable to use other
Packit 4c4d6b
   schemas that extend the hyper schema's meta- schema.
Packit 4c4d6b
Packit 4c4d6b
   Optional parameters: pretty
Packit 4c4d6b
Packit 4c4d6b
   The value of the pretty parameter may be true or false to indicate if
Packit 4c4d6b
   additional whitespace has been included to make the JSON
Packit 4c4d6b
   representation easier to read.
Packit 4c4d6b
Packit 4c4d6b
8.1.  Registry of Link Relations
Packit 4c4d6b
Packit 4c4d6b
   This registry is maintained by IANA per RFC 4287 and this
Packit 4c4d6b
   specification adds three values: "full", "create", "instances".  New
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 21]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   assignments are subject to IESG Approval, as outlined in [RFC5226].
Packit 4c4d6b
   Requests should be made by email to IANA, which will then forward the
Packit 4c4d6b
   request to the IESG, requesting approval.
Packit 4c4d6b
Packit 4c4d6b
9.  References
Packit 4c4d6b
Packit 4c4d6b
9.1.  Normative References
Packit 4c4d6b
Packit 4c4d6b
   [RFC3986]                          Berners-Lee, T., Fielding, R., and
Packit 4c4d6b
                                      L. Masinter, "Uniform Resource
Packit 4c4d6b
                                      Identifier (URI): Generic Syntax",
Packit 4c4d6b
                                      STD 66, RFC 3986, January 2005.
Packit 4c4d6b
Packit 4c4d6b
   [RFC2119]                          Bradner, S., "Key words for use in
Packit 4c4d6b
                                      RFCs to Indicate Requirement
Packit 4c4d6b
                                      Levels", BCP 14, RFC 2119,
Packit 4c4d6b
                                      March 1997.
Packit 4c4d6b
Packit 4c4d6b
   [RFC4287]                          Nottingham, M., Ed. and R. Sayre,
Packit 4c4d6b
                                      Ed., "The Atom Syndication
Packit 4c4d6b
                                      Format", RFC 4287, December 2005.
Packit 4c4d6b
Packit 4c4d6b
   [RFC3339]                          Klyne, G., Ed. and C. Newman,
Packit 4c4d6b
                                      "Date and Time on the Internet:
Packit 4c4d6b
                                      Timestamps", RFC 3339, July 2002.
Packit 4c4d6b
Packit 4c4d6b
   [RFC2045]                          Freed, N. and N. Borenstein,
Packit 4c4d6b
                                      "Multipurpose Internet Mail
Packit 4c4d6b
                                      Extensions (MIME) Part One: Format
Packit 4c4d6b
                                      of Internet Message Bodies",
Packit 4c4d6b
                                      RFC 2045, November 1996.
Packit 4c4d6b
Packit 4c4d6b
9.2.  Informative References
Packit 4c4d6b
Packit 4c4d6b
   [RFC4627]                          Crockford, D., "The application/
Packit 4c4d6b
                                      json Media Type for JavaScript
Packit 4c4d6b
                                      Object Notation (JSON)", RFC 4627,
Packit 4c4d6b
                                      July 2006.
Packit 4c4d6b
Packit 4c4d6b
   [RFC2616]                          Fielding, R., Gettys, J., Mogul,
Packit 4c4d6b
                                      J., Frystyk, H., Masinter, L.,
Packit 4c4d6b
                                      Leach, P., and T. Berners-Lee,
Packit 4c4d6b
                                      "Hypertext Transfer Protocol --
Packit 4c4d6b
                                      HTTP/1.1", RFC 2616, June 1999.
Packit 4c4d6b
Packit 4c4d6b
   [RFC5226]                          Narten, T. and H. Alvestrand,
Packit 4c4d6b
                                      "Guidelines for Writing an IANA
Packit 4c4d6b
                                      Considerations Section in RFCs",
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 22]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
                                      BCP 26, RFC 5226, May 2008.
Packit 4c4d6b
Packit 4c4d6b
   [I-D.hammer-discovery]             Hammer-Lahav, E., "LRDD: Link-
Packit 4c4d6b
                                      based Resource Descriptor
Packit 4c4d6b
                                      Discovery",
Packit 4c4d6b
                                      draft-hammer-discovery-04 (work in
Packit 4c4d6b
                                      progress), March 2010.
Packit 4c4d6b
Packit 4c4d6b
   [I-D.gregorio-uritemplate]         Gregorio, J., Fielding, R.,
Packit 4c4d6b
                                      Hadley, M., and M. Nottingham,
Packit 4c4d6b
                                      "URI Template",
Packit 4c4d6b
                                      draft-gregorio-uritemplate-04
Packit 4c4d6b
                                      (work in progress), March 2010.
Packit 4c4d6b
Packit 4c4d6b
   [I-D.nottingham-http-link-header]  Nottingham, M., "Web Linking", dra
Packit 4c4d6b
                                      ft-nottingham-http-link-header-08
Packit 4c4d6b
                                      (work in progress), March 2010.
Packit 4c4d6b
Packit 4c4d6b
   [W3C.REC-html401-19991224]         Hors, A., Jacobs, I., and D.
Packit 4c4d6b
                                      Raggett, "HTML 4.01
Packit 4c4d6b
                                      Specification", World Wide Web
Packit 4c4d6b
                                      Consortium Recommendation REC-
Packit 4c4d6b
                                      html401-19991224, December 1999, <
Packit 4c4d6b
                                      http://www.w3.org/TR/1999/
Packit 4c4d6b
                                      REC-html401-19991224>.
Packit 4c4d6b
Packit 4c4d6b
Appendix A.  Change Log
Packit 4c4d6b
Packit 4c4d6b
   -02
Packit 4c4d6b
Packit 4c4d6b
   o  Replaced maxDecimal attribute with divisibleBy attribute
Packit 4c4d6b
Packit 4c4d6b
   o  Added slash-delimited fragment resolution protocol and made it the
Packit 4c4d6b
      default.
Packit 4c4d6b
Packit 4c4d6b
   o  Added language about using links outside of schemas by referencing
Packit 4c4d6b
      it's normative URI.
Packit 4c4d6b
Packit 4c4d6b
   o  Added uniqueItems attribute
Packit 4c4d6b
Packit 4c4d6b
   o  Added targetSchema attribute to link description object
Packit 4c4d6b
Packit 4c4d6b
   -01
Packit 4c4d6b
Packit 4c4d6b
   o  Fixed category and updates from template
Packit 4c4d6b
Packit 4c4d6b
   -00
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 23]
Packit 4c4d6b

Packit 4c4d6b
Internet-Draft           JSON Schema Media Type               March 2010
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
   o  Initial draft
Packit 4c4d6b
Packit 4c4d6b
Appendix B.  Open Issues
Packit 4c4d6b
Packit 4c4d6b
   Should we give a preference to MIME headers over Link headers (or
Packit 4c4d6b
   only use one)?
Packit 4c4d6b
Packit 4c4d6b
   Should we use "profile" as the media type parameter instead?
Packit 4c4d6b
Packit 4c4d6b
   Should "root" be a MIME parameter instead of a schema attribute?
Packit 4c4d6b
Packit 4c4d6b
   Should "format" be renamed to "mediaType" or "contentType" to reflect
Packit 4c4d6b
   the usage MIME media types that are allowed.
Packit 4c4d6b
Packit 4c4d6b
   I still do not like how dates are handled.
Packit 4c4d6b
Packit 4c4d6b
   Should "slash-delimited" or "dot-delimited" be the default fragment
Packit 4c4d6b
   resolution protocol?
Packit 4c4d6b
Packit 4c4d6b
Author's Address
Packit 4c4d6b
Packit 4c4d6b
   Kris Zyp (editor)
Packit 4c4d6b
   SitePen (USA)
Packit 4c4d6b
   530 Lytton Avenue
Packit 4c4d6b
   Palo Alto, CA 94301
Packit 4c4d6b
   USA
Packit 4c4d6b
Packit 4c4d6b
   Phone: +1 650 968 8787
Packit 4c4d6b
   EMail: kris@sitepen.com
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Packit 4c4d6b
Zyp                    Expires September 24, 2010              [Page 24]
Packit 4c4d6b

Packit 4c4d6b