This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-04
Channels
- # adventofcode (154)
- # announcements (1)
- # babashka (8)
- # beginners (28)
- # bristol-clojurians (3)
- # calva (131)
- # cider (43)
- # clj-kondo (14)
- # clojure (135)
- # clojure-europe (1)
- # clojure-italy (7)
- # clojure-madison (1)
- # clojure-nl (6)
- # clojure-spec (8)
- # clojure-uk (90)
- # clojurescript (47)
- # core-async (9)
- # cryogen (4)
- # cursive (12)
- # datomic (9)
- # emacs (7)
- # fulcro (5)
- # graalvm (56)
- # joker (4)
- # juxt (1)
- # leiningen (6)
- # off-topic (62)
- # pathom (4)
- # pedestal (2)
- # reagent (2)
- # reitit (5)
- # ring (2)
- # schema (4)
- # shadow-cljs (133)
- # sql (38)
- # tools-deps (10)
- # vim (28)
@ikitommi I posted a minimal repro above. It needs all the boilerplate since the problem does not show up when calling encode directly
I have a problem that I hope can be solved via a simple config change that I can't figure out. I have an api created with routes using reitit and I am also creating the swagger-ui endpoint. The app is deployed via aws api gateway. Let's say the endpoint is https://myapi.execute-api.us-east-1.amazonaws.com. The api gateway then allows you to create stages (e.g. dev) so that the base url is now (for dev) https://myapi.execute-api.us-east-1.amazonaws.com/dev. My routes all work just fine with this, but my swagger api is unaware of the dev part of the path. Is there something I can do to resolve the base url correctly? Here is my router code for reference. Adding the :url parameter allows my api-docs endpoint to correctly resolve to swagger.json file, but then all the endpoints it references don't have the dev part of the path in them.
(def router
(ring/router
[["/api" {:swagger {:tags ["basic api"]
:summary "This is the api"}}
["/time" {:get (fn [_] (ok (str "The time is: " (Date.))))}]]
["" {:no-doc true}
["/swagger.json" {:get (swagger/create-swagger-handler)}]
["/api-docs*" {:get (swagger-ui/create-swagger-ui-handler {:url "/dev/swagger.json"})}]]]
{:data {:coercion reitit.coercion.spec/coercion
:middleware [params/wrap-params
middleware/wrap-format]}}))
(def handler
(ring/ring-handler
router
(constantly (not-found "Not found"))))
@markbastian try setting :basePath
under swagger, e.g. {:swagger {:basePath "/dev"}}
just needed for the swagger spec endpoint, so into the properties which has the :no-doc
now
Perfect! Thanks so much for the help (and for the awesome library). For completeness, here's the working router should anyone else run into this:
(def router
(ring/router
[["/api" {:swagger {:tags ["basic api"]
:summary "This is the api"}}
["/time" {:get (fn [_] (ok (str "The time is: " (Date.))))}]]
["" {:no-doc true
:swagger {:basePath "/dev"}}
["/swagger.json" {:get (swagger/create-swagger-handler)}]
["/api-docs*" {:get (swagger-ui/create-swagger-ui-handler {:url "/dev/swagger.json"})}]]]
{:data {:coercion reitit.coercion.spec/coercion
:middleware [params/wrap-params
middleware/wrap-format]}}))