swagger-play
swagger-play copied to clipboard
Way to create swagger.json automatically
Hello, I am interested in a way to create a swagger.json automatically during the application start or build phase. Currently, I manually do a call to GET /swagger.json endpoint which returns the generated JSON file. Is there any way I can automate this procedure?
Thanks
How is this project even working for you? Arent you on play 2.7 or newer? Thanks
Yes, I am on play 2.7. Every time to create swagger documentation I call the endpoint. What I would like to achieve it to be created automatically, e.g. when I build or run the app. Thanks
I'm one step behind you, when I do as it says and add this:
libraryDependencies ++= Seq(
"io.swagger" %% "swagger-play2" % "2.0.1-SNAPSHOT"
)
it looks for a jar on mavencentral that isn't here:
https://mvnrepository.com/artifact/io.swagger/swagger-play2 - 2.0.1-SNAPSHOT ain't there
How did you solve this?
This is the one for me: "io.swagger" %% "swagger-play2" % "1.6.1" try this one
That is labeled to support up to scala 2.12, but I'm on 2.13...
I think I had that issue as well when I tried to switch the scala version to 2.13. Eventually I used scala 2.12.19 and following swagger dependency: "io.swagger" %% "swagger-play2" % "1.7.1",
Ah ok you downgraded the scala version. I'm a bit scared to do that just for this module to be honest.
I want to do it at build time, I believe this would have to be some kind of SBT or Maven plugin.
If you want to do it at startup, without calling the endpoint swagger.json
, you could call directly the underlying Swagger controller ApiHelpController
, there are several methods that could use depending on your need.
I published a plugin for this: https://github.com/dwickern/sbt-swagger-play