mirror of
https://github.com/metosin/reitit.git
synced 2025-12-18 08:51:12 +00:00
feat: openapi3 multipart support for schema
This commit is contained in:
parent
60f53d7e7c
commit
acbcec1ed9
2 changed files with 11 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue