reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
An Li 2021-04-26T01:52:32.169200Z

How could I add swagger parameter description to :parameters :query?

"parameters":[{"in":"query","name":"street","description":"","type":"string","required":true},{"in":"query","name":"city","description":"","type":"string","required":true,"enum":["tre","hki"]}
(s/def ::city #{:tre :hki})
(s/def ::address (s/keys :req-un [::street ::city]))

 ["/test"
    {:get {:parameters {:query ::address}
           :handler (fn [] (constantly (ok)))}}]

cjsauer 2021-04-26T21:09:06.174400Z

Hello 👋 , I’m new to reitit and have a basic question: how does one integrate format negotiation with request coercion? They seem to be at odds with one another. For example, say I have a PUT endpoint that can accept both application/json in the body, or x-www-form-urlencoded . How does one specify this in the :parameters map so that coercion is applied correctly in both cases? https://cljdoc.org/d/metosin/reitit/0.5.12/doc/ring/pluggable-coercion, the :parameters map forces you to know a priori where the incoming payload is located, e.g. in the :body, or in the :form , etc

cjsauer 2021-04-27T12:57:18.177Z

Thanks for the reply. So I think :path and :body parameter sources work fine together as in your example, but it’s specifically :form and :body that appear incompatible. They both source from the body of the request, but with a different assumed encoding.