kurko / ember-json-api

JSON API adapter for Ember Data.
MIT License
254 stars 62 forks source link

Ember Data tries to find model for 'error' when returning error messages #29

Closed egeriis closed 9 years ago

egeriis commented 10 years ago

Per jsonapi.org spec it should be possible to pass errors alone or alongside other payload. But it appears that ember-json-api doesn't handle this correctly, as Ember Data is trying to look for an error model when I return an errors array with my payload.

Example payload:

{
  "goals": [
    {
      "id": 2,
      "badge_id": 5,
      "target": 100,
      "target_type": "actions",
      "target_title": "",
      "target_description": "",
      "start": "2014-09-18",
      "end": "2014-09-25",
      "name": "My goal",
      "description": "Nullam quis risus eget urna mollis ornare vel eu leo. Donec sed odio dui. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Nulla vitae elit libero, a pharetra augue. Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
      "visible_to": "select",
      "created_at": "2014-09-11 10:48:08",
      "updated_at": "2014-09-11 10:48:08",
      "deleted_at": null,
      "links": {
        "category": 2
      }
    },
    {
      "id": 3,
      "badge_id": 5,
      "target": 150,
      "target_type": "actions",
      "target_title": "",
      "target_description": "",
      "start": "2014-09-19",
      "end": "2014-09-25",
      "name": "ABC",
      "description": "Nulla vitae elit libero, a pharetra augue. Etiam porta sem malesuada magna mollis euismod. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Nullam quis risus eget urna mollis ornare vel eu leo. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.",
      "visible_to": "select",
      "created_at": "2014-09-11 10:51:07",
      "updated_at": "2014-09-11 10:55:53",
      "deleted_at": null,
      "links": {
        "category": 2
      }
    }
  ],
  "errors": [
    {
      "code": 2,
      "title": "Unknown linked resources requested",
      "description": "These linked resources are not available: departments"
    }
  ]
}
jonkoops commented 9 years ago

I am closing this issue due to lack of activity and the impending deprecation in favour of the official Ember Data adapter. If you think this is an issue that relates to Ember Data please report the issue there.