Skip to content

Commit 88faaf9

Browse files
committed
Support c-api in GAE, Fixes #227
1 parent cccb6cc commit 88faaf9

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
## 1.0.3-SNAPSHOT
22

33
* Strip nils from `:middleware`, fixes [#228](https://github.com/metosin/compojure-api/issues/228)
4+
* Lazily require `ring.swagger.validator` namespace in `compojure.api.swagger/validate` to allow compojure-api apps in [Google App Engine](https://cloud.google.com/appengine), Fixes [#227](https://github.com/metosin/compojure-api/issues/227). **NOTE** exluding `metosin/scjsv` will cause the validate to fail at runtime.
5+
6+
```
7+
[metosin/compojure-api "1.0.3" :exclusions [[metosin/scjsv]]]
8+
```
49

510
* updated dependencies:
611

src/compojure/api/swagger.clj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
[compojure.api.middleware :as mw]
55
[ring.util.http-response :refer [ok]]
66
[ring.swagger.common :as rsc]
7-
[ring.swagger.validator :as v]
87
[ring.swagger.middleware :as rsm]
98
[ring.swagger.core :as swagger]
109
[ring.swagger.ui :as rsui]
@@ -116,10 +115,13 @@
116115
(defn validate
117116
"Validates a api. If the api is Swagger-enabled, the swagger-spec
118117
is requested and validated against the JSON Schema. Returns either
119-
the (valid) api or throws an exception."
118+
the (valid) api or throws an exception. Requires lazily the
119+
ring.swagger.validator -namespace allowing it to be excluded, #227"
120120
[api]
121+
(require 'ring.swagger.validator)
121122
(when-let [uri (swagger-spec-path api)]
122-
(let [{status :status :as response} (api {:request-method :get
123+
(let [validate (resolve 'ring.swagger.validator/validate)
124+
{status :status :as response} (api {:request-method :get
123125
:uri uri
124126
mw/rethrow-exceptions? true})
125127
body (-> response :body slurp (cheshire/parse-string true))]
@@ -129,7 +131,7 @@
129131
{:status status
130132
:body body})))
131133

132-
(when-let [errors (seq (v/validate body))]
134+
(when-let [errors (seq (validate body))]
133135
(throw (ex-info (str "Invalid swagger spec from " uri)
134136
{:errors errors
135137
:body body})))))

0 commit comments

Comments
 (0)