From 01b476b342533af51bac7054dbc835b91d0c188c Mon Sep 17 00:00:00 2001 From: Joel Kaasinen Date: Fri, 19 Apr 2024 09:35:09 +0300 Subject: [PATCH 1/3] fix: remove unsupported coercions when generating swagger If we don't remove them, :responses :content gets passed out verbatim in the swagger.json, breaking stuff. In particular, fixes the swagger.json in examples/reitit-malli-swagger. Reported broken in #669. --- modules/reitit-swagger/src/reitit/swagger.cljc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/reitit-swagger/src/reitit/swagger.cljc b/modules/reitit-swagger/src/reitit/swagger.cljc index fffba6eb..039f53c5 100644 --- a/modules/reitit-swagger/src/reitit/swagger.cljc +++ b/modules/reitit-swagger/src/reitit/swagger.cljc @@ -68,11 +68,13 @@ (defn- swagger-path [path opts] (-> path (trie/normalize opts) (str/replace #"\{\*" "{"))) -(defn -warn-unsupported-coercions [{:keys [request responses] :as _data}] +(defn -remove-unsupported-coercions [{:keys [request responses] :as data}] (when request (println "WARNING [reitit.coercion]: swagger apidocs don't support :request coercion")) (when (some :content (vals responses)) - (println "WARNING [reitit.coercion]: swagger apidocs don't support :responses :content coercion"))) + (println "WARNING [reitit.coercion]: swagger apidocs don't support :responses :content coercion")) + (cond-> (dissoc data :request) + responses (assoc :responses (update-vals responses #(dissoc % :content))))) (defn -get-swagger-apidocs [coercion data] (let [swagger-parameter {:query :query @@ -80,10 +82,10 @@ :form :formData :header :header :path :path - :multipart :formData}] - (-warn-unsupported-coercions data) + :multipart :formData} + cleaned (-remove-unsupported-coercions data)] (->> (update - data + cleaned :parameters (fn [parameters] (->> parameters From ff957661e5bac1c5d5d948fa5d914a0da1522c61 Mon Sep 17 00:00:00 2001 From: Joel Kaasinen Date: Fri, 19 Apr 2024 09:54:57 +0300 Subject: [PATCH 2/3] doc: update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1779b0af..ed540fab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ We use [Break Versioning][breakver]. The version numbers follow a `. Date: Fri, 19 Apr 2024 10:15:45 +0300 Subject: [PATCH 3/3] doc: reitit requires clojure 1.11 now that we're using update-vals --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5a4415ac..a7124f5b 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,8 @@ All main modules bundled: Optionally, the parts can be required separately. +Reitit requires Clojure 1.11. + ## Quick start ```clj