|
1135 | 1135 | </section>
|
1136 | 1136 |
|
1137 | 1137 | <section title="Schema annotations and extension vocabularies">
|
| 1138 | + <t> |
| 1139 | + Schema validation is a useful mechanism for annotating instance data |
| 1140 | + with additional information. This section describes the rules for |
| 1141 | + determining when and how annotations apply to an instance, and specifies |
| 1142 | + a small general-purpose annotation vocabulary. |
| 1143 | + </t> |
| 1144 | + <t> |
| 1145 | + Additional vocabularies SHOULD make use of this mechanism for applying |
| 1146 | + their keywords to instances. |
| 1147 | + </t> |
| 1148 | + <section title="Applicability and attachment"> |
| 1149 | + <t> |
| 1150 | + Annotations can be applied to an instance when it is valid against |
| 1151 | + the schema that includes the annotation keywords. For any given location |
| 1152 | + in the instance (referred to as a sub-instance), each (sub)schema against |
| 1153 | + which it successfully validates is considered to be <spanx>applicable</spanx> |
| 1154 | + to that sub-instance. The (sub)schema is said to be <spanx>attached</spanx> |
| 1155 | + to each sub-instance to which it applies. |
| 1156 | + </t> |
| 1157 | + <t> |
| 1158 | + A validation implementation MAY choose to implement determining subschema |
| 1159 | + applicability and providing access to the value(s) of applicable annotation |
| 1160 | + keywords. Implementation of this feature MAY instead be done separately. |
| 1161 | + </t> |
| 1162 | + <t> |
| 1163 | + Since many subschemas can be applicable to any single sub-isntance, each |
| 1164 | + annotation keyword or vocabulary needs to specify how to handle multiple |
| 1165 | + occurrences with different values. In the absence of keyword-specific |
| 1166 | + handling rules, an implementation MUST collect all values and make them |
| 1167 | + available as a data structure in which order is not significant and items |
| 1168 | + need not be unique. |
| 1169 | + </t> |
| 1170 | + <section title="Combinatoric and conditional schemas"> |
| 1171 | + <t> |
| 1172 | + Annotations in branches of an "anyOf", "oneOf", or "if"/"then"/"else" |
| 1173 | + that do not validate, or in a "dependencies" subschema that is not relevant |
| 1174 | + to the instance, MUST be ignored. |
| 1175 | + </t> |
| 1176 | + <t> |
| 1177 | + Annotations in a subschema contained within a "not", at any depth, |
| 1178 | + including any number of intervening additional "not" subschemas, MUST be |
| 1179 | + ignored. |
| 1180 | + </t> |
| 1181 | + </section> |
| 1182 | + <section title="Annotations and short-circuit validation"> |
| 1183 | + <t> |
| 1184 | + Schema keywords MUST be applied to all possible sub-instances when |
| 1185 | + considering annotations, even if such application can be short-circuited |
| 1186 | + when only the overall validation result is needed. |
| 1187 | + </t> |
| 1188 | + <t> |
| 1189 | + An example of this is the "contains" keyword, which need only be evaluated |
| 1190 | + against array elements until it produces at least one successful outcome |
| 1191 | + in order to be implemented. However, when annotations are considered, |
| 1192 | + it must be checked against every array element, and the annotations MUST |
| 1193 | + be applied to every element that successfully validates against the |
| 1194 | + "contains" susbschema. |
| 1195 | + </t> |
| 1196 | + </section> |
| 1197 | + </section> |
1138 | 1198 |
|
1139 | 1199 | <section title='"title" and "description"'>
|
1140 | 1200 | <t>
|
|
0 commit comments