Skip to content

Commit 707f650

Browse files
committed
Draft 02: draft-zyp-json-schema-02
2 parents 2072fee + 1bc1d9f commit 707f650

File tree

5 files changed

+87
-40
lines changed

5 files changed

+87
-40
lines changed

hyper-schema.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
2-
"$schema" : "http://json-schema.org/draft-01/hyper-schema#",
3-
"id" : "http://json-schema.org/draft-01/hyper-schema#",
2+
"$schema" : "http://json-schema.org/draft-02/hyper-schema#",
3+
"id" : "http://json-schema.org/draft-02/hyper-schema#",
44

55
"properties" : {
66
"links" : {
77
"type" : "array",
8-
"items" : {"$ref" : "http://json-schema.org/draft-01/links#"},
8+
"items" : {"$ref" : "http://json-schema.org/draft-02/links#"},
99
"optional" : true
1010
},
1111

1212
"fragmentResolution" : {
1313
"type" : "string",
1414
"optional" : true,
15-
"default" : "dot-delimited"
15+
"default" : "slash-delimited"
1616
},
1717

1818
"root" : {
@@ -63,6 +63,6 @@
6363
}
6464
],
6565

66-
"fragmentResolution" : "dot-delimited",
67-
"extends" : {"$ref" : "http://json-schema.org/draft-01/schema#"}
66+
"fragmentResolution" : "slash-delimited",
67+
"extends" : {"$ref" : "http://json-schema.org/draft-02/schema#"}
6868
}

json-ref.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"$schema" : "http://json-schema.org/draft-01/hyper-schema#",
3-
"id" : "http://json-schema.org/draft-01/json-ref#",
2+
"$schema" : "http://json-schema.org/draft-02/hyper-schema#",
3+
"id" : "http://json-schema.org/draft-02/json-ref#",
44

55
"items" : {"$ref" : "#"},
66
"additionalProperties" : {"$ref" : "#"},

jsonschema.xml

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,9 @@
1919
<?rfc subcompact="no"?>
2020
<?rfc strict="no"?>
2121
<?rfc rfcedstyle="yes"?>
22-
<rfc category="info" docName="draft-zyp-json-schema-01" ipr="trust200811">
23-
22+
<rfc category="info" docName="draft-zyp-json-schema-02" year="2010" ipr="trust200902">
2423
<front>
25-
<!--
26-
[TODO] Enter the full document title and an abbreviated version
27-
to use in the page header.
28-
-->
24+
2925

3026
<title abbrev="JSON Schema Media Type">A JSON Media Type for Describing the Structure and Meaning of JSON Documents</title>
3127

@@ -49,7 +45,7 @@
4945
</address>
5046
</author>
5147

52-
<date year="2009" />
48+
<date year="2010" />
5349

5450
<workgroup>Internet Engineering Task Force</workgroup>
5551

