|
51 | 51 | </address>
|
52 | 52 | </author>
|
53 | 53 |
|
54 |
| - <date year="2021"/> |
| 54 | + <date year="2022"/> |
55 | 55 | <workgroup>Internet Engineering Task Force</workgroup>
|
56 | 56 | <keyword>JSON</keyword>
|
57 | 57 | <keyword>Schema</keyword>
|
|
134 | 134 | data in several ways.
|
135 | 135 | </t>
|
136 | 136 | <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 | + Keywords can be classified by their functions. |
| 142 | + The most important classes are validation, annotation, and applicator keywords. |
141 | 143 | </t>
|
142 | 144 | <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—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 |
144 | 197 | consists of a list of keywords, together with their syntax and semantics.
|
145 | 198 | A dialect is defined as a set of vocabularies and their required support
|
146 | 199 | identified in a meta-schema.
|
|
0 commit comments