- BREAKING: the router option key to extract body format has been renamed:
:extract-request-format
=>:reitit.coercion/extract-request-format
- should only concern you if you are not using Muuntaja.
- the
r/routes
returns just the path + data tuples as documented, not the compiled route results. To get the compiled results, user/compiled-routes
instead. - welcome route name conflict resolution! If router has routes with same names, router can't be created. fix 'em.
- In case of just one swagger api per router, the swagger api doesn't have to identified, so this works now:
(require '[reitit.ring :as ring])
(require '[reitit.swagger :as swagger])
(require '[reitit.swagger-ui :as swagger-ui])
(ring/ring-handler
(ring/router
[["/ping"
{:get (fn [_] {:status 200, :body "pong"})}]
["/swagger.json"
{:get {:no-doc true
:handler (swagger/create-swagger-handler)}}]])
(swagger-ui/create-swagger-ui-handler {:path "/"}))
- BREAKING: pass swagger-ui
:config
as-is (instead of mixed-casing keys) to swagger-ui, fixes #109:- see docs for available parameters.
(swagger-ui/create-swagger-ui-handler
{:path "/"
:url "/api/swagger.json"
:config {:jsonEditor true
:validatorUrl nil}})
reitit.coercion/coerce!
coerced all parameters found in match, e.g. injecting in:query-parameters
intoMatch
with coerce those too if:query
coercion is defined.- if response coercion is not defined for a response status, response is still returned
spec-tools.data-spec/maybe
can be used in spec-coercion.
(def router
(reitit.core/router
["/spec" {:coercion reitit.coercion.spec/coercion}
["/:number/:keyword" {:parameters {:path {:number int?
:keyword keyword?}
:query (ds/maybe {:int int?})}}]]
{:compile reitit.coercion/compile-request-coercers}))
(-> (reitit.core/match-by-path router "/spec/10/kikka")
(assoc :query-params {:int "10"})
(reitit.coercion/coerce!))
; {:path {:number 10, :keyword :kikka}
; :query {:int 10}}
reitit.core/match->path
to create full paths from match, including the query parameters:
(require '[reitit.core :as r])
(-> (r/router ["/:a/:b" ::route])
(r/match-by-name! ::route {:a "olipa", :b "kerran"})
(r/match->path))
; "/olipa/kerran"
(-> (r/router ["/:a/:b" ::route])
(r/match-by-name! ::route {:a "olipa", :b "kerran"})
(r/match->path {:iso "pöriläinen"}))
; "/olipa/kerran?iso=p%C3%B6ril%C3%A4inen"
[metosin/spec-tools "0.7.1"]
with swagger generation enhancements, see the CHANGELOG- if response coercion is not defined for a response status, no
:schema
is not emitted. - updated dependencies:
[metosin/spec-tools "0.7.1"] is available but we use "0.7.0"
- if response coercion is not defined for a response status, no
:schema
is not emitted.
- Better handling of
nil
in route syntax:- explicit
nil
after path string is always handled asnil
route nil
as path string causes the whole route to benil
nil
as child route is stripped away
- explicit
(testing "nil routes are stripped"
(is (= [] (r/routes (r/router nil))))
(is (= [] (r/routes (r/router [nil ["/ping"]]))))
(is (= [] (r/routes (r/router [nil [nil] [[nil nil nil]]]))))
(is (= [] (r/routes (r/router ["/ping" [nil "/pong"]])))))
- Use HTTP redirect (302) with index-files in
reitit.ring/create-resource-handler
. reitit.ring/create-default-handler
now conforms to RING Spec, Fixes #83
- updated dependencies:
[metosin/schema-tools "0.10.3"] is available but we use "0.10.2"
- Fix Swagger-paths, by Kirill Chernyshov.
-
Use HTTP redirect (302) with index-files in
reitit.swagger-ui/create-swagger-ui-handler
. -
updated dependencies:
[metosin/jsonista "0.2.1"] is available but we use "0.2.0"
linear-router
now works with unnamed catch-all parameters, e.g."/files/*"
match-by-path
encodes parameters into strings using (internal)reitit.impl/IntoString
protocol. Handles all of: strings, numbers, keywords, booleans, objects. Fixes #75.
(require '[reitit.core :as r])
(r/match-by-name
(r/router
["/coffee/:type" ::coffee])
::coffee
{:type :luwak})
;#Match{:template "/coffee/:type",
; :data {:name :user/coffee},
; :result nil,
; :path-params {:type "luwak"},
; :path "/coffee/luwak"}
-
reitit.ring/default-handler
now works correctly with async ring -
new helper
reitit.ring/router
to compose routes outside of a router. -
reitit.ring/create-resource-handler
function to serve static routes. See docs. -
new dependencies:
[ring/ring-core "1.6.3"]
- New module to produce swagger-docs from routing tree, including
Coercion
definitions. Works with both middleware & interceptors and Schema & Spec. See docs and example project.
New module to server pre-integrated Swagger-ui. See docs.
- new dependencies:
[metosin/jsonista "0.2.0"]
[metosin/ring-swagger-ui "2.2.10"]
[metosin/spec-tools "0.7.0"] is available but we use "0.6.1"
[metosin/schema-tools "0.10.2"] is available but we use "0.10.1"
- First release