fix invalid swagger json
CI / Test + coverage (push) Successful in 14s

This commit is contained in:
2026-09-19 06:22:49 -09:00
parent 2fcdb17fdd
commit 4e0ddb601d
2 changed files with 15 additions and 2 deletions
+12 -1
View File
@@ -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