Hi, just starting reading up on JSON:API after getting increasingly frustrated with the lack of sufficiently robust standards on our how best to design HTTP+JSON-based APIs to handle all the needs of modern applications. I quite like what I’ve seen so far from reading through the jsonapi.org site, but some questions:
a) why not mandate a specific ‘date’ format? The lack of a good standard for JSON in this regard has been the source of much grief to many of us. For instance I quite like the Date(nnnn)
format that a few APIs use, but generally have stuck to ISO 8601 based formats even though there’s significant variation among many commonly used libraries as to how exactly how such dates should be parsed or formatted.
b) the guidelines on returning HTTP error codes seem like they could be clearer. In particular - if the URL refers to a valid endpoint supported by the server but the particular requested resource doesn’t exist, should 401 be used - even if it’s something in the query string parameters or POST body that might be referring to a non-existing entity? And what HTTP status code should be used if a server is able to partially fulfil a POST request, making certain modifications to server state but not others. In fact the current specification disallows having a response with both ‘data’ and ‘errors’ in the response - but for instance, I work with some APIs that support bulk-creation/update requests, where it’s possible that some entities are created and others not, and that return both data for the created entities (ids etc.), and errors for the ones that can’t be created. How would these work in JSON:API?
c) I’d especially like to see guidelines on URLs/HTTP methods for operations that aren’t typical CRUD-type operations. For instance, payment gateway type APIs where a common operation is to authorize a payment - there’s no resource being created, read, updated or deleted in any meaningful sense. What would be the ideal {json:api} URL for such an operation? Another common example is APIs that are such a particular type of ‘update’ where extremely restricted operations are possible and where the REST-like convention of doing a POST or a PATCH to the resource with just the updates in the message body sits awkwardly (e.g. a particular resource might support the concept of being ‘locked’ or ‘unlocked’, but to update to ‘unlocked’ requires the user to specify particular additional information that isn’t intended to become part of the persisted state of the resource).
d) what’s the rationale behind allowing hyphens in JSON:API field names? I’ve used a few APIs that do just that and the complications it raises with backend serialization/deserialization is always a pain: very very few programming languages support hyphens in names.
e) are there any planned recommendations on how servers should deal with field names they don’t recognise? Personal experience strongly suggests it’s far better for servers to reject JSON with unrecognised field names (as it’s most likely that whoever programmed the client is expecting the field to be read by the server).
f) any planned recommendations on how best to support data-types such as Enums or UUIDs?
g) any consideration given to JSON schemas, whether via swagger or other means, and how they’d work with JSON:API?
h) any planned recommendations on API security?
i) perhaps most controversially - is it too late to be so focused on JSON when Protobuf and other binary formats might end up making it obsolete?
Thanks and sorry if any of this has already been debated to death here.
Dylan