Skip to content

Commit 582b6ab

Browse files
committed
1.1.11
1 parent 43c5fa7 commit 582b6ab

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
## Unreleased
22

3+
## 1.1.11 (25.7.2017)
4+
5+
* **BREAKING**: in `compojure.api.swagger`, the `swagger-ui` and `swagger-docs` now take options map with `path` key instead of separate optional path & vararg opts.
6+
- normally you would use swagger api-options or `swagger-routes` and thus be unaffected of this.
7+
8+
* updated dependencies:
9+
10+
```clj
11+
[prismatic/plumbing "0.5.4"] is available but we use "0.5.3"
12+
[cheshire "5.7.1"] is available but we use "5.6.3"
13+
[compojure "1.6.0"] is available but we use "1.5.2"
14+
[prismatic/schema "1.1.6"] is available but we use "1.1.3"
15+
[ring-middleware-format "0.7.2"] is available but we use "0.7.0"
16+
[metosin/ring-http-response "0.9.0"] is available but we use "0.8.1"
17+
[metosin/ring-swagger "0.24.1"] is available but we use "0.22.14"
18+
```
19+
320
## 1.1.10 (11.1.2017)
421

522
* Updated dependencies to [avoid a path traversal vulnerability](https://groups.google.com/forum/#!topic/clojure/YDrKBV26rnA) in Ring.

project.clj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
:url "http://www.eclipse.org/legal/epl-v10.html"
66
:distribution :repo
77
:comments "same as Clojure"}
8-
:dependencies [[prismatic/plumbing "0.5.3"]
8+
:dependencies [[prismatic/plumbing "0.5.4"]
99
[potemkin "0.4.3"]
10-
[cheshire "5.6.3"]
11-
[compojure "1.5.2"]
12-
[prismatic/schema "1.1.3"]
10+
[cheshire "5.7.1"]
11+
[compojure "1.6.0"]
12+
[prismatic/schema "1.1.6"]
1313
[org.tobereplaced/lettercase "1.0.0"]
1414
[frankiesardo/linked "1.2.9"]
15-
[ring-middleware-format "0.7.0"]
16-
[metosin/ring-http-response "0.8.1"]
17-
[metosin/ring-swagger "0.22.14"]
15+
[ring-middleware-format "0.7.2"]
16+
[metosin/ring-http-response "0.9.0"]
17+
[metosin/ring-swagger "0.24.1"]
1818
[metosin/ring-swagger-ui "2.2.8"]]
1919
:profiles {:uberjar {:aot :all
2020
:ring {:handler examples.thingie/app}
@@ -26,7 +26,7 @@
2626
:dev {:repl-options {:init-ns user}
2727
:plugins [[lein-clojars "0.9.1"]
2828
[lein-midje "3.2.1"]
29-
[lein-ring "0.9.7"]
29+
[lein-ring "0.12.0"]
3030
[funcool/codeina "0.5.0"]]
3131
:dependencies [[org.clojure/clojure "1.8.0"]
3232
[slingshot "0.12.2"]
@@ -44,7 +44,7 @@
4444
:source-paths ["examples/thingie/src" "examples/thingie/dev-src"]
4545
:main examples.server}
4646
:perf {:jvm-opts ^:replace []}
47-
:logging {:dependencies [[org.clojure/tools.logging "0.3.1"]]}
47+
:logging {:dependencies [[org.clojure/tools.logging "0.4.0"]]}
4848
:1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}}
4949
:eastwood {:namespaces [:source-paths]
5050
:add-linters [:unused-namespaces]}

src/compojure/api/swagger.clj

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[ring.swagger.common :as rsc]
77
[ring.swagger.middleware :as rsm]
88
[ring.swagger.core :as swagger]
9-
[ring.swagger.ui :as rsui]
9+
[ring.swagger.swagger-ui :as swagger-ui]
1010
[ring.swagger.swagger2 :as swagger2]
1111
[compojure.api.routes :as routes]))
1212

@@ -28,15 +28,14 @@
2828
(swagger2/transform-operations routes/non-nil-routes)
2929
(swagger2/transform-operations routes/strip-no-doc-endpoints)))
3030

31-
(defn swagger-ui [& params]
31+
(defn swagger-ui [options]
32+
(assert (map? options) "Since 1.1.11, compojure.api.swagger/swagger-ui takes just one map as argument, with `:path` for the path.")
3233
(c/undocumented
33-
(apply rsui/swagger-ui params)))
34+
(swagger-ui/swagger-ui options)))
3435

35-
(defn swagger-docs [& body]
36-
(let [[path body] (if (string? (first body))
37-
[(first body) (rest body)]
38-
["/swagger.json" body])
39-
[extra-info] (common/extract-parameters body false)]
36+
(defn swagger-docs [{:keys [path] :or {path "/swagger.json"} :as options}]
37+
(assert (map? options) "Since 1.1.11, compojure.api.swagger/swagger-docs takes just one map as argument, with `:path` for the path.")
38+
(let [extra-info (dissoc options :path)]
4039
(c/GET path request
4140
:no-doc true
4241
:name ::swagger
@@ -57,21 +56,15 @@
5756
(defn swagger-routes
5857
"Returns routes for swagger-articats (ui & spec). Accepts an options map, with the
5958
following options:
60-
61-
**:ui** Uri for the swagger-ui (defaults to \"/\").
59+
**:ui** Path for the swagger-ui (defaults to \"/\").
6260
Setting the value to nil will cause the swagger-ui not to be mounted
63-
64-
**:spec** Uri for the swagger-spec (defaults to \"/swagger.json\")
61+
**:spec** Path for the swagger-spec (defaults to \"/swagger.json\")
6562
Setting the value to nil will cause the swagger-ui not to be mounted
66-
6763
**:data** Swagger data in the Ring-Swagger format.
68-
6964
**:options**
7065
**:ui** Options to configure the ui
7166
**:spec** Options to configure the spec. Nada at the moment.
72-
7367
Example options:
74-
7568
{:ui \"/api-docs\"
7669
:spec \"/swagger.json\"
7770
:options {:ui {:jsonEditor true}
@@ -89,8 +82,9 @@
8982
:tags [{:name \"sausages\", :description \"Sausage api-set\"}]}}"
9083
([] (swagger-routes {}))
9184
([options]
92-
(let [{:keys [ui spec data] {ui-options :ui} :options} (merge swagger-defaults options)]
85+
(let [{:keys [ui spec data] {ui-options :ui} :options} (merge swagger-defaults options)
86+
path (apply str (remove clojure.string/blank? [(:basePath data) spec]))]
9387
(if (or ui spec)
9488
(c/routes
95-
(if ui (apply swagger-ui ui (mapcat identity (merge (if spec {:swagger-docs (apply str (remove clojure.string/blank? [(:basePath data) spec]))}) ui-options))))
96-
(if spec (apply swagger-docs spec (mapcat identity data))))))))
89+
(if ui (swagger-ui (merge (if spec {:swagger-docs path}) ui-options {:path ui})))
90+
(if spec (swagger-docs (assoc data :path spec))))))))

0 commit comments

Comments
 (0)