This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-27
Channels
- # announcements (2)
- # babashka (60)
- # beginners (73)
- # calva (23)
- # cider (2)
- # clj-kondo (19)
- # cljs-dev (31)
- # clojure (29)
- # clojure-berlin (1)
- # clojure-europe (6)
- # clojure-nl (17)
- # clojure-spec (21)
- # clojure-uk (15)
- # clojurescript (54)
- # core-async (48)
- # cursive (35)
- # datomic (12)
- # emacs (12)
- # fulcro (66)
- # graalvm (3)
- # graphql (16)
- # jackdaw (1)
- # malli (1)
- # off-topic (11)
- # pedestal (4)
- # re-frame (10)
- # reitit (1)
- # rewrite-clj (8)
- # ring-swagger (8)
- # shadow-cljs (14)
- # spacemacs (2)
- # vim (5)
Howdy, I setup ring-swagger as the docs explained ( added to deps.edn )
metosin/ring-swagger {:mvn/version "0.26.2"}
metosin/ring-swagger-ui {:mvn/version "3.20.1"}
used the example json ( in file that is required by my middleware.clj file that requires ring-middleware and handles ring requests )
(s/defschema User {:id s/Str,
:name s/Str
:address {:street s/Str
:city (s/enum :tre :hki)}})
(s/with-fn-validation
(rs/swagger-json
{:info {:version "1.0.0"
:title "Sausages"
:description "Sausage description"
:termsOfService " "
:contact {:name "My API Team"
:email ""
:url ""}
:license {:name "Eclipse Public License"
:url ""}}
:tags [{:name "user"
:description "User stuff"}]
:paths {"/api/ping" {:get {}}
"/user/:id" {:post {:summary "User Api"
:description "User Api description"
:tags ["user"]
:parameters {:path {:id s/Str}
:body User}
:responses {200 {:schema User
:description "Found it!"}
404 {:description "Ohnoes."}}}}}}))
restarted everything, went to localhost:300/swagger.json and did not see anything
Am I missing something ?@dansudol swagger-json
is a pure function to create a swagger spec. You need to serve that yourself. See https://github.com/metosin/compojure-api how it uses ring-swagger to emit swagger docs out of compojure routes
we are not using composure for routing but rather just handling routing ourselves in ring middleware , do i need to setup composure or should I return this json and let my front end framework ( fulcro ) show the json as swagger ( I am so confused )
you need to have a route that serves the generated spec as json. Swagger-ui is configured to use that path (for example "/swagger.json"
) to genererate the ui from. Hope this helps
oh .. ok .. so i would manually set up a public route that served back my swagger json .. from a route named swagger.json
sorta makes sense .. i will try that now
ok .. i have the backend returning the swagger json .. now, how would i get the nice swagger UI look and feel for the front end ?
is there a way to convert that json to html before i return the json ( or instead of the json ) ?