Fork me on GitHub

Is it possible to set a maximum number with schema-tools and swagger support?


Howdy fam! how do i add http header to the following

         {:post {:summary "upload a file"
                 :parameters {:multipart {:file multipart/temp-file-part}}
                 :responses {200 {:body {:name string?, :size int?}}}
                 :handler (fn [{{{:keys [file]} :multipart} :parameters}]
                            {:status 200
                             :body {:name (:filename file)
                                    :size (:size file)}})}}]


when i try :parameters

{:header "custom-header" "custom-value"}
I get spec errors like
Request coercion failed: #reitit.coercion.CoercionError{:spec #Spec{:form (clojure.spec.alpha/keys :req-un [:spec$2980/custom-header])


I think if it were me I’d make the handler fn take the request object directly, and then pull out the parts that I wanted. The :headers key is in the request at the same level as the :parameters key so if you do what to do destructuring, I think it would have to look something like this

(fn [{{{:keys [file]} :multipart} :parameters
      {custom-value "custom-header"} :headers}]
  {:status 200
   :custom-header custom-value
   :body {:name (:filename file)
          :size (:size file)}})


None of these seem to work. {:post {:headers ...} or {:post {:parameters {:headers .. } or {:post {:parameters {:header .. } the last one at least shows up in the swagger window but i still get spec coercion errors


@kbosompem maybe {:parameters {:header {:custom-header string?}}}


@mitchelkuijpers I think so, you can have something like (s/constrained s/Int #(< % 10)) to add guard for the validation and add :swagger/maximum 10 to get the swagger docs too

metal 4

after a few hours of battling it. the parameters are case sensitive and keys remain strings unlike form, query and body params which become clojure keywords. I miss intellisense.