deprecated : Boolean
deprecated
BooleanThis keyword indicates that applications should refrain from using the declared property.
Value |
This keyword must be set to a boolean value
Hint: Use the jsonschema metaschema and jsonschema lint commands to catch keywords set to invalid values
|
---|---|
Kind | Annotation |
Applies To | Any |
Base Dialect | 2020-12 |
Changed In | None |
Introduced In | 2019-09 |
Vocabulary | Meta Data |
Specification | https://json-schema.org/draft/2020-12/json-schema-validation.html#section-9.3 |
Metaschema | https://json-schema.org/draft/2020-12/meta/meta-data |
Official Tests | None |
Default |
false
|
Annotation |
Boolean
The boolean value set by this keyword
Hint: Use the jsonschema validate command to collect annotations from the command-line
|
Affected By | None |
Affects | None |
Also See |
The deprecated
keyword, when set to true
, signifies that an instance value
(such as a specific object property) should not be used and may be removed or
rejected in the future. This keyword does not affect validation, but the
evaluator will collect its value as an annotation.
Best Practice
Avoid setting this keyword to the default value false
. If an instance value
is not considered to be deprecated, the best practice is to omit the use of
this keyword altogether. This prevents unnecessarily generating and collecting
an annotation that does not carry any additional meaning.
Common Pitfall
Tooling makers must be careful when statically traversing schemas in search of occurences of this keyword. It is possible for schemas to make use of this keyword behind conditional operators, references, or any other type of keyword that makes it hard or even impossible to correctly locate these values without fully evaluating the schema against an instance. The only bullet proof method is through annotation collection.
For example, an instance property might only be deprecated under certain
conditions determined by a dynamic operator like anyOf
.
Examples
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"country": { "type": "string" },
"city": { "type": "string", "deprecated": true }
}
}
{ "country": "United Kingdom", "city": "London" }
{ "keyword": "/properties/city/deprecated", "instance": "/city", "value": true }
{ "country": "United Kingdom" }
{ "city": 1 }
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"country": { "type": "string" },
"city": { "type": "string" }
},
"dependentSchemas": {
"country": {
"properties": { "city": { "deprecated": true } }
}
}
}
{ "country": "United Kingdom", "city": "London" }
{ "keyword": "/dependentSchemas/country/properties/city/deprecated", "instance": "/city", "value": true }
{ "city": "London" }
{ "country": "United Kingdom" }
{ "city": 1 }