The :coercion
can be set to any of: api
, context
or endpoint. So, should work.
@salo.kristian check this out:
(clojure.spec.alpha/valid? ::instruments (repeat 10 "test")) ;;true
(GET "/" []
:coercion :spec
:summary "Get all user's instruments"
:return ::instruments
(ok (repeat 10 "test"))) ;;works
(GET "/" []
:coercion :spec
:summary "Get all user's instruments"
:return ::instruments
(ok (repeat 10 "test"))) ;;works
(GET "/:id" [id]
:coercion :spec
:summary "Get all user's instruments"
:return ::instruments
(ok (repeat 10 id))) ;;works with get /3
so, maybe something with your destructuring?
I also tried it without any destructuring, and the same problem persists. Something else in my api definition is probably causing it. I'll need to debug it further
If you can put a minimial repro, I can try to help too.
Found the problem. I had this in my root routes file:
(api/context "/instruments" []
:auth-rules buddy/authenticated?
:responses {401 {}
403 {}}
:tags ["Instrument"]
instrument/routes)
The syntax in the :responses
route param is invalid, and caused this problem. What is interesting is that setting :coercion :spec
anywhere in the route definition caused the error to be thrown. With the default Schema validation everything was working fine. I now included the required keys in the :responses
maps and everything is working fine. Thanks for the help anyways!@salo.kristian looks like a bug. Could you write an issue out of that? Thanks.