mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 00:11:11 +00:00
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:
commit
8dc1e50c44
2 changed files with 45 additions and 3 deletions
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in a new issue