mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 08:21:11 +00:00
cleanup
This commit is contained in:
parent
550ea6da58
commit
3f265888a4
4 changed files with 138 additions and 139 deletions
|
|
@ -267,14 +267,14 @@
|
||||||
(let [pong (constantly "ok")
|
(let [pong (constantly "ok")
|
||||||
routes ["/api" {:mw [:api]}
|
routes ["/api" {:mw [:api]}
|
||||||
["/ping" :kikka]
|
["/ping" :kikka]
|
||||||
["/user/:id" {:parameters {:id "String"}}
|
["/user/:id" {:parameters {:path {:id :string}}}
|
||||||
["/:sub-id" {:parameters {:sub-id "String"}}]]
|
["/:sub-id" {:parameters {:path {:sub-id :string}}}]]
|
||||||
["/pong" pong]
|
["/pong" pong]
|
||||||
["/admin" {:mw [:admin] :roles #{:admin}}
|
["/admin" {:mw [:admin] :roles #{:admin}}
|
||||||
["/user" {:roles ^:replace #{:user}}]
|
["/user" {:roles ^:replace #{:user}}]
|
||||||
["/db" {:mw [:db]}]]]
|
["/db" {:mw [:db]}]]]
|
||||||
expected [["/api/ping" {:mw [:api], :name :kikka}]
|
expected [["/api/ping" {:mw [:api], :name :kikka}]
|
||||||
["/api/user/:id/:sub-id" {:mw [:api], :parameters {:id "String", :sub-id "String"}}]
|
["/api/user/:id/:sub-id" {:mw [:api], :parameters {:path [{:id :string} {:sub-id :string}]}}]
|
||||||
["/api/pong" {:mw [:api], :handler pong}]
|
["/api/pong" {:mw [:api], :handler pong}]
|
||||||
["/api/admin/user" {:mw [:api :admin], :roles #{:user}}]
|
["/api/admin/user" {:mw [:api :admin], :roles #{:user}}]
|
||||||
["/api/admin/db" {:mw [:api :admin :db], :roles #{:admin}}]]
|
["/api/admin/db" {:mw [:api :admin :db], :roles #{:admin}}]]
|
||||||
|
|
@ -282,7 +282,7 @@
|
||||||
(is (= expected (impl/resolve-routes routes (r/default-router-options))))
|
(is (= expected (impl/resolve-routes routes (r/default-router-options))))
|
||||||
(is (= (r/map->Match
|
(is (= (r/map->Match
|
||||||
{:template "/api/user/:id/:sub-id"
|
{:template "/api/user/:id/:sub-id"
|
||||||
:data {:mw [:api], :parameters {:id "String", :sub-id "String"}}
|
:data {:mw [:api], :parameters {:path [{:id :string} {:sub-id :string}]}}
|
||||||
:path "/api/user/1/2"
|
:path "/api/user/1/2"
|
||||||
:path-params {:id "1", :sub-id "2"}})
|
:path-params {:id "1", :sub-id "2"}})
|
||||||
(r/match-by-path router "/api/user/1/2"))))))
|
(r/match-by-path router "/api/user/1/2"))))))
|
||||||
|
|
|
||||||
|
|
@ -370,7 +370,7 @@
|
||||||
{:description (str "description " nom)})})]
|
{:description (str "description " nom)})})]
|
||||||
[#'spec/coercion (fn [nom] {nom (st/spec {:spec string?
|
[#'spec/coercion (fn [nom] {nom (st/spec {:spec string?
|
||||||
:description (str "description " nom)})})]]]
|
:description (str "description " nom)})})]]]
|
||||||
(testing coercion
|
(testing (str coercion)
|
||||||
(let [app (ring/ring-handler
|
(let [app (ring/ring-handler
|
||||||
(ring/router
|
(ring/router
|
||||||
[["/parameters"
|
[["/parameters"
|
||||||
|
|
@ -451,7 +451,7 @@
|
||||||
(assoc
|
(assoc
|
||||||
(ds/spec ::foo {nom (st/spec string? {:openapi/example "EXAMPLE"})})
|
(ds/spec ::foo {nom (st/spec string? {:openapi/example "EXAMPLE"})})
|
||||||
:openapi/example {nom "EXAMPLE2"}))]]]
|
:openapi/example {nom "EXAMPLE2"}))]]]
|
||||||
(testing coercion
|
(testing (str coercion)
|
||||||
(let [app (ring/ring-handler
|
(let [app (ring/ring-handler
|
||||||
(ring/router
|
(ring/router
|
||||||
[["/examples"
|
[["/examples"
|
||||||
|
|
@ -531,7 +531,7 @@
|
||||||
[#'spec/coercion
|
[#'spec/coercion
|
||||||
reitit.http.interceptors.multipart/bytes-part
|
reitit.http.interceptors.multipart/bytes-part
|
||||||
string?]]]
|
string?]]]
|
||||||
(testing coercion
|
(testing (str coercion)
|
||||||
(let [app (ring/ring-handler
|
(let [app (ring/ring-handler
|
||||||
(ring/router
|
(ring/router
|
||||||
[["/upload"
|
[["/upload"
|
||||||
|
|
@ -569,7 +569,7 @@
|
||||||
[[#'malli/coercion (fn [nom] [:map [nom :string]])]
|
[[#'malli/coercion (fn [nom] [:map [nom :string]])]
|
||||||
[#'schema/coercion (fn [nom] {nom s/Str})]
|
[#'schema/coercion (fn [nom] {nom s/Str})]
|
||||||
[#'spec/coercion (fn [nom] {nom string?})]]]
|
[#'spec/coercion (fn [nom] {nom string?})]]]
|
||||||
(testing coercion
|
(testing (str coercion)
|
||||||
(let [app (ring/ring-handler
|
(let [app (ring/ring-handler
|
||||||
(ring/router
|
(ring/router
|
||||||
[["/parameters"
|
[["/parameters"
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,6 @@
|
||||||
rrc/coerce-request-middleware
|
rrc/coerce-request-middleware
|
||||||
rrc/coerce-response-middleware]}})))
|
rrc/coerce-response-middleware]}})))
|
||||||
|
|
||||||
(require '[fipp.edn])
|
|
||||||
(deftest swagger-test
|
(deftest swagger-test
|
||||||
(testing "endpoints work"
|
(testing "endpoints work"
|
||||||
(testing "spec"
|
(testing "spec"
|
||||||
|
|
@ -430,7 +429,7 @@
|
||||||
[#'spec/coercion
|
[#'spec/coercion
|
||||||
reitit.http.interceptors.multipart/bytes-part
|
reitit.http.interceptors.multipart/bytes-part
|
||||||
string?]]]
|
string?]]]
|
||||||
(testing coercion
|
(testing (str coercion)
|
||||||
(let [app (ring/ring-handler
|
(let [app (ring/ring-handler
|
||||||
(ring/router
|
(ring/router
|
||||||
[["/upload"
|
[["/upload"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue