Fork me on GitHub
Michaël Salihi08:04:32

Do I must use the wrap-keyword-param Ring middleware ? Or maybe Reitit Ring Coercion ? I can see this information on this issue > wrap-keyword-params (reitit coercion does this, so not needed?)

Michaël Salihi13:04:10

@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 ? 🙂


@UFBL6R4P3 the coercion middleware does the key transformations for all defined :parameters. So, if you use coercion, it’s not needed

Michaël Salihi13:04:47

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 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



if I got this right, the transformation is handled by 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: 1. We currenttly have:

 (st/spec {:spec    string?
           :swagger {:type   "string"
                     :format "password"}}))
;; => {:type "string"}
We expect
{: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


(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!

👍 4

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 .. 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