Skip to content

Commit 2784b50

Browse files
committed
Allow boolean subschemas everywhere.
This is one alternative for issue #101. If accepted, the meta-schema change will come separately after PR #168 is merged.
1 parent f36d132 commit 2784b50

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

jsonschema-core.xml

+27-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
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 document MUST consist of an object, known as the root schema.
193193
</t>
194194
<t>
195195
Properties that are used to describe the instance are called keywords, or schema keywords.
@@ -231,6 +231,31 @@
231231
In this example document, the schema titled "array item" is a subschema,
232232
and the schema titled "root" is the root schema.
233233
</t>
234+
<t>
235+
A subschema MUST be an object or a boolean, where boolean values are equivalent to object schemas as follows:
236+
</t>
237+
<t>
238+
true:
239+
</t>
240+
<figure>
241+
<artwork>
242+
<![CDATA[
243+
{}
244+
]]>
245+
</artwork>
246+
</figure>
247+
<t>
248+
false:
249+
</t>
250+
<figure>
251+
<artwork>
252+
<![CDATA[
253+
{
254+
"not": {}
255+
}
256+
]]>
257+
</artwork>
258+
</figure>
234259
</section>
235260

236261
</section>
@@ -323,7 +348,7 @@
323348
<xref target="RFC3986">RFC3986 Section 5.1</xref> defines how to determine the default base URI of a document.
324349
</t>
325350
<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.
351+
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.
327352
</t>
328353
</section>
329354

jsonschema-validation.xml

+9-13
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 subschema or an array of valid subschemas.
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 subschema.
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 subschema.
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 subschema.
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 subschema.
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 subschema.
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,
@@ -649,7 +645,7 @@
649645
<section title="definitions">
650646
<t>
651647
This keyword's value MUST be an object. Each member value of this object
652-
MUST be a valid JSON Schema.
648+
MUST be a valid subschema.
653649
</t>
654650
<t>
655651
This keyword plays no role in validation per se. Its role is to provide

0 commit comments

Comments
 (0)