Fork me on GitHub
#ring-swagger
<
2019-02-22
>
ikitommi08:02:04

The :coercion can be set to any of: api, context or endpoint. So, should work.

mping09:02:25

@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

mping09:02:40

so, maybe something with your destructuring?

salokristian12:02:03

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

ikitommi12:02:25

If you can put a minimial repro, I can try to help too.

salokristian17:02:32

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!

ikitommi19:02:30

@salo.kristian looks like a bug. Could you write an issue out of that? Thanks.