Skip to content

Commit

Permalink
Merge pull request #89 from preoctopus/master
Browse files Browse the repository at this point in the history
Generated swagger.json doesn't de-keyword (fixes #88)
  • Loading branch information
ikitommi committed Feb 25, 2016
2 parents 7e6082c + 4478838 commit 98ec68b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/ring/swagger/swagger2.clj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
(defmethod extract-parameter :body [_ model options]
(if-let [schema (rsc/peek-schema model)]
(let [schema-json (jsons/->swagger model options)]
(vector {:in :body
(vector {:in "body"
:name (name (s/schema-name schema))
:description (or (:description (jsons/->swagger schema options)) "")
:required (not (jsons/maybe? model))
Expand All @@ -55,7 +55,7 @@
json-schema (jsons/->swagger v options)]
:when json-schema]
(merge
{:in in
{:in (name in)
:name (name rk)
:description ""
:required (or (= in :path) (s/required-key? k))}
Expand Down
4 changes: 2 additions & 2 deletions test/ring/swagger/swagger2_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
(fact "s/either stuff is correctly named"
(-> (swagger-json {:paths {"/ab" {:get {:parameters {:body SchemaAB}}}}})
(get-in [:paths "/ab" :get :parameters 0]))
=> {:in :body
=> {:in "body"
:name "SchemaA"
:description ""
:required true
Expand All @@ -343,7 +343,7 @@
(fact "body wrapped in Maybe make's it optional"
(-> (swagger-json {:paths {"/maybe" {:post {:parameters {:body (s/maybe {:kikka s/Str})}}}}})
(get-in [:paths "/maybe" :post :parameters 0]))
=> (contains {:in :body, :required false}))
=> (contains {:in "body", :required false}))

(fact "path-parameters with .dot extension, #82"
(swagger-json
Expand Down
30 changes: 15 additions & 15 deletions test/ring/swagger/swagger2_unit_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -187,34 +187,34 @@
:formData {:f Integer}} {})

=> [{:name "Pet"
:in :body
:in "body"
:description ""
:required true
:schema {:$ref "#/definitions/Pet"}}
{:name "id"
:in :query
:in "query"
:description ""
:required true
:type "integer"
:format "int64"}
{:name "q"
:in :query
:in "query"
:description ""
:required false
:type "string"}
{:name "p"
:in :path
:in "path"
:description ""
:required true
:type "integer"
:format "int64"}
{:name "h"
:in :header
:in "header"
:description ""
:required true
:type "string"}
{:name "f"
:in :formData
:in "formData"
:description ""
:required true
:type "integer"
Expand All @@ -230,13 +230,13 @@

=> [{:name "q"
:description ""
:in :query
:in "query"
:required true
:type "string"}
{:name "l"
:description ""
:format "int64"
:in :query
:in "query"
:required false
:type "integer"}])

Expand All @@ -248,13 +248,13 @@

=> [{:name "q"
:description ""
:in :path
:in "path"
:required true
:type "string"}
{:name "l"
:description ""
:format "int64"
:in :path
:in "path"
:required true
:type "integer"}]))

Expand All @@ -263,7 +263,7 @@

=> [{:name "Body"
:description ""
:in :body
:in "body"
:required true
:schema {:type "array"
:items {:$ref "#/definitions/Body"}}}])
Expand All @@ -273,7 +273,7 @@

=> [{:name "Body"
:description ""
:in :body
:in "body"
:required true
:schema {:type "array"
:uniqueItems true
Expand All @@ -284,7 +284,7 @@

=> [{:description "foo"
:name "Body"
:in :body
:in "body"
:required true
:schema {:$ref "#/definitions/Body"}}])

Expand All @@ -293,7 +293,7 @@

=> [{:description "foo"
:name "Body"
:in :body
:in "body"
:required true
:schema {:type "array"
:items {:$ref "#/definitions/Body"}}}]))
Expand Down Expand Up @@ -453,7 +453,7 @@
:operationId ..operationid..
:consumes ["application/xyz"]
:produces ["application/xyz"]
:parameters [{:in :path
:parameters [{:in "path"
:name "id"
:description ""
:required true
Expand Down

0 comments on commit 98ec68b

Please sign in to comment.