{"action":"created","issue":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1004","repository_url":"https://api.github.com/repos/rails-api/active_model_serializers","labels_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1004/labels{/name}","comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1004/comments","events_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1004/events","html_url":"https://github.com/rails-api/active_model_serializers/pull/1004","id":94871180,"number":1004,"title":"[RFC] JSON API Errors (Initial implementation and roadmap for full feature-set)","user":{"login":"bf4","id":142914,"avatar_url":"https://avatars.githubusercontent.com/u/142914?v=3","gravatar_id":"","url":"https://api.github.com/users/bf4","html_url":"https://github.com/bf4","followers_url":"https://api.github.com/users/bf4/followers","following_url":"https://api.github.com/users/bf4/following{/other_user}","gists_url":"https://api.github.com/users/bf4/gists{/gist_id}","starred_url":"https://api.github.com/users/bf4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bf4/subscriptions","organizations_url":"https://api.github.com/users/bf4/orgs","repos_url":"https://api.github.com/users/bf4/repos","events_url":"https://api.github.com/users/bf4/events{/privacy}","received_events_url":"https://api.github.com/users/bf4/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rails-api/active_model_serializers/labels/C:%20JSON%20API","name":"C: JSON API","color":"CCCCCC"},{"url":"https://api.github.com/repos/rails-api/active_model_serializers/labels/Feature","name":"Feature","color":"009800"},{"url":"https://api.github.com/repos/rails-api/active_model_serializers/labels/RFC","name":"RFC","color":"fbca04"},{"url":"https://api.github.com/repos/rails-api/active_model_serializers/labels/V:%200.10.x","name":"V: 0.10.x","color":"bfd4f2"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":44,"created_at":"2015-07-14T05:29:57Z","updated_at":"2016-03-07T01:11:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1004","html_url":"https://github.com/rails-api/active_model_serializers/pull/1004","diff_url":"https://github.com/rails-api/active_model_serializers/pull/1004.diff","patch_url":"https://github.com/rails-api/active_model_serializers/pull/1004.patch"},"body":"For discussion of how serializing errors is different from resources\r\n\r\n- may often be an instance of ActiveModel::Error\r\n  - which we'd want to call 'messages' on\r\n  - if not, should we expect a hash? or give the end-user an object they must use?\r\n- is necessarily a collection of error objects, each with it's own 'source' and 'detail'\r\n  - it's not quite right to use an ArraySerializer\r\n\r\nImplemented:\r\n\r\n- [ ] [422 for errors](https://github.com/rails-api/active_model_serializers/pull/1004#issuecomment-181708926).. \r\n  - [ ] but see https://github.com/rails-api/active_model_serializers/pull/1004#discussion_r46471845 for concerns and alternative implementations\r\n\r\n- [x] error root key to collection of error objects\r\n  - [x] The members data and errors MUST NOT coexist in the same document.\r\n- [x] error objects from ActiveModel::Error\r\n- [ ] id: a unique identifier for this particular occurrence of the problem.\r\n- [ ] links: a links object containing the following members:\r\n  - [ ] about: a link that leads to further details about this particular occurrence of the problem.\r\n- [ ] status: the HTTP status code applicable to this problem, expressed as a string value.\r\n- [ ] code: an application-specific error code, expressed as a string value.\r\n- [ ] title: a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.\r\n- [x] detail: a human-readable explanation specific to this occurrence of the problem.\r\n- [x] source: an object containing references to the source of the error, optionally including any of the following members:\r\n  -  [x] pointer: a JSON Pointer [RFC6901](https://tools.ietf.org/html/rfc6901) to the associated entity in the request document [e.g. \"/data\" for a primary data object, or \"/data/attributes/title\" for a specific attribute].\r\n  -  [x] parameter: a string indicating which query parameter caused the error.\r\n- [ ] meta: a meta object containing non-standard meta-information about the error.\r\n\r\n\r\nTest:\r\n- [x] multiple error objects\r\n- [x] serializable resource? \r\n- [ ] Controller\r\n  - [x] `test/action_controller/json_api/errors_test.rb`\r\n  - [ ] `test/action_controller/rescue_from_test.rb`\r\n  - [ ] [`rescue_with_handler`, `handle_exceptions`](https://github.com/rails-api/active_model_serializers/pull/1004#discussion_r46471845)\r\n- [x] DOCS\r\n\r\nI included relevant json-api details in the PR as comment for convenience, but will remove most as this PR matures.\r\n\r\nref: \r\n- ams issue: https://github.com/rails-api/active_model_serializers/issues/933\r\n- http://jsonapi.org/format/#error-object\r\n- http://jsonapi.org/examples/\r\n- https://github.com/json-api/json-api/pull/828\r\n- other implementations\r\n  - https://github.com/cerebris/jsonapi-resources/blob/42a3c6409964a0f91544813e9a0437d248832ef4/lib/jsonapi/exceptions.rb\r\n  - https://github.com/cerebris/jsonapi-resources/blob/28ac3971f8b9e73073575d41439ffe263d7e56f5/test/controllers/controller_test.rb#L452-L462\r\n  - https://github.com/cerebris/jsonapi-resources/blob/28ac3971f8b9e73073575d41439ffe263d7e56f5/test/controllers/controller_test.rb#L2412-L2429\r\n  - https://github.com/chingor13/json_api_client/blob/cf79aba96cbc9ff66a793d07f43b025fd8f70b38/lib/json_api_client/error_collector.rb#L34-L48\r\n  - https://github.com/manyminds/api2go/blob/3023e50d563e6ec642b46a4f044812cb232661a1/error.go\r\n  - https://github.com/emberjs/data/blob/1f866da3b4a4edcf70fdf346cd6e6be6cfaecfab/packages/ember-data/lib/adapters/errors.js#L3-L154\r\n  - Usage in Ember\r\n    - http://emberjs.com/blog/2015/06/18/ember-data-1-13-released.html#toc_using-json-api-error-object-format\r\n    - ember-data\r\n      - [lib/adapters/errors.js](https://github.com/emberjs/data/blob/d842890357840700f0ee17f152415be0cba16030/packages/ember-data/lib/adapters/errors.js#L114-L132)\r\n      - [lib/adapters/rest-adapter.js](https://github.com/emberjs/data/blob/3930e457f36a0bbdde0155c1b98ebe976e607358/packages/ember-data/lib/adapters/rest-adapter.js#L913-L925)\r\n      - [lib/serializers/json-serializer.js](https://github.com/emberjs/data/blob/944f7e4b537cdc7cd2a80718d0447453c01de2db/packages/ember-data/lib/serializers/json-serializer.js#L1225-L1276)\r\n      - [adapter-errors-test.js](https://github.com/emberjs/data/blob/21ebe9b61b33acd910c0d485e17926c89c51d9f6/packages/ember-data/tests/unit/adapter-errors-test.js#L32-L48)\r\n      - [json-serializer-test.js](https://github.com/emberjs/data/blob/90a0011c8e5e1c41d1667c96a38c4a5e4a9c1e64/packages/ember-data/tests/integration/serializers/json-serializer-test.js#L566-L622)\r\n- libs to review for ideas\r\n  - http://jsonapi.org/implementations/#server-libraries-ruby\r\n  - https://github.com/endpoints/endpoints/blob/master/src/format-jsonapi/index.js\r\n  - https://github.com/chingor13/json_api_client\r\n  - https://github.com/jsmestad/jsonapi-consumer\r\n  - https://github.com/ember-data/active-model-adapter\r\n- libs to consider\r\n  - [Hana, JSON Pointer implementations](https://github.com/tenderlove/hana/blob/5da3b986cd529c680c96aacf20fc7f3c223d8102/test/test_hana.rb#L13-L66)\r\n\r\n## Usage\r\n\r\n```ruby\r\n# POST /api/{plural_resource_name}\r\ndef create  \r\n  set_resource(resource_class.new(resource_params))\r\n\r\n  if get_resource.save\r\n    render :show, status: :created, adapter: :json_api\r\n  else\r\n    render json: get_resource.errors, status: :unprocessable_entity, adapter: :json_api, serializer: ActiveModel::Serializer::ErrorSerializer\r\n  end\r\nend\r\n```"},"comment":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/comments/193028575","html_url":"https://github.com/rails-api/active_model_serializers/pull/1004#issuecomment-193028575","issue_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1004","id":193028575,"user":{"login":"bf4","id":142914,"avatar_url":"https://avatars.githubusercontent.com/u/142914?v=3","gravatar_id":"","url":"https://api.github.com/users/bf4","html_url":"https://github.com/bf4","followers_url":"https://api.github.com/users/bf4/followers","following_url":"https://api.github.com/users/bf4/following{/other_user}","gists_url":"https://api.github.com/users/bf4/gists{/gist_id}","starred_url":"https://api.github.com/users/bf4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bf4/subscriptions","organizations_url":"https://api.github.com/users/bf4/orgs","repos_url":"https://api.github.com/users/bf4/repos","events_url":"https://api.github.com/users/bf4/events{/privacy}","received_events_url":"https://api.github.com/users/bf4/received_events","type":"User","site_admin":false},"created_at":"2016-03-07T01:11:21Z","updated_at":"2016-03-07T01:11:21Z","body":"@NullVoxPopuli \r\n\r\n> do we want to merge a partial feature, \r\n\r\nThis PR is done.  It will be the basis of any future error feature prs."}}