Skip to content

Commit 3e879a8

Browse files
committed
Expand the Overview section to put some context to vocabularies
1 parent d962a20 commit 3e879a8

File tree

1 file changed

+58
-5
lines changed

1 file changed

+58
-5
lines changed

jsonschema-core.xml

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,66 @@
136136
data in several ways.
137137
</t>
138138
<t>
139-
JSON Schema uses keywords to assert constraints on JSON instances or annotate those
140-
instances with additional information. Additional keywords are used to apply
141-
assertions and annotations to more complex JSON data structures, or based on
142-
some sort of condition.
139+
A JSON Schema document is comprised of a set of keywords,
140+
which are specified as properties in a JSON object.
141+
The name of the keyword is used as the property name,
142+
and any arguments to the keyword are provided as the value.
143+
Keywords can be classified by their functions.
144+
The most important classes are assertion, annotation, and applicator keywords.
143145
</t>
144146
<t>
145-
To facilitate re-use, keywords can be organized into vocabularies. A vocabulary
147+
"Assertion keywords" form the basis of JSON Schema.
148+
Given a schema and an instance, the instance is "valid" if all of the keywords in
149+
the schema are valid against the instance.
150+
Assertion keywords may be used to describe a set of JSON documents.
151+
Without any assertion keywords, the set of all valid instances is the set of all valid JSON documents.
152+
Typically, adding assertion keywords reduces the set of valid JSON documents.
153+
Keywords are defined to not be redundant with other keywords:
154+
For example, the "minimum" keyword only shrinks the valid set of numbers, but not strings or other
155+
types&#x2014;this is what the "type" keyword does.
156+
</t>
157+
<t>
158+
When an instance validates against a schema, "annotation keywords" may provide "annotations":
159+
metadata that describes the instance.
160+
For example, you can document the meaning of a property,
161+
suggest a default value for new instances,
162+
generate a list of hyperlinks from the instance,
163+
or declare relationships between data.
164+
</t>
165+
<t>
166+
"Applicator keywords" are keywords that accept sub-schemas as part of their argument,
167+
which are validated against the instance in some fashion.
168+
Applicator keywords may use or modify the validation result of their sub-schemas,
169+
for example, to be valid conditional on which sub-schemas are valid
170+
(e.g. the "if", "then", "oneOf", or "anyOf" keywords).
171+
They may also validate a schema against values within the instance,
172+
for example, a specific property within the object (the "properties" keyword).
173+
The "$ref" keyword is a special applicator keyword that takes a reference to a schema,
174+
instead of a literal schema. This allows schemas to be defined recursively.
175+
</t>
176+
<t>
177+
Applicator keywords typically also return the annotations from their valid schemas.
178+
Since only annotations from valid schemas can be returned,
179+
applicator keywords may be used to specify annotations that conditionally appear,
180+
depending on the validation result of other keywords.
181+
</t>
182+
<t>
183+
Since keywords are listed in an object by their name,
184+
they may be used at most once per schema and sub-schema.
185+
However, the effect of multiple keywords may be achieved by listing each keyword in its own sub-schema,
186+
inside an applicator keyword designed for this purpose, such as the "allOf" keyword.
187+
Additionally, many keywords can often be reduced to a single keyword;
188+
for example, when using "minimum", only the highest value of many will be effective.
189+
As a short form, the booleans true/false represent a schema that's always valid/invalid, respectively.
190+
</t>
191+
<t>
192+
JSON Schema documents can themselves be described by a schema.
193+
In this context, this "schema of the schema" is called the meta-schema.
194+
In addition to a core vocabulary and a default validation vocabulary,
195+
JSON Schema supports some amount of customization by providing a custom meta-schema.
196+
</t>
197+
<t>
198+
To facilitate re-use, the meta-schema organizes keywords into vocabularies. A vocabulary
146199
consists of a list of keywords, together with their syntax and semantics.
147200
A dialect is defined as a set of vocabularies and their required support
148201
identified in a meta-schema.

0 commit comments

Comments
 (0)