This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-03
Channels
- # announcements (7)
- # beginners (114)
- # boot (5)
- # calva (25)
- # cider (26)
- # clojure (82)
- # clojure-dev (20)
- # clojure-europe (2)
- # clojure-italy (8)
- # clojure-losangeles (4)
- # clojure-norway (6)
- # clojure-uk (16)
- # clojurescript (21)
- # clojurex (3)
- # core-async (24)
- # cursive (25)
- # datomic (17)
- # emacs (5)
- # events (4)
- # fulcro (9)
- # funcool (1)
- # graalvm (4)
- # hyperfiddle (2)
- # midje (2)
- # mount (2)
- # off-topic (10)
- # pathom (11)
- # pedestal (5)
- # re-frame (36)
- # reagent (15)
- # reitit (3)
- # ring (4)
- # slack-help (2)
- # spacemacs (3)
- # sql (16)
- # tools-deps (5)
I'm new to Clojure and Reitit so it could be just that I've misunderstood something basic.
I'm looking at https://github.com/metosin/reitit/blob/master/doc/ring/swagger.md#more-complete-example and how it sets its parameters with :parameters {:body {:x int?, :y int?}}
in the "plus with spec body parameters" route. Is it possible to use a richer spec in there instead of just defining query parameters? Should I look at spec-tools or spec.alpha or both or netiher? I'd like to ultimately pass json to my route and I don't know if this is the way it should be done.
Hi @kari.pahula! The example you posted :parameters {:body {:x int?, :y int?}}
is actually defining what a body
of a POST request should look like (a map with keys :x
and :y
where their values satisfy the predicate int?
). The data could come in as JSON or EDN or whatever and it's read into Clojure data structures by muuntaja
. Muuntaja can deal with several transport formats, including JSON.
You can define arbitrarily complex specs with both spec.alpha
and spec-tools
and it should "just work" with Reitit afaik. spec-tools
provides bunch of extra functionality and convenience on top of spec.alpha
.
Well, quite. I must have misunderstood the swagger ui or something. I ran the ring-swagger example again and it does indeed accept curl -i
.