Fork me on GitHub
#ring-swagger
<
2020-02-08
>
antonmos19:02:08

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

antonmos19:02:36

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

ikitommi20:02:45

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

ikitommi20:02:33

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

ikitommi20:02:27

but glad you got it working!

antonmos20:02:48

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

ikitommi20:02:31

sure, please do