From de2d810b7cae7f4fe062d5f6817139b127a2f006 Mon Sep 17 00:00:00 2001 From: Joel Kaasinen Date: Wed, 15 Mar 2023 16:51:01 +0200 Subject: [PATCH] test: multiple parts in multipart-test --- test/cljc/reitit/openapi_test.clj | 38 +++++++++++++++++++------------ 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/test/cljc/reitit/openapi_test.clj b/test/cljc/reitit/openapi_test.clj index 80d18f8b..7e9bfcda 100644 --- a/test/cljc/reitit/openapi_test.clj +++ b/test/cljc/reitit/openapi_test.clj @@ -432,25 +432,32 @@ (is (nil? (validate spec)))))))) (deftest multipart-test - (doseq [[coercion file-schema] - [[#'malli/coercion [:map {:json-schema {:type "string" - :format "binary"}} - [:filename :string] - [:content-type :string] - [:bytes :int]]] - [#'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]]] + (doseq [[coercion file-schema string-schema] + [[#'malli/coercion + [:map {:json-schema {:type "string" + :format "binary"}} + [:filename :string] + [:content-type :string] + [:bytes :int]] + :string] + [#'schema/coercion + (schema-tools.core/schema {:filename s/Str + :content-type s/Str + :bytes s/Num} + {:openapi {:type "string" + :format "binary"}}) + s/Str] + [#'spec/coercion + reitit.http.interceptors.multipart/bytes-part + string?]]] (testing coercion (let [app (ring/ring-handler (ring/router [["/upload" {:post {:decription "upload" :coercion @coercion - :parameters {:multipart {:file file-schema}} + :parameters {:multipart {:file file-schema + :more string-schema}} :handler identity}}] ["/openapi.json" {:get {:handler (openapi/create-openapi-handler) @@ -465,8 +472,9 @@ (is (nil? (get-in spec [:paths "/upload" :post :parameters]))) (is (= (merge {:type "object" :properties {:file {:type "string" - :format "binary"}} - :required ["file"]} + :format "binary"} + :more {:type "string"}} + :required ["file" "more"]} (when-not (= #'spec/coercion coercion) {:additionalProperties false})) (-> spec