I’m trying to write a minimal, custom, JSON:API 1.1 implementation using Python.
For the top level, the RFC/doc says:
https://jsonapi.org/format/#document-top-level
A document MUST contain at least one of the following top-level members:
- data: the document’s “primary data”.
- errors: an array of error objects.
- meta: a meta object that contains non-standard meta-information.
- a member defined by an applied extension.
The members data and errors MUST NOT coexist in the same document.
The way I read that is:
- “data” is optional
- “errors” is optional
- “meta” is optional
- “member from an extension” is optional
However, at least 1 of them needs to be present in the document. Also “data” and “errors” must never be in the same document.
I’m having a hard time modeling this. Is there a way to do it using the type system or do I have to do custom validation of some sort?
Data|Errors|Meta|ExtensionMember
doesn’t cut it ????