{"action":"created","issue":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/3986","labels_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/3986/labels{/name}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/3986/comments","events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/3986/events","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/3986","id":100118366,"number":3986,"title":"[feature] JSON API response formatting with external package","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},"labels":[],"state":"open","locked":false,"assignee":{"login":"sloria","id":2379650,"avatar_url":"https://avatars.githubusercontent.com/u/2379650?v=3","gravatar_id":"","url":"https://api.github.com/users/sloria","html_url":"https://github.com/sloria","followers_url":"https://api.github.com/users/sloria/followers","following_url":"https://api.github.com/users/sloria/following{/other_user}","gists_url":"https://api.github.com/users/sloria/gists{/gist_id}","starred_url":"https://api.github.com/users/sloria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sloria/subscriptions","organizations_url":"https://api.github.com/users/sloria/orgs","repos_url":"https://api.github.com/users/sloria/repos","events_url":"https://api.github.com/users/sloria/events{/privacy}","received_events_url":"https://api.github.com/users/sloria/received_events","type":"User","site_admin":false},"milestone":null,"comments":22,"created_at":"2015-08-10T17:10:05Z","updated_at":"2015-08-18T20:43:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/3986","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/3986","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/3986.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/3986.patch"},"body":"<h1> Purpose </h1>\r\n\r\nWe are changing the formatting of JSON responses in the API to match the JSONAPI v1 spec http://jsonapi.org/format/. References Issue #3074.  This PR allows our application to work with a 3rd party package https://github.com/django-json-api/django-rest-framework-json-api/tree/develop to handle JSON response formatting for us. For now, working off a fork of this package until it covers more cases under the spec or allows for customization: https://github.com/pattisdr/django-rest-framework-json-api/tree/develop\r\n\r\nSimilar to #3683 , which manually changed our JSON response formatting.\r\n\r\n<h1> Changes </h1>\r\n\r\n* Changes REST_FRAMEWORK settings to use parsers/pagination/renderers from package\r\n* Removes our base pagination and renderers\r\n* Removes nesting of `detail` view under `data` as package is handling nesting\r\n* Creates HyperlinkedIdentityFieldWithMeta inheriting from HyperlinkedIdentityField which allows creation of relationships links with meta arguments.  Also returns None if lookup_value is None, such as when a `node` doesn't have a parent.\r\n* Changes `root` view into class-based view as this is package assumption https://github.com/django-json-api/django-rest-framework-json-api/tree/develop#usage\r\n* Nests Node registration, dashboard, and collection attributes same level as `title` and `category` to adhere to JSON API spec\r\n* Adds `action` and `resource_name` to views so package knows if this is a list or detail view and can extract `type`\r\n* Removes class Meta from serializers\r\n* Adds package fork to requirements\r\n* Modifies tests to handle new formatting\r\n\r\n<h3> New Node format</h3>\r\n![screen shot 2015-08-17 at 9 43 28 am](https://cloud.githubusercontent.com/assets/9755598/9306072/17bdb97c-44c4-11e5-970f-c003af9caa46.png)\r\n\r\n<h3> Old Node format</h3>\r\n![screen shot 2015-07-20 at 9 57 30 am](https://cloud.githubusercontent.com/assets/9755598/8777406/cacb35f4-2ec5-11e5-9602-b917c6478322.png)\r\n<h3> New Contributor format </h3>\r\n![screen shot 2015-08-10 at 1 25 45 pm](https://cloud.githubusercontent.com/assets/9755598/9178032/0bf86d00-3f63-11e5-8192-dff11ba9fc1d.png)\r\n\r\n<h3> Old Contributor format </h3>\r\n![screen shot 2015-07-20 at 10 03 11 am](https://cloud.githubusercontent.com/assets/9755598/8777555/ac6f4e78-2ec6-11e5-94ee-decbbba35a1e.png)\r\n\r\n### New Node Links ~~Pointer~~ format \r\n![screen shot 2015-08-17 at 9 45 56 am](https://cloud.githubusercontent.com/assets/9755598/9306149/800e4e42-44c4-11e5-8ed2-2fb086004044.png)\r\n\r\n\r\n<h3> Old Pointer format </h3>\r\n![screen shot 2015-07-20 at 10 06 59 am](https://cloud.githubusercontent.com/assets/9755598/8777591/f1c60c6e-2ec6-11e5-8657-01e44a01bdbd.png)\r\n<h3> New Folder format </h3>\r\n![screen shot 2015-08-10 at 1 28 58 pm](https://cloud.githubusercontent.com/assets/9755598/9178100/74739a4e-3f63-11e5-81b2-06c406f0c329.png)\r\n\r\n<h3> Old Folder format </h3>\r\n![screen shot 2015-07-20 at 10 14 36 am](https://cloud.githubusercontent.com/assets/9755598/8777808/4978467e-2ec8-11e5-9365-12b4c94335c4.png)\r\n<h3> New Files format </h3>\r\n![screen shot 2015-08-10 at 1 28 47 pm](https://cloud.githubusercontent.com/assets/9755598/9178103/77135d0c-3f63-11e5-9602-24ee6539cbc4.png)\r\n\r\n<h3> Old Files format </h3>\r\n![screen shot 2015-07-20 at 10 14 18 am](https://cloud.githubusercontent.com/assets/9755598/8777800/42761554-2ec8-11e5-94d9-c1d24dbf4e44.png)\r\n<h3> New Root format </h3>\r\n![screen shot 2015-08-14 at 4 00 27 pm](https://cloud.githubusercontent.com/assets/9755598/9282868/57b78e3c-429d-11e5-9a17-915a8c0484fc.png)\r\n\r\n\r\n<h3> Old Root format </h3>\r\n![screen shot 2015-07-21 at 12 31 38 pm](https://cloud.githubusercontent.com/assets/9755598/8806370/656a3f4a-2fa4-11e5-8c1e-980b357a39a2.png)\r\n\r\n<h3> New exception </h3>\r\n![screen shot 2015-08-14 at 3 59 17 pm](https://cloud.githubusercontent.com/assets/9755598/9282840/1e50c726-429d-11e5-83bc-0f70d9d31374.png)\r\n\r\n\r\n<h3> Old exception </h3>\r\n![screen shot 2015-07-22 at 9 47 16 am](https://cloud.githubusercontent.com/assets/9755598/8826761/c2b3c18c-3056-11e5-8da6-c8b35bf168c5.png)\r\n\r\n<h3> New Response Headers </h3>\r\n![screen shot 2015-08-10 at 1 30 56 pm](https://cloud.githubusercontent.com/assets/9755598/9178158/b651e876-3f63-11e5-9fbe-f4abf8e006ea.png)\r\n\r\n\r\n<h3> Old Response Headers </h3>\r\n![screen shot 2015-07-23 at 11 46 14 am](https://cloud.githubusercontent.com/assets/9755598/8854882/47b4e760-3130-11e5-9835-0aad24c59e75.png)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/comments/132344749","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/3986#issuecomment-132344749","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/3986","id":132344749,"user":{"login":"sloria","id":2379650,"avatar_url":"https://avatars.githubusercontent.com/u/2379650?v=3","gravatar_id":"","url":"https://api.github.com/users/sloria","html_url":"https://github.com/sloria","followers_url":"https://api.github.com/users/sloria/followers","following_url":"https://api.github.com/users/sloria/following{/other_user}","gists_url":"https://api.github.com/users/sloria/gists{/gist_id}","starred_url":"https://api.github.com/users/sloria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sloria/subscriptions","organizations_url":"https://api.github.com/users/sloria/orgs","repos_url":"https://api.github.com/users/sloria/repos","events_url":"https://api.github.com/users/sloria/events{/privacy}","received_events_url":"https://api.github.com/users/sloria/received_events","type":"User","site_admin":false},"created_at":"2015-08-18T20:43:06Z","updated_at":"2015-08-18T20:43:06Z","body":"`get_keys` seems to be broken:\r\n\r\nhttps://github.com/django-json-api/django-rest-framework-json-api/compare/develop...pattisdr:develop#diff-e2e58e3e5c345fc3b14c160b3a00a64cR11\r\n\r\n```python\r\nget_keys({'foo': {'bar': 42}})  # ['bar']\r\n```\r\n\r\nShouldn't it return `['foo', 'bar']`?"}}