ayush / swagger-play2

Enables Swagger on Play 2.0
http://swagger.wordnik.com
18 stars 6 forks source link

Null pointer on simple exemple #7

Closed rlemaire closed 12 years ago

rlemaire commented 12 years ago

Hi,

I tried to use this plugin and have the following exception.

I'm new to swagger, so maybe I'm missing something.

Here's the routes I add :

GET /resources.json controllers.ApiHelpController.getResources GET /resources.xml controllers.ApiHelpController.getResources

GET /departureTime.json controllers.ApiHelpController.getResource(path = "/admin") GET /departureTime.xml controllers.ApiHelpController.getResource(path = "/admin")

The Controller (I tried removing the @ApiParamsImplicit) : @Api("/admin") public class TestSwaggerController extends Controller {

@Path("/add-employee")
@ApiOperation(value = "Add a new employee", notes = "", responseClass = "string", httpMethod = "POST")
@ApiParamsImplicit({ @ApiParamImplicit(name = "id", value = "id of employee", required = true, dataType = "string", paramType = "query"),
        @ApiParamImplicit(name = "name", value = "Name of employee", required = true, dataType = "string", paramType = "query"),
        @ApiParamImplicit(name = "salary", value = "The salary which the poor soul gets", required = true, dataType = "string", paramType = "query") })
public static Result addEmployee() {
    return ok();
}

}

And the exception.

play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[NullPointerException: null]] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [play_2.9.1.jar:2.0.1] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [play_2.9.1.jar:2.0.1] at akka.actor.Actor$class.apply(Actor.scala:311) [akka-actor.jar:2.0.1] at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1.jar:2.0.1] at akka.actor.ActorCell.invoke(ActorCell.scala:619) [akka-actor.jar:2.0.1] at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:196) [akka-actor.jar:2.0.1] Caused by: java.lang.NullPointerException: null at controllers.SwaggerBaseApiController.JsonResponse(ApiHelpController.scala:64) ~[swagger-play2_2.9.1.jar:1.0.1] at controllers.SwaggerBaseApiController.returnValue(ApiHelpController.scala:59) ~[swagger-play2_2.9.1.jar:1.0.1] at controllers.ApiHelpController$$anonfun$getResource$1.apply(ApiHelpController.scala:36) ~[swagger-play2_2.9.1.jar:1.0.1] at controllers.ApiHelpController$$anonfun$getResource$1.apply(ApiHelpController.scala:34) ~[swagger-play2_2.9.1.jar:1.0.1] at play.api.mvc.Action$$anon$1.apply(Action.scala:170) ~[play_2.9.1.jar:2.0.1] at play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply(Invoker.scala:126) ~[play_2.9.1.jar:2.0.1]

ayush commented 12 years ago

Hi @rlemaire we've moved the official swagger-play2 module to here:

https://github.com/wordnik/swagger-core/tree/master/modules/swagger-play2

And will have a "release" of it shortly after it reaches feature parity with the JAX-RS version. So can you try that branch, those instructions and post back any issues to there?

Here is a sample project to get you started:

https://github.com/wordnik/swagger-core/tree/master/samples/scala-play2

rlemaire commented 12 years ago

Hi Ayush,

Thank you very much for your answer.

I already tried this version, but it doesn't compile (at least on my machine), so I though the other version was the right one.

I'm going to follow the project on github to see your releases. We may use it later.

[INFO] .../swagger-core/modules/swagger-jaxrs-utils/src/main/scala:-1: info: compiling [INFO] Compiling 3 source files to .../swagger-core/modules/swagger-jaxrs-utils/target/classes at 1336985888641 [ERROR] .../swagger-core/modules/swagger-jaxrs-utils/src/main/scala/com/wordnik/resource/util/HealthEndpoint.scala:21: error: HealthSnapshot is not a member of com.wordnik.util.perf [INFO] import com.wordnik.util.perf.HealthSnapshot [INFO] ^ [ERROR] .../swagger-core/modules/swagger-jaxrs-utils/src/main/scala/com/wordnik/resource/util/HealthEndpoint.scala:35: error: not found: value HealthSnapshot [INFO] def getHealth = Response.ok.entity(HealthSnapshot.get()).build [INFO] ^ [ERROR] two errors found

Regards,

Raphaël Lemaire

2012/5/14 Ayush Gupta < reply@reply.github.com

Hi @rlemaire we've moved the official swagger-play2 module to here:

https://github.com/wordnik/swagger-core/tree/master/modules/swagger-play2

And will have a "release" of it shortly after it reaches feature parity with the JAX-RS version. So can you try that branch, those instructions and post back any issues to there?

Here is a sample project to get you started:

https://github.com/wordnik/swagger-core/tree/master/samples/scala-play2


Reply to this email directly or view it on GitHub: https://github.com/ayush/swagger-play2/issues/7#issuecomment-5683986

ayush commented 12 years ago

Thats because the latest worknik-oss is not being used. I just replied to that issue here: https://github.com/wordnik/swagger-core/issues/33

fehguy commented 12 years ago

@rlemaire the wordnik-oss snapshot is updated in sonatype now, so you should be able to build w/o locally building.