diff --git a/modules/reitit-schema/src/reitit/coercion/schema.cljc b/modules/reitit-schema/src/reitit/coercion/schema.cljc index 07dc5ce6..ce66e153 100644 --- a/modules/reitit-schema/src/reitit/coercion/schema.cljc +++ b/modules/reitit-schema/src/reitit/coercion/schema.cljc @@ -70,7 +70,7 @@ (update $ :schema #(coercion/-compile-model this % nil)) $))]))}))) :openapi (merge - (when (seq (dissoc parameters :body :request)) + (when (seq (dissoc parameters :body :request :multipart)) (openapi/openapi-spec {::openapi/parameters (into (empty parameters) @@ -85,6 +85,10 @@ (when-let [default (get-in parameters [:request :body])] (zipmap content-types (repeat default))) (:content (:request parameters)))})}) + (when (:multipart parameters) + {:requestBody + (openapi/openapi-spec + {::openapi/content {"multipart/form-data" (:multipart parameters)}})}) (when responses {:responses (into diff --git a/test/cljc/reitit/openapi_test.clj b/test/cljc/reitit/openapi_test.clj index 3f789a47..80d18f8b 100644 --- a/test/cljc/reitit/openapi_test.clj +++ b/test/cljc/reitit/openapi_test.clj @@ -15,6 +15,7 @@ [reitit.ring.coercion :as rrc] [reitit.swagger-ui :as swagger-ui] [schema.core :as s] + [schema-tools.core] [spec-tools.data-spec :as ds])) (defn validate @@ -437,7 +438,11 @@ [:filename :string] [:content-type :string] [:bytes :int]]] - #_[#'schema/coercion (fn [nom] {nom s/Str})] + [#'schema/coercion (schema-tools.core/schema {:filename s/Str + :content-type s/Str + :bytes s/Num} + {:openapi {:type "string" + :format "binary"}})] [#'spec/coercion reitit.http.interceptors.multipart/bytes-part]]] (testing coercion (let [app (ring/ring-handler