This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-13
Channels
- # adventofcode (35)
- # announcements (2)
- # arachne (1)
- # beginners (71)
- # chestnut (2)
- # cider (100)
- # cljdoc (17)
- # cljs-dev (17)
- # cljsjs (2)
- # cljsrn (2)
- # clojure (53)
- # clojure-austin (2)
- # clojure-europe (1)
- # clojure-finland (2)
- # clojure-italy (3)
- # clojure-nl (7)
- # clojure-russia (56)
- # clojure-spec (56)
- # clojure-uk (35)
- # clojurescript (58)
- # community-development (14)
- # core-async (9)
- # cursive (22)
- # data-science (5)
- # datomic (14)
- # duct (5)
- # emacs (2)
- # expound (4)
- # figwheel-main (6)
- # fulcro (23)
- # kaocha (8)
- # lumo (7)
- # off-topic (10)
- # pathom (6)
- # re-frame (17)
- # reitit (31)
- # ring (3)
- # rum (1)
- # shadow-cljs (45)
- # spacemacs (10)
- # sql (12)
- # testing (9)
- # tools-deps (130)
@ikitommi wrapping the body spec in spec-tools worked thanks. However I had to overwrite the version of ring-swagger-ui pulled in as the current one doesn't seem to support examples that are collections (which is what I needed). Also I can't seem to get an example showing for query params, only body. When I wrap a query spec in spec-tools, the parameter just disappears from the generated json entirely. As far as you are aware should this work?
didn’t know. For query-params, I think you need to describe the examples per parameter, e.g. :query {:kikka (st/spec int? {:swagger/example 42}), :kukka (st/spec string? {:swagger/example "kukka"}}
the spec->swagger could read it from the top-level, but doesn’t do that today. PR/Issue welcome for that.
I just jumped to the latest version (3.20.1) and that works. Not sure at what point it started though.
Hi reitit guys! just looking for some help when you have this kind of routing defned
(ring/router [["/:id" ["" {:get {:responses {200 {}}
:parameters {:path-params {:id string?}}
:handler (fn [{{:keys [id]} :path-params}]
{:id id})}}]]
["/ole" {:get {:handler (fn [req] {:ok "api/ole"})}}]
["/olo" {:get {:handler (fn [req] {:ok "api/olo"})}}]
])
i’m getting this error:
Router contains conflicting route paths:
/:id -> /ole -> /olo
I have this kind of routes in a compojure working app so i thought i could translate it directly to reitit :thinking_face:
BTW: Thanks in advance for this great library!
is there counterproductive point in using {:conflicts (constantly nil)}
?
On an unrelated topic, is it possible to coerce a string parameter to a local date? I was achieving this by accident with a spec that used a conformer with a misconfigured unform fn (used identity) but I've just updated reitit and see the request-coercer now calls st/coerce rather than conform and now keeps the value as a string.
@tangrammer thanks! if you set {:conflicts nil}
, all the conflicting routes are served with linear-router, in order they are defined. If all the routes are in conflict, it’s bit slower. If you just have few conflicting ones, the perf doesn’t degrade.
@ikitommi good to know it 🙂 and thanks for the answer!
@jdommett request-coercer calls both st/coerce
and if that didn’t work, st/conform
. I think it should work the same as before. Could you give an example?
Yeh I can see that. My issue was I have wrong code where my unform fn is identity so in the previous implementation it would call conform, all was good, then unform which left all the values conformed. So accidently all is good and my strings come out as localdates. But now coerce is called which appears to leave the strings as is (presumably because I am misunderstanding how coercion should be configured). It coerces fine and so doesn't go on to call conform.
So I want to fix my code by setting the correct unform fn (which would be datetostring) and also work out what magic needs to be sprinkled to get coerce to turn my string into a local date.
@ikitommi here is a gist showing an example API that behaves differently using reitit 0.2.0 and 0.2.13 - https://gist.github.com/insano10/a0dda1c10246860d9bfc1b345298c3f1
I'm certain I'm just not defining my specs correctly to get the string turned into a LocalDate, but I'm not sure what to change
@jdommett had time to look the example. here’s a working(?) version: https://gist.github.com/ikitommi/a64314c915cffe46fbd2cef95074a12f
so, you need to define the string->date function as a spec-tools transformer and define the actual spec so that it validates that it’s a date.
@tangrammer actually, in your case, the two static routes are unreachable, as the first path if tested first and always matches. By design, reitit doesn't support parameter type guards.
Hello. I'm a reitit newb so please forgive me if this is obviously wrong but is the pedestal-swagger example missing some resources? When i go to the swagger.json endpoint, i get an unstyled json struct