Skip to content

Commit

Permalink
fix: don't add extra :schema nil to swagger :parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
opqdonut committed Aug 30, 2023
1 parent 30be01e commit 60b4231
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/malli/swagger.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@
(cond-> x
parameters (update :parameters
#(mapv (fn [p]
(update p :schema dissoc :definitions))
(if (contains? p :schema)
(update p :schema dissoc :definitions)
p))
%))
responses (update :responses
#(reduce-kv (fn [rs k v]
Expand Down
21 changes: 19 additions & 2 deletions test/malli/swagger_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,29 @@
:name "body"
:required true
:schema {:properties {:foo {:type "string"}}
:required [:foo], :type "object"}}]
:required [:foo] :type "object"}}
{:description ""
:in "query"
:name :a
:required true
:type "string"}
{:description ""
:in "query"
:name :b
:required true
:type "string"}
{:description ""
:in "header"
:name :c
:required true
:type "string"}]
:responses {200 {:description ""
:schema {:properties {:bar {:type "string"}}
:required [:bar], :type "object"}}}}
(swagger/swagger-spec {::swagger/parameters
{:body [:map [:foo :string]]}
{:body [:map [:foo :string]]
:query [:map [:a :string] [:b :string]]
:header [:map [:c :string]]}
::swagger/responses
{200 {:schema [:map [:bar :keyword]]}}}))))
(testing "generates swagger for ::parameters w/ basic schema + registry"
Expand Down

0 comments on commit 60b4231

Please sign in to comment.