I started using JSONAPI in one of my pet projects, and first of all I like it for providing clear guidance on how one can structure a json-response / request body for resources.
Occasionally I get second thoughts however, as I find certain design decisions unintuitive or maybe not exactly RESTful. So I thought this might be a good place to get some answers about them (points to where I can read about it would be totally fine, too).
- a resource is defined by its URL, why keep a separate (“id”, “type”) pair for that?
- id fields kind of assume that for every model type you have multiple instances. I find that a bit overassuming, since I would say that an endpoint like
currentUsermight make sense that would be a singleton with the current user being a relationship of that resource.
- why separate attributes and relationships? Relationships could kind of be normal attributes I think that distinguish themselves by the value they have from other attributes.