{"action":"created","issue":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4260","labels_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4260/labels{/name}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4260/comments","events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4260/events","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/4260","id":105444252,"number":4260,"title":"[RfR] Add embed= support to API endpoints","user":{"login":"samchrisinger","id":2207561,"avatar_url":"https://avatars.githubusercontent.com/u/2207561?v=3","gravatar_id":"","url":"https://api.github.com/users/samchrisinger","html_url":"https://github.com/samchrisinger","followers_url":"https://api.github.com/users/samchrisinger/followers","following_url":"https://api.github.com/users/samchrisinger/following{/other_user}","gists_url":"https://api.github.com/users/samchrisinger/gists{/gist_id}","starred_url":"https://api.github.com/users/samchrisinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samchrisinger/subscriptions","organizations_url":"https://api.github.com/users/samchrisinger/orgs","repos_url":"https://api.github.com/users/samchrisinger/repos","events_url":"https://api.github.com/users/samchrisinger/events{/privacy}","received_events_url":"https://api.github.com/users/samchrisinger/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2015-09-08T18:35:03Z","updated_at":"2015-10-23T16:25:12Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4260","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/4260","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/4260.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/4260.patch"},"body":"# Purpose\r\n\r\nJSONAPI defines a way to include related resources in a request (http://jsonapi.org/format/#fetching-includes). For us this means we could make a request like ```/api/v2/nodes/abcdef/?include=children``` to fetch a node and its children in a single requests.\r\n\r\nUnfortunately the JSON-API spec has some drawbacks, so we're implementing a similar feature: embed. This directly embeds the view response for the related resource in the API response.\r\n\r\n# Changes \r\n\r\n- Implement JSONAPIBaseView to generically handle\r\n  - injection of the request into the serializer context\r\n  - injection of a dictionary of zero or more partial functions ( object -> dict) into the serializer context. These functions are called in the JSONAPISerializer's to_representation method when appropriate. \r\n- Add JSONAPIBaseView to existing view classes\r\n\r\n# Side effects\r\n\r\nNone"},"comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/comments/150625147","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/4260#issuecomment-150625147","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4260","id":150625147,"user":{"login":"pattisdr","id":9755598,"avatar_url":"https://avatars.githubusercontent.com/u/9755598?v=3","gravatar_id":"","url":"https://api.github.com/users/pattisdr","html_url":"https://github.com/pattisdr","followers_url":"https://api.github.com/users/pattisdr/followers","following_url":"https://api.github.com/users/pattisdr/following{/other_user}","gists_url":"https://api.github.com/users/pattisdr/gists{/gist_id}","starred_url":"https://api.github.com/users/pattisdr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pattisdr/subscriptions","organizations_url":"https://api.github.com/users/pattisdr/orgs","repos_url":"https://api.github.com/users/pattisdr/repos","events_url":"https://api.github.com/users/pattisdr/events{/privacy}","received_events_url":"https://api.github.com/users/pattisdr/received_events","type":"User","site_admin":false},"created_at":"2015-10-23T16:25:12Z","updated_at":"2015-10-23T16:25:12Z","body":"I don't think `relationships` objects are allowed to be empty https://github.com/CenterForOpenScience/osf.io/pull/3683#issuecomment-136938751, so when there is an empty relationships object, it is removed before returning the response.  I wonder if we should do the same thing for `embeds`?  \r\n"}}