How to add Swagger to a Play framework project

Viewed 861

I have a Play project and need to add Swagger to it. Started following this guide: play-swagger and even did thealternative setup steps, but the swagger page is empty. Just a header appears on the page. Where should I look for mistakes or did I miss something?

Also, there is another guide: Swagger UI and Play Framework, but the sbt cannot resolve the given dependency. Does it need a specific resolver?

I've added this dependency:

"org.webjars" % "swagger-ui" % "2.2.0"

and this sbt plugin:

addSbtPlugin("com.iheart" %% "sbt-play-swagger" % "0.7.5")

(Play version 2.6, sbt version 1.x, Scala version 2.12.x) There is a swagger.yml file in the conf folder. The contents of the Swagger UI dist folder is in the public/swagger folder. The routes file contains these lines:

### NoDocs ###
GET   /docs/swagger-ui/*file        controllers.Assets.at(path:String="/public/lib/swagger-ui", file:String)

### NoDocs ###
GET   /assets/swagger.json          controllers.swagger.ApiSpecs.specs

from alternative setup and the controller class specified in the same guide is also present. The Swagger UI index.hml contatins this line:

url: "http://localhost:9000/assets/swagger.json"
0 Answers
Related