Skip to content

Commit 1afc34b

Browse files
committed
Emphasize and clarify annotations
This does not change the intended behavior, but generalizes some points presented as exceptions (e.g. why annotations under "not" are never used), and calls annotations out as a first-class use case in the core specification.
1 parent 3eb883d commit 1afc34b

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

jsonschema-core.xml

+14
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@
137137
</t>
138138
</section>
139139

140+
<section title="Annotation">
141+
<t>
142+
JSON Schema can annotate an instance with information, whenever the instance
143+
validates against the schema object containing the annotation, and all of its
144+
parent schema objects.
145+
</t>
146+
<t>
147+
Detailed annotation behavior, along with a small set of basic annotation
148+
keywords are defined in
149+
<xref target="json-schema-validation">the validation specification</xref>.
150+
</t>
151+
</section>
152+
140153
<section title="Hypermedia and Linking">
141154
<t>
142155
JSON Hyper-Schema describes the hypertext structure of a JSON document.
@@ -1160,6 +1173,7 @@ User-Agent: product-name/5.4.1 so-cool-json-schema/1.0.2 curl/7.43.0
11601173
<t hangText="draft-handrews-json-schema-01">
11611174
<list style="symbols">
11621175
<t>This draft is purely a clarification with no functional changes</t>
1176+
<t>Emphasized annotations as a primary usage of JSON Schema</t>
11631177
<t>Clarified $id by use cases</t>
11641178
<t>Exhaustive schema identification examples</t>
11651179
<t>Replaced "external referencing" with how and when an implementation might know of a schema from another doucment</t>

jsonschema-validation.xml

+18-7
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,22 @@
246246
Additional vocabularies SHOULD make use of this mechanism for applying
247247
their own annotations to instances.
248248
</t>
249-
<section title="Negated Schemas">
249+
<section title="Annotations and Validation Outcomes">
250250
<t>
251-
Annotations in a subschema contained within a "not", at any depth,
252-
including any number of intervening additional "not" subschemas, MUST be
253-
ignored. Similarly, annotations within a failing branch of a "oneOf",
254-
"anyOf", "then", or "else" MUST be ignored.
251+
Annotations are collected whenever an instance is valid against
252+
a schema object, and all of that schema object's parent schemas.
253+
</t>
254+
<t>
255+
In particular, annotations in a subschema contained within a "not",
256+
at any depth, including any number of intervening additional "not"
257+
subschemas, MUST be ignored. If the instance was valid against the
258+
"not" subschema, then by definition it is not valid against the schema
259+
that contains the "not", so the "not" subschema's annotations are not used.
260+
</t>
261+
<t>
262+
Similarly, annotations within a failing branch of a "oneOf", "anyOf",
263+
"then", or "else" MUST be ignored even when the instance successfully
264+
validates against the complete schema document.
255265
</t>
256266
</section>
257267
<section title="Annotations and Short-Circuit Validation">
@@ -1494,8 +1504,9 @@
14941504
<t hangText="draft-handrews-json-schema-validation-01">
14951505
<list style="symbols">
14961506
<t>This draft is purely a clarification with no functional changes</t>
1497-
<t>Restored ommitted "if present" clause for "else" under "if"</t>
1498-
<t>Clarified that when "if" is absent, the results of "then" and "else" are ignored</t>
1507+
<t>Provided the general principle behind ignoring annotations under "not" and similar cases</t>
1508+
<t>Clarified "if"/"then"/"else" validation interactions</t>
1509+
<t>Clarified "if"/"then"/"else" behavior for annotation</t>
14991510
<t>Minor formatting and cross-referencing improvements</t>
15001511
</list>
15011512
</t>

0 commit comments

Comments
 (0)