This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-10
Channels
- # adventofcode (76)
- # announcements (7)
- # aws (3)
- # babashka (75)
- # beginners (25)
- # calva (37)
- # cider (9)
- # clara (4)
- # clj-kondo (17)
- # cljsrn (1)
- # clojure (106)
- # clojure-europe (4)
- # clojure-india (2)
- # clojure-italy (12)
- # clojure-nl (27)
- # clojure-spec (33)
- # clojure-uk (20)
- # clojurescript (103)
- # clojutre (3)
- # core-async (1)
- # cryogen (10)
- # cursive (24)
- # datomic (113)
- # dirac (5)
- # emacs (12)
- # events (4)
- # fulcro (64)
- # garden (5)
- # jobs (1)
- # kaocha (5)
- # luminus (2)
- # malli (14)
- # off-topic (53)
- # planck (11)
- # re-frame (9)
- # reagent (16)
- # reitit (26)
- # remote-jobs (2)
- # shadow-cljs (137)
- # spacemacs (34)
@doubleagent you might be using too old version of Clojure, qualified-keyword?
was added in 1.9
It's possible to set optional params or put some default overridable values so that users can make a request without passing them? I searched thru the docs without luck.
:parameters {:body {:image (st/spec {:spec string? :swagger/default "/9j/4AAQSkZJRgABAQAAAQABAAD ..."})
; Can I make the following optional?
:mask-size (st/spec {:spec (s/nilable nat-int?) :swagger/default "8"}) ; I tried using nilable with no luck..
:mask-probability (st/spec {:spec (s/nilable double?) :swagger/default "0.5"})
:batch-size (st/spec {:spec (s/nilable nat-int?) :swagger/default "30"})}}
In this case I would like to express that image
must be passed and other params are optional. Am I missing something?@beltramo.ale here's the complete guide for data-specs: https://cljdoc.org/d/metosin/spec-tools/0.10.0/doc/data-specs
Thanks for the quick reply but I don't see how that can apply to my issue. Maybe I didn't explain well my issue.
Sorry to bother you, where should I put the data-spec definition? I tried
:parameters {:body {:image (st/spec {:spec string? :swagger/default "/9j/4AAQSkZJRgABAQAAAQABAAD ..."})
:mask-size (ds/opt nat-int?)
:mask-probability (ds/opt double?)
:batch-size (ds/opt nat-int?)}}
and
:parameters {:body {:image (st/spec {:spec string? :swagger/default "/9j/4AAQSkZJRgABAQAAAQABAAD ..."})
; Can I make the following optional?
:mask-size (st/spec {:spec (ds/opt nat-int?) :swagger/default "8"}) ; I tried using nilable with no luck..
:mask-probability (st/spec {:spec (ds/opt double?) :swagger/default "0.5"})
:batch-size (st/spec {:spec (ds/opt nat-int?) :swagger/default "30"})}}
and
:parameters {:body {:image (st/spec {:spec string? :swagger/default "/9j/4AAQSkZJRgABAQAAAQABAAD ..."})
:mask-size (ds/spec (ds/opt nat-int?))
:mask-probability (ds/spec (ds/opt double?))
:batch-size (ds/spec (ds/opt nat-int?))}}
and
:parameters {:body {:image (st/spec {:spec string? :swagger/default "/9j/4AAQSkZJRgABAQAAAQABAAD ..."})
:mask-size (ds/spec {:spec {::size (ds/opt nat-int?)}})
:mask-probability (ds/spec {:spec {::prob (ds/opt double?)}})
:batch-size (ds/spec {:spec {::batch (ds/opt nat-int?)}})}}
but I still got Request coercion failed
if I'm not passing one of the optionals.:parameters {:body {:image (st/spec {:spec string? :swagger/default "/9j/4AAQSkZJRgABAQAAAQABAAD ..."})
(ds/opt :mask-size) nat-int?}}
I'm afraid that it's not working. I still got coercion failed [...] (clojure.core/contains? % :mask-size)
My bad, manual shut down and reload the JVM sorted it out. Thanks for the help, seems working now.
@ikitommi thanks!
I've got this namespace: http://dpaste.com/0D5VRNM. If make changes to hello-world
and re-eval then I am able to see the changes after a page refresh. However, if cc-routes
looks like this: ["/" {:get hello-world}]
I won't see changes after a re-eval. What's the difference?
@doubleagent the routes are compiled (and cached) when a router is created. To reset the router after changes in routes, you should use a tool like tools.namespace
, Integrant-repl or a file watcher
https://github.com/clojure/tools.namespace/blob/master/README.md#reloading-code-usage
@ikitommi are you saying the router doesn't lookup hello-world
when the second form is used?
instead it uses a cached version of the function
for performance, i'm guessing?
I worked around it by wrapping the call to ring-handler
in a fn which takes a request.
found some guides on https://cljdoc.org/d/metosin/reitit/0.3.10/doc/advanced/dev-workflow
ah, thanks. probably should have read through this first