Skip to content

$recursiveRef part 3 of 3: Update meta-schemas #655

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

Merged
merged 1 commit into from
Nov 13, 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
58 changes: 5 additions & 53 deletions hyper-schema.json
Original file line number Diff line number Diff line change
@@ -1,67 +1,19 @@
{
"$schema": "http://json-schema.org/draft-08/hyper-schema#",
"$id": "http://json-schema.org/draft-08/hyper-schema#",
"$id": "http://json-schema.org/draft-08/hyper-schema",
"$recursiveAnchor": true,

"title": "JSON Hyper-Schema",
"$defs": {
"schemaArray": {
"allOf": [
{ "$ref": "http://json-schema.org/draft-08/schema#/$defs/schemaArray" },
{
"items": { "$ref": "#" }
}
]
}
},
"allOf": [ { "$ref": "http://json-schema.org/draft-08/schema#" } ],
"$ref": "http://json-schema.org/draft-08/schema",
"properties": {
"additionalItems": { "$ref": "#" },
"additionalProperties": { "$ref": "#"},
"dependentSchemas": { "$ref": "#" },
"dependencies": {
"$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"",
"additionalProperties": {
"anyOf": [
{ "$ref": "#" },
{ "type": "array" }
]
}
},
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/$defs/schemaArray" }
]
},
"$defs": {
"additionalProperties": { "$ref": "#" }
},
"definitions": {
"$comment": "Renamed to $defs, but retained here to ensure compatibility",
"additionalProperties": { "$ref": "#" }
},
"patternProperties": {
"additionalProperties": { "$ref": "#" }
},
"properties": {
"additionalProperties": { "$ref": "#" }
},
"if": { "$ref": "#" },
"then": { "$ref": "#" },
"else": { "$ref": "#" },
"allOf": { "$ref": "#/$defs/schemaArray" },
"anyOf": { "$ref": "#/$defs/schemaArray" },
"oneOf": { "$ref": "#/$defs/schemaArray" },
"not": { "$ref": "#" },
"contains": { "$ref": "#" },
"propertyNames": { "$ref": "#" },
"base": {
"type": "string",
"format": "uri-template"
},
"links": {
"type": "array",
"items": {
"$ref": "http://json-schema.org/draft-08/links#"
"$ref": "http://json-schema.org/draft-08/links"
}
}
},
Expand Down
10 changes: 5 additions & 5 deletions links.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-08/hyper-schema#",
"$id": "http://json-schema.org/draft-08/links#",
"$id": "http://json-schema.org/draft-08/links",
"title": "Link Description Object",
"allOf": [
{ "required": [ "rel", "href" ] },
Expand Down Expand Up @@ -36,7 +36,7 @@
"format": "uri-template"
},
"hrefSchema": {
"$ref": "http://json-schema.org/draft-08/hyper-schema#",
"$recursiveRef": "http://json-schema.org/draft-08/hyper-schema",
"default": false
},
"templatePointers": {
Expand All @@ -63,23 +63,23 @@
"type": "string"
},
"targetSchema": {
"$ref": "http://json-schema.org/draft-08/hyper-schema#",
"$recursiveRef": "http://json-schema.org/draft-08/hyper-schema",
"default": true
},
"targetMediaType": {
"type": "string"
},
"targetHints": { },
"headerSchema": {
"$ref": "http://json-schema.org/draft-08/hyper-schema#",
"$recursiveRef": "http://json-schema.org/draft-08/hyper-schema",
"default": true
},
"submissionMediaType": {
"type": "string",
"default": "application/json"
},
"submissionSchema": {
"$ref": "http://json-schema.org/draft-08/hyper-schema#",
"$recursiveRef": "http://json-schema.org/draft-08/hyper-schema",
"default": true
},
"$comment": {
Expand Down
34 changes: 18 additions & 16 deletions schema.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"$schema": "http://json-schema.org/draft-08/schema#",
"$id": "http://json-schema.org/draft-08/schema#",
"$recursiveAnchor": true,

"title": "Core schema meta-schema",
"$defs": {
"schemaArray": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#" }
"items": { "$recursiveRef": "#" }
},
"nonNegativeInteger": {
"type": "integer",
Expand Down Expand Up @@ -55,13 +57,13 @@
},
"$defs": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"additionalProperties": { "$recursiveRef": "#" },
"default": {}
},
"definitions": {
Copy link
Member

@gregsdennis gregsdennis Sep 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although not part of this PR, specifically, can definitions just redirect to $defs rather than repeating the subschema? Or is there some deeper purpose to having it explicit?

Maybe something like

"definitions": {
  "$recursiveRef": "#/properties/$defs",
  "$comment": "look at how well keywords fit right next to $refs!"
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of feel like best practices is for refs to target #/$defs/..., not #/properties/..., and it seems overkill to factor this out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair, but it also feels redundant to have a definition that is truly supposed to be the same thing in here twice. Maybe move the whole thing to a definition and have both properties reference it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the explicitness more than I am concerned about a 3-line redundancy here.

"$comment": "While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.",
"type": "object",
"additionalProperties": { "$ref": "#" },
"additionalProperties": { "$recursiveRef": "#" },
"default": {}
},
"title": {
Expand Down Expand Up @@ -101,10 +103,10 @@
"type": "string",
"format": "regex"
},
"additionalItems": { "$ref": "#" },
"additionalItems": { "$recursiveRef": "#" },
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$recursiveRef": "#" },
{ "$ref": "#/$defs/schemaArray" }
]
},
Expand All @@ -114,26 +116,26 @@
"type": "boolean",
"default": false
},
"contains": { "$ref": "#" },
"contains": { "$recursiveRef": "#" },
"maxProperties": { "$ref": "#/$defs/nonNegativeInteger" },
"minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
"required": { "$ref": "#/$defs/stringArray" },
"additionalProperties": { "$ref": "#" },
"additionalProperties": { "$recursiveRef": "#" },
"properties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"additionalProperties": { "$recursiveRef": "#" },
"default": {}
},
"patternProperties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"additionalProperties": { "$recursiveRef": "#" },
"propertyNames": { "format": "regex" },
"default": {}
},
"dependentSchemas": {
"type": "object",
"additionalProperties": {
"$ref": "#"
"$recursiveRef": "#"
}
},
"dependentRequired": {
Expand All @@ -147,12 +149,12 @@
"type": "object",
"additionalProperties": {
"anyOf": [
{ "$ref": "#" },
{ "$recursiveRef": "#" },
{ "$ref": "#/$defs/stringArray" }
]
}
},
"propertyNames": { "$ref": "#" },
"propertyNames": { "$recursiveRef": "#" },
"const": true,
"enum": {
"type": "array",
Expand All @@ -174,12 +176,12 @@
"format": { "type": "string" },
"contentMediaType": { "type": "string" },
"contentEncoding": { "type": "string" },
"if": { "$ref": "#" },
"then": { "$ref": "#" },
"else": { "$ref": "#" },
"if": { "$recursiveRef": "#" },
"then": { "$recursiveRef": "#" },
"else": { "$recursiveRef": "#" },
"allOf": { "$ref": "#/$defs/schemaArray" },
"anyOf": { "$ref": "#/$defs/schemaArray" },
"oneOf": { "$ref": "#/$defs/schemaArray" },
"not": { "$ref": "#" }
"not": { "$recursiveRef": "#" }
}
}