ring-swagger

ring-swagger & compojure-api
danielcompton 2018-11-15T03:40:11.069800Z

Is there a way to get Compojure-API/Spec-tools to return an expound error instead of the default Clojure spec one? I've looked at the ::ex/response-validation handler, but it seems like it's a bit late by that point. I'd need to work out which spec to use and which data to use to validate against.

danielcompton 2018-11-15T03:40:31.070200Z

Alternatively, does anyone have a good way of representing validation errors with Clojure spec and APIs?

niels 2018-11-15T08:19:37.070300Z

In for answers. I was hoping expound/orchestra could help with making it more readable but haven't actually looked at it yet.

niels 2018-11-15T15:41:31.071300Z

https://github.com/metosin/reitit/blob/master/doc/basics/route_data_validation.md reitit has the option to swap out spec.alpha/explain with something else, like expound. But I haven't figured out a nice way to do it with compojure-api yet

niels 2018-11-15T16:27:03.073800Z

thought I was close, using (create-coercion), but didn't get there. Would like to hear if compojure-api has something similar to reitit, just like in this blogpost: https://www.metosin.fi/blog/reitit-ring/

ikitommi 2018-11-15T18:03:07.082900Z

@nmdrenard @danielcompton I think it would belong to the coercion impl, maybe the spec coerxion should take options map, which would allow setting the formatter. Still, expound emits just one string, would it be returned as one field over json/edn/transit? Or as a text/plain response? Or just log it?

ikitommi 2018-11-15T18:04:44.085Z

reitit & c-api have ~same coercion impl, so it could be copied to both when done.

ikitommi 2018-11-15T18:06:15.087600Z

the current spec explain option in reitit is for the route (endpoint) data, for development time, not for runtime coercion.

danielcompton 2018-11-15T20:07:06.089900Z

It's mostly for in dev, so a single string in a map response would be ok

danielcompton 2018-11-15T20:07:18.090200Z

Or text/plain too, + logging

ro6 2018-11-15T20:28:21.091100Z

my API is returning 200 OK for undefined routes. Is there some default I need to override somewhere? I've looked through the docs but didn't find anything.

ikitommi 2018-11-15T20:32:13.091900Z

@danielcompton ok, wrote - https://github.com/metosin/compojure-api/issues/400. Might be a one-liner to fix.

ikitommi 2018-11-15T20:32:55.092700Z

@robert.mather.rmm nothing in the c-api stack does that. 99% bets on 3rd party middleware.

ro6 2018-11-15T20:34:30.092900Z

ok, thanks