Fork me on GitHub

@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.


what version of the swagger-ui supports the examples for collections?


I just jumped to the latest version (3.20.1) and that works. Not sure at what point it started though.


Thanks for the query example, will give it a try


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.


so, if you have to have conflicts, just disable it.


@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.


I've had a Google but sorry am failing to find the secret sauce.


@ikitommi here is a gist showing an example API that behaves differently using reitit 0.2.0 and 0.2.13 -


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


Thanks for any help you can give :woman-bowing:


@jdommett thanks for gist, I'll dive into that today.


@jdommett had time to look the example. here’s a working(?) version:


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.


normal clojure.spec conformers should not be used here.


hope this helps.


Awesome thanks for that. I'll try it out tomorrow


Yup that works great. Thanks a lot for your help


@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.

👍 5

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