@@ -176,14 +172,21 @@ JSON documents.
176172
for flexibly communicating how a JSON representation should be
177173
interpreted and validated, such that user agents can properly understand
178174
acceptable structures and extrapolate hyperlink information
179-
with the JSON document. This specification does not define a protocol.
175+
with the JSON document. It is acknowledged that JSON documents come
176+
in a variety of structures, and JSON is unique in that the structure
177+
of stored data structures often prescribes a non-ambiguous definite
178+
JSON representation. Attempting to force a specific structure is generally
179+
not viable, and therefore JSON Schema allows for great flexibility
180+
in the structure of JSON data that it describes.
181+
</t>
182+
<t>This specification is protocol agnostic.
180183
The underlying protocol (such as HTTP) should sufficiently define the
181184
semantics of the client-server interface, the retrieval of resource
182185
representations linked to by JSON representations, and modification of
183186
those resources. The goal of this
184187
format is to sufficiently describe JSON structures such that one can
185188
utilize existing information available in existing JSON
186-
representations from a large variety of services that leverage a REST
189+
representations from a large variety of services that leverage a representational state transfer
187190
architecture using existing protocols.
188191
</t>
189192
</section>
@@ -204,12 +207,12 @@ JSON documents.
204207
instance data. Two approaches are recommended for declaring the
205208
relation to the schema that describes the meaning of a JSON instance's (or collection
206209
of instances) structure. A MIME type parameter named
207-
"describedby" or a Link header with a relation of "describedby" SHOULD be used:
210+
"profile" or a Link header with a relation of "describedby" SHOULD be used:
208211
<figure>
209212
<artwork>
210213
<![CDATA[
211214
Content-Type: application/json;
212-
describedby=http://json.com/my-hyper-schema
215+
profile=http://json.com/my-hyper-schema
213216
]]></artwork></figure>
214217
or if the content is being transferred by a protocol (such as HTTP) that
215218
provides headers, a Link header can be used:
@@ -240,7 +243,7 @@ collection.
240243
<artwork>
241244
<![CDATA[
242245
Content-Type: application/json;
243-
describedby=http://www.json-schema.org/hyper-schema
246+
profile=http://www.json-schema.org/hyper-schema
244247
]]></artwork></figure>
245248
</t>
246249
</section>
@@ -301,7 +304,7 @@ If the property is not defined or is not in this list, than any type of value is
301304
<t>This should be an object type definition, which is an object with property definitions that correspond to instance object properties. When the instance value is an object, the property values of the instance object must conform to the property definitions in this object. In this object, each property definition's value should be a schema, and the property's name should be the name of the instance property that it defines.</t>
302305
</section>
303306
<section title="items">
304-
<t>This should be a schema or an array of schemas. When this is an object/schema and the instance value is an array, all the items in the array must conform to this schema. When this is an array of schemas and the instance value is an array, each position in the instance array must conform to the schema in the corresponding position for this array. This called tuple typing. When tuple typing is used, additional items are allowed, disallowed, or constrained by the additionalProperties attribute using the same rules as extra properties for objects..</t>
307+
<t>This should be a schema or an array of schemas. When this is an object/schema and the instance value is an array, all the items in the array must conform to this schema. When this is an array of schemas and the instance value is an array, each position in the instance array must conform to the schema in the corresponding position for this array. This called tuple typing. When tuple typing is used, additional items are allowed, disallowed, or constrained by the additionalProperties attribute using the same rules as extra properties for objects. The default value is an empty schema which allows any value for items in the instance array.</t>
305308
</section>
306309
<section title="optional">
307310
<t>This indicates that the instance property in the instance object is optional. This is false by default.</t>
@@ -348,6 +351,9 @@ of this property may be a string, indicating the require property name. Or the v
348351
<section title="maxItems">
349352
<t>This indicates the maximum number of values in an array when an array is the instance value.</t>
350353
</section>
354+
<section title="uniqueItems">
355+
<t>This indicates that all the items in an array must be unique (no two identical values) within that array when an array is the instance value.</t>
356+
</section>
351357
<section title="pattern">
352358
<t>When the instance value is a string, this provides a regular expression that a instance string value should match in order to be valid. Regular expressions should follow the regular expression specification from ECMA 262/Perl 5</t></section>
353359
<section title="maxLength">
@@ -395,8 +401,8 @@ If the instance property value is a string, this indicates that the string shoul
395401
<section title="default">
396402
<t>This indicates the default for the instance property.</t>
397403
</section>
398-
<section title="maxDecimal">
399-
<t>This indicates the maximum number of decimal places in a floating point number. By default there is no maximum.</t>
404+
<section title="divisibleBy">
405+
<t>This indicates that the instance property value must be divisible by the given schema value when the instance property value is a number.</t>
400406
</section>
401407
<section title="disallow">
402408
<t>This attribute may take the same values as the "type" attribute, however if the instance matches the type or if this value is an array and the instance matches any type or schema in the array, than this instance is not valid.</t>
@@ -423,16 +429,23 @@ relations of the instances.
423429
</t>
424430
<section title="Link Description Object">
425431
<t>
426-
A link description object is used to describe the link relations
427-
of instances of a schema.
432+
A link description object is used to describe the link relations. In
433+
the context of a schema, it defines the link relations of the
434+
instances of the schema, and can be parameterized by the instance
435+
values. The link description format can be used on its own in
436+
regular (non-schema documents), and use of this format can
437+
be declared by referencing the normative link description
438+
schema as the the schema for the data structure that uses the
439+
links. The URI of the normative link description schema is: http://json-schema.org/links.
428440
</t>
429441
<section title="href">
430442
<t>
431443
The value of the "href" link description property
432444
indicates the target URI of the related resource. The value
433445
of the instance property should be resolved as a URI-Reference per [RFC3986]
434446
and may be a relative URI. The base URI to be used for relative resolution
435-
should be the URI used to retrieve the instance object (not the schema).
447+
should be the URI used to retrieve the instance object (not the schema)
448+
when used in the context of a schema.
436449
Also, the URI may be parametrized by the property values of the instance
437450
object.
438451
</t>
@@ -541,6 +554,10 @@ This would indicate that for the first item in the collection, it's own
541554
relation should be resolved to the resource at "/Resource/parent".
542555
The "children" collection would be located at "/Resource/?upId=thing".
543556
</t>
557+
<section title="targetSchema">
558+
<t>This property value can be a schema that defines the expected
559+
structure of the JSON representation of the target of the link.</t>
560+
</section>
544561
</section>
545562
<section title="Submission Link Properties">
546563
<t>
@@ -617,7 +634,7 @@ for the form action.
617634
resolving fragment identifiers in URIs within the instance
618635
representations. This applies to the instance object URIs and all
619636
children of the instance object's URIs. The default fragment resolution
620-
protocol is "dot-delimited", which is defined below. Other fragment
637+
protocol is "slash-delimited", which is defined below. Other fragment
621638
resolution protocols may be used, but are not defined in this
622639
document.
623640

@@ -685,6 +702,11 @@ fragment identifier resolution
685702
</figure>
686703
</t>
687704
</section>
705+
<section title="slash-delimited fragment resolution">
706+
<t>The slash-delimited fragment resolution protocol is exactly the same as
707+
dot-delimited fragment resolution protocol except that the "/" character
708+
(\x2F) is used as the delimiter between property names (instead of ".").</t>
709+
</section>
688710

