mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 16:31:11 +00:00
test: nicer handling of missing :additionalProperties for spec
This commit is contained in:
parent
0c82ce0e4d
commit
66e7c9e1c8
1 changed files with 31 additions and 24 deletions
|
|
@ -408,18 +408,21 @@
|
|||
(get-in [:paths "/parameters" :post :parameters])
|
||||
normalize))))
|
||||
(testing "body parameter"
|
||||
(is (match? {:schema {:type "object"
|
||||
(is (match? {:schema (merge {:type "object"
|
||||
:properties {:b {:type "string"}}
|
||||
#_#_:additionalProperties false ;; not present for spec
|
||||
:required ["b"]}}
|
||||
:required ["b"]}
|
||||
;; spec outputs open schemas
|
||||
(when-not (#{#'spec/coercion} coercion)
|
||||
{:additionalProperties false}))}
|
||||
(-> spec
|
||||
(get-in [:paths "/parameters" :post :requestBody :content "application/json"])
|
||||
normalize))))
|
||||
(testing "body response"
|
||||
(is (match? {:schema {:type "object"
|
||||
(is (match? {:schema (merge {:type "object"
|
||||
:properties {:ok {:type "string"}}
|
||||
#_#_:additionalProperties false ;; not present for spec
|
||||
:required ["ok"]}}
|
||||
:required ["ok"]}
|
||||
(when-not (#{#'spec/coercion} coercion)
|
||||
{:additionalProperties false}))}
|
||||
(-> spec
|
||||
(get-in [:paths "/parameters" :post :responses 200 :content "application/json"])
|
||||
normalize))))
|
||||
|
|
@ -458,32 +461,36 @@
|
|||
app
|
||||
:body)]
|
||||
(testing "body parameter"
|
||||
(is (match? {:schema {:type "object"
|
||||
(is (match? {:schema (merge {:type "object"
|
||||
:properties {:b {:type "string"}}
|
||||
#_#_:additionalProperties false ;; not present for spec
|
||||
:required ["b"]}}
|
||||
:required ["b"]}
|
||||
(when-not (#{#'spec/coercion} coercion)
|
||||
{:additionalProperties false}))}
|
||||
(-> spec
|
||||
(get-in [:paths "/parameters" :post :requestBody :content "application/json"])
|
||||
normalize)))
|
||||
(is (match? {:schema {:type "object"
|
||||
(is (match? {:schema (merge {:type "object"
|
||||
:properties {:c {:type "string"}}
|
||||
#_#_:additionalProperties false ;; not present for spec
|
||||
:required ["c"]}}
|
||||
:required ["c"]}
|
||||
(when-not (#{#'spec/coercion} coercion)
|
||||
{:additionalProperties false}))}
|
||||
(-> spec
|
||||
(get-in [:paths "/parameters" :post :requestBody :content "application/edn"])
|
||||
normalize))))
|
||||
(testing "body response"
|
||||
(is (match? {:schema {:type "object"
|
||||
(is (match? {:schema (merge {:type "object"
|
||||
:properties {:ok {:type "string"}}
|
||||
#_#_:additionalProperties false ;; not present for spec
|
||||
:required ["ok"]}}
|
||||
:required ["ok"]}
|
||||
(when-not (#{#'spec/coercion} coercion)
|
||||
{:additionalProperties false}))}
|
||||
(-> spec
|
||||
(get-in [:paths "/parameters" :post :responses 200 :content "application/json"])
|
||||
normalize)))
|
||||
(is (match? {:schema {:type "object"
|
||||
(is (match? {:schema (merge {:type "object"
|
||||
:properties {:edn {:type "string"}}
|
||||
#_#_:additionalProperties false ;; not present for spec
|
||||
:required ["edn"]}}
|
||||
:required ["edn"]}
|
||||
(when-not (#{#'spec/coercion} coercion)
|
||||
{:additionalProperties false}))}
|
||||
(-> spec
|
||||
(get-in [:paths "/parameters" :post :responses 200 :content "application/edn"])
|
||||
normalize))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue