Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I mark a property in JSON schema as deprecated?

I have a JSON schema that defines JSON documents. There's an use case where we want to deprecate a particular attribute in favour of a new attribute being introduced and want to mark the old attribute as deprecated. Does JSON schema support that?

like image 521
Abhay Dubey Avatar asked Jan 26 '18 12:01

Abhay Dubey


People also ask

What is deprecated in JSON?

A root schema containing "deprecated" with a value of true indicates that the entire resource being described MAY be removed in the future.

What does exclusion minimum property in JSON Schema mean?

Gets or sets a flag indicating whether the value can not equal the number defined by the minimum attribute (Minimum).

What is schema validation in JSON?

JSON Schema validation asserts constraints on the structure of instance data. An instance location that satisfies all asserted constraints is then annotated with any keywords that contain non-assertion information, such as descriptive metadata and usage hints.

What is JSON Schema properties?

Properties. The properties (key-value pairs) on an object are defined using the properties keyword. The value of properties is an object, where each key is the name of a property and each value is a schema used to validate that property.


1 Answers

Draft 2019-09 of the JSON Schema Validation spec, published on 2019-09-16, now defines the deprecated meta-data annotation:

The value of this keyword MUST be a boolean. When multiple occurrences of this keyword are applicable to a single sub-instance, applications SHOULD consider the instance location to be deprecated if any occurrence specifies a true value.

If "deprecated" has a value of boolean true, it indicates that applications SHOULD refrain from usage of the declared property. It MAY mean the property is going to be removed in the future.

A root schema containing "deprecated" with a value of true indicates that the entire resource being described MAY be removed in the future.

When the "deprecated" keyword is applied to an item in an array by means of "items", if "items" is a single schema, the deprecation relates to the whole array, while if "items" is an array of schemas, the deprecation relates to the corrosponding [sic] item according to the subschemas position.

Omitting this keyword has the same behavior as a value of false.

like image 84
Holistic Developer Avatar answered Nov 04 '22 23:11

Holistic Developer