Skip to content

Commit

Permalink
Remove a nil :definitions key
Browse files Browse the repository at this point in the history
  • Loading branch information
HughPowell committed Sep 20, 2023
1 parent 9e32739 commit 65e8235
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/spec_tools/swagger/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,14 @@
x))
x)))

(defn- raise-refs-to-top [x]
(cond-> x
(:paths x) (->
(assoc :definitions (apply merge (map :definitions (mapcat vals (vals (:paths x))))))
(update :paths update-vals (fn [path] (update-vals path #(dissoc % :definitions)))))))
(defn- raise-refs-to-top [swagger-doc]
(let [swagger-doc'
(cond-> swagger-doc
(:paths swagger-doc) (->
(assoc :definitions (apply merge (map :definitions (mapcat vals (vals (:paths swagger-doc))))))
(update :paths update-vals (fn [path] (update-vals path #(dissoc % :definitions))))))]
(cond-> swagger-doc'
(nil? (:definitions swagger-doc')) (dissoc swagger-doc' :definitions))))

;;
;; generate the swagger spec
Expand Down

0 comments on commit 65e8235

Please sign in to comment.