Skip to content

Commit 15ad0ed

Browse files
authored
Merge pull request #167 from handrews/bool2
Allow boolean schemas everywhere (root and subschemas)
2 parents e38d074 + 2501650 commit 15ad0ed

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

jsonschema-core.xml

+19-5
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,18 @@
185185
</t>
186186
</section>
187187

188-
<section title="JSON Schema document">
188+
<section title="JSON Schema documents">
189189
<t>
190190
A JSON Schema document, or simply a schema, is a JSON document used to describe an instance.
191191
A schema is itself interpreted as an instance.
192-
A JSON schema MUST be an object.
192+
A JSON Schema MUST be an object or a boolean.
193+
</t>
194+
<t>
195+
Boolean values are equivalent to the following behaviors:
196+
<list style="hanging">
197+
<t hangText="true">Always passes validation, as if the empty schema {}</t>
198+
<t hangText="false">Always fails validation, as if the schema { "not":{} }</t>
199+
</list>
193200
</t>
194201
<t>
195202
Properties that are used to describe the instance are called keywords, or schema keywords.
@@ -231,6 +238,9 @@
231238
In this example document, the schema titled "array item" is a subschema,
232239
and the schema titled "root" is the root schema.
233240
</t>
241+
<t>
242+
As with the root schema, a subschema is either an object or a boolean.
243+
</t>
234244
</section>
235245

236246
</section>
@@ -299,8 +309,11 @@
299309

300310
<section title="Schema references with $ref">
301311
<t>
302-
Any time a subschema is expected, a schema may instead use an object containing a "$ref" property.
303-
The value of the $ref is a URI Reference.
312+
The "$ref" keyword is used to reference a schema, and provides the ability to validate recursive structures through self-reference.
313+
</t>
314+
<t>
315+
An object schema with a "$ref" property MUST be interpreted as a "$ref" reference.
316+
The value of the "$ref" property MUST be a URI Reference.
304317
Resolved against the current URI base, it identifies the URI of a schema to use.
305318
All other properties in a "$ref" object MUST be ignored.
306319
</t>
@@ -323,7 +336,7 @@
323336
<xref target="RFC3986">RFC3986 Section 5.1</xref> defines how to determine the default base URI of a document.
324337
</t>
325338
<t>
326-
Informatively, the initial base URI of a schema is the URI it was found at, or a suitable substitute URI if none is known.
339+
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.
327340
</t>
328341
</section>
329342

@@ -660,6 +673,7 @@ User-Agent: so-cool-json-schema/1.0.2 curl/7.43.0
660673
<t hangText="draft-wright-json-schema-01">
661674
<list style="symbols">
662675
<t>Updated intro</t>
676+
<t>Allowed for any schema to be a boolean</t>
663677
</list>
664678
</t>
665679
<t hangText="draft-wright-json-schema-00">

jsonschema-validation.xml

+8-12
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,7 @@
327327

328328
<section title="items">
329329
<t>
330-
The value of "items" MUST be either an object or an array of objects.
331-
Each object MUST be a valid JSON Schema.
330+
The value of "items" MUST be either a valid JSON Schema or an array of valid JSON Schemas.
332331
</t>
333332
<t>
334333
If absent, it can be considered present with an empty schema.
@@ -350,8 +349,7 @@
350349

351350
<section title="additionalItems">
352351
<t>
353-
The value of "additionalItems" MUST be a boolean or an object.
354-
If it is an object, the object MUST be a valid JSON Schema.
352+
The value of "additionalItems" MUST be a valid JSON Schema.
355353
</t>
356354
<t>
357355
If absent, it can be considered present with an empty schema.
@@ -466,7 +464,7 @@
466464
<section title="properties">
467465
<t>
468466
The value of "properties" MUST be an object. Each value of this object
469-
MUST be an object, and each object MUST be a valid JSON Schema.
467+
MUST be a valid JSON Schema.
470468
</t>
471469
<t>
472470
If absent, it can be considered the same as an empty object.
@@ -487,7 +485,7 @@
487485
The value of "patternProperties" MUST be an object. Each property name
488486
of this object SHOULD be a valid regular expression, according to the
489487
ECMA 262 regular expression dialect. Each property value of this object
490-
MUST be an object, and each object MUST be a valid JSON Schema.
488+
MUST be a valid JSON Schema.
491489
</t>
492490
<t>
493491
If absent, it can be considered the same as an empty object.
@@ -506,8 +504,7 @@
506504

507505
<section title="additionalProperties">
508506
<t>
509-
The value of "additionalProperties" MUST be a boolean or an
510-
object. If it is an object, the object MUST be a valid JSON Schema.
507+
The value of "additionalProperties" MUST be a valid JSON Schema.
511508
</t>
512509
<t>
513510
If "additionalProperties" is absent, it may be considered present with
@@ -535,12 +532,11 @@
535532
</t>
536533
<t>
537534
This keyword's value MUST be an object. Each property specifies a dependency.
538-
Each dependency value MUST be an object or an array.
535+
Each dependency value MUST be an array or a valid JSON Schema.
539536
</t>
540537
<t>
541-
If the dependency value is an object, it MUST be a valid JSON Schema. If the
542-
dependency key is a property in the instance, the dependency value must validate
543-
against the entire instance.
538+
If the dependency value is a subschema, and the dependency key is a property
539+
in the instance, the entire instance must validate against the dependency value.
544540
</t>
545541
<t>
546542
If the dependency value is an array, each element in the array,

0 commit comments

Comments
 (0)