mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 00:11:11 +00:00
Add regression test for swagger-spec 3arity handler
This commit is contained in:
parent
8bb5755ced
commit
cca55c5bd5
1 changed files with 67 additions and 60 deletions
|
|
@ -68,66 +68,73 @@
|
||||||
(testing "swagger-spec"
|
(testing "swagger-spec"
|
||||||
(let [spec (:body (app
|
(let [spec (:body (app
|
||||||
{:request-method :get
|
{:request-method :get
|
||||||
:uri "/api/swagger.json"}))]
|
:uri "/api/swagger.json"}))
|
||||||
(is (= {:x-id #{::math}
|
expected {:x-id #{::math}
|
||||||
:swagger "2.0"
|
:swagger "2.0"
|
||||||
:info {:title "my-api"}
|
:info {:title "my-api"}
|
||||||
:paths {"/api/schema/plus/{z}" {:get {:parameters [{:description ""
|
:paths {"/api/schema/plus/{z}" {:get {:parameters [{:description ""
|
||||||
:format "int32"
|
:format "int32"
|
||||||
:in "query"
|
:in "query"
|
||||||
:name "x"
|
:name "x"
|
||||||
:required true
|
:required true
|
||||||
:type "integer"}
|
:type "integer"}
|
||||||
{:description ""
|
{:description ""
|
||||||
:format "int32"
|
:format "int32"
|
||||||
:in "query"
|
:in "query"
|
||||||
:name "y"
|
:name "y"
|
||||||
:required true
|
:required true
|
||||||
:type "integer"}
|
:type "integer"}
|
||||||
{:in "path"
|
{:in "path"
|
||||||
:name "z"
|
:name "z"
|
||||||
:description ""
|
:description ""
|
||||||
:type "integer"
|
:type "integer"
|
||||||
:required true
|
:required true
|
||||||
:format "int32"}]
|
:format "int32"}]
|
||||||
:responses {200 {:description ""
|
:responses {200 {:description ""
|
||||||
:schema {:additionalProperties false
|
:schema {:additionalProperties false
|
||||||
:properties {"total" {:format "int32"
|
:properties {"total" {:format "int32"
|
||||||
:type "integer"}}
|
:type "integer"}}
|
||||||
:required ["total"]
|
:required ["total"]
|
||||||
:type "object"}}
|
:type "object"}}
|
||||||
400 {:schema {:type "string"}
|
400 {:schema {:type "string"}
|
||||||
:description "kosh"}
|
:description "kosh"}
|
||||||
500 {:description "fail"}}
|
500 {:description "fail"}}
|
||||||
:summary "plus"}}
|
:summary "plus"}}
|
||||||
"/api/spec/plus/{z}" {:get {:parameters [{:description ""
|
"/api/spec/plus/{z}" {:get {:parameters [{:description ""
|
||||||
:format "int64"
|
:format "int64"
|
||||||
:in "query"
|
:in "query"
|
||||||
:name "x"
|
:name "x"
|
||||||
:required true
|
:required true
|
||||||
:type "integer"}
|
:type "integer"}
|
||||||
{:description ""
|
{:description ""
|
||||||
:format "int64"
|
:format "int64"
|
||||||
:in "query"
|
:in "query"
|
||||||
:name "y"
|
:name "y"
|
||||||
:required true
|
:required true
|
||||||
:type "integer"}
|
:type "integer"}
|
||||||
{:in "path"
|
{:in "path"
|
||||||
:name "z"
|
:name "z"
|
||||||
:description ""
|
:description ""
|
||||||
:type "integer"
|
:type "integer"
|
||||||
:required true
|
:required true
|
||||||
:format "int64"}]
|
:format "int64"}]
|
||||||
:responses {200 {:description ""
|
:responses {200 {:description ""
|
||||||
:schema {:properties {"total" {:format "int64"
|
:schema {:properties {"total" {:format "int64"
|
||||||
:type "integer"}}
|
:type "integer"}}
|
||||||
:required ["total"]
|
:required ["total"]
|
||||||
:type "object"}}
|
:type "object"}}
|
||||||
400 {:schema {:type "string"}
|
400 {:schema {:type "string"}
|
||||||
:description "kosh"}
|
:description "kosh"}
|
||||||
500 {:description "fail"}}
|
500 {:description "fail"}}
|
||||||
:summary "plus"}}}}
|
:summary "plus"}}}}]
|
||||||
spec)))))
|
(is (= expected spec))
|
||||||
|
|
||||||
|
(testing "ring-async swagger-spec"
|
||||||
|
(let [response* (atom nil)
|
||||||
|
respond (partial reset! response*)]
|
||||||
|
(app {:request-method :get
|
||||||
|
:uri "/api/swagger.json"} respond (fn [_] (is false)))
|
||||||
|
(is (= expected (:body @response*))))))))
|
||||||
|
|
||||||
(defn spec-paths [app uri]
|
(defn spec-paths [app uri]
|
||||||
(-> {:request-method :get, :uri uri} app :body :paths keys))
|
(-> {:request-method :get, :uri uri} app :body :paths keys))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue