From d0ff64df57c5c31ea6280ab5f0d6c92213ebd197 Mon Sep 17 00:00:00 2001 From: Joel Kaasinen Date: Wed, 15 Mar 2023 16:01:57 +0200 Subject: [PATCH] test: simplify openapi_test.clj a bit more --- test/cljc/reitit/openapi_test.clj | 74 +++++++++++++++---------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/test/cljc/reitit/openapi_test.clj b/test/cljc/reitit/openapi_test.clj index 6ae134b2..3db5533f 100644 --- a/test/cljc/reitit/openapi_test.clj +++ b/test/cljc/reitit/openapi_test.clj @@ -408,23 +408,23 @@ (get-in [:paths "/parameters" :post :parameters]) normalize)))) (testing "body parameter" - (is (match? {:schema (merge {:type "object" - :properties {:b {:type "string"}} - :required ["b"]} - ;; spec outputs open schemas - (when-not (#{#'spec/coercion} coercion) - {:additionalProperties false}))} + (is (match? (merge {:type "object" + :properties {:b {:type "string"}} + :required ["b"]} + ;; spec outputs open schemas + (when-not (#{#'spec/coercion} coercion) + {:additionalProperties false})) (-> spec - (get-in [:paths "/parameters" :post :requestBody :content "application/json"]) + (get-in [:paths "/parameters" :post :requestBody :content "application/json" :schema]) normalize)))) (testing "body response" - (is (match? {:schema (merge {:type "object" - :properties {:ok {:type "string"}} - :required ["ok"]} - (when-not (#{#'spec/coercion} coercion) - {:additionalProperties false}))} + (is (match? (merge {:type "object" + :properties {:ok {:type "string"}} + :required ["ok"]} + (when-not (#{#'spec/coercion} coercion) + {:additionalProperties false})) (-> spec - (get-in [:paths "/parameters" :post :responses 200 :content "application/json"]) + (get-in [:paths "/parameters" :post :responses 200 :content "application/json" :schema]) normalize)))) (testing "spec is valid" (is (nil? (validate spec)))))))) @@ -461,38 +461,38 @@ app :body)] (testing "body parameter" - (is (match? {:schema (merge {:type "object" - :properties {:b {:type "string"}} - :required ["b"]} - (when-not (#{#'spec/coercion} coercion) - {:additionalProperties false}))} + (is (match? (merge {:type "object" + :properties {:b {:type "string"}} + :required ["b"]} + (when-not (#{#'spec/coercion} coercion) + {:additionalProperties false})) (-> spec - (get-in [:paths "/parameters" :post :requestBody :content "application/json"]) + (get-in [:paths "/parameters" :post :requestBody :content "application/json" :schema]) normalize))) - (is (match? {:schema (merge {:type "object" - :properties {:c {:type "string"}} - :required ["c"]} - (when-not (#{#'spec/coercion} coercion) - {:additionalProperties false}))} + (is (match? (merge {:type "object" + :properties {:c {:type "string"}} + :required ["c"]} + (when-not (#{#'spec/coercion} coercion) + {:additionalProperties false})) (-> spec - (get-in [:paths "/parameters" :post :requestBody :content "application/edn"]) + (get-in [:paths "/parameters" :post :requestBody :content "application/edn" :schema]) normalize)))) (testing "body response" - (is (match? {:schema (merge {:type "object" - :properties {:ok {:type "string"}} - :required ["ok"]} - (when-not (#{#'spec/coercion} coercion) - {:additionalProperties false}))} + (is (match? (merge {:type "object" + :properties {:ok {:type "string"}} + :required ["ok"]} + (when-not (#{#'spec/coercion} coercion) + {:additionalProperties false})) (-> spec - (get-in [:paths "/parameters" :post :responses 200 :content "application/json"]) + (get-in [:paths "/parameters" :post :responses 200 :content "application/json" :schema]) normalize))) - (is (match? {:schema (merge {:type "object" - :properties {:edn {:type "string"}} - :required ["edn"]} - (when-not (#{#'spec/coercion} coercion) - {:additionalProperties false}))} + (is (match? (merge {:type "object" + :properties {:edn {:type "string"}} + :required ["edn"]} + (when-not (#{#'spec/coercion} coercion) + {:additionalProperties false})) (-> spec - (get-in [:paths "/parameters" :post :responses 200 :content "application/edn"]) + (get-in [:paths "/parameters" :post :responses 200 :content "application/edn" :schema]) normalize)))) (testing "validation" (let [query {:request-method :post