This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-16
Channels
- # announcements (1)
- # babashka (23)
- # beginners (157)
- # boot (3)
- # calva (2)
- # chlorine-clover (12)
- # cider (14)
- # clara (5)
- # clj-kondo (6)
- # cljs-dev (61)
- # cljsrn (30)
- # clojure (65)
- # clojure-argentina (8)
- # clojure-berlin (2)
- # clojure-europe (13)
- # clojure-france (9)
- # clojure-germany (2)
- # clojure-italy (4)
- # clojure-nl (6)
- # clojure-portugal (2)
- # clojure-romania (2)
- # clojure-uk (76)
- # clojurescript (56)
- # conjure (52)
- # core-async (37)
- # datomic (209)
- # duct (17)
- # emacs (17)
- # exercism (1)
- # fulcro (26)
- # graalvm (5)
- # instaparse (2)
- # jackdaw (9)
- # jobs-discuss (27)
- # joker (2)
- # juxt (23)
- # leiningen (4)
- # malli (11)
- # midje (3)
- # pedestal (2)
- # quil (2)
- # re-frame (78)
- # reagent (8)
- # reitit (18)
- # remote-jobs (1)
- # ring (2)
- # ring-swagger (1)
- # shadow-cljs (29)
- # sql (11)
- # test-check (12)
- # tools-deps (5)
- # xtdb (16)
- # yada (4)
Do I must use the wrap-keyword-param
Ring middleware ?
Or maybe Reitit Ring Coercion ?
I can see this information on this issue https://github.com/metosin/reitit/issues/85:
> wrap-keyword-params
(reitit coercion does this, so not needed?)
@U055NJ5CC I found one of your answers who seems confirm that wrap-keyword-params
is not mandatory to keywordize.
Can you confirm please ? Any clue ? 🙂
https://clojurians-log.clojureverse.org/reitit/2018-07-30/1532938985.000098
@UFBL6R4P3 the coercion middleware does the key transformations for all defined :parameter
s. So, if you use coercion, it’s not needed
Well, thank for your guidance! I will read the coercion documentation further!
How do I make a field a password field with swagger? I'm trying to translate https://swagger.io/docs/specification/data-models/data-types/ to edn and have tried:
["/auth" {:post auth-handler
:swagger {:parameters {:password {:type :string
:format :password}}}
:parameters {:form {:username string?
:password string?}}}]
That adds an unlabelled extra field. I also tried changing the :password entry in the form block to {:type :string :format :password} but no dice. Does anyone here know the right way to do it? Thanks!the swagger parameter syntax doesn"t look right. I believe it accepts a vector of maps. But I think wrapping the actual spec predicate might be easier here: {:parameters {:form {:password (spec-tools.core/spec {:spec string? :swagger {:type "string", :format "password"}}) ...}}}
might work.
Thanks for the tip. I tried this based on what you suggested:
["/auth" {:post auth-handler
:swagger {:security {}}
:parameters {:form {:username string?
:password (spec-tools.core/spec {:spec string?
:swagger {:type "string"
:format "password"}})}}}]
It still is showing the password field in plaintext. Any ideas?hello, @U0JUR9FPH could you try the following:
(st/spec {:spec string?
:description {:swagger {:type "string"
:format "password"}}})
sorry bad formatting, im not enjoying this new ui 😕If I understand you right, you are suggesting this:
["/auth" {:post auth-handler
:swagger {:security {}}
:parameters {:form {:username string?
:password (spec-tools.core/spec {:spec string?
:description {:swagger {:type "string"
:format "password"}}})}}}]
Still show the password.The description is now [object Object].
Is there a "passthrough" coercion or something in which you can just use edn which is translated to swagger json? If it matter, I am using the
reitit.coercion.spec/coercion
coercion.if I got this right, the transformation is handled by
1. spec-tools.swagger.core/transform
and the extra arg format
is not interpreted correctly there, because it shares some code with json-schema transformation which expects this extra :description
therefore:We currenttly have:
(spec-tools.swagger.core/transform
(st/spec {:spec string?
:swagger {:type "string"
:format "password"}}))
;; => {:type "string"}
{:type "string"
:format "password"}
EDIT: missed the point here.. there is already a dispatch specifically for swagger.@U0JUR9FPH sorry for the trial and error.. seems like spec-tools.swagger is expecting namespaced keys
Awesome! It worked. For completeness should anyone be looking, here is the complete route:
["/auth" {:post auth-handler
:swagger {:security {}}
:parameters {:form {:username string?
:password (st/spec {:spec string?
:swagger/type "string"
:swagger/format "password"})}}}]
Thanks again for all the help!awesome! #malli supports the plain :swagger
too, it seems it's not backported to spec-tools.
@U055NJ5CC the backport is very simple, I made the change at https://github.com/metosin/spec-tools/pull/229 .. you can use
(st/spec {:spec string?
:swagger {:type "string"}
:swagger/format "password"})
;;=> {:type "string" :format "password"}
if you desired too.. my ocd does not allow me but.. people. rsrs