How to deal best with relationship in contained list item

Hi Michael,

It’s quite interesting discussion you linked with various opinions.
With my case I just wanted represent a simple example as actually my model is a little bit more complicated :wink:

That’s why using "meta" is not an option.
So it probably best to introduce a fabricated resource.
In the example below a use id’s 1, 2 but it probably would be better to use some opaque id here.

Note that I’m also not adding self links to the ingredients resources as I have no resource endpoint for them.
Looking at the spec this is not required. So basically this ingredients resources can only be retrieved as part of the recipes resource, but not on itself, although that feels a little bit weird to be honest.

      {
        "data": {
          "type": "recipes",
          "id": "1",
          "attributes": {
            "title": "Baked potatoes",
            "ingredients: [
              { "name": "potatoe", "quantity": "1 kg" },
              { "name": "salt", "quantity": "10 gr" }
            ]
          },
          "ingredients": {
            "links": {
              "self": "http://example.com/recipes/1/relationships/ingredients",
              "related": "http://example.com/recipes/1/ingredients"
            },
            "data": [
              { "type": "ingredients", "id": "1" },
              { "type": "ingredients", "id": "2" }
            ]
          },
          "links": {
            "self": "http://example.com/recipes/1"
          }
        },
        "included": [{
          "type": "ingredients",
          "id": "1",
          "attributes": {
            "name": "potatoe",
            "quantity": "1 kg"
          }
        }, {
          "type": "ingredients",
          "id": "2",
          "attributes": {
            "name": "salt",
            "quantity": "10 gr"
          }
        }]
      }