Skip to content

Commit ea2484c

Browse files
committed
Add "$ref" for subschemas.
This is the same approach used in the PR for Draft 05 meta-schemas in the web site repo.
1 parent d7739d3 commit ea2484c

File tree

2 files changed

+58
-20
lines changed

2 files changed

+58
-20
lines changed

hyper-schema.json

+23-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"allOf": [
88
{ "$ref": "http://json-schema.org/drafts/schema" },
99
{
10-
"items": { "$ref": "#" }
10+
"items": { "$ref": "#/definitions/subSchema" }
1111
}
1212
]
1313
},
@@ -30,7 +30,7 @@
3030
},
3131
"targetSchema": {
3232
"description": "JSON Schema describing the link target",
33-
"allOf": [ { "$ref": "#" } ]
33+
"allOf": [ { "$ref": "#/definitions/subSchema" } ]
3434
},
3535
"mediaType": {
3636
"description": "media type (as defined by RFC 2046) describing the link target",
@@ -47,52 +47,64 @@
4747
},
4848
"schema": {
4949
"description": "Schema describing the data to submit along with the request",
50-
"allOf": [ { "$ref": "#" } ]
50+
"allOf": [ { "$ref": "#/definitions/subSchema" } ]
5151
}
5252
}
53+
},
54+
"subSchema": {
55+
"oneOf": [
56+
{
57+
"allOf": [
58+
{ "$ref": "#" },
59+
{ "$ref": "http://json-schema.org/draft/schema#/definitions/notJsonReference" }
60+
]
61+
},
62+
{ "$ref": "http://json-schema.org/draft/schema#/definitions/jsonReference" }
63+
]
5364
}
5465
},
66+
5567
"allOf": [ { "$ref": "http://json-schema.org/draft/schema#" } ],
5668
"properties": {
5769
"additionalItems": {
5870
"anyOf": [
5971
{ "type": "boolean" },
60-
{ "$ref": "#" }
72+
{ "$ref": "#/definitions/subSchema" }
6173
]
6274
},
6375
"additionalProperties": {
6476
"anyOf": [
6577
{ "type": "boolean" },
66-
{ "$ref": "#" }
78+
{ "$ref": "#/definitions/subSchema" }
6779
]
6880
},
6981
"dependencies": {
7082
"additionalProperties": {
7183
"anyOf": [
72-
{ "$ref": "#" },
84+
{ "$ref": "#/definitions/subSchema" },
7385
{ "type": "array" }
7486
]
7587
}
7688
},
7789
"items": {
7890
"anyOf": [
79-
{ "$ref": "#" },
91+
{ "$ref": "#/definitions/subSchema" },
8092
{ "$ref": "#/definitions/schemaArray" }
8193
]
8294
},
8395
"definitions": {
84-
"additionalProperties": { "$ref": "#" }
96+
"additionalProperties": { "$ref": "#/definitions/subSchema" }
8597
},
8698
"patternProperties": {
87-
"additionalProperties": { "$ref": "#" }
99+
"additionalProperties": { "$ref": "#/definitions/subSchema" }
88100
},
89101
"properties": {
90-
"additionalProperties": { "$ref": "#" }
102+
"additionalProperties": { "$ref": "#/definitions/subSchema" }
91103
},
92104
"allOf": { "$ref": "#/definitions/schemaArray" },
93105
"anyOf": { "$ref": "#/definitions/schemaArray" },
94106
"oneOf": { "$ref": "#/definitions/schemaArray" },
95-
"not": { "$ref": "#" },
107+
"not": { "$ref": "#/definitions/subSchema" },
96108

97109
"base": {
98110
"description": "URI Template resolved as for the 'href' keyword in the Link Description Object. The resulting URI Reference is resolved against the current URI base and sets the new URI base for URI references within the instance.",

schema.json

+35-9
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,25 @@
33
"id": "http://json-schema.org/draft/schema#",
44
"title": "Core schema meta-schema",
55
"definitions": {
6+
"jsonReferece": {
7+
"type": "object",
8+
"properties": {
9+
"$ref": {
10+
"type": "string",
11+
"format": "uriref"
12+
}
13+
},
14+
"required": [ "$ref" ]
15+
},
16+
"notJsonReference": {
17+
"not": {
18+
"required": [ "$ref" ]
19+
}
20+
},
621
"schemaArray": {
722
"type": "array",
823
"minItems": 1,
9-
"items": { "$ref": "#" }
24+
"items": { "$ref": "#/definitions/subSchema" }
1025
},
1126
"positiveInteger": {
1227
"type": "integer",
@@ -33,6 +48,17 @@
3348
"type": "array",
3449
"items": { "type": "string" },
3550
"uniqueItems": true
51+
},
52+
"subSchema": {
53+
"oneOf": [
54+
{
55+
"allOf": [
56+
{ "$ref": "#" },
57+
{ "$ref": "#/definitions/notJsonReference" }
58+
]
59+
},
60+
{ "$ref": "#/definitions/jsonReference" }
61+
]
3662
}
3763
},
3864
"type": "object",
@@ -80,13 +106,13 @@
80106
"additionalItems": {
81107
"anyOf": [
82108
{ "type": "boolean" },
83-
{ "$ref": "#" }
109+
{ "$ref": "#/definitions/subSchema" }
84110
],
85111
"default": {}
86112
},
87113
"items": {
88114
"anyOf": [
89-
{ "$ref": "#" },
115+
{ "$ref": "#/definitions/subSchema" },
90116
{ "$ref": "#/definitions/schemaArray" }
91117
],
92118
"default": {}
@@ -104,30 +130,30 @@
104130
"additionalProperties": {
105131
"anyOf": [
106132
{ "type": "boolean" },
107-
{ "$ref": "#" }
133+
{ "$ref": "#/definitions/subSchema" }
108134
],
109135
"default": {}
110136
},
111137
"definitions": {
112138
"type": "object",
113-
"additionalProperties": { "$ref": "#" },
139+
"additionalProperties": { "$ref": "#/definitions/subSchema" },
114140
"default": {}
115141
},
116142
"properties": {
117143
"type": "object",
118-
"additionalProperties": { "$ref": "#" },
144+
"additionalProperties": { "$ref": "#/definitions/subSchema" },
119145
"default": {}
120146
},
121147
"patternProperties": {
122148
"type": "object",
123-
"additionalProperties": { "$ref": "#" },
149+
"additionalProperties": { "$ref": "#/definitions/subSchema" },
124150
"default": {}
125151
},
126152
"dependencies": {
127153
"type": "object",
128154
"additionalProperties": {
129155
"anyOf": [
130-
{ "$ref": "#" },
156+
{ "$ref": "#/definitions/subSchema" },
131157
{ "$ref": "#/definitions/stringArray" }
132158
]
133159
}
@@ -153,7 +179,7 @@
153179
"allOf": { "$ref": "#/definitions/schemaArray" },
154180
"anyOf": { "$ref": "#/definitions/schemaArray" },
155181
"oneOf": { "$ref": "#/definitions/schemaArray" },
156-
"not": { "$ref": "#" }
182+
"not": { "$ref": "#/definitions/subSchema" }
157183
},
158184
"dependencies": {
159185
"exclusiveMaximum": [ "maximum" ],

0 commit comments

Comments
 (0)