test: simplify openapi_test.clj a bit more

This commit is contained in:
Joel Kaasinen 2023-03-15 16:01:57 +02:00
parent bcd12d9f31
commit d0ff64df57

View file

@ -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