ring-swagger

ring-swagger & compojure-api
ikitommi 2018-10-24T04:53:28.000100Z

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

petr.mensik 2018-10-24T09:44:06.000100Z

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

ikitommi 2018-10-24T10:29:38.000100Z

@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)})

ikitommi 2018-10-24T10:31:01.000100Z

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.

ikitommi 2018-10-24T10:31:12.000100Z

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

ikitommi 2018-10-24T10:31:45.000100Z

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

petr.mensik 2018-10-24T10:38:17.000100Z

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