Skip to content

Commit 9c5eb1f

Browse files
committed
Forbid "$schema" in subschemas
This modifies the meta-schemas to explicitly forbid "$schema" in subschemas, and adds "$vocabularies".
1 parent 5ef3786 commit 9c5eb1f

File tree

3 files changed

+62
-32
lines changed

3 files changed

+62
-32
lines changed

hyper-schema.json

+24-14
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,63 @@
11
{
22
"$schema": "http://json-schema.org/draft-06/hyper-schema#",
33
"$id": "http://json-schema.org/draft-06/hyper-schema#",
4+
"$vocabularies": [
5+
"http://json-schema.org/draft-06/schema#",
6+
"http://json-schema.org/draft-06/hyper-schema#"
7+
],
48
"title": "JSON Hyper-Schema",
59
"definitions": {
610
"schemaArray": {
711
"allOf": [
812
{ "$ref": "http://json-schema.org/draft-06/schema#/definitions/schemaArray" },
913
{
10-
"items": { "$ref": "#" }
14+
"items": { "$ref": "#/definitions/subschema" }
1115
}
1216
]
17+
},
18+
"subschema": {
19+
"allOf": [
20+
{ "$ref": "#" },
21+
{ "properties": { "$schema": false } }
22+
]
1323
}
1424
},
1525
"allOf": [ { "$ref": "http://json-schema.org/draft-06/schema#" } ],
1626
"properties": {
17-
"additionalItems": { "$ref": "#" },
18-
"additionalProperties": { "$ref": "#"},
27+
"additionalItems": { "$ref": "#/definitions/subschema" },
28+
"additionalProperties": { "$ref": "#/definitions/subschema"},
1929
"dependencies": {
2030
"additionalProperties": {
2131
"anyOf": [
22-
{ "$ref": "#" },
32+
{ "$ref": "#/definitions/subschema" },
2333
{ "type": "array" }
2434
]
2535
}
2636
},
2737
"items": {
2838
"anyOf": [
29-
{ "$ref": "#" },
39+
{ "$ref": "#/definitions/subschema" },
3040
{ "$ref": "#/definitions/schemaArray" }
3141
]
3242
},
3343
"definitions": {
34-
"additionalProperties": { "$ref": "#" }
44+
"additionalProperties": { "$ref": "#/definitions/subschema" }
3545
},
3646
"patternProperties": {
37-
"additionalProperties": { "$ref": "#" }
47+
"additionalProperties": { "$ref": "#/definitions/subschema" }
3848
},
3949
"properties": {
40-
"additionalProperties": { "$ref": "#" }
50+
"additionalProperties": { "$ref": "#/definitions/subschema" }
4151
},
42-
"if": {"$ref": "#"},
43-
"then": {"$ref": "#"},
44-
"else": {"$ref": "#"},
52+
"if": {"$ref": "#/definitions/subschema"},
53+
"then": {"$ref": "#/definitions/subschema"},
54+
"else": {"$ref": "#/definitions/subschema"},
4555
"allOf": { "$ref": "#/definitions/schemaArray" },
4656
"anyOf": { "$ref": "#/definitions/schemaArray" },
4757
"oneOf": { "$ref": "#/definitions/schemaArray" },
48-
"not": { "$ref": "#" },
49-
"contains": { "$ref": "#" },
50-
"propertyNames": { "$ref": "#" },
58+
"not": { "$ref": "#/definitions/subschema" },
59+
"contains": { "$ref": "#/definitions/subschema" },
60+
"propertyNames": { "$ref": "#/definitions/subschema" },
5161

5262
"base": {
5363
"type": "string"

links.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"$schema": "http://json-schema.org/draft-06/hyper-schema#",
33
"$id": "http://json-schema.org/draft-06/links#",
4+
"$vocabularies": [
5+
"http://json-schema.org/draft-06/schema#",
6+
"http://json-schema.org/draft-06/hyper-schema#"
7+
],
48
"title": "Link Description Object",
59
"type": "object",
610
"required": [ "href" ],
@@ -21,7 +25,7 @@
2125
},
2226
"hrefSchema": {
2327
"allOf": [
24-
{ "$ref": "http://json-schema.org/draft-06/hyper-schema#" }
28+
{ "$ref": "http://json-schema.org/draft-06/hyper-schema#/definitions/subschema" }
2529
]
2630
},
2731
"hrefRequired": {
@@ -53,7 +57,7 @@
5357
},
5458
"targetSchema": {
5559
"allOf": [
56-
{ "$ref": "http://json-schema.org/draft-06/hyper-schema#" }
60+
{ "$ref": "http://json-schema.org/draft-06/hyper-schema#/definitions/subschema" }
5761
]
5862
},
5963
"targetHints": { },
@@ -62,7 +66,7 @@
6266
},
6367
"headerSchema": {
6468
"allOf": [
65-
{ "$ref": "http://json-schema.org/draft-06/hyper-schema#" }
69+
{ "$ref": "http://json-schema.org/draft-06/hyper-schema#/definitions/subschema" }
6670
]
6771
},
6872
"submissionEncType": {
@@ -71,7 +75,7 @@
7175
},
7276
"submissionSchema": {
7377
"allOf": [
74-
{ "$ref": "http://json-schema.org/draft-06/hyper-schema#" }
78+
{ "$ref": "http://json-schema.org/draft-06/hyper-schema#/definitions/subschema" }
7579
]
7680
},
7781
"$comment": {

schema.json

+30-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
{
22
"$schema": "http://json-schema.org/draft-06/schema#",
33
"$id": "http://json-schema.org/draft-06/schema#",
4+
"$vocabularies": [
5+
"http://json-schema.org/draft-06/schema#"
6+
],
47
"title": "Core schema meta-schema",
58
"definitions": {
69
"schemaArray": {
710
"type": "array",
811
"minItems": 1,
9-
"items": { "$ref": "#" }
12+
"items": { "$ref": "#/definitions/subschema" }
1013
},
1114
"nonNegativeInteger": {
1215
"type": "integer",
@@ -34,6 +37,12 @@
3437
"items": { "type": "string" },
3538
"uniqueItems": true,
3639
"default": []
40+
},
41+
"subschema": {
42+
"allOf": [
43+
{ "$ref": "#" },
44+
{ "properties": { "$schema": false } }
45+
]
3746
}
3847
},
3948
"type": ["object", "boolean"],
@@ -46,6 +55,13 @@
4655
"type": "string",
4756
"format": "uri"
4857
},
58+
"$vocabularies": {
59+
"type": "array",
60+
"items": {
61+
"type": "string",
62+
"format": "uri"
63+
}
64+
},
4965
"$ref": {
5066
"type": "string",
5167
"format": "uri-reference"
@@ -90,10 +106,10 @@
90106
"type": "string",
91107
"format": "regex"
92108
},
93-
"additionalItems": { "$ref": "#" },
109+
"additionalItems": { "$ref": "#/definitions/subschema" },
94110
"items": {
95111
"anyOf": [
96-
{ "$ref": "#" },
112+
{ "$ref": "#/definitions/subschema" },
97113
{ "$ref": "#/definitions/schemaArray" }
98114
],
99115
"default": {}
@@ -104,37 +120,37 @@
104120
"type": "boolean",
105121
"default": false
106122
},
107-
"contains": { "$ref": "#" },
123+
"contains": { "$ref": "#/definitions/subschema" },
108124
"maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
109125
"minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
110126
"required": { "$ref": "#/definitions/stringArray" },
111-
"additionalProperties": { "$ref": "#" },
127+
"additionalProperties": { "$ref": "#/definitions/subschema" },
112128
"definitions": {
113129
"type": "object",
114-
"additionalProperties": { "$ref": "#" },
130+
"additionalProperties": { "$ref": "#/definitions/subschema" },
115131
"default": {}
116132
},
117133
"properties": {
118134
"type": "object",
119-
"additionalProperties": { "$ref": "#" },
135+
"additionalProperties": { "$ref": "#/definitions/subschema" },
120136
"default": {}
121137
},
122138
"patternProperties": {
123139
"type": "object",
124-
"additionalProperties": { "$ref": "#" },
140+
"additionalProperties": { "$ref": "#/definitions/subschema" },
125141
"propertyNames": { "format": "regex" },
126142
"default": {}
127143
},
128144
"dependencies": {
129145
"type": "object",
130146
"additionalProperties": {
131147
"anyOf": [
132-
{ "$ref": "#" },
148+
{ "$ref": "#/definitions/subschema" },
133149
{ "$ref": "#/definitions/stringArray" }
134150
]
135151
}
136152
},
137-
"propertyNames": { "$ref": "#" },
153+
"propertyNames": { "$ref": "#/definitions/subschema" },
138154
"const": {},
139155
"enum": {
140156
"type": "array",
@@ -155,13 +171,13 @@
155171
"format": { "type": "string" },
156172
"contentMediaType": { "type": "string" },
157173
"contentEncoding": { "type": "string" },
158-
"if": {"$ref": "#"},
159-
"then": {"$ref": "#"},
160-
"else": {"$ref": "#"},
174+
"if": {"$ref": "#/definitions/subschema"},
175+
"then": {"$ref": "#/definitions/subschema"},
176+
"else": {"$ref": "#/definitions/subschema"},
161177
"allOf": { "$ref": "#/definitions/schemaArray" },
162178
"anyOf": { "$ref": "#/definitions/schemaArray" },
163179
"oneOf": { "$ref": "#/definitions/schemaArray" },
164-
"not": { "$ref": "#" }
180+
"not": { "$ref": "#/definitions/subschema" }
165181
},
166182
"default": {}
167183
}

0 commit comments

Comments
 (0)