mirror of
https://github.com/metosin/reitit.git
synced 2026-02-01 18:30:33 +00:00
test: multiple parts in multipart-test
This commit is contained in:
parent
acbcec1ed9
commit
de2d810b7c
1 changed files with 23 additions and 15 deletions
|
|
@ -432,25 +432,32 @@
|
||||||
(is (nil? (validate spec))))))))
|
(is (nil? (validate spec))))))))
|
||||||
|
|
||||||
(deftest multipart-test
|
(deftest multipart-test
|
||||||
(doseq [[coercion file-schema]
|
(doseq [[coercion file-schema string-schema]
|
||||||
[[#'malli/coercion [:map {:json-schema {:type "string"
|
[[#'malli/coercion
|
||||||
:format "binary"}}
|
[:map {:json-schema {:type "string"
|
||||||
[:filename :string]
|
:format "binary"}}
|
||||||
[:content-type :string]
|
[:filename :string]
|
||||||
[:bytes :int]]]
|
[:content-type :string]
|
||||||
[#'schema/coercion (schema-tools.core/schema {:filename s/Str
|
[:bytes :int]]
|
||||||
:content-type s/Str
|
:string]
|
||||||
:bytes s/Num}
|
[#'schema/coercion
|
||||||
{:openapi {:type "string"
|
(schema-tools.core/schema {:filename s/Str
|
||||||
:format "binary"}})]
|
:content-type s/Str
|
||||||
[#'spec/coercion reitit.http.interceptors.multipart/bytes-part]]]
|
:bytes s/Num}
|
||||||
|
{:openapi {:type "string"
|
||||||
|
:format "binary"}})
|
||||||
|
s/Str]
|
||||||
|
[#'spec/coercion
|
||||||
|
reitit.http.interceptors.multipart/bytes-part
|
||||||
|
string?]]]
|
||||||
(testing coercion
|
(testing coercion
|
||||||
(let [app (ring/ring-handler
|
(let [app (ring/ring-handler
|
||||||
(ring/router
|
(ring/router
|
||||||
[["/upload"
|
[["/upload"
|
||||||
{:post {:decription "upload"
|
{:post {:decription "upload"
|
||||||
:coercion @coercion
|
:coercion @coercion
|
||||||
:parameters {:multipart {:file file-schema}}
|
:parameters {:multipart {:file file-schema
|
||||||
|
:more string-schema}}
|
||||||
:handler identity}}]
|
:handler identity}}]
|
||||||
["/openapi.json"
|
["/openapi.json"
|
||||||
{:get {:handler (openapi/create-openapi-handler)
|
{:get {:handler (openapi/create-openapi-handler)
|
||||||
|
|
@ -465,8 +472,9 @@
|
||||||
(is (nil? (get-in spec [:paths "/upload" :post :parameters])))
|
(is (nil? (get-in spec [:paths "/upload" :post :parameters])))
|
||||||
(is (= (merge {:type "object"
|
(is (= (merge {:type "object"
|
||||||
:properties {:file {:type "string"
|
:properties {:file {:type "string"
|
||||||
:format "binary"}}
|
:format "binary"}
|
||||||
:required ["file"]}
|
:more {:type "string"}}
|
||||||
|
:required ["file" "more"]}
|
||||||
(when-not (= #'spec/coercion coercion)
|
(when-not (= #'spec/coercion coercion)
|
||||||
{:additionalProperties false}))
|
{:additionalProperties false}))
|
||||||
(-> spec
|
(-> spec
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue