ring-swagger

ring-swagger & compojure-api
antonmos 2020-02-08T19:53:08.026700Z

this gave me the hunch that the following should work - and it does!

(def user-ids-spec
  (st/spec
    {:spec (s/coll-of ::corespec/user-id)
     :description "comma separated list of user-ids"
     :json-schema/type {:type "string"}
     :json-schema/example "1,2,3"
     :decode/string #(cs/split %2 #",")
     :encode/string #(cs/join %2 ",")}))
(context "/v1" []
    :coercion :spec
    (GET "/events" []
      :coercion :spec
      :query-params [user-ids :- user-ids-spec]
      (println "foo" (pr-str {} user-ids 30)))))
i.e. instead of registering result of st/spec with s/def i am just referencing it in the :query-params specification

antonmos 2020-02-08T19:54:36.027300Z

Let me know if you want me to open an issue or update the docs somewhere.

ikitommi 2020-02-08T20:02:45.027800Z

what is different with that code? looks the same as the original?

ikitommi 2020-02-08T20:03:33.028300Z

oh, the s/def… sounds like a bug to me.

ikitommi 2020-02-08T20:04:27.028700Z

but glad you got it working!

antonmos 2020-02-08T20:07:48.029200Z

should i open a PR for a change in -map-spec?

ikitommi 2020-02-08T20:16:31.029900Z

sure, please do