mirror of
https://github.com/metosin/reitit.git
synced 2025-12-18 08:51:12 +00:00
Merge pull request #671 from metosin/fix-example
fix: remove unsupported coercions when generating swagger
This commit is contained in:
commit
f41d555b62
3 changed files with 10 additions and 5 deletions
|
|
@ -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)
|
* 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)
|
* Fetch OpenAPI content types from Muuntaja [#636](https://github.com/metosin/reitit/issues/636)
|
||||||
* **BREAKING** OpenAPI support is now clj only
|
* **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:
|
* Updated dependencies:
|
||||||
|
|
||||||
```clojure
|
```clojure
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@ All main modules bundled:
|
||||||
|
|
||||||
Optionally, the parts can be required separately.
|
Optionally, the parts can be required separately.
|
||||||
|
|
||||||
|
Reitit requires Clojure 1.11.
|
||||||
|
|
||||||
## Quick start
|
## Quick start
|
||||||
|
|
||||||
```clj
|
```clj
|
||||||
|
|
|
||||||
|
|
@ -68,11 +68,13 @@
|
||||||
(defn- swagger-path [path opts]
|
(defn- swagger-path [path opts]
|
||||||
(-> path (trie/normalize opts) (str/replace #"\{\*" "{")))
|
(-> 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
|
(when request
|
||||||
(println "WARNING [reitit.coercion]: swagger apidocs don't support :request coercion"))
|
(println "WARNING [reitit.coercion]: swagger apidocs don't support :request coercion"))
|
||||||
(when (some :content (vals responses))
|
(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]
|
(defn -get-swagger-apidocs [coercion data]
|
||||||
(let [swagger-parameter {:query :query
|
(let [swagger-parameter {:query :query
|
||||||
|
|
@ -80,10 +82,10 @@
|
||||||
:form :formData
|
:form :formData
|
||||||
:header :header
|
:header :header
|
||||||
:path :path
|
:path :path
|
||||||
:multipart :formData}]
|
:multipart :formData}
|
||||||
(-warn-unsupported-coercions data)
|
cleaned (-remove-unsupported-coercions data)]
|
||||||
(->> (update
|
(->> (update
|
||||||
data
|
cleaned
|
||||||
:parameters
|
:parameters
|
||||||
(fn [parameters]
|
(fn [parameters]
|
||||||
(->> parameters
|
(->> parameters
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue