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.
Alternatively, does anyone have a good way of representing validation errors with Clojure spec and APIs?
In for answers. I was hoping expound/orchestra could help with making it more readable but haven't actually looked at it yet.
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
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/
@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?
reitit & c-api have ~same coercion impl, so it could be copied to both when done.
the current spec explain option in reitit is for the route (endpoint) data, for development time, not for runtime coercion.
It's mostly for in dev, so a single string in a map response would be ok
Or text/plain too, + logging
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.
@danielcompton ok, wrote - https://github.com/metosin/compojure-api/issues/400. Might be a one-liner to fix.
@robert.mather.rmm nothing in the c-api stack does that. 99% bets on 3rd party middleware.
ok, thanks