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
(:require
[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
(routes
;; Static resources
(resources "/cljs-out" {:root "public/cljs-out"})
(resources "/css" {:root "public/css"})
(resources "/" {:root "public"})
;; API
(api
(swagger-routes {:ui "/api-docs"})
(context "/api" []
(GET "/getter" []
:query-params [n]
(-> (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))]
res))))
;; index.html for SPA (handle 404 clientside)
(GET "*" []
(-> (ok (slurp (io/resource "index.html")))
(content-type "text/html")))))
@sooheon you need to set :spec
key to swagger-routes
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"})