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?)
@ikitommi 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
@admin055 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!@ikitommi 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. rsrsthe 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, @markbastian 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.@markbastian sorry for the trial and error.. seems like spec-tools.swagger is expecting namespaced keys
(st/spec {:spec string? :swagger/type "string" :swagger/format "password"})
should work.
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!