Skip to content

Commit 0512e51

Browse files
committed
Rearrange meta-schemas to allow "$ref".
This moves the "normal" schema objects into definitions, ensures that no object with "$ref" can validate as a non-reference, and defines both the core/validation an hyper-schemas as either the appropriate regular object or a reference.
1 parent 9d3c5a4 commit 0512e51

File tree

2 files changed

+193
-178
lines changed

2 files changed

+193
-178
lines changed

hyper-schema.json

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -34,73 +34,77 @@
3434
},
3535
"schema": { "$ref": "#" }
3636
}
37-
}
38-
},
39-
"allOf": [
40-
{
41-
"$ref": "http://json-schema.org/draft/schema"
42-
}
43-
],
44-
"properties": {
45-
"additionalItems": {
46-
"anyOf": [
47-
{ "type": "boolean" },
48-
{ "$ref": "#" }
49-
]
50-
},
51-
"additionalProperties": {
52-
"anyOf": [
53-
{ "type": "boolean" },
54-
{ "$ref": "#" }
55-
]
56-
},
57-
"dependencies": {
58-
"additionalProperties": {
59-
"anyOf": [
60-
{ "$ref": "#" },
61-
{ "type": "array" }
62-
]
63-
}
64-
},
65-
"items": {
66-
"anyOf": [
67-
{ "$ref": "#" },
68-
{ "$ref": "#/definitions/schemaArray" }
69-
]
70-
},
71-
"definitions": {
72-
"additionalProperties": { "$ref": "#" }
73-
},
74-
"patternProperties": {
75-
"additionalProperties": { "$ref": "#" }
76-
},
77-
"properties": {
78-
"additionalProperties": { "$ref": "#" }
79-
},
80-
"allOf": { "$ref": "#/definitions/schemaArray" },
81-
"anyOf": { "$ref": "#/definitions/schemaArray" },
82-
"oneOf": { "$ref": "#/definitions/schemaArray" },
83-
"not": { "$ref": "#" },
84-
85-
"base": {
86-
"type": "string"
8737
},
88-
"links": {
89-
"type": "array",
90-
"items": { "$ref": "#/definitions/linkDescription" }
91-
},
92-
"media": {
93-
"type": "object",
38+
"hyperSchemaObject": {
9439
"properties": {
95-
"type": {
96-
"type": "string"
40+
"additionalItems": {
41+
"anyOf": [
42+
{ "type": "boolean" },
43+
{ "$ref": "#" }
44+
]
45+
},
46+
"additionalProperties": {
47+
"anyOf": [
48+
{ "type": "boolean" },
49+
{ "$ref": "#" }
50+
]
51+
},
52+
"dependencies": {
53+
"additionalProperties": {
54+
"anyOf": [
55+
{ "$ref": "#" },
56+
{ "type": "array" }
57+
]
58+
}
59+
},
60+
"items": {
61+
"anyOf": [
62+
{ "$ref": "#" },
63+
{ "$ref": "#/definitions/schemaArray" }
64+
]
9765
},
98-
"binaryEncoding": {
66+
"definitions": {
67+
"additionalProperties": { "$ref": "#" }
68+
},
69+
"patternProperties": {
70+
"additionalProperties": { "$ref": "#" }
71+
},
72+
"properties": {
73+
"additionalProperties": { "$ref": "#" }
74+
},
75+
"allOf": { "$ref": "#/definitions/schemaArray" },
76+
"anyOf": { "$ref": "#/definitions/schemaArray" },
77+
"oneOf": { "$ref": "#/definitions/schemaArray" },
78+
"not": { "$ref": "#" },
79+
80+
"base": {
9981
"type": "string"
82+
},
83+
"links": {
84+
"type": "array",
85+
"items": { "$ref": "#/definitions/linkDescription" }
86+
},
87+
"media": {
88+
"type": "object",
89+
"properties": {
90+
"type": {
91+
"type": "string"
92+
},
93+
"binaryEncoding": {
94+
"type": "string"
95+
}
96+
}
10097
}
10198
}
10299
}
103100
},
101+
"oneOf": [
102+
"allOf": [
103+
{ "$ref": "http://json-schema.org/draft-05/schema#/definitions/schemaObject" },
104+
{ "$ref": "#/definitions/hyperSchemaObject" }
105+
],
106+
{ "$ref": "http://json-schema.org/draft-05/schema#/definitions/jsonReference" }
107+
],
104108
"links": [
105109
{
106110
"rel": "self",

schema.json

Lines changed: 130 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -43,131 +43,142 @@
4343
"type": "array",
4444
"items": { "type": "string" },
4545
"uniqueItems": true
46-
}
47-
},
48-
"type": "object",
49-
"properties": {
50-
"id": {
51-
"type": "string",
52-
"format": "uriref"
53-
},
54-
"$schema": {
55-
"type": "string",
56-
"format": "uri"
57-
},
58-
"title": {
59-
"type": "string"
60-
},
61-
"description": {
62-
"type": "string"
63-
},
64-
"default": {},
65-
"multipleOf": {
66-
"type": "number",
67-
"minimum": 0,
68-
"exclusiveMinimum": true
69-
},
70-
"maximum": {
71-
"type": "number"
72-
},
73-
"exclusiveMaximum": {
74-
"type": "boolean",
75-
"default": false
76-
},
77-
"minimum": {
78-
"type": "number"
79-
},
80-
"exclusiveMinimum": {
81-
"type": "boolean",
82-
"default": false
8346
},
84-
"maxLength": { "$ref": "#/definitions/positiveInteger" },
85-
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
86-
"pattern": {
87-
"type": "string",
88-
"format": "regex"
89-
},
90-
"additionalItems": {
91-
"anyOf": [
92-
{ "type": "boolean" },
93-
{ "$ref": "#" }
94-
],
95-
"default": {}
96-
},
97-
"items": {
98-
"anyOf": [
99-
{ "$ref": "#" },
100-
{ "$ref": "#/definitions/schemaArray" }
101-
],
102-
"default": {}
103-
},
104-
"maxItems": { "$ref": "#/definitions/positiveInteger" },
105-
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
106-
"uniqueItems": {
107-
"type": "boolean",
108-
"default": false
109-
},
110-
"contains": { "$ref": "#" },
111-
"maxProperties": { "$ref": "#/definitions/positiveInteger" },
112-
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
113-
"required": { "$ref": "#/definitions/stringArray" },
114-
"additionalProperties": {
115-
"anyOf": [
116-
{ "type": "boolean" },
117-
{ "$ref": "#" }
118-
],
119-
"default": {}
120-
},
121-
"definitions": {
47+
"schemaObject": {
12248
"type": "object",
123-
"additionalProperties": { "$ref": "#" },
124-
"default": {}
125-
},
126-
"properties": {
127-
"type": "object",
128-
"additionalProperties": { "$ref": "#" },
129-
"default": {}
130-
},
131-
"patternProperties": {
132-
"type": "object",
133-
"additionalProperties": { "$ref": "#" },
134-
"default": {}
135-
},
136-
"dependencies": {
137-
"type": "object",
138-
"additionalProperties": {
139-
"anyOf": [
140-
{ "$ref": "#" },
141-
{ "$ref": "#/definitions/stringArray" }
142-
]
143-
}
144-
},
145-
"const": {},
146-
"enum": {
147-
"type": "array",
148-
"minItems": 1,
149-
"uniqueItems": true
150-
},
151-
"type": {
152-
"anyOf": [
153-
{ "$ref": "#/definitions/simpleTypes" },
154-
{
49+
"properties": {
50+
"id": {
51+
"type": "string",
52+
"format": "uriref"
53+
},
54+
"$schema": {
55+
"type": "string",
56+
"format": "uri"
57+
},
58+
"title": {
59+
"type": "string"
60+
},
61+
"description": {
62+
"type": "string"
63+
},
64+
"default": {},
65+
"multipleOf": {
66+
"type": "number",
67+
"minimum": 0,
68+
"exclusiveMinimum": true
69+
},
70+
"maximum": {
71+
"type": "number"
72+
},
73+
"exclusiveMaximum": {
74+
"type": "boolean",
75+
"default": false
76+
},
77+
"minimum": {
78+
"type": "number"
79+
},
80+
"exclusiveMinimum": {
81+
"type": "boolean",
82+
"default": false
83+
},
84+
"maxLength": { "$ref": "#/definitions/positiveInteger" },
85+
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
86+
"pattern": {
87+
"type": "string",
88+
"format": "regex"
89+
},
90+
"additionalItems": {
91+
"anyOf": [
92+
{ "type": "boolean" },
93+
{ "$ref": "#" }
94+
],
95+
"default": {}
96+
},
97+
"items": {
98+
"anyOf": [
99+
{ "$ref": "#" },
100+
{ "$ref": "#/definitions/schemaArray" }
101+
],
102+
"default": {}
103+
},
104+
"maxItems": { "$ref": "#/definitions/positiveInteger" },
105+
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
106+
"uniqueItems": {
107+
"type": "boolean",
108+
"default": false
109+
},
110+
"contains": { "$ref": "#" },
111+
"maxProperties": { "$ref": "#/definitions/positiveInteger" },
112+
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
113+
"required": { "$ref": "#/definitions/stringArray" },
114+
"additionalProperties": {
115+
"anyOf": [
116+
{ "type": "boolean" },
117+
{ "$ref": "#" }
118+
],
119+
"default": {}
120+
},
121+
"definitions": {
122+
"type": "object",
123+
"additionalProperties": { "$ref": "#" },
124+
"default": {}
125+
},
126+
"properties": {
127+
"type": "object",
128+
"additionalProperties": { "$ref": "#" },
129+
"default": {}
130+
},
131+
"patternProperties": {
132+
"type": "object",
133+
"additionalProperties": { "$ref": "#" },
134+
"default": {}
135+
},
136+
"dependencies": {
137+
"type": "object",
138+
"additionalProperties": {
139+
"anyOf": [
140+
{ "$ref": "#" },
141+
{ "$ref": "#/definitions/stringArray" }
142+
]
143+
}
144+
},
145+
"const": {},
146+
"enum": {
155147
"type": "array",
156-
"items": { "$ref": "#/definitions/simpleTypes" },
157148
"minItems": 1,
158149
"uniqueItems": true
150+
},
151+
"type": {
152+
"anyOf": [
153+
{ "$ref": "#/definitions/simpleTypes" },
154+
{
155+
"type": "array",
156+
"items": { "$ref": "#/definitions/simpleTypes" },
157+
"minItems": 1,
158+
"uniqueItems": true
159+
}
160+
]
161+
},
162+
"format": { "type": "string" },
163+
"allOf": { "$ref": "#/definitions/schemaArray" },
164+
"anyOf": { "$ref": "#/definitions/schemaArray" },
165+
"oneOf": { "$ref": "#/definitions/schemaArray" },
166+
"not": { "$ref": "#" }
167+
},
168+
"dependencies": {
169+
"exclusiveMaximum": [ "maximum" ],
170+
"exclusiveMinimum": [ "minimum" ]
171+
},
172+
"not": {
173+
"properties": {
174+
"$ref": {}
159175
}
160-
]
161-
},
162-
"format": { "type": "string" },
163-
"allOf": { "$ref": "#/definitions/schemaArray" },
164-
"anyOf": { "$ref": "#/definitions/schemaArray" },
165-
"oneOf": { "$ref": "#/definitions/schemaArray" },
166-
"not": { "$ref": "#" }
167-
},
168-
"dependencies": {
169-
"exclusiveMaximum": [ "maximum" ],
170-
"exclusiveMinimum": [ "minimum" ]
176+
}
177+
}
171178
},
179+
"oneOf": [
180+
{ "$ref": "#/definitions/schemaObject" },
181+
{ "$ref": "#/definitions/jsonReference" }
182+
],
172183
"default": {}
173184
}

0 commit comments

Comments
 (0)