mirror of
https://github.com/metosin/reitit.git
synced 2026-02-17 08:15:56 +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]}]
|
[{:keys [::r/router ::r/match :request-method]}]
|
||||||
(let [{:keys [id] :as swagger} (-> match :result request-method :data :swagger)
|
(let [{:keys [id] :as swagger} (-> match :result request-method :data :swagger)
|
||||||
swagger (set/rename-keys swagger {:id :x-id})
|
swagger (set/rename-keys swagger {:id :x-id})
|
||||||
this-swagger? #(-> % second :swagger :id (= id))
|
accept-route #(-> % second :swagger :id (= id))
|
||||||
transform-endpoint (fn [[method endpoint]]
|
transform-endpoint (fn [[method {{:keys [coercion no-doc swagger] :as data} :data}]]
|
||||||
(let [coercion (-> endpoint :data :coercion)]
|
(if (and data (not no-doc))
|
||||||
(if (and endpoint (-> endpoint :data :no-doc not))
|
[method
|
||||||
[method (meta-merge
|
(meta-merge
|
||||||
(if coercion
|
(if coercion
|
||||||
(coercion/-get-apidocs coercion :swagger (-> endpoint :data)))
|
(coercion/-get-apidocs coercion :swagger data))
|
||||||
(-> endpoint :data (select-keys [:tags :summary :description]))
|
(select-keys data [:tags :summary :description])
|
||||||
(-> endpoint :data :swagger (dissoc :id)))])))
|
(dissoc swagger :id))]))
|
||||||
transform-path (fn [[p _ c]]
|
transform-path (fn [[p _ c]]
|
||||||
(if-let [endpoint (some->> c (keep transform-endpoint) (seq) (into {}))]
|
(if-let [endpoint (some->> c (keep transform-endpoint) (seq) (into {}))]
|
||||||
[p endpoint]))]
|
[p endpoint]))]
|
||||||
(if id
|
(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
|
{:status 200
|
||||||
:body (meta-merge swagger {:paths paths})}))))
|
:body (meta-merge swagger {:paths paths})}))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue