Skip to content

Commit e0868cc

Browse files
committed
Updated specification to include fixes from the community:
-Fixed examples -"uniqueItems" now enforces array and object items, defined algorithm -Moved "default" back to core schema -Tweaked wording in "format" -Re-replaced "maxDecimal" with "divisibleBy" -Tweaked wording in hyper-schema "properties". Removed vague sentence regarding forms (this can be re-added when a better description is defined).
1 parent cf472d8 commit e0868cc

File tree

3 files changed

+44
-30
lines changed

3 files changed

+44
-30
lines changed

draft-zyp-json-schema-03.xml

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,20 @@
132132
"properties":{
133133
"id":{
134134
"type":"number",
135-
"description":"Product identifier"
135+
"description":"Product identifier",
136+
"required":true
136137
},
137138
"name":{
138139
"description":"Name of the product",
139-
"type":"string"
140+
"type":"string",
141+
"required":true
140142
},
141143
"price":{
142144
"type": "number",
143-
"minimum":0
145+
"minimum":0,
146+
"required":true
144147
},
145148
"tags":{
146-
"optional":true,
147149
"type":"array",
148150
"items":{
149151
"type":"string"
@@ -163,8 +165,8 @@
163165
}
164166
]]></artwork>
165167
<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+
This schema defines the properties of the instance JSON documents,
169+
the required properties (id, name, and price), as well as an optional
168170
property (tags). This also defines the link relations of the instance
169171
JSON documents.
170172
</postamble>
@@ -279,8 +281,10 @@ Content-Type: application/json;
279281
280282
"properties":{
281283
"name":{"type":"string"},
282-
"age" :{"type":"integer"},
283-
"maximum":125
284+
"age" :{
285+
"type":"integer",
286+
"maximum":125
287+
}
284288
}
285289
}
286290
]]></artwork>
@@ -323,7 +327,7 @@ If the property is not defined or is not in this list, then any type of value is
323327
]]></artwork>
324328
</figure>
325329
</section>
326-
<section title="properties">
330+
<section title="properties" anchor="properties">
327331
<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>
328332
</section>
329333
<section title="patternProperties">
@@ -369,8 +373,16 @@ The dependency value can take one of two forms:
369373
<section title="maxItems">
370374
<t>This attribute defines the maximum number of values in an array when the array is the instance value.</t>
371375
</section>
372-
<section title="uniqueItems">
373-
<t>This attribute indicates that all the items in an array MUST be unique (no two identical values) within that array when the array is the instance value. Uniqueness is only defined for primitive types: strings, numbers, booleans, and nulls.</t>
376+
<section title="uniqueItems" anchor="uniqueItems">
377+
<t>This attribute indicates that all items in an array instance MUST be unique (contains no two identical values).</t>
378+
<t>Two instance are consider equal if they are both of the same type and:
379+
<list>
380+
<t>are null; or</t>
381+
<t>are booleans/numbers/strings and have the same value; or</t>
382+
<t>are arrays, contains the same number of items, and each item in the array is equal to the corresponding item in the other array; or</t>
383+
<t>are objects, contains the same property names, and each property in the object is equal to the corresponding property in the other object.</t>
384+
</list>
385+
</t>
374386
</section>
375387
<section title="pattern">
376388
<t>When the instance value is a string, this provides a regular expression that a string instance MUST match in order to be valid. Regular expressions SHOULD follow the regular expression specification from ECMA 262/Perl 5</t></section>
@@ -381,7 +393,10 @@ The dependency value can take one of two forms:
381393
<t>When the instance value is a string, this defines the minimum length of the string.</t>
382394
</section>
383395
<section title="enum">
384-
<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>
396+
<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. Comparison of enum values uses the same algorithm as defined in <xref target="uniqueItems">"uniqueItems"</xref>.</t>
397+
</section>
398+
<section title="default">
399+
<t>This attribute defines the default value of the instance when the instance is undefined.</t>
385400
</section>
386401
<section title="title">
387402
<t>This attribute is a string that provides a short description of the instance property.</t>
@@ -390,7 +405,7 @@ The dependency value can take one of two forms:
390405
<t>This attribute is a string that provides a full description of the of purpose the instance property.</t>
391406
</section>
392407

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 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>
408+
<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 MAY (but are not required to) validate that the instance values conform to a format. The following formats are predefined:</t>
394409
<t>
395410
<list style="hanging">
396411
<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,10 +423,10 @@ The dependency value can take one of two forms:
408423
</t><t hangText="host-name">This SHOULD be a host-name.</t>
409424
</list>
410425
</t>
411-
<t>Additional custom formats MAY be referenced with a URI.</t>
426+
<t>Additional custom formats MAY be created. These custom formats MAY be expressed as an URI, and this URI MAY reference a schema of that format.</t>
412427
</section>
413-
<section title="maxDecimal">
414-
<t>This attribute defines the maximum number of decimal points a number instance can have.</t>
428+
<section title="divisibleBy">
429+
<t>This attribute defines what value the number instance must be divisible by with no remainder. (The result of the division must be an integer.)</t>
415430
</section>
416431
<section title="disallow">
417432
<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, then this instance is not valid.</t>
@@ -658,12 +673,10 @@ the default media type.
658673
</section>
659674
<section title="properties">
660675
<t>
661-
This is inherited from the base JSON schema definition, and can follow the
662-
same structure, but its meaning SHOULD be used to define the acceptable
676+
This attribute has the same structure as the core JSON Schema <xref target="properties">"properties" attribute</xref>,
677+
but its meaning SHOULD be used to define the acceptable
663678
property names and values for the action (whether it be for the GET query
664-
or POST body). If properties are omitted, and this form is the child of a
665-
schema, the properties from the parent schema SHOULD be used as the basis
666-
for the form action.
679+
or POST body).
667680
</t>
668681
</section>
669682
</section>
@@ -760,10 +773,6 @@ If the instance property value is a string, this attribute defines that the stri
760773
</t>
761774
</section>
762775

