Fork me on GitHub
#ring-swagger
<
2016-02-24
>
timgilbert06:02:25

Hey, wondering if y’all would be amenable to a PR for something. I frequently find that when I’ve got a response body that doesn’t match a schema, the only thing I get back is the schema validation errors, and I’d like to log the response body I was trying to return at that time. So what I’d like to do is assoc it into the (ex-info) call here: https://github.com/metosin/compojure-api/blob/master/src/compojure/api/meta.clj#L66 …and then in my custom error handler I can retrieve it and log it.

timgilbert06:02:36

It would basically be something like (assoc body :type ::ex/response-validation :failed-body (:body response))

juhoteperi07:02:35

You can just replace the exception handler for schema errors

juhoteperi07:02:01

Yes, I think this would be useful

ikitommi07:02:54

Also think it’s a great idea. It could have more info too, like the :in defining what was the coercion about. Something like in Kekkonen: https://github.com/metosin/kekkonen/blob/master/src/kekkonen/core.clj#L299-L311

ikitommi07:02:09

(It might not be a good idea to pass the Schema, as it might not serialize)

juhoteperi07:02:26

It would make sense to move error from top-level map to some property, but that would break existing response validation error handlers so not sure if we want to change that

ikitommi07:02:58

sure, would have been ok to break that for 1.0.0, but could be just an addition now.