ring-swagger

ring-swagger & compojure-api
ikitommi 2019-02-22T08:29:04.005600Z

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

2019-02-22T09:31:25.006600Z

@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

2019-02-22T09:31:40.007200Z

so, maybe something with your destructuring?

salokristian 2019-02-22T12:28:03.008900Z

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

ikitommi 2019-02-22T12:34:25.009400Z

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

salokristian 2019-02-22T17:20:32.013300Z

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!

ikitommi 2019-02-22T19:28:30.015Z

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