Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move "definitions" to core as "$defs", start appendix on moved/renamed keywords #570

Merged
merged 5 commits into from
Mar 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hyper-schema-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "array",
"items": {
"allOf": [
{"$ref": "http://json-schema.org/draft-08/links#/definitions/noRequiredFields" }
{"$ref": "http://json-schema.org/draft-08/links#/$defs/noRequiredFields" }
],
"type": "object",
"required": [
Expand Down
16 changes: 10 additions & 6 deletions hyper-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"$schema": "http://json-schema.org/draft-08/hyper-schema#",
"$id": "http://json-schema.org/draft-08/hyper-schema#",
"title": "JSON Hyper-Schema",
"definitions": {
"$defs": {
"schemaArray": {
"allOf": [
{ "$ref": "http://json-schema.org/draft-08/schema#/definitions/schemaArray" },
{ "$ref": "http://json-schema.org/draft-08/schema#/$defs/schemaArray" },
{
"items": { "$ref": "#" }
}
Expand All @@ -27,10 +27,14 @@
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/schemaArray" }
{ "$ref": "#/$defs/schemaArray" }
]
},
"$defs": {
"additionalProperties": { "$ref": "#" }
},
"definitions": {
"$comment": "Renamed to $defs, but retained here to ensure compatibility",
"additionalProperties": { "$ref": "#" }
},
"patternProperties": {
Expand All @@ -42,9 +46,9 @@
"if": {"$ref": "#"},
"then": {"$ref": "#"},
"else": {"$ref": "#"},
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"allOf": { "$ref": "#/$defs/schemaArray" },
"anyOf": { "$ref": "#/$defs/schemaArray" },
"oneOf": { "$ref": "#/$defs/schemaArray" },
"not": { "$ref": "#" },
"contains": { "$ref": "#" },
"propertyNames": { "$ref": "#" },
Expand Down
68 changes: 51 additions & 17 deletions jsonschema-core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -629,11 +629,11 @@
<![CDATA[
{
"$id": "http://example.com/root.json",
"definitions": {
"$defs": {
"A": { "$id": "#foo" },
"B": {
"$id": "other.json",
"definitions": {
"$defs": {
"X": { "$id": "#bar" },
"Y": { "$id": "t/inner.json" }
}
Expand All @@ -660,39 +660,39 @@
<t>http://example.com/root.json#</t>
</list>
</t>
<t hangText="#/definitions/A">
<t hangText="#/$defs/A">
<list>
<t>http://example.com/root.json#foo</t>
<t>http://example.com/root.json#/definitions/A</t>
<t>http://example.com/root.json#/$defs/A</t>
</list>
</t>
<t hangText="#/definitions/B">
<t hangText="#/$defs/B">
<list>
<t>http://example.com/other.json</t>
<t>http://example.com/other.json#</t>
<t>http://example.com/root.json#/definitions/B</t>
<t>http://example.com/root.json#/$defs/B</t>
</list>
</t>
<t hangText="#/definitions/B/definitions/X">
<t hangText="#/$defs/B/$defs/X">
<list>
<t>http://example.com/other.json#bar</t>
<t>http://example.com/other.json#/definitions/X</t>
<t>http://example.com/root.json#/definitions/B/definitions/X</t>
<t>http://example.com/other.json#/$defs/X</t>
<t>http://example.com/root.json#/$defs/B/$defs/X</t>
</list>
</t>
<t hangText="#/definitions/B/definitions/Y">
<t hangText="#/$defs/B/$defs/Y">
<list>
<t>http://example.com/t/inner.json</t>
<t>http://example.com/t/inner.json#</t>
<t>http://example.com/other.json#/definitions/Y</t>
<t>http://example.com/root.json#/definitions/B/definitions/Y</t>
<t>http://example.com/other.json#/$defs/Y</t>
<t>http://example.com/root.json#/$defs/B/$defs/Y</t>
</list>
</t>
<t hangText="#/definitions/C">
<t hangText="#/$defs/C">
<list>
<t>urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f</t>
<t>urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f#</t>
<t>http://example.com/root.json#/definitions/C</t>
<t>http://example.com/root.json#/$defs/C</t>
</list>
</t>
</list>
Expand Down Expand Up @@ -776,7 +776,7 @@
"type": "array",
"items": { "$ref": "#item" }
},
"definitions": {
"$defs": {
"single": {
"$id": "#item",
"type": "object",
Expand All @@ -788,7 +788,7 @@
</artwork>
</figure>
<t>
When an implementation encounters the &lt;#/definitions/single&gt; schema,
When an implementation encounters the &lt;#/$defs/single&gt; schema,
it resolves the "$id" URI reference against the current base URI to form
&lt;http://example.net/root.json#item&gt;.
</t>
Expand All @@ -814,6 +814,40 @@
</t>
</section>
</section>

<section title='Schema Re-Use With "$defs"'>
<t>
The "$defs" keyword provides a standardized location for schema
authors to inline re-usable JSON Schemas into a more general schema.
The keyword does not directly affect the validation result.
</t>
<t>
This keyword's value MUST be an object.
Each member value of this object MUST be a valid JSON Schema.
</t>
<t>
As an example, here is a schema describing an array of positive
integers, where the positive integer constraint is a subschema in
"$defs":

<figure>
<artwork>
<![CDATA[
{
"type": "array",
"items": { "$ref": "#/$defs/positiveInteger" },
"$defs": {
"positiveInteger": {
"type": "integer",
"exclusiveMinimum": 0
}
}
}
]]>
</artwork>
</figure>
</t>
</section>
</section>

<section title='Comments With "$comment"'>
Expand Down Expand Up @@ -1172,7 +1206,7 @@ User-Agent: product-name/5.4.1 so-cool-json-schema/1.0.2 curl/7.43.0
<list style="hanging">
<t hangText="draft-handrews-json-schema-02">
<list style="symbols">
<t></t>
<t>Moved "definitions" from the Validation specification here as "$defs"</t>
</list>
</t>
<t hangText="draft-handrews-json-schema-01">
Expand Down
22 changes: 11 additions & 11 deletions jsonschema-hyperschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ Link: <https://schema.example.com/entry> rel=describedBy
"type": "object",
"required": ["data"],
"properties": {
"id": {"$ref": "#/definitions/id"},
"id": {"$ref": "#/$defs/id"},
"data": true
},
"links": [
Expand All @@ -1639,7 +1639,7 @@ Link: <https://schema.example.com/entry> rel=describedBy
"targetSchema": {"$ref": "#"}
}
],
"definitions": {
"$defs": {
"id": {
"type": "integer",
"minimum": 1,
Expand All @@ -1652,7 +1652,7 @@ Link: <https://schema.example.com/entry> rel=describedBy
<t>
Our "thing" has a server-assigned id, which is required in order to
construct the "self" link. It also has a "data" field which can be
of any type. The reason for the "definitions" section will be clear
of any type. The reason for the "$defs" section will be clear
in the next example.
</t>
<t>
Expand All @@ -1678,7 +1678,7 @@ Link: <https://schema.example.com/entry> rel=describedBy
"hrefSchema": {
"required": ["id"],
"properties": {
"id": {"$ref": "thing#/definitions/id"}
"id": {"$ref": "thing#/$defs/id"}
}
},
"targetSchema": {"$ref": "thing#"}
Expand Down Expand Up @@ -1993,7 +1993,7 @@ Link: <https://api.example.com/trees/1/nodes/456> rev=up
"type": "object",
"required": ["data"],
"properties": {
"id": {"$ref": "#/definitions/id"},
"id": {"$ref": "#/$defs/id"},
"data": true
},
"links": [
Expand All @@ -2009,7 +2009,7 @@ Link: <https://api.example.com/trees/1/nodes/456> rev=up
"submissionSchema": {"$ref": "#"}
}
],
"definitions": {
"$defs": {
"id": {
"type": "integer",
"minimum": 1,
Expand Down Expand Up @@ -2206,9 +2206,9 @@ Link: <https://api.example.com/trees/1/nodes/456> rev=up
"meta": {
"type": "object",
"properties": {
"prev": {"$ref": "#/definitions/pagination"},
"current": {"$ref": "#/definitions/pagination"},
"next": {"$ref": "#/definitions/pagination"}
"prev": {"$ref": "#/$defs/pagination"},
"current": {"$ref": "#/$defs/pagination"},
"next": {"$ref": "#/$defs/pagination"}
}
}
},
Expand Down Expand Up @@ -2242,7 +2242,7 @@ Link: <https://api.example.com/trees/1/nodes/456> rev=up
"targetSchema": {"$ref": "#"}
}
],
"definitions": {
"$defs": {
"pagination": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -2348,7 +2348,7 @@ Link: <https://api.example.com/trees/1/nodes/456> rev=up
"rel": "tag:rel.example.com,2017:thing-collection",
"href": "/things{?offset,limit}",
"hrefSchema": {
"$ref": "thing-collection#/definitions/pagination"
"$ref": "thing-collection#/$defs/pagination"
},
"submissionSchema": {
"$ref": "thing#"
Expand Down
53 changes: 18 additions & 35 deletions jsonschema-validation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1233,40 +1233,6 @@

</section>

<section title='Schema Re-Use With "definitions"'>
<t>
The "definitions" keywords provides a standardized location for schema
authors to inline re-usable JSON Schemas into a more general schema.
The keyword does not directly affect the validation result.
</t>
<t>
This keyword's value MUST be an object.
Each member value of this object MUST be a valid JSON Schema.
</t>
<t>
As an example, here is a schema describing an array of positive
integers, where the positive integer constraint is a subschema in
"definitions":

<figure>
<artwork>
<![CDATA[
{
"type": "array",
"items": { "$ref": "#/definitions/positiveInteger" },
"definitions": {
"positiveInteger": {
"type": "integer",
"exclusiveMinimum": 0
}
}
}
]]>
</artwork>
</figure>
</t>
</section>

<section title="Schema Annotations">
<t>
Schema validation is a useful mechanism for annotating instance data
Expand Down Expand Up @@ -1470,6 +1436,23 @@
&RFC4329;
</references>

<section title="Keywords Moved from Validation to Core">
<t>
Several keywords have been moved from this document into the
<xref target="json-schema">Core Specification</xref> as of this draft, in some
cases with re-naming or other changes. This affects the following former
validation keywords:
<list style="hanging">
<t hangText='"definitions"'>
Renamed to "$defs" to match "$ref" and be shorter to type.
Schema vocabulary authors SHOULD NOT define a "definitions" keyword
with different behavior in order to avoid invalidating schemas that
still use the older name.
</t>
</list>
</t>
</section>

<section title="Acknowledgments">
<t>
Thanks to
Expand Down Expand Up @@ -1503,7 +1486,7 @@
<list style="hanging">
<t hangText="draft-handrews-json-schema-validation-02">
<list style="symbols">
<t></t>
<t>Moved "definitions" to the core spec as "$defs"</t>
</list>
</t>
<t hangText="draft-handrews-json-schema-validation-01">
Expand Down
4 changes: 2 additions & 2 deletions links.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"title": "Link Description Object",
"allOf": [
{ "required": [ "rel", "href" ] },
{ "$ref": "#/definitions/noRequiredFields" }
{ "$ref": "#/$defs/noRequiredFields" }
],
"definitions": {
"$defs": {
"noRequiredFields": {
"type": "object",
"properties": {
Expand Down
Loading