json-schema-spec icon indicating copy to clipboard operation
json-schema-spec copied to clipboard

How to declare deprecation date and reason

Open FrancescoReviso opened this issue 3 years ago • 3 comments

With JSON-Schema I can flag a field or my entire document by setting the deprecated meta-data attribute to true. Besides flagging the field as deprecated I would like to add a date and a reason (particularly useful when I would like to suggest to use another field replacing the deprecated ones). Is there any way to do it by following JSON-Schema specification? If it is not the case, is there any best practice/pattern to follow? Thanks

FrancescoReviso avatar Mar 17 '22 10:03 FrancescoReviso

The latest draft specifies that unknown keywords are to be collected as annotations. This means that you should be free to add "keywords" that you want (e.g. deprecation-date) and you should get their values as annotations in the output.

gregsdennis avatar Mar 17 '22 11:03 gregsdennis

The latest draft specifies that unknown keywords are to be collected as annotations. This means that you should be free to add "keywords" that you want (e.g. deprecation-date) and you should get their values as annotations in the output.

thanks for your suggestion. This official document discusses annotations but it does not explictily state whether you can use custom "keywords". Moreover I use AJV and Newtonsoft validation libraries and none of them seems to support annotations in the output, only valid and errors. Do you know any existing library that has already implemented support for annotations?

FrancescoReviso avatar Mar 17 '22 12:03 FrancescoReviso

I just happen to know of one! Check out mine: https://www.nuget.org/packages/JsonSchema.Net/

gregsdennis avatar Mar 17 '22 19:03 gregsdennis