Skip to content

don't crash swagger generation on :content, fix examples #637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/http-swagger/src/example/server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
{:get {:summary "downloads a file"
:swagger {:produces ["image/png"]}
:responses {200 {:description "an image"
:content {"image/png" any?}}}
:content {"image/png" {:schema any?}}}}
:handler (fn [_]
{:status 200
:headers {"Content-Type" "image/png"}
Expand Down
2 changes: 1 addition & 1 deletion examples/ring-malli-swagger/src/example/server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
{:get {:summary "downloads a file"
:swagger {:produces ["image/png"]}
:responses {200 {:description "an image"
:content {"image/png" any?}}}
:content {"image/png" {:schema string?}}}}
:handler (fn [_]
{:status 200
:headers {"Content-Type" "image/png"}
Expand Down
2 changes: 2 additions & 0 deletions examples/ring-spec-swagger/src/example/server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
["/download"
{:get {:summary "downloads a file"
:swagger {:produces ["image/png"]}
:responses {200 {:description "an image"
:content {"image/png" {:schema string?}}}}
:handler (fn [_]
{:status 200
:headers {"Content-Type" "image/png"}
Expand Down
1 change: 1 addition & 0 deletions modules/reitit-malli/src/reitit/coercion/malli.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
(for [[status response] responses]
[status (as-> response $
(set/rename-keys $ {:body :schema})
(dissoc $ :content)
(update $ :description (fnil identity ""))
(if (:schema $)
(update $ :schema swagger/transform {:type :schema})
Expand Down
4 changes: 3 additions & 1 deletion modules/reitit-schema/src/reitit/coercion/schema.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
(into
(empty 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
(throw
(ex-info
Expand Down
1 change: 1 addition & 0 deletions modules/reitit-spec/src/reitit/coercion/spec.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
(empty responses)
(for [[k response] responses]
[k (as-> response $
(dissoc $ :content)
(set/rename-keys $ {:body :schema}))]))})))
;; :openapi handled in reitit.openapi/-get-apidocs-openapi
(throw
Expand Down