File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11## Unreleased
22
3+ * Fixed path parameter handling in cases where path parameter is followed by an extension
4+ ([ #196 ] ( https://github.com/metosin/compojure-api/issues/196 ) , [ metosin/ring-swagger #82 ] ( https://github.com/metosin/ring-swagger/issues/82 ) )
35* [ Updated ring-swagger] ( https://github.com/metosin/ring-swagger/blob/master/CHANGELOG.md#Unreleased )
46* Added ` compojure.api.exception/with-logging ` helper to add logging to exception handlers.
57 * Check extended wiki guide on [ exception handling] ( https://github.com/metosin/compojure-api/wiki/Exception-handling#logging )
Original file line number Diff line number Diff line change 151151; ; ensure path parameters
152152; ;
153153
154- (defn path-params [s]
155- (map (comp keyword second) (re-seq #":(.[^:|(/]*)[/]?" s)))
154+ (defn path-params
155+ " Finds path-parameter keys in an uri.
156+
157+ Regex copied from Clout and Ring-swagger."
158+ [s]
159+ (map (comp keyword second) (re-seq #":([\p {L}_][\p {L}_0-9-]*)" s)))
156160
157161(defn string-path-parameters [uri]
158162 (let [params (path-params uri)]
Original file line number Diff line number Diff line change 169169 '(r1 r2)))
170170 => {:paths {" /:id" {:get {:parameters {:path {:id String}}}}
171171 " /kukka/:id" {:get {:parameters {:path {:id Long}}}}}})
172+
173+ (fact " string-path-parameters"
174+ (string-path-parameters " /:foo.json" ) => {:foo String})
175+
176+ (fact " path params followed by an extension"
177+ (first
178+ (swagger-info
179+ '(GET* " /:foo.json" []
180+ :path-params [foo :- String]
181+ identity)))
182+ => {:paths {" /:foo.json" {:get {:parameters {:path {:foo String}}}}}})
You can’t perform that action at this time.
0 commit comments