Skip to content

Commit ecbd1d4

Browse files
committed
Merge branch 'rootChanges' of git://github.com/garycourt/json-schema
2 parents d328037 + 3215871 commit ecbd1d4

File tree

1 file changed

+59
-54
lines changed

1 file changed

+59
-54
lines changed

draft-zyp-json-schema-03.xml

Lines changed: 59 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@
124124
for the purpose of describing a resource and determining hyperlinks
125125
within the representation. </t>
126126

127-
<t>
128-
An example JSON Schema that describes products might look like:
129127
<figure>
128+
<preamble>An example JSON Schema that describes products might look like:</preamble>
130129
<artwork><![CDATA[
131130
{
132131
"name":"Product",
@@ -162,16 +161,18 @@
162161
}
163162
]
164163
}
165-
]]></artwork></figure>
166-
This schema defines the properties of the instance JSON documents and
167-
their required properties (id, name, and price) as well as an optional
168-
property (tags). This also defines the link relations of the instance
169-
JSON documents.
170-
</t>
164+
]]></artwork>
165+
<postamble>
166+
This schema defines the properties of the instance JSON documents and
167+
their required properties (id, name, and price) as well as an optional
168+
property (tags). This also defines the link relations of the instance
169+
JSON documents.
170+
</postamble>
171+
</figure>
171172
<section title="Terminology">
172-
<t>For this specification, a schema will be used to denote a JSON Schema
173-
definition, and an instance refers to the JSON object or array that the schema
174-
will be describing and validating</t>
173+
<t>For this specification, <spanx style="strong">schema</spanx> will be used to denote a JSON Schema
174+
definition, and an <spanx style="strong">instance</spanx> refers to a JSON value that the schema
175+
will be describing and validating.</t>
175176

