如何将 JSON 架构中的 属性 标记为已弃用?
How do I mark a property in JSON schema as deprecated?
我有一个定义 JSON 文档的 JSON 架构。有一个用例,我们希望弃用特定属性以支持引入新属性,并希望将旧属性标记为已弃用。 JSON 模式支持吗?
目前没有,但计划在未来版本的规范中使用。
对效果的讨论发生在 https://github.com/json-schema-org/json-schema-spec/issues/74
Henry 在 Sep 2017 中将其添加到未来的草案里程碑中,但在我们实现它之前仍有问题需要解决。
更新,查看有关 2019-09 版草案的其他答案!
Draft 2019-09 of the JSON Schema Validation spec, published on 2019-09-16, now defines deprecated
元数据注释:
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.
我有一个定义 JSON 文档的 JSON 架构。有一个用例,我们希望弃用特定属性以支持引入新属性,并希望将旧属性标记为已弃用。 JSON 模式支持吗?
目前没有,但计划在未来版本的规范中使用。 对效果的讨论发生在 https://github.com/json-schema-org/json-schema-spec/issues/74
Henry 在 Sep 2017 中将其添加到未来的草案里程碑中,但在我们实现它之前仍有问题需要解决。
更新,查看有关 2019-09 版草案的其他答案!
Draft 2019-09 of the JSON Schema Validation spec, published on 2019-09-16, now defines deprecated
元数据注释:
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.