Skip to content

Commit 25d0109

Browse files
authored
Merge pull request #1512 from json-schema-org/gregsdennis/unknown-keywords
Remove support for unrecognized keywords
2 parents 7ec52f3 + e3a5aa2 commit 25d0109

File tree

1 file changed

+6
-36
lines changed

1 file changed

+6
-36
lines changed

jsonschema-core.md

+6-36
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ identified in a meta-schema.
6767

6868
JSON Schema can be extended either by defining additional vocabularies, or less
6969
formally by defining additional keywords outside of any vocabulary. Unrecognized
70-
individual keywords simply have their values collected as annotations, while the
71-
behavior with respect to an unrecognized vocabulary can be controlled when
72-
declaring which vocabularies are in use.
70+
individual keywords are not supported.
7371

7472
This document defines a core vocabulary that MUST be supported by any
7573
implementation, and cannot be disabled. Its keywords are each prefixed with a
@@ -216,8 +214,8 @@ adjacent keywords.
216214
Extension keywords, meaning those defined outside of this document and its
217215
companions, are free to define other behaviors as well.
218216

219-
A JSON Schema MAY contain properties which are not schema keywords or are not
220-
recognized as schema keywords. The behavior of such keywords is governed by
217+
A JSON Schema MUST NOT contain properties which are not schema keywords or are
218+
not recognized as schema keywords. The behavior of such keywords is governed by
221219
{{unrecognized}}.
222220

223221
An empty schema is a JSON Schema with no properties.
@@ -440,10 +438,8 @@ vocabularies MUST NOT define any keywords which begin with this prefix.
440438

441439
#### Handling of unrecognized or unsupported keywords {#unrecognized}
442440

443-
Implementations SHOULD treat keywords they do not recognize, or that they
444-
recognize but do not support, as annotations, where the value of the keyword is
445-
the value of the annotation. Whether an implementation collects these
446-
annotations or not, they MUST otherwise ignore the keywords.
441+
Implementations MUST refuse to evaluate schemas which contain keywords which
442+
they do not know how to process or explicitly choose not to process.
447443

448444
## Keyword Behaviors
449445

@@ -831,11 +827,6 @@ re-use. These keywords do not affect validation or annotation results. Their
831827
purpose in the core vocabulary is to ensure that locations are available for
832828
certain purposes and will not be redefined by extension keywords.
833829

834-
While these keywords do not directly affect results, as explained in
835-
{{non-schemas}} unrecognized extension keywords that reserve locations for
836-
re-usable schemas may have undesirable interactions with references in certain
837-
circumstances.
838-
839830
### Loading Instance Data
840831

841832
While none of the vocabularies defined as part of this or the associated
@@ -1008,13 +999,7 @@ refuse to process that schema.
1008999

10091000
Implementations that do not support a vocabulary that is optionally used by a
10101001
schema SHOULD proceed with processing the schema. The keywords will be
1011-
considered to be unrecognized keywords as addressed by {{unrecognized}}. Note
1012-
that since the recommended behavior for such keywords is to collect them as
1013-
annotations, vocabularies consisting only of annotations will have the same
1014-
behavior when used optionally whether the implementation supports them or not.
1015-
This allows annotation-only vocabularies to be supported without custom code,
1016-
even in implementations that do not support providing custom code for extension
1017-
vocabularies.
1002+
considered to be unrecognized keywords as addressed by {{unrecognized}}.
10181003

10191004
##### Vocabularies are schema resource-scoped
10201005

@@ -1580,21 +1565,6 @@ that take one or more subschemas as a value. These keywords may be `$defs` and
15801565
the standard applicators from this document, or extension keywords from a known
15811566
vocabulary, or implementation-specific custom keywords.
15821567

1583-
Multi-level structures of unknown keywords are capable of introducing nested
1584-
subschemas, which would be subject to the processing rules for `$id`. Therefore,
1585-
having a reference target in such an unrecognized structure cannot be reliably
1586-
implemented, and the resulting behavior is undefined. Similarly, a reference
1587-
target under a known keyword, for which the value is known not to be a schema,
1588-
results in undefined behavior in order to avoid burdening implementations with
1589-
the need to detect such targets.[^10]
1590-
1591-
[^10]: These scenarios are analogous to fetching a schema over HTTP but
1592-
receiving a response with a Content-Type other than `application/schema+json`.
1593-
An implementation can certainly try to interpret it as a schema, but the origin
1594-
server offered no guarantee that it actually is any such thing. Therefore,
1595-
interpreting it as such has security implication and may produce unpredictable
1596-
results.
1597-
15981568
Note that single-level custom keywords with identical syntax and semantics to
15991569
`$defs` do not allow for any intervening `$id` keywords, and therefore will
16001570
behave correctly under implementations that attempt to use any reference target

0 commit comments

Comments
 (0)