+12
-1
@@ -10,6 +10,17 @@
|
||||
[tbd.health.routes :as health]
|
||||
[tbd.math.routes :as math]))
|
||||
|
||||
(defn- swagger-handler
|
||||
"reitit emits `\"definitions\": null` when no route declares a schema, which
|
||||
violates the Swagger 2.0 schema (must be an object) and makes validators reject the spec."
|
||||
[]
|
||||
(let [handler (swagger/create-swagger-handler)]
|
||||
(fn [req]
|
||||
(let [resp (handler req)]
|
||||
(cond-> resp
|
||||
(and (map? (:body resp)) (nil? (:definitions (:body resp))))
|
||||
(update :body dissoc :definitions))))))
|
||||
|
||||
;; Each logical group (health, users, orders, ...) owns a `tbd.<group>.routes`
|
||||
;; namespace that returns its own route subtree; they're concatenated here.
|
||||
(def router
|
||||
@@ -17,7 +28,7 @@
|
||||
[["/swagger.json"
|
||||
{:get {:no-doc true
|
||||
:swagger {:info {:title "tbd API" :version "1.0.0"}}
|
||||
:handler (swagger/create-swagger-handler)}}]
|
||||
:handler (swagger-handler)}}]
|
||||
["/" {:get {:no-doc true
|
||||
:handler (fn [_req]
|
||||
{:status 200
|
||||
|
||||
Reference in New Issue
Block a user