swagger-api / swagger-play

Apache License 2.0
330 stars 181 forks source link

Swagger UI Error with Play 2.5.x Application #171

Closed joesan closed 6 years ago

joesan commented 6 years ago

I just tried to integrate Swagger for my Play framework application and I'm getting NullPointer Exceptions:

I have raised a question in Stackoverflow: https://stackoverflow.com/questions/48974996/play-framework-swagger-ui-integration-error

Here is the problem description once again!

I'm trying to integrate Swagger UI for the Rest API which is served by Play Framework 2.5.x

I did the following:

Included the following dependencies in my build.sbt "io.swagger" %% "swagger-play2" % "1.5.3" "org.webjars" %% "webjars-play" % "2.5.0-4" "org.webjars" % "swagger-ui" % "2.2.0" Added the following to my routes: GET /swagger.json controllers.ApiHelpController.getResources GET /docs/ controllers.Assets.at(path="/public/swagger-ui",file="index.html") GET /docs/*file controllers.Assets.at(path="/public/swagger-ui",file) I then try accessing the swagger.json Here is the error that I get:

[error] application -

! @77515gnlp - Internal server error, for (GET) [/swagger.json] ->

play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[NullPointerException: null]] at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:280) at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:206) at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:100) at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:99) at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:346) at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:345) at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:36) at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:70) at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:44) at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:252) Caused by: java.lang.NullPointerException: null at play.modules.swagger.ApiListingCache$$anonfun$listing$1.apply(ApiListingCache.scala:15) at play.modules.swagger.ApiListingCache$$anonfun$listing$1.apply(ApiListingCache.scala:11) at scala.Option.orElse(Option.scala:289) at play.modules.swagger.ApiListingCache$.listing(ApiListingCache.scala:11) at controllers.SwaggerBaseApiController.getResourceListing(ApiHelpController.scala:128) at controllers.ApiHelpController$$anonfun$getResources$1.apply(ApiHelpController.scala:74) at controllers.ApiHelpController$$anonfun$getResources$1.apply(ApiHelpController.scala:71) at play.api.mvc.ActionBuilder$$anonfun$apply$13.apply(Action.scala:371) at play.api.mvc.ActionBuilder$$anonfun$apply$13.apply(Action.scala:370) at play.api.mvc.Action$.invokeBlock(Action.scala:498) Is there anything else that I should be adding or looking into?

UnconventionalMindset commented 6 years ago

I answered you on stack overflow

webron commented 6 years ago

Unfortunately, we don't provide nor maintain the webjars, so we can't help with it.