mirror of
https://github.com/metosin/reitit.git
synced 2025-12-23 18:41:11 +00:00
just validation
This commit is contained in:
parent
ea5ec93793
commit
f41006c8bb
1 changed files with 13 additions and 0 deletions
|
|
@ -208,6 +208,13 @@
|
|||
(ring/router
|
||||
["/api"
|
||||
|
||||
["/custom" {:summary "just validation"
|
||||
:coercion (reitit.coercion.malli/create {:transformers {}})
|
||||
:post {:parameters {:body [:map [:x int?]]}
|
||||
:responses {200 {:body [:map [:x int?]]}}
|
||||
:handler (fn [req]
|
||||
{:status 200
|
||||
:body (-> req :parameters :body)})}}]
|
||||
["/or" {:post {:summary "accepts either of two map schemas"
|
||||
:parameters {:body or-maps-schema}
|
||||
:responses {200 {:body [:map [:msg string?]]}}
|
||||
|
|
@ -265,6 +272,12 @@
|
|||
rrc/coerce-request-middleware
|
||||
rrc/coerce-response-middleware])]
|
||||
|
||||
(testing "just validation"
|
||||
(is (= 400 (:status (app {:uri "/api/custom"
|
||||
:request-method :post
|
||||
:muuntaja/request {:format "application/edn"}
|
||||
:body-params 123})))))
|
||||
|
||||
(testing "or #407"
|
||||
(is (= {:status 200
|
||||
:body {:msg "you sent x"}}
|
||||
|
|
|
|||
Loading…
Reference in a new issue