plexus / yaks

Ruby library for building hypermedia APIs
http://rubygems.org/gems/yaks
MIT License
236 stars 26 forks source link

Output JSON-API Error Object #110

Closed amkirwan closed 9 years ago

amkirwan commented 9 years ago

This request adds an error serializer method to generate correctly formatted JSON-API error object. Previously there was no error serializer for JSON-API which caused errors mappers to render incorrectly. Details on the JSON-API error object format are listed in the docs .

plexus commented 9 years ago

Thanks for the pull request! I need to think this through, since it sets conventions for how error resources should look in Yaks, something we don't have as of yet.

It'll probably be after the weekend before I can get back to you.

amkirwan commented 9 years ago

I understand in regards to setting a convention, I'm not sure what would be the best way to handle that. I'm using JSON-API in my applications so I'm not sure if the other formats explicitly define an error object like JSON-API does.

One thought was that by creating serialize_error method the end user could override that if they wanted to change how errors were formatted.

The other issue regarding JSON-API that I was going to try and figure out was how to format self and related links in relationships objects. Currently I don't think Yaks formats them correctly

plexus commented 9 years ago

@amkirwan I have tried to formulate a concrete proposal for a unified model for representing errors in Yaks. Please have a look at #112 and see if you have any feedback or input.

I'm going to close this pull request, if we can reach agreement on the approach outlined in #112 I'm happy to add error handling to JSON-API.

coveralls commented 7 years ago

Coverage Status

Changes Unknown when pulling 560d309801af3d3de78559e7abd413fc2bf398b1 on amkirwan:error_json_api into on plexus:master.