mirror of
https://github.com/metosin/reitit.git
synced 2025-12-24 19:08:24 +00:00
Lift definitions to root of swagger.json
...so that all of the absolute $ref's to them will resolve
This commit is contained in:
parent
229171c7e3
commit
4f31304a1a
1 changed files with 10 additions and 2 deletions
|
|
@ -102,9 +102,17 @@
|
|||
(if-let [endpoint (some->> c (keep transform-endpoint) (seq) (into {}))]
|
||||
[(swagger-path p (r/options router)) endpoint]))
|
||||
map-in-order #(->> % (apply concat) (apply array-map))
|
||||
paths (->> router (r/compiled-routes) (filter accept-route) (map transform-path) map-in-order)]
|
||||
paths (->> router (r/compiled-routes) (filter accept-route) (map transform-path) map-in-order)
|
||||
definitions (reduce-kv
|
||||
(fn [ds _ v]
|
||||
(let [ks (keys v)]
|
||||
(merge ds (apply merge
|
||||
(for [k ks]
|
||||
(when-let [method-map (get v k)]
|
||||
(:definitions method-map)))))))
|
||||
{} paths)]
|
||||
{:status 200
|
||||
:body (meta-merge swagger {:paths paths})}))
|
||||
:body (meta-merge swagger {:paths paths :definitions definitions})}))
|
||||
([req res raise]
|
||||
(try
|
||||
(res (create-swagger req))
|
||||
|
|
|
|||
Loading…
Reference in a new issue