Skip to content

Commit 6f98c87

Browse files
committed
backport muuntaja json parse
1 parent 6b8b9c6 commit 6f98c87

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## NEXT
44
* drop support for Clojure 1.8
55
* upgrade cheshire 5.13.0
6+
* Backport: use muuntaja in compojure.api.validator
67

78
## 1.1.14 (2024-04-30)
89
* Remove potemkin [#445](https://github.com/metosin/compojure-api/issues/445)

src/compojure/api/methods.clj

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(ns compojure.api.methods)
2+
3+
(def all-methods #{:get :head :patch :delete :options :post :put})

src/compojure/api/validator.clj

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
(ns compojure.api.validator
22
(:require [compojure.api.swagger :as swagger]
3-
[cheshire.core :as cheshire]
3+
[compojure.api.impl.json :as json]
44
[ring.swagger.validator :as rsv]
5+
[muuntaja.core :as m]
56
[compojure.api.middleware :as mw]))
67

78
(defn validate
8-
"Validates a api. If the api is Swagger-enabled, the swagger-spec
9+
"Validates an api. If the api is Swagger-enabled, the swagger-spec
910
is requested and validated against the JSON Schema. Returns either
1011
the (valid) api or throws an exception. Requires lazily the
1112
ring.swagger.validator -namespace allowing it to be excluded, #227"
1213
[api]
1314
(when-let [uri (swagger/swagger-spec-path api)]
1415
(let [{status :status :as response} (api {:request-method :get
1516
:uri uri
16-
mw/rethrow-exceptions? true})
17-
body (-> response :body slurp (cheshire/parse-string true))]
17+
::mw/rethrow-exceptions? true})
18+
body (->> response :body (m/decode json/muuntaja "application/json"))]
1819

1920
(when-not (= status 200)
2021
(throw (ex-info (str "Coudn't read swagger spec from " uri)

0 commit comments

Comments
 (0)