763-
<section title="default">
764-
<t>This attribute defines the default value of the instance when the instance is undefined.</t>
765-
</section>
766-
767776
<section title="pathStart">
768777
<t>
769778
This attribute is a URI that defines what the instance's URI MUST start with in order to validate.
@@ -927,12 +936,11 @@ instead of numbers</t>
927936
<t>Added more explanation of nullability.</t>
928937
<t>Removed "alternate" attribute.</t>
929938
<t>Upper cased many normative usages of must, may, and should.</t>
930-
<t>Replaced "divisibleBy" attribute with "maxDecimal" attribute.</t>
931939
<t>Replaced "optional" attribute with "required" attribute.</t>
932940
<t>Replaced "maximumCanEqual" attribute with "exclusiveMaximum" attribute.</t>
933941
<t>Replaced "minimumCanEqual" attribute with "exclusiveMinimum" attribute.</t>
934942
<t>Replaced "requires" attribute with "dependencies" attribute.</t>
935-
<t>Moved "default" and "contentEncoding" attributes to hyper schema</t>
943+
<t>Moved "contentEncoding" attribute to hyper schema.</t>
936944
<t>Added "additionalItems" attribute.</t>
937945
<t>Added "id" attribute.</t>
938946
<t>Switched self-referencing variable substitution from "-this" to "@" to align with reserved characters in URI template.</t>

hyper-schema

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@
6969
"type" : "string"
7070
},
7171

72-
"default" : {
73-
},
74-
7572
"requires" : {
7673
"type" : ["string", "http://json-schema.org/hyper-schema-or-uri"]
7774
},

schema

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@
108108
"uniqueItems" : true
109109
},
110110

111+
"default" : {
112+
"type" : "any"
113+
},
114+
111115
"title" : {
112116
"type" : "string"
113117
},
@@ -137,6 +141,11 @@
137141
"type" : ["#", "array"],
138142
"items" : "#",
139143
"default" : {}
144+
},
145+
146+
"id" : {
147+
"type" : "string",
148+
"format" : "uri"
140149
}
141150
},
142151
"links" : [

0 commit comments

Comments
 (0)