This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-22
Channels
- # announcements (21)
- # aws (7)
- # beginners (105)
- # berlin (1)
- # calva (14)
- # cider (20)
- # clj-kondo (62)
- # cljdoc (7)
- # cljsrn (1)
- # clojure (206)
- # clojure-dev (2)
- # clojure-europe (11)
- # clojure-france (2)
- # clojure-italy (2)
- # clojure-nl (1)
- # clojure-uk (34)
- # clojured (1)
- # clojurescript (52)
- # copenhagen-clojurians (2)
- # core-async (1)
- # cryogen (3)
- # cursive (36)
- # data-science (27)
- # datomic (48)
- # emacs (1)
- # events (1)
- # fulcro (27)
- # hoplon (51)
- # jobs-discuss (1)
- # leiningen (1)
- # nrepl (2)
- # off-topic (52)
- # pathom (43)
- # quil (10)
- # re-frame (11)
- # reitit (28)
- # remote-jobs (2)
- # shadow-cljs (36)
- # sql (12)
- # tools-deps (7)
- # vim (32)
- # xtdb (17)
Hi,
Trying to grasp coercing with spec.
Playing with this ex https://github.com/metosin/reitit/tree/master/examples/http-swagger
Why does request params get coerced based on spec, but response do not.
{200 {:body {:total pos-int?}}}
If my response is :total "123"
it won't coerce "123" to 123 and throw and error.
@johan178 I think the response is more for validation than coercion
@toni.vanhala thanks. I read it before, but I still could not understand why it was solving problem differently than specs :)
Now I do :)
Wow how did you make it so fast?!
@johan178 you can override the muuntaja settings. there should be examples to override the muuntaja transit format readers/writers in both muuntaja docs and hopefully in the reitit docs.
main focus for reitit 1.0.0 is to get coherent configs (and config errors) for everything. now, itās⦠bad.
@neo2551 performance is built from bottom-up, by separating compilation & execution. With coercion, the uber case is a deeply nested map+vector schema, where all subschemas can be presented in JSON. The transformation compiler with json-tranformer puns nil
out of the pipeline and the top level m/transformer
returns identity
= ānothing to doā. Canāt beat that š
Haha nice one
@rschmukler great explanation. will check the issue comments later today
hi! love the swagger integration so far but i'm not really experienced with spec⦠how do i specify optional query parameters?
I hoped I could just do a (s/nilable string?)
but it was still coerced into a required parameter
for normal specs, use :opt
for keys, with data-specs, you wrap the keys with ds/opt
.
Hi, is it possible to prevent route conflicts by constrain valid chars in path parameters?
@akiel welcome! there are no route guards in reitit, by design. I think such a thing could be built already, but making it performant would be non-trivial.
it would basically be linear matching on guarded routes and allowing some kind of guard function to ignore a match (and finding next match).
one thing I was thinking was to add a route data hint :conflicting
etc, which would allow one to mark conflicting routes manually. This way, if there is just few routes conflicting, marking them would allow the conflict resolution to be enabled for other routes.
Understand. I have routes like Patient/{id} and Patient/_history, were Idās canāt contain underscores. So in this special case I could think about a performant implementation. But in a general guard case you are right.
you can order the routes like so that Patient/_history
is first, Patient/{id}
is second. If you disable the conflict resolution, they (only the conflicting ones) will be run in order so the first one matches.
@tonsky had a nice sorted which reordered the routes automatically so that the wildcards are last, in some gist..
actually, it was on pedestal, but ported that to reitit, hereās the gist: https://gist.github.com/ikitommi/d3382348ac50639ae7914ffc0f19bb0f. Original: https://tonsky.me/blog/pedestal/