Closed ardlema closed 9 years ago
hi, can you please take a look at the updated sample? There was a fix required for play > 2.0 which is currently in this snapshot:
The updated samples are here:
https://github.com/wordnik/swagger-core/tree/master/samples/java-play2
https://github.com/wordnik/swagger-core/tree/master/samples/scala-play2
please reopen if still an issue.
I am trying to add swagger to my Play 2.1-Scala 2.10 application and I'm not sure what I'm doing wrong. In order to just test and see if I can make it work I added the required annotations to my controller:
@Api(value = "/receta", listingPath = "/api-docs.{format}/receta", description = "Operations about Recipes") object CookBookController extends Controller {
@ApiOperation(value = "Gets the recipe of a specific description", notes = "Returns a Recipe", responseClass = "model.Recipe", httpMethod = "GET") @ApiErrors(Array( new ApiError(code = 404, reason = "Recipe not found"))) def getReceta(@ApiParam(value = "Description of the recipe")@PathParam("descripcion") descripcion: String) = Action { implicit request => val receta = Repository.getRecipeByDescription(descripcion)
}
Then, I added the following routes:
GET /receta/:descripcion controllers.CookBookController.getReceta(descripcion: String) POST /receta controllers.CookBookController.createReceta()
GET /api-docs.json controllers.ApiHelpController.getResources GET /api-docs.json/receta controllers.ApiHelpController.getResource(path = "/api-docs.json/receta") GET /receta.json/:descripcion controllers.CookBookController.getReceta(descripcion)
But when I try to go to http://localhost:9000/api-docs.json I am getting the following error:
@6foj3n87p - Internal server error, for (GET) [/api-docs.json] ->
sbt.PlayExceptions$CompilationException: Compilation error[not found: type PathParam] at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15$$anonfun$apply$16.apply(PlayReloader.scala:349) ~[na:na] at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15$$anonfun$apply$16.apply(PlayReloader.scala:349) ~[na:na] at scala.Option.map(Option.scala:133) ~[scala-library.jar:na] at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15.apply(PlayReloader.scala:349) ~[na:na] at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15.apply(PlayReloader.scala:346) ~[na:na] at scala.Option.map(Option.scala:133) ~[scala-library.jar:na]
I have tried with all the versions of swagger (1.2.2, 1.2.3, 1.2.4 & 1.2.5)