Fork me on GitHub
An Li01:04:32

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

(s/def ::city #{:tre :hki})
(s/def ::address (s/keys :req-un [::street ::city]))

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


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


You would need to specify coercion in both places, here is a small example

:put    {:handler    ...
         :middleware ...
         :parameters {:path {:recipe-id string?}
                      :body {:name string? :prep-time number? :public boolean? :img string?}}
         :responses  ...}
         :summary    "Update recipe"}
The coercion is done with coercion spec. Hope it helps


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.