active_model_serializers/docs/howto/add_top_level_links.md
Leandro Cesquini Pereira 1844c162f1 Adds support for top-level links to JsonApi adapter
http://jsonapi.org/format/#document-top-level

fix failing tests

support for top-level links limited to jsonapi adapter

Move docs from README to docs/ dir

move links to json-api adapter & create Links class to hold links data
2016-02-03 10:16:22 -02:00

826 B

How to add top-level links

JsonApi supports a links object to be specified at top-level, that you can specify in the render:

  render json: @posts, links: { "self": "http://example.com/api/posts" }

That's the result:

{
  "data": [
    {
      "type": "posts",
      "id": "1",
      "attributes": {
        "title": "JSON API is awesome!",
        "body": "You should be using JSON API",
        "created": "2015-05-22T14:56:29.000Z",
        "updated": "2015-05-22T14:56:28.000Z"
      }
    }
  ],
  "links": {
    "self": "http://example.com/api/posts"
  }
}

This feature is specific to JsonApi, so you have to use the use the JsonApi Adapter