Fork me on GitHub
#ring-swagger
<
2018-10-24
>
ikitommi04:10:28

@petr.mensik could you explain your use case bit more? There are several ways…

petr.mensik09:10:06

I plan to feed it to the AWS API Gateway to automate API creation and update directly from code. I might also use this project which expects swagger.json in target folder https://github.com/trieloff/lein-aws-apigateway

ikitommi10:10:38

@petr.mensik One way is to ask the generated out of an app:

(require '[compojure.api.swagger :as swagger])

;; the app
(def app ...)

(app {:request-method :get, :uri (swagger/swagger-spec-path app)})

ikitommi10:10:01

the default swagger-endpoint is named :compojure.api.swagger/swagger and that function uses the reverse-routing to find the uri and then you just ask the response.

ikitommi10:10:12

(defn swagger-spec-path
  [app]
  (some-> app
          routes/get-routes
          routes/route-lookup-table
          ::swagger
          keys
          first))

ikitommi10:10:45

not documented that well, but one can get the reverse-routing tree out of an app, and lot’s of other things too.

petr.mensik10:10:17

Sounds like a good option, thank you! haven't thought of reverse routing