Skip to content

Commit e848101

Browse files
committed
Move applicability/attachement information.
Generalize this and move it into validation, updating the hyper-schema spec to reference it.
1 parent 4803441 commit e848101

File tree

2 files changed

+71
-26
lines changed

2 files changed

+71
-26
lines changed

jsonschema-hyperschema.xml

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -175,32 +175,6 @@
175175
relations for the instance, with URIs incorporating values from the instance.
176176
</postamble>
177177
</figure>
178-
179-
<section title="Interaction with validation">
180-
<t>
181-
Hyper-schema keywords can be applied when the instance is valid against
182-
the schema that includes those keywords.
183-
</t>
184-
<t>
185-
Hyper-schemas MUST NOT be applied to an instance if the instance fails to
186-
validate against the validation keywords within or containing the hyper-schema.
187-
Hyper-schema keywords in branches of an "anyOf", "oneOf", or "if"/"then"/"else"
188-
that do not validate, or in a "dependencies" subschema that is not relevant
189-
to the instance, MUST be ignored.
190-
</t>
191-
<t>
192-
Hyper-schema keywords in a subschema contained within a "not", at any depth,
193-
including any number of intervening additional "not" subschemas, MUST be
194-
ignored.
195-
</t>
196-
<t>
197-
If the subschema for a "contains" keyword contains hyper-schema keywords they
198-
MUST be applied to all array elements that validate against the schema. While
199-
finding a single validating element is sufficient to determine the validation
200-
outcome, when hyper-schema keywords are present, the subschema MUST be evaluated
201-
against all array elements.
202-
</t>
203-
</section>
204178
</section>
205179

206180
<section title="Meta-schema">
@@ -211,6 +185,17 @@
211185
</section>
212186

213187
<section title="Schema keywords">
188+
<t>
189+
Hyper-schema keywords can be applied when the instance is valid against
190+
the schema that includes those keywords, as outlined in
191+
<xref target="json-schema-validation">Section 10.1 of JSON Schema validation</xref>.
192+
</t>
193+
<t>
194+
When multiple subschemas are applicable to a given sub-instance, all "link"
195+
arrays MUST be concatenated, in any order, into a single array. Each object
196+
in the resulting array MUST retain its own list of applicable "base" values,
197+
in resolution order, from the same schema and any parent schemas.
198+
</t>
214199
<section title="base">
215200
<t>
216201
If present, this keyword is resolved against the current URI base that the

jsonschema-validation.xml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,66 @@
11351135
</section>
11361136

11371137
<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>
11381198

11391199
<section title='"title" and "description"'>
11401200
<t>

0 commit comments

Comments
 (0)