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 "<http://helloreverb.com/terms/>"
:contact {:name "My API Team"
:email "<mailto:foo@example.com|foo@example.com>"
:url "<http://www.metosin.fi>"}
:license {:name "Eclipse Public License"
:url "<http://www.eclipse.org/legal/epl-v10.html>"}}
: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 ) ?