Skip to content

Commit 27ac669

Browse files
committed
split 0.22.0 & 0.23.0 (with ring-swagger changes)
1 parent 1c02b83 commit 27ac669

File tree

7 files changed

+58
-10
lines changed

7 files changed

+58
-10
lines changed

CHANGELOG.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1-
## 0.22.0-SNAPSHOT
1+
## 0.23.0-SNAPSHOT
2+
3+
* Ring-swagger 0.21.0
4+
* **BREAKING**: new signature for dispatching custom JSON Schema transformations, old signature will break (nicely at compile-time), see [Readme](https://github.com/metosin/ring-swagger/blob/master/README.md) for details.
5+
* **BREAKING**: File support moved to ring-swagger. Use `ring.swagger.upload` instead of `compojure.api.upload`.
6+
* Support for collections in query parameters. E.g. `:query-params [x :- [Long]]` & url `?x=1&x=2&x=3` should result in `x` being `[1 2 3]`.
7+
8+
## 0.22.0 (30.6.2015)
29

310
* Optional integration with [Component](https://github.com/stuartsierra/component).
411
Use either `:components`-option of `api-middleware` or `wrap-components`-middleware
512
to associate the components with your API. Then you can use `:components`-restructuring
613
to destructure your components using letk syntax.
714
* fix for [#123](https://github.com/metosin/compojure-api/issues/123)
15+
* support for pluggable coercion, at both api-level & endpoint-level with option `:coercion`. See the[the tests](./test/compojure/api/coercion_test.clj).
16+
* coercion is a function of type - `ring-request->coercion-type->coercion-matcher` allowing protocol-based coercion in the future
17+
** BREAKING**: if you have created custom restructurings using `src-coerce`, they will break (nicely at compile-time)
18+
819
* new restucturing `:swagger` just for swagger-docs. Does not do any coercion.
920

1021
```clojure
@@ -17,11 +28,6 @@
1728
...)
1829
```
1930

20-
* Ring-swagger 0.21.0
21-
* **BREAKING**: new signature for dispatching custom JSON Schema transformations, old signature will break (nicely at compile-time), see [Readme](https://github.com/metosin/ring-swagger/blob/master/README.md) for details.
22-
* **BREAKING**: File support moved to ring-swagger. Use `ring.swagger.upload` instead of `compojure.api.upload`.
23-
* Support for collections in query parameters. E.g. `:query-params [x :- [Long]]` & url `?x=1&x=2&x=3` should result in `x` being `[1 2 3]`.
24-
2531
```clojure
2632
[metosin/ring-swagger "0.21.0-SNAPSHOT"] is available but we use "0.20.4"
2733
[cheshire "5.5.0"] is available but we use "5.4.0"

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,10 @@ Mostly provided by Ring-Swagger. Restructuring `:multipart-params` pushes also `
658658
available consumption.
659659

660660
```clojure
661+
;; versions before 0.23.0
662+
(require '[compojure.api.upload :as upload])
663+
664+
;; versions 0.23.0+
661665
(require '[ring.swagger.upload :as upload])
662666

663667
(POST*

examples/src/examples/thingie.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(ns examples.thingie
22
(:require [ring.util.http-response :refer :all]
33
[compojure.api.sweet :refer :all]
4-
[ring.swagger.upload :refer :all]
4+
[compojure.api.upload :refer :all]
55
[schema.core :as s]
66
ring.swagger.json-schema-dirty
77
[examples.pizza :refer [pizza-routes Pizza]]

project.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
[prismatic/schema "0.4.3"]
1414
[org.tobereplaced/lettercase "1.0.0"]
1515
[metosin/ring-http-response "0.6.2"]
16-
[metosin/ring-swagger "0.21.0-SNAPSHOT"]
16+
[metosin/ring-swagger "0.20.4"]
17+
[metosin/schema-tools "0.4.3"]
1718
[metosin/ring-middleware-format "0.6.0"]
1819
[backtick "0.3.3"]
1920
[metosin/ring-swagger-ui "2.1.5-M2"]]

src/compojure/api/meta.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"Return source code for coerce! for a schema with coercion type,
7171
extracted from a key in a ring request."
7272
[schema, key, type :- mw/CoercionType]
73-
(assert (not (#{:query :json} type)) (str type " is DEPRECATED"))
73+
(assert (not (#{:query :json} type)) (str type " is DEPRECATED since 0.22.0. Use :body or :string instead."))
7474
`(let [value# (keywordize-keys (~key ~+compojure-api-request+))]
7575
(if-let [matcher# (~type (mw/get-coercion-matcher-provider ~+compojure-api-request+))]
7676
(schema/coerce! ~schema value# matcher#)

src/compojure/api/upload.clj

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
(ns compojure.api.upload
2+
(:require [potemkin :refer [import-vars]]
3+
[ring.middleware.multipart-params]
4+
[ring.swagger.json-schema :as js]
5+
[schema.core :as s]))
6+
7+
(import-vars
8+
[ring.middleware.multipart-params
9+
10+
wrap-multipart-params])
11+
12+
; Works exactly like map schema but wrapped in record for json-type dispatch
13+
(defrecord Upload [m]
14+
schema.core.Schema
15+
(walker [this]
16+
(let [sub-walker (s/subschema-walker m)]
17+
(clojure.core/fn [x]
18+
(if (schema.utils/error? x)
19+
x
20+
(sub-walker x)))))
21+
(explain [this] (cons 'file m)))
22+
23+
(def TempFileUpload
24+
"Schema for file param created by ring.middleware.multipart-params.temp-file store."
25+
(->Upload {:filename s/Str
26+
:content-type s/Str
27+
:size s/Int
28+
(s/optional-key :tempfile) java.io.File}))
29+
30+
(def ByteArrayUpload
31+
"Schema for file param created by ring.middleware.multipart-params.byte-array store."
32+
(->Upload {:filename s/Str
33+
:content-type s/Str
34+
:bytes s/Any}))
35+
36+
(defmethod js/json-type Upload [_] {:type "file"})

test/compojure/api/integration_test.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,8 @@
10391039
status => 200
10401040
body => {:magic 42})))))
10411041

1042-
(fact "sequential string parameters"
1042+
; TODO: works with 0.23.0-SNAPSHOT
1043+
#_(fact "sequential string parameters"
10431044
(let [app (api
10441045
(GET* "/ints" []
10451046
:query-params [i :- [s/Int]]

0 commit comments

Comments
 (0)