diff --git a/src/compojure/api/meta.clj b/src/compojure/api/meta.clj
index 004da161..4a2a4e38 100644
--- a/src/compojure/api/meta.clj
+++ b/src/compojure/api/meta.clj
@@ -766,7 +766,7 @@
(and (seq? body)
(boolean
(when-some [v (resolve-var &env (first body))]
- (when (middleware-vars (symbol v))
+ (when (middleware-vars (var->sym v))
(let [[_ mid & body] body]
(and (static-form? &env mid)
(static-body? &env body))))))))
diff --git a/src/compojure/api/middleware.clj b/src/compojure/api/middleware.clj
index 86f637d1..c3edda43 100644
--- a/src/compojure/api/middleware.clj
+++ b/src/compojure/api/middleware.clj
@@ -321,6 +321,8 @@
(defn- ring-middleware-format-api-middleware
[handler options]
+ (require 'ring.middleware.format-params
+ 'ring.middleware.format-response)
(let [{:keys [exceptions format components]} options
{:keys [formats params-opts response-opts]} format]
(cond-> handler
@@ -329,12 +331,12 @@
(seq formats) (rsm/wrap-swagger-data {:produces (->mime-types (remove response-only-mimes formats))
:consumes (->mime-types formats)})
true (wrap-options (select-keys options [:ring-swagger :coercion]))
- (seq formats) ((requiring-resolve 'ring.middleware.format-params/wrap-restful-params)
+ (seq formats) ((resolve 'ring.middleware.format-params/wrap-restful-params)
{:formats (remove response-only-mimes formats)
:handle-error handle-req-error
:format-options params-opts})
exceptions (wrap-exceptions exceptions)
- (seq formats) ((requiring-resolve 'ring.middleware.format-response/wrap-restful-response)
+ (seq formats) ((resolve 'ring.middleware.format-response/wrap-restful-response)
{:formats formats
:predicate serializable?
:format-options response-opts})
diff --git a/test/compojure/api/integration_test.clj b/test/compojure/api/integration_test.clj
index dc430c78..e8a022da 100644
--- a/test/compojure/api/integration_test.clj
+++ b/test/compojure/api/integration_test.clj
@@ -553,90 +553,87 @@
:definitions {}
:paths {"/user" {:get {:responses {:default {:description ""}}}}}}))))
- (fact "swagger-routes"
+ (testing "swagger-routes"
- (fact "with defaults"
+ (testing "with defaults"
(let [app (api (swagger-routes))]
- (fact "api-docs are mounted to /"
+ (testing "api-docs are mounted to /"
(let [[status body] (raw-get* app "/")]
- status => 200
- body => #"
Swagger UI"))
+ (is (= 200 status))
+ (is (str/includes? body "Swagger UI"))))
- (fact "spec is mounted to /swagger.json"
+ (testing "spec is mounted to /swagger.json"
(let [[status body] (get* app "/swagger.json")]
- status => 200
- body => (contains {:swagger "2.0"})))))
+ (is (= 200 status))
+ (is (= "2.0" (:swagger body)))))))
- (fact "with partial overridden values"
+ (testing "with partial overridden values"
(let [app (api (swagger-routes {:ui "/api-docs"
:data {:info {:title "Kikka"}
:paths {"/ping" {:get {}}}}}))]
- (fact "api-docs are mounted"
+ (testing "api-docs are mounted"
(let [[status body] (raw-get* app "/api-docs")]
- status => 200
- body => #"Swagger UI"))
+ (is (= 200 status))
+ (is (str/includes? body "Swagger UI"))))
- (fact "spec is mounted to /swagger.json"
+ (testing "spec is mounted to /swagger.json"
(let [[status body] (get* app "/swagger.json")]
- status => 200
- body => (contains
- {:swagger "2.0"
- :info (contains
- {:title "Kikka"})
- :paths (contains
- {(keyword "/ping") anything})}))))))
+ (is (= 200 status))
+ (is (= "2.0" (:swagger body)))
+ (is (= "Kikka" (-> body :info :title)))
+ (is (some? (-> body :paths (get (keyword "/ping"))))))))))
- (fact "swagger via api-options"
+ (testing "swagger via api-options"
- (fact "with defaults"
+ (testing "with defaults"
(let [app (api)]
- (fact "api-docs are not mounted"
+ (testing "api-docs are not mounted"
(let [[status body] (raw-get* app "/")]
- status => nil))
+ (is (nil? status))))
- (fact "spec is not mounted"
+ (testing "spec is not mounted"
(let [[status body] (get* app "/swagger.json")]
- status => nil))))
+ (is (nil? status))))))
- (fact "with spec"
+ (testing "with spec"
(let [app (api {:swagger {:spec "/swagger.json"}})]
- (fact "api-docs are not mounted"
+ (testing "api-docs are not mounted"
(let [[status body] (raw-get* app "/")]
- status => nil))
+ (is (nil? status))))
- (fact "spec is mounted to /swagger.json"
+ (testing "spec is mounted to /swagger.json"
(let [[status body] (get* app "/swagger.json")]
- status => 200
- body => (contains {:swagger "2.0"}))))))
+ (is (nil? status))
+ (is (= "2.0" (:swagger body))))))))
- (fact "with ui"
+ (testing "with ui"
(let [app (api {:swagger {:ui "/api-docs"}})]
- (fact "api-docs are mounted"
+ (testing "api-docs are mounted"
(let [[status body] (raw-get* app "/api-docs")]
- status => 200
- body => #"Swagger UI"))
+ (is-200-status status)
+ (is (str/includes? body "Swagger UI"))))
- (fact "spec is not mounted"
+ (testing "spec is not mounted"
(let [[status body] (get* app "/swagger.json")]
- status => nil))))
+ (is (nil? status))))))
- (fact "with ui and spec"
+ (testing "with ui and spec"
(let [app (api {:swagger {:spec "/swagger.json", :ui "/api-docs"}})]
- (fact "api-docs are mounted"
+ (testing "api-docs are mounted"
(let [[status body] (raw-get* app "/api-docs")]
- status => 200
- body => #"Swagger UI"))
+ (is-200-status status)
+ (is (str/includes? body "Swagger UI"))))
- (fact "spec is mounted to /swagger.json"
+ (testing "spec is mounted to /swagger.json"
(let [[status body] (get* app "/swagger.json")]
- status => 200
- body => (contains {:swagger "2.0"}))))))
+ (is-200-status status)
+ (is (= "2.0" (:swagger body))))))))
(deftest muuntaja-swagger-docs-test
(let [app (api