This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-12
Channels
- # announcements (65)
- # aws (1)
- # babashka (12)
- # beginners (111)
- # bristol-clojurians (1)
- # cider (32)
- # clj-kondo (55)
- # clojars (3)
- # clojure (71)
- # clojure-europe (17)
- # clojure-france (4)
- # clojure-italy (36)
- # clojure-losangeles (8)
- # clojure-nl (6)
- # clojure-uk (115)
- # clojurescript (2)
- # datomic (99)
- # fulcro (32)
- # graalvm (12)
- # graphql (20)
- # hoplon (203)
- # meander (56)
- # mount (3)
- # off-topic (17)
- # pathom (17)
- # reitit (22)
- # shadow-cljs (32)
- # spacemacs (9)
- # tools-deps (19)
- # vim (25)
- # vscode (3)
So I'm using reitit.ring.coercion with retitit.coercion.spec and I noticed an inconsistency in query parameter handling: Let's say I have a spec like (s/def ::numbers (s/coll-of int?))
and I use that as query param, the swagger ui will render a ui that looks like the screenshot which is cool and all, but the parameter will be concatenated in the url, like numbers=1,2,3
instead of the expected format numbers=1&numbers=2&numbers=3
The solution seems to be defining collectionFormat=multi
as noted here: https://swagger.io/docs/specification/2-0/describing-parameters/#array-and-multi-value-parameters
@U055NJ5CC where would be the place to fix this? here? I'm not very familiar with the codebasehttps://github.com/metosin/spec-tools/blob/master/src/spec_tools/swagger/core.cljc#L59-L63
looks like it. You should check for the parameter type, this applies only for query params, right? See https://github.com/metosin/spec-tools/blob/master/src/spec_tools/swagger/core.cljc#L76
This should work too: (s/def ::numbers (st/spec {:spec (s/coll-of int?), :swagger/collectionFormat "multi"}))
e.g. all keys with swagger
ns are pushed to swagger docs. didn’t test that, but recall it’s so 🙂
Do people have comments on default exception handling? The current “don’t log, don’t tell users too much about errors” is not the friendliest detault (with reitit-ring
).
copying this from projects:
(exception/create-exception-middleware
(merge
exception/default-handlers
{::exception/wrap (fn [handler ^Exception e request]
(log/error e (.getMessage e))
(handler e request))}))
(defn logging-compile
[logger
{{:keys [enabled? log-start-fn log-end-fn log-error-fn]
:or {enabled? false
log-start-fn default-log-start
log-end-fn default-log-end
log-error-fn default-log-error}}
:logging} _]
(when enabled?
{:enter (fn logging-interceptor-enter [ctx]
(let [ctx' (add-start-nano ctx)]
(when log-start-fn
(log-start-fn logger ctx'))
ctx'))
:leave (fn logging-interceptor-leave [ctx]
(when log-end-fn
(log-end-fn logger ctx))
ctx)
:error (fn logging-interceptor-error [ctx]
(when log-error-fn
(log-error-fn logger ctx))
ctx)}))
(defn logging-interceptor
[logger]
{:name ::logging
:spec ::logging-interceptor
:compile (partial logging-compile logger)})
Separate ns with clojure.tools.logging handlers would work in many cases
yep, that’s what we use as well, but I think it’s application/endpoint dependent what/how you want to log. Though thing to tackle generally
I'm looking for a clean back-button interception method the ask confirmation when they are leaving unsaved data, and doesn't make changes to the history stack or use reitit controllers if they say "no." Surely someone here has dealt with this?
Standard javascript solutions want a window.beforeunload call with a conf; I'm not sure how this will behave with SPA, but other solutoins with react-router does the job, so it would make sense to have this in reitit's provenance