This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-08
Channels
- # announcements (4)
- # aws (3)
- # babashka (5)
- # beginners (16)
- # cider (8)
- # clj-kondo (3)
- # clojars (8)
- # clojure (115)
- # clojure-uk (15)
- # clojurescript (18)
- # data-science (5)
- # datomic (14)
- # fulcro (49)
- # funcool (6)
- # graalvm (3)
- # graphql (4)
- # lumo (17)
- # malli (5)
- # off-topic (15)
- # reitit (18)
- # ring-swagger (8)
- # rum (2)
- # shadow-cljs (35)
- # tools-deps (18)
- # uncomplicate (2)
- # vrac (1)
@ikitommi i tracked it down to this function https://github.com/metosin/compojure-api/blob/6d705dd4e08d3a55c55080eab94a00161473910f/src/compojure/api/coercion/spec.clj#L57
which one in-turn calls https://github.com/metosin/spec-tools/blob/d0137de90420cd95f40efcff78f3710bcbaf92f4/src/spec_tools/data_spec.cljc#L89
that registers a spec that no longer has the :decode/string
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