From a9cacd78ce122f0afe43f797bf86433b9e1c785f Mon Sep 17 00:00:00 2001 From: Kevin van Rooijen Date: Mon, 20 May 2019 17:30:17 +0200 Subject: [PATCH 1/2] Properly access ::s/problems key in coercion-spec --- modules/reitit-spec/src/reitit/coercion/spec.cljc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/reitit-spec/src/reitit/coercion/spec.cljc b/modules/reitit-spec/src/reitit/coercion/spec.cljc index 48d346d8..41e64fe6 100644 --- a/modules/reitit-spec/src/reitit/coercion/spec.cljc +++ b/modules/reitit-spec/src/reitit/coercion/spec.cljc @@ -110,7 +110,7 @@ (into-spec model name)) (-open-model [_ spec] spec) (-encode-error [_ error] - (let [problems (::s/problems error)] + (let [problems (-> error :problems ::s/problems)] (-> error (update :spec (comp str s/form)) (assoc :problems (mapv #(update % :pred stringify-pred) problems))))) From 259dd2410568128c81ae7270874845ecb5521f8e Mon Sep 17 00:00:00 2001 From: Kevin van Rooijen Date: Mon, 20 May 2019 18:37:55 +0200 Subject: [PATCH 2/2] Add test to ensure that the problems key is populated --- test/cljc/reitit/ring_coercion_test.cljc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/cljc/reitit/ring_coercion_test.cljc b/test/cljc/reitit/ring_coercion_test.cljc index 3bc7b4bc..c152c00b 100644 --- a/test/cljc/reitit/ring_coercion_test.cljc +++ b/test/cljc/reitit/ring_coercion_test.cljc @@ -95,7 +95,9 @@ (app valid-request)))) (testing "invalid request" - (let [{:keys [status]} (app invalid-request)] + (let [{:keys [status body]} (app invalid-request) + problems (:problems body)] + (is (= 1 (count problems))) (is (= 400 status)))) (testing "invalid response"