Skip to content

Commit

Permalink
Allow boolean subschemas everywhere.
Browse files Browse the repository at this point in the history
This implements issue #101
  • Loading branch information
handrews committed Nov 4, 2016
1 parent 356af3b commit 8ca6faa
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 59 deletions.
36 changes: 15 additions & 21 deletions hyper-schema.json
Expand Up @@ -6,45 +6,35 @@
{"$ref": "http://json-schema.org/draft-04/schema#"}
],
"properties": {
"additionalItems": {
"anyOf": [
{"type": "boolean"},
{"$ref": "#"}
]
},
"additionalProperties": {
"anyOf": [
{"type": "boolean"},
{"$ref": "#"}
]
},
"additionalItems": { "$ref": "#/definitions/subSchema" },
"additionalProperties": { "$ref": "#/definitions/subSchema" },
"dependencies": {
"additionalProperties": {
"anyOf": [
{"$ref": "#"},
{"$ref": "#/definitions/subSchema"},
{"type": "array"}
]
}
},
"items": {
"anyOf": [
{"$ref": "#"},
{"$ref": "#/definitions/subSchema"},
{"$ref": "#/definitions/schemaArray"}
]
},
"definitions": {
"additionalProperties": {"$ref": "#"}
"additionalProperties": {"$ref": "#/definitions/subSchema"}
},
"patternProperties": {
"additionalProperties": {"$ref": "#"}
"additionalProperties": {"$ref": "#/definitions/subSchema"}
},
"properties": {
"additionalProperties": {"$ref": "#"}
"additionalProperties": {"$ref": "#/definitions/subSchema"}
},
"allOf": {"$ref": "#/definitions/schemaArray"},
"anyOf": {"$ref": "#/definitions/schemaArray"},
"oneOf": {"$ref": "#/definitions/schemaArray"},
"not": { "$ref": "#" },
"not": { "$ref": "#/definitions/subSchema" },

"links": {
"type": "array",
Expand Down Expand Up @@ -73,9 +63,13 @@
}
},
"definitions": {
"subSchema": {
"anyOf": [ {"$ref": "#"}, {"type": "boolean"} ],
"default": true
},
"schemaArray": {
"type": "array",
"items": {"$ref": "#"}
"items": {"$ref": "#/definitions/subSchema"}
},
"linkDescription": {
"title": "Link Description Object",
Expand All @@ -96,7 +90,7 @@
},
"targetSchema": {
"description": "JSON Schema describing the link target",
"$ref": "#"
"$ref": "#/definitions/subschema"
},
"mediaType": {
"description": "media type (as defined by RFC 2046) describing the link target",
Expand All @@ -113,7 +107,7 @@
},
"schema": {
"description": "Schema describing the data to submit along with the request",
"$ref": "#"
"$ref": "/definitions/subschema#"
}
}
}
Expand Down
29 changes: 27 additions & 2 deletions jsonschema-core.xml
Expand Up @@ -187,7 +187,7 @@
<t>
A JSON Schema document, or simply a schema, is a JSON document used to describe an instance.
A schema is itself interperted as an instance.
A JSON schema MUST be an object.
A JSON Schema document MUST consist of an object, known as the root schema.
</t>
<t>
Properties that are used to describe the instance are called keywords, or schema keywords.
Expand Down Expand Up @@ -229,6 +229,31 @@
In this example document, the schema titled "array item" is a subschema,
and the schema titled "root" is the root schema.
</t>
<t>
A subschema MUST be an object or a boolean, where boolean values are equivalent to object schemas as follows:
</t>
<t>
true:
</t>
<figure>
<artwork>
<![CDATA[
{}
]]>
</artwork>
</figure>
<t>
false:
</t>
<figure>
<artwork>
<![CDATA[
{
"not": {}
}
]]>
</artwork>
</figure>
</section>

</section>
Expand Down Expand Up @@ -321,7 +346,7 @@
<xref target="RFC3986">RFC3986 Section 5.1</xref> defines how to determine the default base URI of a document.
</t>
<t>
Informatively, the initial base URI of a schema is the URI it was found at, or a suitable substitute URI if none is known.
Informatively, the initial base URI of a schema is the URI at which it was found, or a suitable substitute URI if none is known.
</t>
</section>

Expand Down
22 changes: 9 additions & 13 deletions jsonschema-validation.xml
Expand Up @@ -313,8 +313,7 @@

