|
206 | 206 | accept-route (fn [route] |
207 | 207 | (-> route second :openapi :id (or ::default) (trie/into-set) (set/intersection ids) seq)) |
208 | 208 | definitions (volatile! {}) |
209 | | - transform-endpoint (fn [[method {{:keys [coercion no-doc openapi] :as data} :data |
210 | | - middleware :middleware |
211 | | - interceptors :interceptors}]] |
212 | | - (if (and data (not no-doc)) |
213 | | - [method |
214 | | - (meta-merge |
215 | | - (apply meta-merge (keep (comp :openapi :data) middleware)) |
216 | | - (apply meta-merge (keep (comp :openapi :data) interceptors)) |
217 | | - (if coercion |
218 | | - (-get-apidocs-openapi coercion data definitions)) |
219 | | - (select-keys data [:tags :summary :description]) |
220 | | - (strip-top-level-keys openapi))])) |
| 209 | + transform-endpoint (fn [path [method {{:keys [coercion no-doc openapi] :as data} :data |
| 210 | + middleware :middleware |
| 211 | + interceptors :interceptors}]] |
| 212 | + (try |
| 213 | + (if (and data (not no-doc)) |
| 214 | + [method |
| 215 | + (meta-merge |
| 216 | + (apply meta-merge (keep (comp :openapi :data) middleware)) |
| 217 | + (apply meta-merge (keep (comp :openapi :data) interceptors)) |
| 218 | + (if coercion |
| 219 | + (-get-apidocs-openapi coercion data definitions)) |
| 220 | + (select-keys data [:tags :summary :description]) |
| 221 | + (strip-top-level-keys openapi))]) |
| 222 | + (catch Throwable t |
| 223 | + (throw (ex-info "While building openapi docs" {:path path :method method}))))) |
221 | 224 | transform-path (fn [[p _ c]] |
222 | | - (if-let [endpoint (some->> c (keep transform-endpoint) (seq) (into {}))] |
| 225 | + (if-let [endpoint (some->> c (keep (partial transform-endpoint p)) (seq) (into {}))] |
223 | 226 | [(openapi-path p (r/options router)) endpoint])) |
224 | 227 | map-in-order #(->> % (apply concat) (apply array-map)) |
225 | 228 | paths (->> router (r/compiled-routes) (filter accept-route) (map transform-path) map-in-order)] |
|
0 commit comments