176177
</section>
177178
<section title="Design Considerations">
@@ -185,8 +186,8 @@ JSON documents.
185186
in a variety of structures, and JSON is unique in that the structure
186187
of stored data structures often prescribes a non-ambiguous definite
187188
JSON representation. Attempting to force a specific structure is generally
188-
not viable, and therefore JSON Schema allows for great flexibility
189-
in the structure of JSON data that it describes.
189+
not viable, and therefore JSON Schema allows for a great flexibility
190+
in the structure of the JSON data that it describes.
190191
</t>
191192
<t>This specification is protocol agnostic.
192193
The underlying protocol (such as HTTP) should sufficiently define the
@@ -234,7 +235,7 @@ Link: <http://json.com/my-hyper-schema>; rel="describedby"
234235
that it is defined by (the instance data SHOULD be valid for those schemas).
235236
Or if the document is a collection of instances, the collection MAY contain
236237
instances from different schemas. When collections contain heterogeneous
237-
instances, the pathStart attribute MAY be specified in the
238+
instances, the "pathStart" attribute MAY be specified in the
238239
schema to disambiguate which schema should be applied for each item in the
239240
collection. However, ultimately, the mechanism for referencing a schema is up to the
240241
media type of the instance documents (if they choose to specify that schemas
@@ -291,8 +292,11 @@ Content-Type: application/json;
291292

292293
<section title="type">
293294
<t>
295+
This attribute defines what the primitive type or the schema of the instance MUST be in order to validate.
296+
This attribute can take one of two forms:
297+
294298
<list style="hanging">
295-
<t hangText="Simple type definition">A string indicating a primitive or simple type. The following are acceptable strings:
299+
<t hangText="Simple Types">A string indicating a primitive or simple type. The following are acceptable string values:
296300

297301
<list style="hanging">
298302
<t hangText="string">Value MUST be a string.</t>
@@ -307,49 +311,52 @@ included in a union, null values are not allowed (the primitives listed above do
307311
If the property is not defined or is not in this list, than any type of value is acceptable. Other type values MAY be used for custom purposes, but minimal validators of the specification implementation can allow any instance value on unknown type values.</t>
308312
</list>
309313
</t>
310-
<t hangText="Union type definition">An array with two or more simple type definitions. Each item in the array MUST be a simple type definition, a schema, or a URI for a schema. The instance value is valid if it is of the same type as one the simple type definitions in the array, or if it is valid by one of the schemas (or schema referenced by the URI) in the array.
314+
<t hangText="Union Types">An array of two or more simple type definitions. Each item in the array MUST be a simple type definition, a schema, or a URI for a schema. The instance value is valid if it is of the same type as one of the simple type definitions in the array, or if it is valid by one of the schemas (or a schema referenced by a URI) in the array.
315+
</t>
316+
</list>
317+
</t>
311318
<figure>
312319
<preamble>For example, a schema that defines if an instance can be a string or a number would be:</preamble>
313320
<artwork><![CDATA[
314321
{"type":["string","number"]}
315322
]]></artwork>
316-
</figure>
317-
</t>
318-
</list>
319-
</t>
323+
</figure>
320324
</section>
321325
<section title="properties">
322-
<t>This is an object with property definitions that define the valid values of instance object property values. 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 MUST be a schema or URI referring to a schema, and the property's name MUST be the name of the instance property that it defines. The instance property value MUST be valid according to the schema from the property definition. Properties are considered unordered, the order of the instance properties MAY be in any order.</t>
326+
<t>This attribute is an object with property definitions that define the valid values of instance object property values. 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 MUST be a schema or URI referring to a schema, and the property's name MUST be the name of the instance property that it defines. The instance property value MUST be valid according to the schema from the property definition. Properties are considered unordered, the order of the instance properties MAY be in any order.</t>
323327
</section>
324328
<section title="additionalProperties">
325-
<t>This provides a default property definition for all properties that are not explicitly defined in an object type definition. The value MUST be a schema or a URI referencing a schema. If false is provided, no additional properties are allowed beyond the properties defined in the schema and the super schemas (the schemas that the schema extends). The default value is an empty schema which allows any value for additional properties.</t>
329+
<t>This attribute defines a schema for all properties that are not explicitly defined in an object type definition. If specified, the value MUST be a schema, a URI referencing a schema, or a boolean. If false is provided, no additional properties are allowed beyond the properties defined in the schema. The default value is an empty schema which allows any value for additional properties.</t>
326330
</section>
327331
<section title="items">
328-
<t>This MUST be a schema or URI referring to a schema or an array of schemas (schema or URI referring to a schema). When this is an object/schema and the instance value is an array, all the items in the array MUST conform to this schema or schema referenced by the URI. 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 additionalItems 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>
332+
<t>This MUST be a schema or URI referring to a schema or an array of schemas (schema or URI referring to a schema). When this is a schema and the instance value is an array, all the items in the array MUST conform to this schema or schema referenced by the URI. 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 additionalItems attribute using the same rules as "additionalProperties" for objects. The default value is an empty schema which allows any value for items in the instance array.</t>
329333
</section>
330334
<section title="additionalItems">
331-
<t>This provides a definition for additional items in array when tuple definition of the items in an array is provided. This can be false to indicate additional items in the array are not allowed, or it can be a schema or a URI referencing a schema to define the type of the additional items.</t>
335+
<t>This provides a definition for additional items in an array instance when tuple definitions of the items is provided. This can be false to indicate additional items in the array are not allowed, or it can be a schema (or a URI referencing a schema) that defines the schema of the additional items.</t>
332336
</section>
333337
<section title="required">
334338
<t>This attribute indicates if the instance must have a value, and not be undefined. This is false by default, making the instance optional.</t>
335339
</section>
336340
<section title="requires">
337-
<t>This attribute indicates that if this property is present in the containing instance object, the property given by requires attribute MUST also be present in the containing instance object. The value
338-
of this property MAY be a string, indicating the require property name. Or the value MAY be a schema or a URI referencing a schema, in which case the containing instance MUST be valid by the schema if the property is present. For example if a object type definition is defined:</t>
341+
<t>If this attribute value is a string, then the containing/parent object of the validating instance MUST have a property with a name of the attribute value in order to validate.
342+
If this attribute value is a schema, then the containing/parent object of the validating instance MUST be validated against the provided schema.</t>
339343
<figure>
344+
<preamble>For example, for the following schema:</preamble>
340345
<artwork><![CDATA[
341346
{
342-
"state":{
343-
"optional":true
344-
},
345-
"town":{
346-
"requires":"state",
347-
"optional":true
347+
"properties" : {
348+
"state":{
349+
"optional":true
350+
},
351+
"town":{
352+
"requires":"state",
353+
"optional":true
354+
}
348355
}
349356
}
350357
]]></artwork>
358+
<postamble>An instance MUST include a state property if a town property is included. If a town property is not included, the state property is optional.</postamble>
351359
</figure>
352-
<t>An instance MUST include a state property if a town property is included. If a town property is not included, the state property is optional.</t>
353360
</section>
354361
<section title="minimum">
355362
<t>This attribute defines the minimum value of the instance property when the type of the instance value is a number.</t>
@@ -381,7 +388,7 @@ of this property MAY be a string, indicating the require property name. Or the v
381388
<t>When the instance value is a string, this defines the minimum length of the string.</t>
382389
</section>
383390
<section title="enum">
384-
<t>This provides an enumeration of possible values that are valid for the instance property. This MUST be an array, and each item in the array represents a possible value for the instance value. If this attribute is defined, the instance value MUST be one of the values in the array in order for the schema to be valid.</t>
391+
<t>This provides an enumeration of all possible values that are valid for the instance property. This MUST be an array, and each item in the array represents a possible value for the instance value. If this attribute is defined, the instance value MUST be one of the values in the array in order for the schema to be valid.</t>
385392
</section>
386393
<section title="title">
387394
<t>This attribute is a string that provides a short description of the instance property.</t>
@@ -390,7 +397,7 @@ of this property MAY be a string, indicating the require property name. Or the v
390397
<t>This attribute is a string that provides a full description of the of purpose the instance property.</t>
391398
</section>
392399

393-
<section title="format"><t>This property defines the type of data, content type, or microformat to be expected in the instance property values. A format attribute MAY be one of the values listed below, and if so, SHOULD adhere to the semantics describing for the format. A format SHOULD only be used give meaning to primitive types (string, integer, number, or boolean). Validators are not required to validate that the instance values conform to a format. The following formats are defined:</t>
400+
<section title="format"><t>This property defines the type of data, content type, or microformat to be expected in the instance property values. A format attribute MAY be one of the values listed below, and if so, SHOULD adhere to the semantics describing for the format. A format SHOULD only be used to give meaning to primitive types (string, integer, number, or boolean). Validators are not required to validate that the instance values conform to a format. The following formats are predefined:</t>
394401
<t>
395402
<list style="hanging">
396403
<t hangText="date-time">This SHOULD be a date in ISO 8601 format of YYYY-MM-DDThh:mm:ssZ in UTC time. This is the recommended form of date/timestamp.
@@ -408,13 +415,13 @@ of this property MAY be a string, indicating the require property name. Or the v
408415
</t><t hangText="host-name">This SHOULD be a host-name.</t>
409416
</list>
410417
</t>
411-
<t>Additional custom formats MAY be defined with a URL to a definition of the format.</t>
418+
<t>Additional custom formats MAY be referenced with a URI.</t>
412419
</section>
413420
<section title="maxDecimal">
414-
<t>This indicates the maximum number of decimal points.</t>
421+
<t>This attribute defines the maximum number of decimal points a number instance can have.</t>
415422
</section>
416423
<section title="disallow">
417-
<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 or a URI referencing a schema in the array, than this instance is not valid.</t>
424+
<t>This attribute takes 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 or a URI referencing a schema in the array, than this instance is not valid.</t>
418425
</section>
419426
<section title="extends">
420427
<t>The value of this property MUST be another schema or a URI referencing a schema which will provide a base schema which the current schema will inherit from. The inheritance rules are such that any instance that is valid according to the current schema MUST be valid according to the referenced schema. This MAY also be an array, in which case, the instance MUST be valid for all the schemas in the array. A schema that extends another schema MAY define additional properties, constrain existing properties, or add other constraints. The schema MUST NOT define a constraint that conflicts with an extended schema such that no instance may satisfy both schemas. An example of using "extends":
@@ -441,7 +448,7 @@ of this property MAY be a string, indicating the require property name. Or the v
441448
<section title="id">
442449
<t>
443450
This defines the URI of this schema (the target is effectively
444-
the "self" relation). This MAY be a relative or absolute. If the URI
451+
a "self" link). This URI MAY be relative or absolute. If the URI
445452
is relative, it SHOULD be resolved against the URI used to retrieve this schema.
446453
</t>
447454
</section>
@@ -452,7 +459,7 @@ attributes that already provided by the core schema with the specific
452459
purpose of informing user agents of relations between resources based
453460
on JSON data. Just as with JSON
454461
schema attributes, all the attributes in hyper schemas are optional.
455-
Therefore an empty object is a valid (non-informative) schema, and
462+
Therefore, an empty object is a valid (non-informative) schema, and
456463
essentially describes plain JSON (no constraints on the structures).
457464
Addition of attributes provides additive information for user agents.</t>
458465

@@ -464,7 +471,7 @@ relations of the instances.
464471
</t>
465472
<section title="Link Description Object">
466473
<t>
467-
A link description object is used to describe the link relations. In
474+
A link description object is used to describe link relations. In
468475
the context of a schema, it defines the link relations of the
469476
instances of the schema, and can be parameterized by the instance
470477
values. The link description format can be used on its own in
@@ -766,24 +773,20 @@ If the instance property value is a string, this attribute defines that the stri
766773

767774
<section title="pathStart">
768775
<t>
769-
This property value is a URI-Reference that indicates the URI that all
770-
the URIs for the instances of the schema MUST start with. When
771-
multiple schemas have been referenced for an instance, the user agent
776+
This attribute is a URI that defines what the instance's URI MUST start with in order to validate.
777+
The value of the "pathStart" attribute MUST be resolved as per <xref target='RFC3986'>RFC 3986, Sec 5</xref>,
778+
and is relative to the instance's URI.
779+
</t>
780+
<t>
781+
When multiple schemas have been referenced for an instance, the user agent
772782
can determine if this schema is applicable for a particular instance by
773-
determining if URI of the instance begins with the pathStart's referenced
774-
URI. pathStart MUST be resolved as per <xref target='RFC3986'>RFC 3986, Sec 5</xref>. If the URI of
775-
the instance does not start with URI indicated by pathStart, or if another
776-
schema specifies a starting URI that is longer and also matches the
783+
determining if the URI of the instance begins with the the value of the "pathStart"
784+
attribute. If the URI of the instance does not start with this URI,
785+
or if another schema specifies a starting URI that is longer and also matches the
777786
instance, this schema SHOULD NOT be applied to the instance. Any schema
778787
that does not have a pathStart attribute SHOULD be considered applicable
779788
to all the instances for which it is referenced.
780789
</t>
781-
<t>
782-
If this URI is relative, it should be resolved against the instance's URI.
783-
784-
</t>
785-
786-
787790
</section>
788791

789792
<section title="mediaType">
@@ -967,12 +970,14 @@ instead of numbers</t>
967970
</section>
968971

969972
<section title="Open Issues">
973+
<t>
970974
<list>
971975
<t>Should we give a preference to MIME headers over Link headers (or only use one)?</t>
972976
<t>Should "root" be a MIME parameter?</t>
973977
<t>Should "format" be renamed to "mediaType" or "contentType" to reflect the usage MIME media types that are allowed?</t>
974978
<t>How should dates be handled?</t>
975979
</list>
980+
</t>
976981
</section>
977982

978983
</back>

0 commit comments

Comments
 (0)