<section title="items">
<t>
The value of "items" MUST be either an object or an array of objects.
Each object MUST be a valid JSON Schema.
The value of "items" MUST be either a valid subschema or an array of valid subschemas.
</t>
<t>
If absent, it can be considered present with an empty schema.
Expand All @@ -336,8 +335,7 @@

<section title="additionalItems">
<t>
The value of "additionalItems" MUST be a boolean or an object.
If it is an object, the object MUST be a valid JSON Schema.
The value of "additionalItems" MUST be a valid subschema.
</t>
<t>
If absent, it can be considered present with an empty schema.
Expand Down Expand Up @@ -437,7 +435,7 @@
<section title="properties">
<t>
The value of "properties" MUST be an object. Each value of this object
MUST be an object, and each object MUST be a valid JSON Schema.
MUST be a valid subschema.
</t>
<t>
If absent, it can be considered the same as an empty object.
Expand All @@ -458,7 +456,7 @@
The value of "patternProperties" MUST be an object. Each property name
of this object SHOULD be a valid regular expression, according to the
ECMA 262 regular expression dialect. Each property value of this object
MUST be an object, and each object MUST be a valid JSON Schema.
MUST be a valid subschema.
</t>
<t>
If absent, it can be considered the same as an empty object.
Expand All @@ -477,8 +475,7 @@

<section title="additionalProperties">
<t>
The value of "additionalProperties" MUST be a boolean or an
object. If it is an object, the object MUST be a valid JSON Schema.
The value of "additionalProperties" MUST be a valid subschema.
</t>
<t>
If "additionalProperties" is absent, it may be considered present with
Expand Down Expand Up @@ -506,12 +503,11 @@
</t>
<t>
This keyword's value MUST be an object. Each property specifies a dependency.
Each dependency value MUST be an object or an array.
Each dependency value MUST be an array or a valid subschema.
</t>
<t>
If the dependency value is an object, it MUST be a valid JSON Schema. If the
dependency key is a property in the instance, the dependency value must validate
against the entire instance.
If the dependency value is a subschema, and the dependency key is a property
in the instance, the entire instance must validate against the dependency value.
</t>
<t>
If the dependency value is an array, it MUST have at least one element, each
Expand Down Expand Up @@ -610,7 +606,7 @@
<section title="definitions">
<t>
This keyword's value MUST be an object. Each member value of this object
MUST be a valid JSON Schema.
MUST be a valid subschema.
</t>
<t>
This keyword plays no role in validation per se. Its role is to provide
Expand Down
37 changes: 14 additions & 23 deletions schema.json
Expand Up @@ -3,10 +3,14 @@
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Core schema meta-schema",
"definitions": {
"subSchema": {
"anyOf": [ {"$ref": "#"}, {"type": "boolean"} ],
"default": true
},
"schemaArray": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#" }
"items": { "$ref": "#/definitions/subSchema" }
},
"positiveInteger": {
"type": "integer",
Expand Down Expand Up @@ -67,19 +71,12 @@
"type": "string",
"format": "regex"
},
"additionalItems": {
"anyOf": [
{ "type": "boolean" },
{ "$ref": "#" }
],
"default": {}
},
"additionalItems": { "$ref": "#/definitions/subSchema" },
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/subSchema" },
{ "$ref": "#/definitions/schemaArray" }
],
"default": {}
]
},
"maxItems": { "$ref": "#/definitions/positiveInteger" },
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
Expand All @@ -90,33 +87,27 @@
"maxProperties": { "$ref": "#/definitions/positiveInteger" },
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
"required": { "$ref": "#/definitions/stringArray" },
"additionalProperties": {
"anyOf": [
{ "type": "boolean" },
{ "$ref": "#" }
],
"default": {}
},
"additionalProperties": { "$ref": "#/definitions/subSchema" },
"definitions": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"additionalProperties": { "$ref": "#/definitions/subSchema" },
"default": {}
},
"properties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"additionalProperties": { "$ref": "#/definitions/subSchema" },
"default": {}
},
"patternProperties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"additionalProperties": { "$ref": "#/definitions/subSchema" },
"default": {}
},
"dependencies": {
"type": "object",
"additionalProperties": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/subSchema" },
{ "$ref": "#/definitions/stringArray" }
]
}
Expand All @@ -141,7 +132,7 @@
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" }
"not": { "$ref": "#/definitions/subSchema" }
},
"dependencies": {
"exclusiveMaximum": [ "maximum" ],
Expand Down

0 comments on commit 8ca6faa

Please sign in to comment.