Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.

Commit 3e5d8e4

Browse files
committed
Allow references wherever a schema is allowed.
This is the final change for Draft 05. The main definitions for both core/validation and hyper-schema are moved into the "definitions" section. In both meta-schemas, the root schemas are now a "oneOf" of either a JSON reference, or (for core/validation) the regular schema object or (for hyper-schema) both the regular schema object and the hyper-schema object. The regular core/validation schema object forbids any "$ref" property, ensuring that both sides of the "oneOf" are never matched at the same time. This ensures that any schema with a "$ref" that is a string validates as a JSON reference and not as a regular schema (as additional properties within a JSON reference are legal but MUST be ignored). Note that an object with a non-string "$ref" will not validate at all.
1 parent beeae19 commit 3e5d8e4

File tree

2 files changed

+195
-180
lines changed

2 files changed

+195
-180
lines changed

draft-05/hyper-schema

Lines changed: 67 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -34,77 +34,81 @@
3434
},
3535
"schema": { "$ref": "#" }
3636
}
37-
}
38-
},
39-
"allOf": [
40-
{
41-
"$ref": "http://json-schema.org/draft-05/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"
87-
},
88-
"links": {
89-
"type": "array",
90-
"items": { "$ref": "#/definitions/linkDescription" }
91-
},
92-
"readOnly": {
93-
"type": "boolean",
94-
"default": false
9537
},
96-
"media": {
97-
"type": "object",
38+
"hyperSchemaObject": {
9839
"properties": {
99-
"type": {
100-
"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+
]
65+
},
66+
"definitions": {
67+
"additionalProperties": { "$ref": "#" }
10168
},
102-
"binaryEncoding": {
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": {
10381
"type": "string"
82+
},
83+
"links": {
84+
"type": "array",
85+
"items": { "$ref": "#/definitions/linkDescription" }
86+
},
87+
"readOnly": {
88+
"type": "boolean",
89+
"default": false
90+
},
91+
"media": {
92+
"type": "object",
93+
"properties": {
94+
"type": {
95+
"type": "string"
96+
},
97+
"binaryEncoding": {
98+
"type": "string"
99+
}
100+
}
104101
}
105102
}
106103
}
107104
},
105+
"oneOf": [
106+
"allOf": [
107+
{ "$ref": "http://json-schema.org/draft-05/schema#/definitions/schemaObject" },
108+
{ "$ref": "#/definitions/hyperSchemaObject" }
109+
],
110+
{ "$ref": "http://json-schema.org/draft-05/schema#/definitions/jsonReference" }
111+
],
108112
"links": [
109113
{
110114
"rel": "self",

0 commit comments

Comments
 (0)