mirror of
https://github.com/metosin/reitit.git
synced 2025-12-27 03:48:25 +00:00
Merge pull request #404 from piotr-yuxuan/master
[0.5.1] Ass default :responses for Swagger-UI
This commit is contained in:
commit
4e9537cecf
2 changed files with 10 additions and 3 deletions
|
|
@ -82,12 +82,14 @@
|
|||
:x-id ids}))
|
||||
accept-route (fn [route]
|
||||
(-> route second :swagger :id (or ::default) (trie/into-set) (set/intersection ids) seq))
|
||||
base-swagger-spec {:responses ^:displace {:default {:description ""}}}
|
||||
transform-endpoint (fn [[method {{:keys [coercion no-doc swagger] :as data} :data
|
||||
middleware :middleware
|
||||
interceptors :interceptors}]]
|
||||
(if (and data (not no-doc))
|
||||
[method
|
||||
(meta-merge
|
||||
base-swagger-spec
|
||||
(apply meta-merge (keep (comp :swagger :data) middleware))
|
||||
(apply meta-merge (keep (comp :swagger :data) interceptors))
|
||||
(if coercion
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@
|
|||
|
||||
["/spec" {:coercion spec/coercion}
|
||||
["/plus/:z"
|
||||
{:get {:summary "plus"
|
||||
{:patch {:summary "patch"
|
||||
:handler (constantly {:status 200})}
|
||||
:get {:summary "plus"
|
||||
:parameters {:query {:x int?, :y int?}
|
||||
:path {:z int?}}
|
||||
:swagger {:responses {400 {:schema {:type "string"}
|
||||
|
|
@ -120,7 +122,10 @@
|
|||
expected {:x-id #{::math}
|
||||
:swagger "2.0"
|
||||
:info {:title "my-api"}
|
||||
:paths {"/api/spec/plus/{z}" {:get {:parameters [{:in "query"
|
||||
:paths {"/api/spec/plus/{z}" {:patch {:parameters []
|
||||
:summary "patch"
|
||||
:responses {:default {:description ""}}}
|
||||
:get {:parameters [{:in "query"
|
||||
:name "x"
|
||||
:description ""
|
||||
:required true
|
||||
|
|
@ -312,7 +317,7 @@
|
|||
(is (= ["/common/ping" "/one/ping" "/two/ping" "/two/deep/ping"]
|
||||
(spec-paths app "/one-two/swagger.json")))))
|
||||
|
||||
(deftest swagger-ui-congif-test
|
||||
(deftest swagger-ui-config-test
|
||||
(let [app (swagger-ui/create-swagger-ui-handler
|
||||
{:path "/"
|
||||
:config {:jsonEditor true}})]
|
||||
|
|
|
|||
Loading…
Reference in a new issue