An sbt plugin which runs swagger-play as part of your build.
Advantages:
- Your application has no runtime dependency on swagger-play or swagger-core (only on swagger-annotations).
- Your application serves
swagger.json
as a static asset. - This plugin optionally includes some extra validation for common Swagger annotation mistakes
In project/plugins.sbt
:
addSbtPlugin("com.github.dwickern" % "sbt-swagger-play" % "0.3.0")
In build.sbt
:
libraryDependencies += "io.swagger" % "swagger-annotations" % "1.6.1"
In conf/routes
:
GET /swagger.json controllers.Assets.at(path="/public", file="swagger.json")
That's it. Now you can annotate your REST endpoints and models with Swagger annotations. Also make sure to set up your application.conf.
If you're already using swagger-play as a dependency in your application, this plugin is meant as a drop-in replacement.
In conf/application.conf
, remove any reference to SwaggerModule
:
# REMOVE:
play.modules.enabled += "play.modules.swagger.SwaggerModule"
In conf/routes
, remove any reference to ApiHelpController
and instead serve swagger.json
as a static asset:
# REMOVE:
GET /swagger.json controllers.ApiHelpController.getResources
# ADD:
GET /swagger.json controllers.Assets.at(path="/public", file="swagger.json")