From bf3242a6f487f89e3fbba24f9e14e86f92a6cf92 Mon Sep 17 00:00:00 2001 From: Aleksandr Zhuravlev Date: Thu, 22 Oct 2020 15:16:55 +0300 Subject: [PATCH 1/3] Get rid of conf.js (not used anymore) --- modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc b/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc index 53a6c04c..01d59cd4 100644 --- a/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc +++ b/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc @@ -32,14 +32,10 @@ (create-swagger-ui-handler nil)) ([options] (let [config-json (fn [{:keys [url config]}] (j/write-value-as-string (merge config {:url url}))) - conf-js (fn [opts] (str "window.API_CONF = " (config-json opts) ";")) options (as-> options $ (update $ :root (fnil identity "swagger-ui")) (update $ :url (fnil identity "/swagger.json")) - (assoc $ :paths {"/conf.js" {:headers {"Content-Type" "application/javascript"} - :status 200 - :body (conf-js $)} - "/config.json" {:headers {"Content-Type" "application/json"} + (assoc $ :paths {"/config.json" {:headers {"Content-Type" "application/json"} :status 200 :body (config-json $)}}))] (ring/routes From abfe8107009829de10647ed5d4c225df67bd2d86 Mon Sep 17 00:00:00 2001 From: Aleksandr Zhuravlev Date: Thu, 22 Oct 2020 15:18:16 +0300 Subject: [PATCH 2/3] Update link to config params doc --- modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc b/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc index 01d59cd4..0aae2991 100644 --- a/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc +++ b/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc @@ -14,7 +14,7 @@ | :path | optional path to mount the handler to. Works only if mounted outside of a router. | :config | parameters passed to swaggger-ui as-is. - See https://github.com/swagger-api/swagger-ui/tree/2.x#parameters + See https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md for all available :config options Examples: From 2fc893bf6fc343100bd403489cae7104722b574e Mon Sep 17 00:00:00 2001 From: Aleksandr Zhuravlev Date: Thu, 22 Oct 2020 16:03:05 +0300 Subject: [PATCH 3/3] Update examples --- .../src/reitit/swagger_ui.cljc | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc b/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc index 0aae2991..52ee5856 100644 --- a/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc +++ b/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc @@ -15,19 +15,17 @@ | :config | parameters passed to swaggger-ui as-is. See https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md - for all available :config options + for all available :config options. Examples: + ``` + (swagger-ui/create-swagger-ui-handler) - ;; with defaults - (create-swagger-ui-handler) - - ;; with path and url set, swagger validator disabled, jsonEditor enabled - (swagger-ui/create-swagger-ui-handler - {:path \"/\" - :url \"/api/swagger.json\" - :config {:validatorUrl nil - :jsonEditor true})" + (swagger-ui/create-swagger-ui-handler + {:path \"/swagger-ui\" + :url \"/api/swagger.json\" + :config {:validatorUrl nil}}) + ```" ([] (create-swagger-ui-handler nil)) ([options]