I’m currently working on implementing the spec and this contains also a validator for the JSON API format. Now I have the problem, that some definitions are a bit imprecise, which makes it hard to implement it properly. Some examples…
Definition of “coexist”, “contain” and "present"
From the spec:
- “The members data and errors MUST NOT coexist in the same document.”
- “If a document does not contain a top-level data key, the included member
MUST NOT be present either.”
- ‘data’ can be NULL and also an empty array
So IMHO following the spec…
- it’s valid to use ‘data’ with a value of NULL and ‘include’ (which doesn’t make sense).
- although ‘data’ is NULL, setting ‘errors’ is invalid (which could be valid).
Is that right or is it a wording problem here?
Allowed link values
The spec includes several examples for ‘self’ and ‘related’ links, and for all ‘self’ values a string is used in these examples - but following the spec, also a link object is allowed for ‘self’ (“a link MUST be represented as either […] string […] link object”).
Is that right?