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

Commit 98a5e0a

Browse files
committed
Add a glossary entry for subschema.
1 parent 9b0683d commit 98a5e0a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

learn/glossary.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,23 @@ Strictly speaking, according to the specification, schemas are themselves JSON d
8383

8484
In recent [drafts](#draft) of the specification, a schema is either a JSON object or a JSON boolean value.
8585

86+
### subschema
87+
88+
A [schema](#schema) which is itself contained within a surrounding parent schema.
89+
Like schemas themselves, in recent [drafts](#draft) of JSON Schema, subschemas are either JSON objects or JSON boolean values.
90+
91+
Within the JSON Schema specification and its [dialects](#dialect), a number of [keywords](#keyword) take subschemas as part of their values.
92+
For example, the `not` keyword takes a subschema value and inverts its result, succeeding whenever the subschema does not succeed, such that the [instance](#instance) `12` is invalid under `{"type": "string"}` but valid under `{"not": {"type": "string"}}`, where `{"type": "string"}` is a subschema contained in the full schema.
93+
94+
Some subschema may appear in more complex nested locations within a parent schema.
95+
The `allOf` keyword, for instance, takes an array of multiple subschemas and succeeds whenever all of the subschemas do individually.
96+
97+
Whether something that otherwise *appears* to be a schema (based on its contents) actually *is* a subschema can be misleading at first glance without context or knowlege about its location within the parent schema.
98+
Specifically, in our above example, `{"type": "string"}` was a subschema of a larger schema, but in the schema `{"enum": {"type": "string"}}` is *not* a subschema, as though it appears to itself look just like the previous subschema, the `enum` keyword does not in fact take a subschema as its value, it instead simply compares its value as an opaque value with no particular meaning, such that the aforementioned schema succeeds when given the *instance* `{"type": "string"}` but fails when given the instance 12.
99+
Said more plainly, whether a particular value is a subschema or not depends on its precise location within a parent schema, as interpretation of the value depends on the defined behavior of the keyword(s) it lives under.
100+
101+
Subschemas may themselves contain sub-subschemas, though colloquially one generally uses the term "subschema" regardless of the level of nesting, further clarifying which larger schema is the parent schema whenever needed.
102+
86103
### vocabulary
87104

88105
A tightly related collection of [keywords](keyword), grouped to facilitate re-use.

0 commit comments

Comments
 (0)