Skip to content

Commit

Permalink
Update meta-schemas with $recursiveRef
Browse files Browse the repository at this point in the history
hyper-schema is a lot simpler now.
  • Loading branch information
handrews committed Sep 17, 2018
1 parent 0cce8aa commit 2e973df
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 98 deletions.
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
23 changes: 6 additions & 17 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 All @@ -22,22 +22,14 @@
]
},
"rel": {
"anyOf": [
{ "type": "string" },
{
"type": "array",
"items": { "type": "string" },
"minItems": 1
}
]
"type": "string"
},
"href": {
"type": "string",
"format": "uri-template"
},
"hrefSchema": {
"$ref": "http://json-schema.org/draft-08/hyper-schema#",
"default": false
"$recursiveRef": "http://json-schema.org/draft-08/hyper-schema"
},
"templatePointers": {
"type": "object",
Expand All @@ -63,24 +55,21 @@
"type": "string"
},
"targetSchema": {
"$ref": "http://json-schema.org/draft-08/hyper-schema#",
"default": true
"$recursiveRef": "http://json-schema.org/draft-08/hyper-schema"
},
"targetMediaType": {
"type": "string"
},
"targetHints": { },
"headerSchema": {
"$ref": "http://json-schema.org/draft-08/hyper-schema#",
"default": true
"$recursiveRef": "http://json-schema.org/draft-08/hyper-schema"
},
"submissionMediaType": {
"type": "string",
"default": "application/json"
},
"submissionSchema": {
"$ref": "http://json-schema.org/draft-08/hyper-schema#",
"default": true
"$recursiveRef": "http://json-schema.org/draft-08/hyper-schema"
},
"$comment": {
"type": "string"
Expand Down
52 changes: 24 additions & 28 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": {
"$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,58 +103,51 @@
"type": "string",
"format": "regex"
},
"additionalItems": { "$ref": "#" },
"additionalItems": { "$recursiveRef": "#" },
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$recursiveRef": "#" },
{ "$ref": "#/$defs/schemaArray" }
]
],
"default": true
},
"maxItems": { "$ref": "#/$defs/nonNegativeInteger" },
"minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
"uniqueItems": {
"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": {
"dependencies": {
"type": "object",
"additionalProperties": {
"$ref": "#"
"$recursiveRef": "#"
}
},
"dependentRequired": {
"requiredDependencies": {
"type": "object",
"additionalProperties": {
"$ref": "#/$defs/stringArray"
}
},
"dependencies": {
"$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"",
"type": "object",
"additionalProperties": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/$defs/stringArray" }
]
}
"propertyNames": {
"additionalProperties": { "$recursiveRef": "#" }
},
"propertyNames": { "$ref": "#" },
"const": true,
"enum": {
"type": "array",
Expand All @@ -174,12 +169,13 @@
"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": "#" }
},
"default": true
}

0 comments on commit 2e973df

Please sign in to comment.