Skip to content

Support for JSONApi conform errors #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gonvaled opened this issue Jan 5, 2016 · 1 comment
Closed

Support for JSONApi conform errors #188

gonvaled opened this issue Jan 5, 2016 · 1 comment

Comments

@gonvaled
Copy link

gonvaled commented Jan 5, 2016

Currently I am receiving the following errors from the django backend:

{
  "errors": {
    "extra_comments": [
      "This field may not be null."
    ],
    "name": [
      "This field may not be null."
    ],
    "due_date": [
      "This field may not be null."
    ],
    "price": [
      "This field may not be null."
    ],
    "payment_type": [
      "This field may not be null."
    ],
    "description": [
      "This field may not be null."
    ]
  }
}

But JSONApi specifies something like:

{
  "errors": [
    {
      "status": "403",
      "source": { "pointer": "/data/attributes/secret-powers" },
      "detail": "Editing secret powers is not authorized on Sundays."
    },
    {
      "status": "422",
      "source": { "pointer": "/data/attributes/volume" },
      "detail": "Volume does not, in fact, go to 11."
    },
    {
      "status": "500",
      "source": { "pointer": "/data/attributes/reputation" },
      "title": "The backend responded with an error",
      "detail": "Reputation service not responding after three requests."
    }
  ]
}

Do I need to configure something, or is this support lacking in django-rest-framework-json-api

There is also a related question in stackoverflow.

@gonvaled
Copy link
Author

gonvaled commented Jan 5, 2016

I would say the documentation needs to mention:

REST_FRAMEWORK = {
    ...
    'EXCEPTION_HANDLER': 'rest_framework_json_api.exceptions.exception_handler',
    ...
}

I found that in the example application, but afaik it is not mentioned in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant