mirror of
https://github.com/metosin/reitit.git
synced 2025-12-20 09:31:11 +00:00
feat: dissoc definitions from swagger methods
we only want the definitions on the very top level of the swagger doc
This commit is contained in:
parent
b316840ea0
commit
241c8367e3
1 changed files with 10 additions and 9 deletions
|
|
@ -127,16 +127,17 @@
|
||||||
[(swagger-path p (r/options router)) endpoint]))
|
[(swagger-path p (r/options router)) endpoint]))
|
||||||
map-in-order #(->> % (apply concat) (apply array-map))
|
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
|
definitions (apply merge
|
||||||
(fn [ds _ v]
|
(for [[_path path-data] paths
|
||||||
(let [ks (keys v)]
|
[_method data] path-data]
|
||||||
(merge ds (apply merge
|
(:definitions data)))
|
||||||
(for [k ks]
|
paths-without-definitions (into {}
|
||||||
(when-let [method-map (get v k)]
|
(for [[path path-data] paths]
|
||||||
(:definitions method-map)))))))
|
[path (into {}
|
||||||
{} paths)]
|
(for [[method data] path-data]
|
||||||
|
[method (dissoc data :definitions)]))]))]
|
||||||
{:status 200
|
{:status 200
|
||||||
:body (meta-merge swagger {:paths paths :definitions definitions})}))
|
:body (meta-merge swagger {:paths paths-without-definitions :definitions definitions})}))
|
||||||
([req res raise]
|
([req res raise]
|
||||||
(try
|
(try
|
||||||
(res (create-swagger req))
|
(res (create-swagger req))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue