Merge pull request #182 from hjhamala/support-vectors-in-baselevel-data-specs

Add support for vector based specs in Swagger generation
This commit is contained in:
Tommi Reiman 2018-11-21 14:41:47 +02:00 committed by GitHub
commit 8dc1e50c44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 3 deletions

View file

@ -53,6 +53,11 @@
(into-spec [this name]
(dissoc (ds/spec (ensure-name name) this) :name))
#?(:clj clojure.lang.PersistentVector
:cljs cljs.core.PersistentVector)
(into-spec [this name]
(dissoc (ds/spec (ensure-name name) this) :name))
Maybe
(into-spec [this name]
(ds/spec (ensure-name name) this))

View file

@ -31,7 +31,17 @@
500 {:description "fail"}}
:handler (fn [{{{:keys [x y]} :query
{:keys [z]} :path} :parameters}]
{:status 200, :body {:total (+ x y z)}})}}]]
{:status 200, :body {:total (+ x y z)}})}
:post {:summary "plus with body"
:parameters {:body [int?]
:path {:z int?}}
:swagger {:responses {400 {:schema {:type "string"}
:description "kosh"}}}
:responses {200 {:body {:total int?}}
500 {:description "fail"}}
:handler (fn [{{{:keys [z]} :path
xs :body} :parameters}]
{:status 200, :body {:total (+ (reduce + xs) z)}})}}]]
["/schema" {:coercion schema/coercion}
["/plus/*z"
@ -58,7 +68,12 @@
(app
{:request-method :get
:uri "/api/spec/plus/3"
:query-params {:x "2", :y "1"}}))))
:query-params {:x "2", :y "1"}})))
(is (= {:body {:total 7}, :status 200}
(app
{:request-method :post
:uri "/api/spec/plus/3"
:body-params [1 3]}))))
(testing "schema"
(is (= {:body {:total 6}, :status 200}
(app
@ -126,7 +141,29 @@
400 {:schema {:type "string"}
:description "kosh"}
500 {:description "fail"}}
:summary "plus"}}}}]
:summary "plus"}
:post {:parameters [{:in "body",
:name "",
:description "",
:required true,
:schema {:type "array",
:items {:type "integer",
:format "int64"}}}
{:in "path"
:name "z"
:description ""
:type "integer"
:required true
:format "int64"}]
:responses {200 {:description ""
:schema {:properties {"total" {:format "int64"
:type "integer"}}
:required ["total"]
:type "object"}}
400 {:schema {:type "string"}
:description "kosh"}
500 {:description "fail"}}
:summary "plus with body"}}}}]
(is (= expected spec))
(testing "ring-async swagger-spec"