Skip to content

Commit 2e973df

Browse files
committed
Update meta-schemas with $recursiveRef
hyper-schema is a lot simpler now.
1 parent 0cce8aa commit 2e973df

File tree

3 files changed

+35
-98
lines changed

3 files changed

+35
-98
lines changed

hyper-schema.json

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,19 @@
11
{
22
"$schema": "http://json-schema.org/draft-08/hyper-schema#",
3-
"$id": "http://json-schema.org/draft-08/hyper-schema#",
3+
"$id": "http://json-schema.org/draft-08/hyper-schema",
4+
"$recursiveAnchor": true,
5+
46
"title": "JSON Hyper-Schema",
5-
"$defs": {
6-
"schemaArray": {
7-
"allOf": [
8-
{ "$ref": "http://json-schema.org/draft-08/schema#/$defs/schemaArray" },
9-
{
10-
"items": { "$ref": "#" }
11-
}
12-
]
13-
}
14-
},
15-
"allOf": [ { "$ref": "http://json-schema.org/draft-08/schema#" } ],
7+
"$ref": "http://json-schema.org/draft-08/schema",
168
"properties": {
17-
"additionalItems": { "$ref": "#" },
18-
"additionalProperties": { "$ref": "#"},
19-
"dependentSchemas": { "$ref": "#" },
20-
"dependencies": {
21-
"$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"",
22-
"additionalProperties": {
23-
"anyOf": [
24-
{ "$ref": "#" },
25-
{ "type": "array" }
26-
]
27-
}
28-
},
29-
"items": {
30-
"anyOf": [
31-
{ "$ref": "#" },
32-
{ "$ref": "#/$defs/schemaArray" }
33-
]
34-
},
35-
"$defs": {
36-
"additionalProperties": { "$ref": "#" }
37-
},
38-
"definitions": {
39-
"$comment": "Renamed to $defs, but retained here to ensure compatibility",
40-
"additionalProperties": { "$ref": "#" }
41-
},
42-
"patternProperties": {
43-
"additionalProperties": { "$ref": "#" }
44-
},
45-
"properties": {
46-
"additionalProperties": { "$ref": "#" }
47-
},
48-
"if": { "$ref": "#" },
49-
"then": { "$ref": "#" },
50-
"else": { "$ref": "#" },
51-
"allOf": { "$ref": "#/$defs/schemaArray" },
52-
"anyOf": { "$ref": "#/$defs/schemaArray" },
53-
"oneOf": { "$ref": "#/$defs/schemaArray" },
54-
"not": { "$ref": "#" },
55-
"contains": { "$ref": "#" },
56-
"propertyNames": { "$ref": "#" },
579
"base": {
5810
"type": "string",
5911
"format": "uri-template"
6012
},
6113
"links": {
6214
"type": "array",
6315
"items": {
64-
"$ref": "http://json-schema.org/draft-08/links#"
16+
"$ref": "http://json-schema.org/draft-08/links"
6517
}
6618
}
6719
},

links.json

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "http://json-schema.org/draft-08/hyper-schema#",
3-
"$id": "http://json-schema.org/draft-08/links#",
3+
"$id": "http://json-schema.org/draft-08/links",
44
"title": "Link Description Object",
55
"allOf": [
66
{ "required": [ "rel", "href" ] },
@@ -22,22 +22,14 @@
2222
]
2323
},
2424
"rel": {
25-
"anyOf": [
26-
{ "type": "string" },
27-
{
28-
"type": "array",
29-
"items": { "type": "string" },
30-
"minItems": 1
31-
}
32-
]
25+
"type": "string"
3326
},
3427
"href": {
3528
"type": "string",
3629
"format": "uri-template"
3730
},
3831
"hrefSchema": {
39-
"$ref": "http://json-schema.org/draft-08/hyper-schema#",
40-
"default": false
32+
"$recursiveRef": "http://json-schema.org/draft-08/hyper-schema"
4133
},
4234
"templatePointers": {
4335
"type": "object",
@@ -63,24 +55,21 @@
6355
"type": "string"
6456
},
6557
"targetSchema": {
66-
"$ref": "http://json-schema.org/draft-08/hyper-schema#",
67-
"default": true
58+
"$recursiveRef": "http://json-schema.org/draft-08/hyper-schema"
6859
},
6960
"targetMediaType": {
7061
"type": "string"
7162
},
7263
"targetHints": { },
7364
"headerSchema": {
74-
"$ref": "http://json-schema.org/draft-08/hyper-schema#",
75-
"default": true
65+
"$recursiveRef": "http://json-schema.org/draft-08/hyper-schema"
7666
},
7767
"submissionMediaType": {
7868
"type": "string",
7969
"default": "application/json"
8070
},
8171
"submissionSchema": {
82-
"$ref": "http://json-schema.org/draft-08/hyper-schema#",
83-
"default": true
72+
"$recursiveRef": "http://json-schema.org/draft-08/hyper-schema"
8473
},
8574
"$comment": {
8675
"type": "string"

schema.json

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{
22
"$schema": "http://json-schema.org/draft-08/schema#",
33
"$id": "http://json-schema.org/draft-08/schema#",
4+
"$recursiveAnchor": true,
5+
46
"title": "Core schema meta-schema",
57
"$defs": {
68
"schemaArray": {
79
"type": "array",
810
"minItems": 1,
9-
"items": { "$ref": "#" }
11+
"items": { "$recursiveRef": "#" }
1012
},
1113
"nonNegativeInteger": {
1214
"type": "integer",
@@ -55,13 +57,13 @@
5557
},
5658
"$defs": {
5759
"type": "object",
58-
"additionalProperties": { "$ref": "#" },
60+
"additionalProperties": { "$recursiveRef": "#" },
5961
"default": {}
6062
},
6163
"definitions": {
6264
"$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.",
6365
"type": "object",
64-
"additionalProperties": { "$ref": "#" },
66+
"additionalProperties": { "$recursiveRef": "#" },
6567
"default": {}
6668
},
6769
"title": {
@@ -101,58 +103,51 @@
101103
"type": "string",
102104
"format": "regex"
103105
},
104-
"additionalItems": { "$ref": "#" },
106+
"additionalItems": { "$recursiveRef": "#" },
105107
"items": {
106108
"anyOf": [
107-
{ "$ref": "#" },
109+
{ "$recursiveRef": "#" },
108110
{ "$ref": "#/$defs/schemaArray" }
109-
]
111+
],
112+
"default": true
110113
},
111114
"maxItems": { "$ref": "#/$defs/nonNegativeInteger" },
112115
"minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
113116
"uniqueItems": {
114117
"type": "boolean",
115118
"default": false
116119
},
117-
"contains": { "$ref": "#" },
120+
"contains": { "$recursiveRef": "#" },
118121
"maxProperties": { "$ref": "#/$defs/nonNegativeInteger" },
119122
"minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
120123
"required": { "$ref": "#/$defs/stringArray" },
121-
"additionalProperties": { "$ref": "#" },
124+
"additionalProperties": { "$recursiveRef": "#" },
122125
"properties": {
123126
"type": "object",
124-
"additionalProperties": { "$ref": "#" },
127+
"additionalProperties": { "$recursiveRef": "#" },
125128
"default": {}
126129
},
127130
"patternProperties": {
128131
"type": "object",
129-
"additionalProperties": { "$ref": "#" },
132+
"additionalProperties": { "$recursiveRef": "#" },
130133
"propertyNames": { "format": "regex" },
131134
"default": {}
132135
},
133-
"dependentSchemas": {
136+
"dependencies": {
134137
"type": "object",
135138
"additionalProperties": {
136-
"$ref": "#"
139+
"$recursiveRef": "#"
137140
}
138141
},
139-
"dependentRequired": {
142+
"requiredDependencies": {
140143
"type": "object",
141144
"additionalProperties": {
142145
"$ref": "#/$defs/stringArray"
143146
}
144147
},
145-
"dependencies": {
146-
"$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"",
147-
"type": "object",
148-
"additionalProperties": {
149-
"anyOf": [
150-
{ "$ref": "#" },
151-
{ "$ref": "#/$defs/stringArray" }
152-
]
153-
}
148+
"propertyNames": {
149+
"additionalProperties": { "$recursiveRef": "#" }
154150
},
155-
"propertyNames": { "$ref": "#" },
156151
"const": true,
157152
"enum": {
158153
"type": "array",
@@ -174,12 +169,13 @@
174169
"format": { "type": "string" },
175170
"contentMediaType": { "type": "string" },
176171
"contentEncoding": { "type": "string" },
177-
"if": { "$ref": "#" },
178-
"then": { "$ref": "#" },
179-
"else": { "$ref": "#" },
172+
"if": { "$recursiveRef": "#" },
173+
"then": { "$recursiveRef": "#" },
174+
"else": { "$recursiveRef": "#" },
180175
"allOf": { "$ref": "#/$defs/schemaArray" },
181176
"anyOf": { "$ref": "#/$defs/schemaArray" },
182177
"oneOf": { "$ref": "#/$defs/schemaArray" },
183-
"not": { "$ref": "#" }
184-
}
178+
"not": { "$recursiveRef": "#" }
179+
},
180+
"default": true
185181
}

0 commit comments

Comments
 (0)