689711

690712
</section>
@@ -774,7 +796,7 @@ With a response of:
774796
<figure>
775797
<artwork>
776798
<![CDATA[
777-
Content-Type: application/json; describedby=/schema-for-this-data
799+
Content-Type: application/json; profile=/schema-for-this-data
778800
[
779801
{"id":"bar", "name":"This representation can be safely treated \
780802
as authoritative "},
@@ -801,10 +823,10 @@ Content-Type: application/json; describedby=/schema-for-this-data
801823
Subtype name: schema+json
802824
</t>
803825
<t>
804-
Required parameters: describedby
826+
Required parameters: profile
805827
</t>
806828
<t>
807-
The value of the describedby parameter should be a URI (relative or absolute) that
829+
The value of the profile parameter should be a URI (relative or absolute) that
808830
refers to the schema used to define the structure of this structure (the
809831
meta-schema). Normally the value would be http://json-schema.org/hyper-schema,
810832
but it is allowable to use other schemas that extend the hyper schema's meta-
@@ -863,6 +885,17 @@ instead of numbers</t>
863885
-->
864886

865887
<section title="Change Log ">
888+
<t>-02</t>
889+
<t>
890+
<list style="symbols">
891+
<t>Replaced maxDecimal attribute with divisibleBy attribute</t>
892+
<t>Added slash-delimited fragment resolution protocol and made it the default.</t>
893+
<t>Added language about using links outside of schemas by referencing it's normative URI.</t>
894+
<t>Added uniqueItems attribute</t>
895+
<t>Added targetSchema attribute to link description object</t>
896+
897+
</list>
898+
</t>
866899
<t>-01</t>
867900
<t>
868901
<list style="symbols">
@@ -884,6 +917,7 @@ instead of numbers</t>
884917
<t>Should "root" be a MIME parameter instead of a schema attribute?</t>
885918
<t>Should "format" be renamed to "mediaType" or "contentType" to reflect the usage MIME media types that are allowed.</t>
886919
<t>I still do not like how dates are handled.</t>
920+
<t>Should "slash-delimited" or "dot-delimited" be the default fragment resolution protocol?</t>
887921

888922
</section>
889923

links.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"$schema" : "http://json-schema.org/draft-01/hyper-schema#",
3-
"id" : "http://json-schema.org/draft-01/links#",
2+
"$schema" : "http://json-schema.org/draft-02/hyper-schema#",
3+
"id" : "http://json-schema.org/draft-02/links#",
44
"type" : "object",
55

66
"properties" : {
@@ -12,6 +12,8 @@
1212
"type" : "string"
1313
},
1414

15+
"targetSchema" : {"$ref" : "http://json-schema.org/draft-02/hyper-schema#"},
16+
1517
"method" : {
1618
"type" : "string",
1719
"default" : "GET",
@@ -26,7 +28,7 @@
2628

2729
"properties" : {
2830
"type" : "object",
29-
"additionalProperties" : {"$ref" : "http://json-schema.org/draft-01/hyper-schema#"},
31+
"additionalProperties" : {"$ref" : "http://json-schema.org/draft-02/hyper-schema#"},
3032
"optional" : true
3133
}
3234
}

schema.json

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"$schema" : "http://json-schema.org/draft-01/hyper-schema#",
3-
"id" : "http://json-schema.org/draft-01/schema#",
2+
"$schema" : "http://json-schema.org/draft-02/hyper-schema#",
3+
"id" : "http://json-schema.org/draft-02/schema#",
44
"type" : "object",
55

66
"properties" : {
@@ -10,6 +10,7 @@
1010
"type" : ["string", {"$ref" : "#"}]
1111
},
1212
"optional" : true,
13+
"uniqueItems" : true,
1314
"default" : "any"
1415
},
1516

@@ -81,6 +82,12 @@
8182
"minimum" : 0
8283
},
8384

85+
"uniqueItems" : {
86+
"type" : "boolean",
87+
"optional" : true,
88+
"default" : false
89+
},
90+
8491
"pattern" : {
8592
"type" : "string",
8693
"optional" : true,
@@ -102,7 +109,8 @@
102109
"enum" : {
103110
"type" : "array",
104111
"optional" : true,
105-
"minItems" : 1
112+
"minItems" : 1,
113+
"uniqueItems" : true
106114
},
107115

108116
"title" : {
@@ -130,16 +138,19 @@
130138
"optional" : true
131139
},
132140

133-
"maxDecimal" : {
134-
"type" : "integer",
141+
"divisibleBy" : {
142+
"type" : "number",
143+
"minimum" : 0,
144+
"minimumCanEqual" : false,
135145
"optional" : true,
136-
"minimum" : 0
146+
"default" : 1
137147
},
138148

139149
"disallow" : {
140150
"type" : ["string", "array"],
141151
"items" : {"type" : "string"},
142-
"optional" : true
152+
"optional" : true,
153+
"uniqueItems" : true
143154
},
144155

145156
"extends" : {

0 commit comments

Comments
 (0)