mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 00:11:11 +00:00
Merge pull request #637 from metosin/fix-openapi-example
don't crash swagger generation on :content, fix examples
This commit is contained in:
commit
76a08a2322
6 changed files with 9 additions and 3 deletions
|
|
@ -77,7 +77,7 @@
|
||||||
{:get {:summary "downloads a file"
|
{:get {:summary "downloads a file"
|
||||||
:swagger {:produces ["image/png"]}
|
:swagger {:produces ["image/png"]}
|
||||||
:responses {200 {:description "an image"
|
:responses {200 {:description "an image"
|
||||||
:content {"image/png" any?}}}
|
:content {"image/png" {:schema any?}}}}
|
||||||
:handler (fn [_]
|
:handler (fn [_]
|
||||||
{:status 200
|
{:status 200
|
||||||
:headers {"Content-Type" "image/png"}
|
:headers {"Content-Type" "image/png"}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
{:get {:summary "downloads a file"
|
{:get {:summary "downloads a file"
|
||||||
:swagger {:produces ["image/png"]}
|
:swagger {:produces ["image/png"]}
|
||||||
:responses {200 {:description "an image"
|
:responses {200 {:description "an image"
|
||||||
:content {"image/png" any?}}}
|
:content {"image/png" {:schema string?}}}}
|
||||||
:handler (fn [_]
|
:handler (fn [_]
|
||||||
{:status 200
|
{:status 200
|
||||||
:headers {"Content-Type" "image/png"}
|
:headers {"Content-Type" "image/png"}
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,8 @@
|
||||||
["/download"
|
["/download"
|
||||||
{:get {:summary "downloads a file"
|
{:get {:summary "downloads a file"
|
||||||
:swagger {:produces ["image/png"]}
|
:swagger {:produces ["image/png"]}
|
||||||
|
:responses {200 {:description "an image"
|
||||||
|
:content {"image/png" {:schema string?}}}}
|
||||||
:handler (fn [_]
|
:handler (fn [_]
|
||||||
{:status 200
|
{:status 200
|
||||||
:headers {"Content-Type" "image/png"}
|
:headers {"Content-Type" "image/png"}
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,7 @@
|
||||||
(for [[status response] responses]
|
(for [[status response] responses]
|
||||||
[status (as-> response $
|
[status (as-> response $
|
||||||
(set/rename-keys $ {:body :schema})
|
(set/rename-keys $ {:body :schema})
|
||||||
|
(dissoc $ :content)
|
||||||
(update $ :description (fnil identity ""))
|
(update $ :description (fnil identity ""))
|
||||||
(if (:schema $)
|
(if (:schema $)
|
||||||
(update $ :schema swagger/transform {:type :schema})
|
(update $ :schema swagger/transform {:type :schema})
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,9 @@
|
||||||
(into
|
(into
|
||||||
(empty responses)
|
(empty responses)
|
||||||
(for [[k response] responses]
|
(for [[k response] responses]
|
||||||
[k (set/rename-keys response {:body :schema})]))})))
|
[k (-> response
|
||||||
|
(dissoc :content)
|
||||||
|
(set/rename-keys {:body :schema}))]))})))
|
||||||
;; :openapi handled in reitit.openapi/-get-apidocs-openapi
|
;; :openapi handled in reitit.openapi/-get-apidocs-openapi
|
||||||
(throw
|
(throw
|
||||||
(ex-info
|
(ex-info
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@
|
||||||
(empty responses)
|
(empty responses)
|
||||||
(for [[k response] responses]
|
(for [[k response] responses]
|
||||||
[k (as-> response $
|
[k (as-> response $
|
||||||
|
(dissoc $ :content)
|
||||||
(set/rename-keys $ {:body :schema}))]))})))
|
(set/rename-keys $ {:body :schema}))]))})))
|
||||||
;; :openapi handled in reitit.openapi/-get-apidocs-openapi
|
;; :openapi handled in reitit.openapi/-get-apidocs-openapi
|
||||||
(throw
|
(throw
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue