ring-swagger & compojure-api
sooheon 2018-08-18T14:08:00.000100Z

My handler looks like this, and when I navigate to /api-docs the swagger page loads but it can’t find swagger.json (500 error) . What’s the obvious mistake I’m making?

(ns sullivan.server.handler
   [compojure.api.sweet :refer :all]
   [compojure.route :refer [resources files]]
   [ring.util.response :refer [redirect]]
   [ring.util.http-response :refer :all]
   [compojure.api.upload :as upload]
   [<http://clojure.java.io|clojure.java.io> :as io]))

(def app
   ;; Static resources
   (resources "/cljs-out" {:root "public/cljs-out"})
   (resources "/css" {:root "public/css"})
   (resources "/" {:root "public"})

   ;; API
    (swagger-routes {:ui "/api-docs"})
    (context "/api" []
      (GET "/getter" []
        :query-params [n]
        (-&gt; (ok n) (content-type "text/plain")))

      (POST "/upload_file" []
        :multipart-params [file :- upload/TempFileUpload]
        :middleware [upload/wrap-multipart-params]
        (let [res (ok (dissoc file :tempfile))]

   ;; index.html for SPA (handle 404 clientside)
   (GET "*" []
     (-&gt; (ok (slurp (io/resource "index.html")))
         (content-type "text/html")))))

ikitommi 2018-08-18T14:13:12.000100Z

@sooheon you need to set :spec key to swagger-routes

sooheon 2018-08-18T14:21:11.000100Z

I thought that had a default, "/swagger.json"? I edited it to the following and it still does not load (swagger-routes {:ui "/api-docs" :spec "/swagger.json"})