> (Sorry if this is a duplicate; I just posted a similar query but it doesn't
> appear to have shown up! Presuming it's lost!)
It is just that you tried and posted with a mail address which wasn't
registered to the group ;)
> We have an application with a json response which has been evolving over
> time. As a consequence we have a number of properties in the response which
> have been deprecated and are just being carried around until we are sure
> that the clients have integrated against the more recent API changes.
> This is what I'm anticipating:
>
> {
> "type" : "object",
> "required" : true,
> "additionalProperties" : false,
> "properties" : {
> "identityUID" : {
> "$ref": "../shared/non-empty-string.json",
> "required" : true
> },
> "anrUid" : {
> "$ref": "../shared/non-empty-string.json",
> "required" : true,
> "deprecated" : {
> "deprecatedOn" : "20120831",
> "description" : "Please use 'indentityUID' instead."
> }
> },
> ...
> }
> }
(you could use an ISO 8601 date format instead -- also, why require
the obsolete property? The new one is required anyway)
I don't really have a thought on this. The problem is that you are
opening up another possible use of JSON Schema and the specification
is currently big enough already ;)
This keyword is not about validation proper, it is not about
hyperlinking either...
I think the biggest problem with this for me is not the fact that it's meta-data (forget "links" - we already have the "title" and "description" properties), it's the fact that it references information outside the schema or the JSON data (in particular, "what is today's date").
{
"version" : 3,
"type" : "object","required" : true,
"additionalProperties" : false,"properties" : {"identityUID" : {"$ref": "../shared/non-empty-string.json","required" : true},"anrUid" : {"$ref": "../shared/non-empty-string.json","required" : true,"deprecated" : {
"version" : "2",
"description" : "Please use 'indentityUID' instead."}},...}}
Currently JSON Schema either matches or it doesn't, on the basis of nothing but the schema and the data. What you are describing sounds like "matches, but with warnings", or "matches when run today, but won't match with the same schema/data in a year's time".
Have you thought about having two schemas - a "permissive" which describes the data your server is outputting, and a "strict" schema for developers to be looking at?
--
You received this message because you are subscribed to the Google Groups "JSON Schema" group.
To view this discussion on the web visit https://groups.google.com/d/msg/json-schema/-/re7udeNpUnQJ.
To post to this group, send email to json-...@googlegroups.com.
To unsubscribe from this group, send email to json-schema...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/json-schema?hl=en.
Surely the JSON schema serves two purposes. One is for validation of data, the other is to allow users of data to anticipate the data that they are to expect. Given data changes shape over time the schema ought to reflect that.
Have you thought about having two schemas - a "permissive" which describes the data your server is outputting, and a "strict" schema for developers to be looking at?The problem with that approach is that there is actually many steeps between those two, given a constantly evolving data resource, and many consumers in different groups.
Surely the JSON schema serves two purposes. One is for validation of data, the other is to allow users of data to anticipate the data that they are to expect. Given data changes shape over time the schema ought to reflect that.True - I agree that it's not just for validation, and that documentation is a goal as well.Do you need this documentation to be machine-readable? If it's intended for humans, could it just go in the "description" property? ({"description": "DEPRECATED IN v2", ...}). Or even, just remove the "anrUid" property from the schema altogether, and put something in the description for "identityUID", saying that it's been replaced?
Have you thought about having two schemas - a "permissive" which describes the data your server is outputting, and a "strict" schema for developers to be looking at?The problem with that approach is that there is actually many steeps between those two, given a constantly evolving data resource, and many consumers in different groups.Yeah, I can see how that's a problem. Hmm.I still feel like a schema should describe a single data format, though, and not try and keep the entire history of the format in one document. As you haven't set "additionalProperties" to be false, could you just omit the "anrUid" field from your v3 documentation, but include it in the data? Old clients would still work, and if anyone's curious, they could go and find the v2 documentation to see what it used to do.
I also wonder whether that would help you test backwards-compatability. It sounds like your sever isn't outputting just the v3 format - it's outputting v3, plus some deprecated fields so that v2 clients can still work. If you had a history of schemas going back (instead of the entire history in one file), then you could validate your current server output against them individually, instead of having one cluttered master schema representing the amalgamated output format.
| mikekelly85 "Design is more the art of preserving changeability than it is the act of achieving perfection." -- @sandimetz 9/3/12 10:19 PM |