swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
http://swagger.io
Apache License 2.0
7.36k stars 2.17k forks source link

PathParam annotation - Compilation problem #343

Closed ardlema closed 9 years ago

ardlema commented 10 years ago

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)

receta match {
  case Some(receta) => Ok(JsonParser.recipeToJson(receta))
  case _ => NotFound
}

}

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)

fehguy commented 10 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:

https://oss.sonatype.org/content/repositories/snapshots/com/wordnik/swagger-play2_2.10/1.2.6-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

fehguy commented 9 years ago

please reopen if still an issue.