Fix default description

https://github.com/metosin/reitit/issues/403
This commit is contained in:
piotr-yuxuan 2020-05-19 23:30:44 +01:00
parent 50f0120e8c
commit 3e8eaa48d7
No known key found for this signature in database
GPG key ID: 7CE94E0B7FFCB423
2 changed files with 9 additions and 3 deletions

View file

@ -92,6 +92,7 @@
(apply meta-merge (keep (comp :swagger :data) interceptors)) (apply meta-merge (keep (comp :swagger :data) interceptors))
(if coercion (if coercion
(coercion/get-apidocs coercion :swagger data)) (coercion/get-apidocs coercion :swagger data))
(when-not (:responses data) {:responses {:default {:description ""}}})
(select-keys data [:tags :summary :description]) (select-keys data [:tags :summary :description])
(strip-top-level-keys swagger))])) (strip-top-level-keys swagger))]))
transform-path (fn [[p _ c]] transform-path (fn [[p _ c]]

View file

@ -25,7 +25,9 @@
["/spec" {:coercion spec/coercion} ["/spec" {:coercion spec/coercion}
["/plus/:z" ["/plus/:z"
{:get {:summary "plus" {:patch {:summary "patch"
:handler (constantly {:status 200})}
:get {:summary "plus"
:parameters {:query {:x int?, :y int?} :parameters {:query {:x int?, :y int?}
:path {:z int?}} :path {:z int?}}
:swagger {:responses {400 {:schema {:type "string"} :swagger {:responses {400 {:schema {:type "string"}
@ -120,7 +122,10 @@
expected {:x-id #{::math} expected {:x-id #{::math}
:swagger "2.0" :swagger "2.0"
:info {:title "my-api"} :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" :name "x"
:description "" :description ""
:required true :required true
@ -312,7 +317,7 @@
(is (= ["/common/ping" "/one/ping" "/two/ping" "/two/deep/ping"] (is (= ["/common/ping" "/one/ping" "/two/ping" "/two/deep/ping"]
(spec-paths app "/one-two/swagger.json"))))) (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 (let [app (swagger-ui/create-swagger-ui-handler
{:path "/" {:path "/"
:config {:jsonEditor true}})] :config {:jsonEditor true}})]