diff --git a/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc b/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc index 53a6c04c..52ee5856 100644 --- a/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc +++ b/modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc @@ -14,32 +14,26 @@ | :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 - for all available :config options + See https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md + 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] (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