Another use case for attributes in relationship objects

Rendall, check out my blog on guidelines for hypermedia here. I’m only halfway through the explanation posts, but the ones remaining are actually out of scope to your question. Since my solution to your problem isn’t fully baked yet, I can’t suggest you use it. However, I think it’s a succinct guide to walk you through how to attack a hypermedia API.

If you’re still in design mode it goes into some very helpful constraints which will answer a lot of this for you.

The reason I suggest this, is you are trying to define your vocabulary as part of your resource representation, and this will cause insane headaches for you down the road, even bigger than the one you’re looking at now. Relationships in JSON Api are essentially the unit of composition description for to compose larger contexts for the resources. If you are having trouble, or explain the relationship of x to y as ‘it depends’ then you haven’t completed the step of making your resources atomic. If extra information is needed for the ‘it depends’ why not just create another resource to describe the state, and you can include the descriptions transitively in that resources relationships/includes section.

Attributes in your example are the data, for JSON Api you have essentially 3 buckets in a resource representation’s serialization. The ‘data’ which is composed of all native data (string, arrays, numbers…etc.), the relationships for holding the relationship objects which describe the relationship between 2 resources (no data), or the include section which brings in the full resource available at a specific URI into the message to actually be part of the compound document.

If you want to include the other resources, you use the “included” section, if you want to just describe and point to other resources you use the relationships section.