yada icon indicating copy to clipboard operation
yada copied to clipboard

Error responses do not serialize to json

Open kendru opened this issue 8 years ago • 0 comments

For a resource that produces a media type of application/json, no response is rendered. I see that the JSON media type is commented out of the declarations in yada.handler/error-representations with a note that JSON serialization is troublesome. I agree that JSON serialization of Clojure data structures is difficult in general, but the complete lack of a response body for errors from JSON resources is surprising.

My thought is that if someone is explicitly supporting a JSON API, they are doing so with the understanding that the semantics of JSON is a subset of EDN, and they are not encoding data that cannot be understood properly under JSON semantics. Assuming that error responses usually do not encode the same complexity of information as successful responses, I think that a naive default JSON-serialization of errors should be included with the ability for the user to plug in their own serialization if desired.

I am happy to open a PR if this change would be welcomed.

kendru avatar Jun 20 '17 22:06 kendru