Skip to content

Commit

Permalink
Merge pull request #939 from metosin/fix/swagger
Browse files Browse the repository at this point in the history
fix: don't add extra `:schema nil` to swagger :parameters
  • Loading branch information
ikitommi authored Aug 31, 2023
2 parents 0d8c098 + 60b4231 commit 6682e8f
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 6682e8f

Please sign in to comment.