File tree 3 files changed +19
-3
lines changed
modules/reitit-core/src/reitit
clj/reitit/ring/middleware
3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 183
183
184
184
(defn response-coercers [coercion responses opts]
185
185
(some->> (for [[status model] responses]
186
- [status (response-coercer coercion model opts)])
186
+ (do
187
+ (when-not (int? status)
188
+ (throw (ex-info " Response status must be int" {:status status})))
189
+ [status (response-coercer coercion model opts)]))
187
190
(filter second) (seq ) (into {})))
188
191
189
192
(defn -compile-parameters [data coercion]
Original file line number Diff line number Diff line change 8
8
[reitit.ring.coercion]
9
9
[reitit.ring.middleware.exception :as exception]
10
10
[ring.util.http-response :as http-response])
11
- (:import (java.sql SQLException SQLWarning)))
11
+ (:import (clojure.lang ExceptionInfo)
12
+ (java.sql SQLException SQLWarning)))
12
13
13
14
(derive ::kikka ::kukka )
14
15
190
191
(is (contains? problems ::s/spec ))
191
192
(is (contains? problems ::s/value ))
192
193
(is (contains? problems ::s/problems ))))))))
194
+
195
+ (deftest response-keys-test
196
+ (is (thrown-with-msg?
197
+ ExceptionInfo
198
+ #"Response status must be int"
199
+ (ring/ring-handler
200
+ (ring/router
201
+ [[" /coercion"
202
+ {:middleware [reitit.ring.coercion/coerce-response-middleware]
203
+ :coercion reitit.coercion.spec/coercion
204
+ :responses {:200 {:body {:total pos-int?}}}
205
+ :handler identity}]])))))
Original file line number Diff line number Diff line change 125
125
(ring/router
126
126
[" /api"
127
127
[" /plus/:e"
128
- {:get {:responses {" 200" { }}
128
+ {:get {:responses {200 { :description 1 }}
129
129
:handler identity}}]]
130
130
{:data {:middleware [rrc/coerce-exceptions-middleware
131
131
rrc/coerce-request-middleware
You can’t perform that action at this time.
0 commit comments