Skip to content

Commit b797a57

Browse files
committed
Expand the Overview section to put some context to vocabularies
1 parent 86d5739 commit b797a57

File tree

1 file changed

+59
-6
lines changed

1 file changed

+59
-6
lines changed

jsonschema-core.xml

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
</address>
5252
</author>
5353

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

0 commit comments

Comments
 (0)