mirror of
https://github.com/metosin/reitit.git
synced 2026-01-06 07:39:49 +00:00
Cleanup
This commit is contained in:
parent
8c39840eca
commit
5da599ac5b
1 changed files with 10 additions and 10 deletions
|
|
@ -70,19 +70,19 @@
|
|||
[{:keys [::r/router ::r/match :request-method]}]
|
||||
(let [{:keys [id] :as swagger} (-> match :result request-method :data :swagger)
|
||||
swagger (set/rename-keys swagger {:id :x-id})
|
||||
this-swagger? #(-> % second :swagger :id (= id))
|
||||
transform-endpoint (fn [[method endpoint]]
|
||||
(let [coercion (-> endpoint :data :coercion)]
|
||||
(if (and endpoint (-> endpoint :data :no-doc not))
|
||||
[method (meta-merge
|
||||
(if coercion
|
||||
(coercion/-get-apidocs coercion :swagger (-> endpoint :data)))
|
||||
(-> endpoint :data (select-keys [:tags :summary :description]))
|
||||
(-> endpoint :data :swagger (dissoc :id)))])))
|
||||
accept-route #(-> % second :swagger :id (= id))
|
||||
transform-endpoint (fn [[method {{:keys [coercion no-doc swagger] :as data} :data}]]
|
||||
(if (and data (not no-doc))
|
||||
[method
|
||||
(meta-merge
|
||||
(if coercion
|
||||
(coercion/-get-apidocs coercion :swagger data))
|
||||
(select-keys data [:tags :summary :description])
|
||||
(dissoc swagger :id))]))
|
||||
transform-path (fn [[p _ c]]
|
||||
(if-let [endpoint (some->> c (keep transform-endpoint) (seq) (into {}))]
|
||||
[p endpoint]))]
|
||||
(if id
|
||||
(let [paths (->> router (r/routes) (filter this-swagger?) (map transform-path) (into {}))]
|
||||
(let [paths (->> router (r/routes) (filter accept-route) (map transform-path) (into {}))]
|
||||
{:status 200
|
||||
:body (meta-merge swagger {:paths paths})}))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue