Update deps & docs

This commit is contained in:
Tommi Reiman 2019-06-15 11:49:11 +03:00
parent 0bcfda755f
commit 47906df7b9
4 changed files with 41 additions and 13 deletions

View file

@ -12,22 +12,37 @@ We use [Break Versioning][breakver]. The version numbers follow a `<major>.<mino
[breakver]: https://github.com/ptaoussanis/encore/blob/master/BREAK-VERSIONING.md
## Unreleased (patch)
## 0.3.8 (2019-06-15)
* Updated dependencies:
```clj
[metosin/schema-tools "0.12.0"] is available but we use "0.11.0"
[metosin/spec-tools "0.9.3"] is available but we use "0.9.2"
[metosin/jsonista "0.2.3"] is available but we use "0.2.2"
```
### `reitit-core`
* Schema coercion supports transformtatins from keywords->clojure, via [schema-tools](https://github.com/metosin/schema-tools).
* Add support for explixit selection of router path-parameter `:syntax`, fixes [#276](https://github.com/metosin/reitit/issues/276)
```clj
(require '[reitit.core :as r])
;; default
(-> (r/router
["http://localhost:8080/api/user/{id}" ::user-by-id])
(r/match-by-path "http://localhost:8080/api/user/123"))
;#Match{:template "http://localhost:8080/api/user/{id}",
; :data {:name :user/user-by-id},
; :result nil,
; :path-params {:id "123", :8080 ":8080"},
; :path "http://localhost:8080/api/user/123"}
;; just bracket-syntax
(-> (r/router
["http://localhost:8080/api/user/{id}" ::user-by-id]
{:syntax :bracket})

View file

@ -134,6 +134,19 @@ Routes are just data, so it's easy to create them programmatically:
Router options `:syntax` allows the path-parameter syntax to be explicitely defined. It takes a keyword or set of keywords as a value. Valid values are `:colon` and `:bracket`. Default value is `#{:colon :bracket}`.
With defaults:
```clj
(-> (r/router
["http://localhost:8080/api/user/{id}" ::user-by-id])
(r/match-by-path "http://localhost:8080/api/user/123"))
;#Match{:template "http://localhost:8080/api/user/{id}",
; :data {:name :user/user-by-id},
; :result nil,
; :path-params {:id "123", :8080 ":8080"},
; :path "http://localhost:8080/api/user/123"}
```
Supporting only `:bracket` syntax:
```clj

View file

@ -28,7 +28,7 @@
[metosin/reitit-pedestal "0.3.7"]
[metosin/ring-swagger-ui "2.2.10"]
[metosin/spec-tools "0.9.3"]
[metosin/schema-tools "0.11.0"]
[metosin/schema-tools "0.12.0"]
[metosin/muuntaja "0.6.4"]
[metosin/jsonista "0.2.3"]
[metosin/sieppari "0.0.0-alpha7"]
@ -48,7 +48,7 @@
[lein-cljsbuild "1.1.7"]
[lein-cloverage "1.1.1"]
[lein-codox "0.10.7"]
[metosin/bat-test "0.4.2"]]
[metosin/bat-test "0.4.3"]]
:profiles {:dev {:jvm-opts ^:replace ["-server"]
@ -96,16 +96,16 @@
[criterium "0.4.5"]
[org.clojure/test.check "0.9.0"]
[org.clojure/tools.namespace "0.2.11"]
[org.clojure/tools.namespace "0.3.0"]
[com.gfredericks/test.chuck "0.2.9"]
[io.pedestal/pedestal.service "0.5.5"]
[org.clojure/core.async "0.4.490"]
[org.clojure/core.async "0.4.500"]
[manifold "0.1.8"]
[funcool/promesa "2.0.1"]
[com.clojure-goes-fast/clj-async-profiler "0.3.1"]
[com.clojure-goes-fast/clj-async-profiler "0.4.0"]
[ring-cors "0.1.13"]
[com.bhauman/rebel-readline "0.1.4"]]}
@ -120,7 +120,7 @@
[io.pedestal/pedestal.service "0.5.5"]
[io.pedestal/pedestal.jetty "0.5.5"]
[calfpath "0.7.2"]
[org.clojure/core.async "0.4.490"]
[org.clojure/core.async "0.4.500"]
[manifold "0.1.8"]
[funcool/promesa "2.0.1"]
[metosin/sieppari]

View file

@ -14,11 +14,11 @@
[["/schema" {:coercion reitit.coercion.schema/coercion}
["/:number/:keyword" {:parameters {:path {:number s/Int
:keyword s/Keyword}
:query (s/maybe {:int s/Int, :ints [s/Int]})}}]]
:query (s/maybe {:int s/Int, :ints [s/Int], :map {s/Int s/Int}})}}]]
["/spec" {:coercion reitit.coercion.spec/coercion}
["/:number/:keyword" {:parameters {:path {:number int?
:keyword keyword?}
:query (ds/maybe {:int int?, :ints [int?]})}}]]
:query (ds/maybe {:int int?, :ints [int?], :map {int? int?}})}}]]
["/none"
["/:number/:keyword" {:parameters {:path {:number int?
:keyword keyword?}}}]]]
@ -30,8 +30,8 @@
(is (= {:path {:keyword :abba, :number 1}, :query nil}
(coercion/coerce! m))))
(let [m (r/match-by-path r "/schema/1/abba")]
(is (= {:path {:keyword :abba, :number 1}, :query {:int 10, :ints [1,2,3]}}
(coercion/coerce! (assoc m :query-params {"int" "10", "ints" ["1" "2" "3"]}))))))
(is (= {:path {:keyword :abba, :number 1}, :query {:int 10, :ints [1,2,3], :map {1 1}}}
(coercion/coerce! (assoc m :query-params {"int" "10", "ints" ["1" "2" "3"], "map" {:1 :1}}))))))
(testing "throws with invalid input"
(let [m (r/match-by-path r "/schema/kikka/abba")]
(is (thrown? ExceptionInfo (coercion/coerce! m))))))
@ -42,8 +42,8 @@
(is (= {:path {:keyword :abba, :number 1}, :query nil}
(coercion/coerce! m))))
(let [m (r/match-by-path r "/schema/1/abba")]
(is (= {:path {:keyword :abba, :number 1}, :query {:int 10, :ints [1,2,3]}}
(coercion/coerce! (assoc m :query-params {"int" "10", "ints" ["1" "2" "3"]}))))))
(is (= {:path {:keyword :abba, :number 1}, :query {:int 10, :ints [1,2,3], :map {1 1}}}
(coercion/coerce! (assoc m :query-params {"int" "10", "ints" ["1" "2" "3"], "map" {:1 :1}}))))))
(testing "throws with invalid input"
(let [m (r/match-by-path r "/spec/kikka/abba")]
(is (thrown? ExceptionInfo (coercion/coerce! m))))))