Skip to content

Commit b0c208b

Browse files
committed
Default behaviors; annotation-dependent results
Describe how default behaviors work in more detail, covering all three major keyword categories. Allow keywords to depend on the presence or absence of adjacent keywords (this is already true with "additionalItems" and "items'). Allow keywords to depend on the annotation results of subschemas and adjacent keywords. This is the fundamental mechanism behind the forthcoming "unevaluatedProperties" and "unevaluatedItems" keywords. The behavior of "additionalProperties" and "additionalItems" can be described with this mechanism (along with the presence or absence mechanism) as well, which will serve as a proof of concept of the approach in a subsequent commit.
1 parent 719629d commit b0c208b

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

jsonschema-core.xml

+38-7
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,43 @@
126126
<section title="Keyword Behaviors">
127127
<t>
128128
JSON Schema keywords fall into several general behavior categories.
129-
Assertions validate that an instance satisfies constraints, annotations
130-
attach information that applications may use in any way they see fit,
131-
and applicators allow for building more complex schemas than a single
132-
schema object would allow.
129+
Assertions validate that an instance satisfies constraints, producing
130+
a boolean result. Annotations attach information that applications
131+
may use in any way they see fit. Applicators allow for building more
132+
complex schemas than a single schema object would allow, by causing
133+
additional schemas to be evaluated.
134+
</t>
135+
<t>
136+
Keyword behavior MAY be defined in terms of the annotation results
137+
of <xref target="root">subschemas</xref> and/or adjacent keywords.
138+
Such keywords MUST NOT result in a circular dependency.
139+
Keywords MAY modify their behavior based on the presence or absence
140+
of another keyword in the same
141+
<xref target="schema-document">schema object</xref>.
142+
</t>
143+
<t>
144+
A missing keyword MUST NOT produce a false assertion result, MUST
145+
NOT produce annotation results, and MUST NOT cause any other schema
146+
to be evaluated as part of its own behavioral definition.
147+
However, given that missing keywords do not contribute annotations,
148+
the lack of annotation results may indirectly change the behavior
149+
of other keywords.
150+
</t>
151+
<t>
152+
In some cases, the missing keyword assertion behavior of a keyword is
153+
identical to that produced by a certain value, and keyword definitions
154+
SHOULD note such values where known. However, even if the value which
155+
produces the default behavior would produce annotation results if
156+
present, the default behavior still MUST NOT result in annotations.
157+
</t>
158+
<t>
159+
Because annotation collection can add significant cost in terms of both
160+
computation and memory, implementations MAY opt out of this feature.
161+
Keywords known to an implementation to have assertion or applicator behavior
162+
that depend on annotation results MUST then be treated as errors, unless
163+
an alternate implementation producing the same behavior is available.
164+
Keywords of this sort SHOULD describe reasonable alternate approaches
165+
when appropriate.
133166
</t>
134167
<t>
135168
Extension keywords SHOULD stay within these categories, keeping in mind
@@ -175,9 +208,7 @@
175208
</t>
176209
<t>
177210
An instance can only fail an assertion that is present in the schema.
178-
In some cases, this no-op behavior is identical to a keyword that exists with
179-
certain values, and keyword definitions SHOULD note such values where known.
180-
These default behaviors MUST NOT result in assertion failures.
211+
181212
</t>
182213
<section title="Assertions and Instance Primitive Types">
183214
<t>

0 commit comments

Comments
 (0)