Skip to content

Commit

Permalink
Merge pull request #671 from metosin/fix-example
Browse files Browse the repository at this point in the history
fix: remove unsupported coercions when generating swagger
  • Loading branch information
opqdonut authored Apr 19, 2024
2 parents a69cfda + 8ce2de3 commit f41d555
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ We use [Break Versioning][breakver]. The version numbers follow a `<major>.<mino
* Handlers can be vars [#585](https://github.com/metosin/reitit/pull/585)
* Fetch OpenAPI content types from Muuntaja [#636](https://github.com/metosin/reitit/issues/636)
* **BREAKING** OpenAPI support is now clj only
* Fix swagger generation when unsupported coercions are present [#671](https://github.com/metosin/reitit/pull/671)
* Updated dependencies:

```clojure
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ All main modules bundled:

Optionally, the parts can be required separately.

Reitit requires Clojure 1.11.

## Quick start

```clj
Expand Down
12 changes: 7 additions & 5 deletions modules/reitit-swagger/src/reitit/swagger.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,24 @@
(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
:body :body
: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
Expand Down

0 comments on commit f41d555

Please sign in to comment.