Giter Club home page Giter Club logo

swagger-play's Introduction

Archived

This project is no longer supported.

Build Status

Swagger Play2 Module

Note

This branch (master) holds the latest version (major version 2.x) for latest play version supported (2.7); branch play-2.6 holds the swagger-play version for play 2.6 version (major.minor version 1.6.x).

Older versions are available though not anymore supported in the archive branch.

Overview

This is a module to support Swagger annotations within Play Framework controllers. It is based on the library https://github.com/swagger-api/swagger-play with several improvements. This library uses Swagger 1.5 and Play 2.7. It can be used for both Scala and Java based applications.

We also would like to support Swagger 2.0 in the future and contributions to that end will be gladly accepted.

New and Noteworthy

  • Minimal dependencies: only depends on the core Play module, so it won't bring unnecessary dependencies on the Akka HTTP server or anything else from Play.
  • SwaggerPlugin no longer depends on on Application.
  • Correct Content-Length generation for JSON (originally proposed in #176)
  • No longer uses deprecated Play configuration methods (proposed in #162). Also uses reference.conf for default values.
  • Clarifies compile-time DI docs (proposed in #157)
  • Handle route delegation properly (#132 updated for Play 2.6)
  • Add support for dataTypeClass in ApiImplicitParam (#174)
  • Add support for API keys (#117)
  • Add support for OAuth2 (#183)

Usage

You can depend on pre-built libraries in maven central by adding the following dependency:

libraryDependencies ++= Seq(
  "io.swagger" %% "swagger-play2" % "2.0.1-SNAPSHOT"
)

Or you can build from source.

sbt publishLocal

Adding Swagger to your Play2 app

There are just a couple steps to integrate your Play2 app with swagger.

1. Add the Swagger module to your application.conf

play.modules.enabled += "play.modules.swagger.SwaggerModule"

2. Add the resource listing to your routes file (you can read more about the resource listing here)


GET     /swagger.json           controllers.ApiHelpController.getResources

3. Annotate your REST endpoints with Swagger annotations. This allows the Swagger framework to create the api-declaration automatically!

In your controller for, say your "pet" resource:

  @ApiResponses(Array(
    new ApiResponse(code = 400, message = "Invalid ID supplied"),
    new ApiResponse(code = 404, message = "Pet not found")))
  def getPetById(
    @ApiParam(value = "ID of the pet to fetch") id: String) = Action {
    implicit request =>
      petData.getPetbyId(getLong(0, 100000, 0, id)) match {
        case Some(pet) => JsonResponse(pet)
        case _ => JsonResponse(new value.ApiResponse(404, "Pet not found"), 404)
      }
  }

What this does is the following:

  • Tells swagger that the methods in this controller should be described under the /api-docs/pet path

  • The Routes file tells swagger that this API listens to /{id}

  • Describes the operation as a GET with the documentation Find pet by Id with more detailed notes Returns a pet ....

  • Takes the param id, which is a datatype string and a path param

  • Returns error codes 400 and 404, with the messages provided

In the routes file, you then wire this api as follows:

GET     /pet/:id                 controllers.PetApiController.getPetById(id)

This will "attach" the /api-docs/pet api to the swagger resource listing, and the method to the getPetById method above

Please note that the minimum configuration needed to have a route/controller be exposed in swagger declaration is to have an Api annotation at class level.

The ApiParam annotation

Swagger for play has two types of ApiParams--they are ApiParam and ApiImplicitParam. The distinction is that some paramaters (variables) are passed to the method implicitly by the framework. ALL body parameters need to be described with ApiImplicitParam annotations. If they are queryParams or pathParams, you can use ApiParam annotations.

application.conf - config options

api.version (String) - version of API | default: "beta"
swagger.api.basepath (String) - base url | default: "http://localhost:9000"
swagger.filter (String) - classname of swagger filter | default: empty
swagger.api.info = {
  contact : (String) - Contact Information | default : empty,
  description : (String) - Description | default : empty,
  title : (String) - Title | default : empty,
  termsOfService : (String) - Terms Of Service | default : empty,
  license : (String) - Terms Of Service | default : empty,
  licenseUrl : (String) - Terms Of Service | default : empty
}

Note on Dependency Injection

This plugin works by default if your application uses Runtime dependency injection.

Nevertheless, the plugin can be initialized using compile time dependency injection. For example, you can add the following to your class that extends BuiltInComponentsFromContext:

// This needs to be eagerly instantiated because this sets global state for swagger
val swaggerPlugin = new SwaggerPluginImpl(environment, configuration)
lazy val apiHelpController = new ApiHelpController(controllerComponents, swaggerPlugin)

Security contact

Please disclose any security-related issues or vulnerabilities by emailing [email protected], instead of using the public issue tracker.

swagger-play's People

Contributors

ale-ambita avatar andersha avatar aswarcewicz avatar benmccann avatar c100k avatar cipacda avatar dwickern avatar fehguy avatar frantuma avatar frosforever avatar gmethvin avatar josephpconley avatar lcamilo15 avatar notflorian avatar npeters avatar ponelat avatar ralphdoe avatar ram-ds avatar rayyildiz avatar targeter avatar tpanagos avatar webron avatar wgroves1 avatar yannmoisan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swagger-play's Issues

New Release?

Is there any chance that we could get a 1.5.1 release pushed out? Latest master solves a number of very key problems (namely the routes file problem) and it would be good to have a central release of this.

Thanks!

circular dependency in swagger 1.2

We are using swagger-play 1.3.7 . (play framework 2.2.1 , swagger 1.2)

my model classes are look like this

public class TypeA {
TypeB b;
TypeB c;
}

public class TypeB {
TypeA a;
CustomBigdecimal bigdecimal;
Map<String, Object> additionalmaps;
}

public class TypeC {
TypeB b;
}

  1. how to overcome this circular dependency in swagger 1.2 ? - swagger UI is hanging
  2. how to convert wrapper CustomBigdecimal to Bigdecimal/string ? - result undefined
  3. how do i represent Maps..-- swagger UI is hanging

any samples link in java is greatly appreciated ..

Swagger & java play 2 class loading problems 1.3.12

From @joantune on March 29, 2015 16:19

Hi!

I have been working with Swagger and its 1.3.12 version
(actually I pushed it up to 1.3.13-SNAPSHOT, only locally, and I took the dependency that I had with rs-api 1.x see issue #900 - but this shouldn't matter, unless there have been new updates that I'm not getting that could fix this)

On a class I had implemented a Key value pair class as such:

@MappedSuperclass
public abstract class ExternallyMappedObj<T extends DoubleExternalDated<?>> extends DoubleExternalDated<T> implements
        ExtenallyMappedInterface {

[...]
    @ElementCollection(fetch = FetchType.EAGER)
    @MapKeyColumn(name = "key")
    @CollectionTable(joinColumns = @javax.persistence.JoinColumn(name = "id"))
    @JsonInclude(Include.NON_EMPTY)
    private final Map<String, Classifier> classifiers = new HashMap<String, Classifier>();

Where Classifier was simply something like:

@Embeddable
public class Classifier {
 String value;
}

Problem is, when codegenerating, I had the error that the class: Map[java.lang.String,models.rawdata.Classifier] could not be found. I tried to add app.classloader().loadClass(Classifier.class.getName()); and app.classloader().loadClass("Map[java.lang.String,models.rawdata.Classifier]"); -> Which fails
and because of that, I tried also

 HashMap<String, Classifier> hashMap = new HashMap<String, Classifier>();
            hashMap.clear();

On Global's public void beforeStart(Application app) so that the classloader would have that class by the time that it needed it to generate the Json, but the error never disappeared.
I ended up using a simple Map<String,String> which works:

  @ElementCollection(fetch = FetchType.EAGER)
    @CollectionTable(joinColumns = @JoinColumn(name = "ID"))
    @MapKeyColumn(name = "name")
    @Column(name = "value")
    private final Map<String, String> classifiers = new HashMap<String, String>();

But it would be cool to allow for a custom value classes. It sounds like a bug on the class loading/mapper of Swagger. As you could probably see from my app.classloader().loadClass("Map[java.lang.String,models.rawdata.Classifier]"); naive try, I have no experience/much knowledge on how the classloaders work, and how they treat these kinds of classes, and because I solved it in another way and I'm pressed for time, I didn't poke much around ModelConverters.scala or SwaggerContext.scala to try to fix this, but still, I think it's an important issue so I explain it here for more capable and less time constrained hands to address this issue.

Thanks for the good work, it has been very helpful. On a seperate note, I'm planning on giving back in the form of a Jekkyll template(s) that I use to generate the documentation (I know that swagger-codegen exists but more often than not, you want to add lots of other stuff to the documentation, plus there are lots of designers that have Jekyll experience). More news on that when I'm not time pressed.

Cheers,
JA

Copied from original issue: swagger-api/swagger-core#944

Provide a way to disable swagger

I search a way to disable swagger in production.

I've tried to comment the module in the application.conf, but the endpoint is still working.

Swagger case class parameters required by default when no Option[]

Hello,
I try swagger-play and this is a very good plugin.

The argument response = classOf[AnalysisHydratedForApp] work well but by default all args are optional in my swagger doc whereas I have a case class with no-option.

So is it possible to change this things (maybe can i change it if you send me some clues).

Have a good day.

swagger 2.0 support for Play

The current swagger-api group implementations for play don't support swagger 2.0. There are a number of different efforts on this front that will hopefully converge on the best possible integration.

The previous (swagger-1.2) support was very "java-ish", requiring annotations in the code, etc., and bundled in a bunch of java-specific libraries which were not used by Play. It would be best to have support for Play that's more scala-centric, and uses the swagger-specification as the routing logic, similar to swagger-inflector.

Error injecting constructor with Unrecognized Type: [null]

CreationException: Unable to create injector, see the following errors:

1) Error injecting constructor, java.lang.IllegalArgumentException: Unrecognized Type: [null]
  at play.modules.swagger.SwaggerPluginImpl.<init>(SwaggerPlugin.scala:33)
  while locating play.modules.swagger.SwaggerPluginImpl
  at play.modules.swagger.SwaggerModule.bindings(SwaggerModule.scala:11):
Binding(interface play.modules.swagger.SwaggerPlugin to ConstructionTarget(class play.modules.swagger.SwaggerPluginImpl) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
  while locating play.modules.swagger.SwaggerPlugin

1 error
        at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:466) ~[guice-4.0.jar:na]
        at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:184) ~[guice-4.0.jar:na]
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110) ~[guice-4.0.jar:na]
        at com.google.inject.Guice.createInjector(Guice.java:96) ~[guice-4.0.jar:na]
        at com.google.inject.Guice.createInjector(Guice.java:73) ~[guice-4.0.jar:na]
        at com.google.inject.Guice.createInjector(Guice.java:62) ~[guice-4.0.jar:na]
        at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126) ~[play_2.11-2.4.6.jar:2.4.6]
        at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93) ~[play_2.11-2.4.6.jar:2.4.6]
        at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21) ~[play_2.11-2.4.6.jar:2.4.6]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:153) ~[play-server_2.11-2.4.6.jar:2.4.6]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:150) ~[play-server_2.11-2.4.6.jar:2.4.6]
        at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[play_2.11-2.4.6.jar:2.4.6]
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:150) ~[play-server_2.11-2.4.6.jar:2.4.6]
        ... 14 common frames omitted
Caused by: java.lang.IllegalArgumentException: Unrecognized Type: [null]
        at com.fasterxml.jackson.databind.type.TypeFactory._constructType(TypeFactory.java:405) ~[jackson-databind-2.5.4.jar:2.5.4]
        at com.fasterxml.jackson.databind.type.TypeFactory.constructType(TypeFactory.java:354) ~[jackson-databind-2.5.4.jar:2.5.4]
        at com.fasterxml.jackson.databind.ObjectMapper.constructType(ObjectMapper.java:1332) ~[jackson-databind-2.5.4.jar:2.5.4]
        at io.swagger.scala.converter.SwaggerScalaModelConverter.resolveProperty(SwaggerScalaModelConverter.scala:32) ~[swagger-scala-module_2.11-1.0.0.jar:1.0.0]
        at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:79) ~[swagger-core-1.5.4.jar:1.5.4]
        at io.swagger.converter.ModelConverters.readAsProperty(ModelConverters.java:58) ~[swagger-core-1.5.4.jar:1.5.4]
        at play.modules.swagger.PlayReader.createProperty(PlayReader.java:644) ~[swagger-play2_2.11-1.5.0.jar:1.5.0]
        at play.modules.swagger.PlayReader.getParameters(PlayReader.java:569) ~[swagger-play2_2.11-1.5.0.jar:1.5.0]
        at play.modules.swagger.PlayReader.parseMethod(PlayReader.java:514) ~[swagger-play2_2.11-1.5.0.jar:1.5.0]
        at play.modules.swagger.PlayReader.read(PlayReader.java:136) ~[swagger-play2_2.11-1.5.0.jar:1.5.0]
        at play.modules.swagger.PlayReader.read(PlayReader.java:60) ~[swagger-play2_2.11-1.5.0.jar:1.5.0]
        at play.modules.swagger.PlayReader.read(PlayReader.java:54) ~[swagger-play2_2.11-1.5.0.jar:1.5.0]
        at play.modules.swagger.ApiListingCache$$anonfun$listing$1.apply(ApiListingCache.scala:17) ~[swagger-play2_2.11-1.5.0.jar:1.5.0]
        at play.modules.swagger.ApiListingCache$$anonfun$listing$1.apply(ApiListingCache.scala:11) ~[swagger-play2_2.11-1.5.0.jar:1.5.0]
        at scala.Option.orElse(Option.scala:289) ~[scala-library-2.11.7.jar:na]
        at play.modules.swagger.ApiListingCache$.listing(ApiListingCache.scala:11) ~[swagger-play2_2.11-1.5.0.jar:1.5.0]
        at play.modules.swagger.SwaggerPluginImpl.<init>(SwaggerPlugin.scala:144) ~[swagger-play2_2.11-1.5.0.jar:1.5.0]
        at play.modules.swagger.SwaggerPluginImpl$$FastClassByGuice$$de7219b8.newInstance(<generated>) ~[guice-4.0.jar:1.5.0]
        at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40) ~[guice-4.0.jar:na]
        at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61) ~[guice-4.0.jar:na]
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105) ~[guice-4.0.jar:na]
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85) ~[guice-4.0.jar:na]
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267) ~[guice-4.0.jar:na]
        at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56) ~[guice-4.0.jar:na]
        at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46) ~[guice-4.0.jar:na]
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103) ~[guice-4.0.jar:na]
        at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40) ~[guice-4.0.jar:na]
        at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145) ~[guice-4.0.jar:na]
        at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41) ~[guice-4.0.jar:na]
        at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205) ~[guice-4.0.jar:na]
        at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199) ~[guice-4.0.jar:na]
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092) ~[guice-4.0.jar:na]
        at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199) ~[guice-4.0.jar:na]
        at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180) ~[guice-4.0.jar:na]
        ... 25 common frames omitted

The stacktrace leads to an error in the resolveProperty method in the SwaggerScalaModelConverter.scala:32. Causing constructType to fail in

val javaType = Json.mapper().constructType(`type`)

So it seems that resolveProperty is the culprit of the issue otherwise (if I misinterpret the stacktrace) a generic error with dependency injection might be also a candidate.

In SwaggerPlugin.scala:33 the dependency injection is done:

class SwaggerPluginImpl @Inject()(lifecycle: ApplicationLifecycle, router: Router, app: Application) extends SwaggerPlugin {

With that very generic failure any help would be greatly appreciated.

Play 2.4 support

Hi,

I try to integrate swagger in my Play 2.4 project. Unfortunately I get a "conflicting cross-version suffixes" error, since this swagger module is compiled for Scala 2.10 and my Play 2.4 project for 2.11. Is there a workaround available or some sort of ETA when Play 2.4 will be supported?

Best regards,
Bennet

Issues with parameter annotation (1.5.0)

When we have a method with more than one parameter of the same type the same @ApiParam fields are applied to both in the swagger json.

I think the reason for this is the following code from PlayReader.java, line 537-548 in the current release):

private List<Annotation> getParamAnnotations(Class<?> cls, Method method, String simpleTypeName) {
    Type[] genericParameterTypes = method.getGenericParameterTypes();
    Annotation[][] paramAnnotations = method.getParameterAnnotations();
    for (int i = 0; i < genericParameterTypes.length; i++) {
        final Type type = TypeFactory.defaultInstance().constructType(genericParameterTypes[i], cls);
        String paramClassName = ((JavaType)type).getRawClass().getSimpleName();
        if (simpleTypeName.equalsIgnoreCase(paramClassName)) {
            return Arrays.asList(paramAnnotations[i]);
        }
    }
    return null;
}

In this code the first annotation that matches the parameter TYPE is returned, making our specification not work in the following example:

public Result accept(
  @ApiParam(value = "Id of the settlement to fetch a file from") @PathParam("id") String id,
  @ApiParam(value = "File id of the file to fetch") @PathParam("fid") String fid) {
return play.mvc.Results.TODO;

}

Since it will return this JSON:

"parameters" : [ {
      "name" : "id",
      "in" : "path",
      "description" : "Id of the settlement to fetch a file from",
      "required" : true,
      "type" : "string",
      "default" : ""
    }, {
      "name" : "fid",
      "in" : "path",
      "description" : "Id of the settlement to fetch a file from", <-- This is wrong
      "required" : true,
      "type" : "string",
      "default" : ""
    },

Wouldn't it be better to match with field position in method declaration with fallback to parameter name and finally fallback to type? Another way would be to use the @PathParam or @QueryParam annotations to bind correct parameter to correct @ApiParam.

Or is this "working as intended"? In other words, we should type them as different types (not a good solution).

Splitted routes bug

I think that I found a bug in swagger. If we split routes as I show below the generated uri by swagger will be

/api/v1/users/

instead

/api/v1/users

(reduntant slash)

file: routes

-> /api/v1/users userApi.Routes

file userApi.routes

POST / UserController.createUser

Inaccurate docs (JAX refs)

I think there are some leftover JAX references, for example line

@ApiParam(value = "ID of the pet to fetch") @PathParam("id") id: String) = Action {

which uses PathParam annotation. I discovered that PathParam is a JAX-RS annotation and therefore tried to make things work with ApiImplicitParam, but without luck. I ended up using a completely different library and it works well. So just a word of feedback - update your docs. They should be as accurate and as simple as possible, without user having to navigate all the way here in order to find out that the reason why PathParam is not available for import is because it's a JAX-RS thing.

Perhaps I am missing something, but in any case make sure to be more precise in the docs, otherwise you frustrate users who c/p your snippet hoping things will work out-of-the-box, only to discover that PathParam is nowhere to be found for import.

Compile time DI exception

I have problem when I'am trying attach Swagger to Play Framework app. Swagger lib scan uninitialized classes and cause problems. Any advices how to deal with it?

I extracted part of app as example:

https://github.com/mgosk/play-swagger-example

  CreationException: Unable to create injector, see the following errors:

    1) Error injecting constructor, java.lang.RuntimeException: There is no started application
      at auth.services.AuthService.<init>(AuthService.scala:24)
      while locating auth.services.AuthService
        for parameter 0 at auth.AnonymousAuthController.<init>(AuthController.scala:16)
      while locating auth.AnonymousAuthController
        for parameter 1 at router.Routes.<init>(Routes.scala:43)
      while locating router.Routes
      while locating play.api.inject.RoutesProvider
      while locating play.api.routing.Router
        for parameter 1 at play.modules.swagger.SwaggerPluginImpl.<init>(SwaggerPlugin.scala:33)
      while locating play.modules.swagger.SwaggerPluginImpl
      at play.modules.swagger.SwaggerModule.bindings(SwaggerModule.scala:11):
    Binding(interface play.modules.swagger.SwaggerPlugin to ConstructionTarget(class play.modules.swagger.SwaggerPluginImpl) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
    while locating play.modules.swagger.SwaggerPlugin

Json data

I have a json

{
"user" : "Anirudh",
"method" : "test",
}

How do I add annotation @ApiImplicitParam to my controller action method? I get "Cannot have multiple body parameters"

Avoid duplication of the same annotations

If have some operations protected by a token.

On each operation, I have to duplicate these annotations.

It's cumbersome and it breaks the DRY principle

  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "token", value = "security token", required = true, paramType = "header", dataType="string")
  ))
  @ApiResponses(Array(
    new ApiResponse(code = 401, message="unauthorized")
  ))
  def method1 = Action.async {…

  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "token", value = "security token", required = true, paramType = "header", dataType="string")
  ))
  @ApiResponses(Array(
    new ApiResponse(code = 401, message="unauthorized")
  ))
  def method2 = Action.async {…

  @ApiImplicitParams(Array(
    new ApiImplicitParam(name = "token", value = "security token", required = true, paramType = "header", dataType="string")
  ))
  @ApiResponses(Array(
    new ApiResponse(code = 401, message="unauthorized")
  ))
  def method3 = Action.async {…

Not supported for imported routes syntax in routes file.

In my conf/routes file I have an imported routes syntax like this.

-> / gulp.Routes

When I add this syntax and start the server. There is a swagger error thrown saying

"play.api.UnexpectedException: Unexpected exception[CreationException: Unable to create injector, see the following errors:

  1. Error injecting constructor, java.lang.IllegalArgumentException: URI is not hierarchical
    at play.modules.swagger.SwaggerPluginImpl.(SwaggerPlugin.scala:33)
    while locating play.modules.swagger.SwaggerPluginImpl
    at play.modules.swagger.SwaggerModule.bindings(SwaggerModule.scala:11): " etc.

I think the problem arise because swagger cannot parse the syntax for imported routes. Any one knows what is happening?

Use Play's RoutesFileParser

You can now include:

"com.typesafe.play" %% "routes-compiler"            % "2.4.6",

And use play.routes.compiler.RoutesFileParser instead of play.modules.swagger.routes.RoutesFileParser

Play Framework binders

From @sebigavril on April 1, 2015 13:14

*Swagger does not work with custom binders defined in Play Framework. Please add support for documenting binders. *

For example...
Using Play Framework, I have defined this route:

GET  /profiles/:profile/emails  @controllers.Emails.indexByProfileId(profile: Long, page: Int ?= 1, pagesize: Int ?= 25)

I use swagger to document the route:

def indexByProfileId(
    @ApiParam(value = "Profile id", required = true) @PathParam("profileId")
    profileId: Long,
    @ApiParam(value = "Page number", required = false) @PathParam("page")
    page: Int,
    @ApiParam(value = "Page size", required = false) @PathParam("pageSize")
    pageSize: Int) = ...

All works well. However, when I try to define a binder for page and pageSize, Swagger doesn't work any more. The binder works if I disable Swagger. This is the exception that is thrown:

Problem loading class:  controllers.Emails.indexByProfileId(profile:com.pure360.db.Id, page:dto.PaginationDTO ?= dto. java
.lang.ClassNotFoundException: class controllers.Emails.indexByProfileId(profile:com.pure360.db.Id, page:dto.PaginationDTO ?= dto not found

I'm supposing that Swagger is confused because the route defines a total of 3 parameters, but the endpoint now defines only 2 because of the binder.

cc @fehguy

Copied from original issue: swagger-api/swagger-core#956

Routes file not working for swagger-play2 1.5.0

top level routes file in conf pointing to top level routes files is broken

file: conf/routes
-> / prod.Routes
-> / dev.Routes

Does not chase down endpoints in local prod.routes, dev.routes This is working correctly in swagger-play2 1.1.13.

Initialisation problem using swagger-play2 1.5.1

I get the following error during the initialisation of Swagger when the application is run in jar form

Caused by: java.lang.IllegalArgumentException: URI is not hierarchical
        at java.io.File.<init>(File.java:418)
        at play.modules.swagger.SwaggerPluginImpl.play$modules$swagger$SwaggerPluginImpl$$parseRoutesHelper$1(SwaggerPlugin.scala:119)

It seems to me getResource() is not the best approach when in jar form
I think the solution is using getResourceAsStream

Configuration of api with Play 2.4

Hi,
I am facing problem while configuring swagger api with Play 2.4. I have follow all the steps that is mention in this url : #5
I am getting compile time error with error message "type ApiHelpController is not a member of package controllers" as corresponding file is there in the controllers package.
Could you please guide me how to resolve this issue.

Thanks

Enhance DSL regarding ApiResponse

Not really an issue, but could this be avoided:

new ApiResponse(code = 400, message = "Invalid ID supplied"),
new ApiResponse(code = 404, message = "Pet not found"))) 

By improving the DSL such that this annotation can live next to where you return the codes inside your controller? could it more specifically, wrap around where the response is returned? boilerplate will be reduced....

Maven?

Hello, when will the play2.4 branch pushed to maven?

Error running tests and in prod mode with version 1.5.0

I am using the 1.5.0 version as a dependency in my play project. When I run in dev mode everything is fine, but when I run in prod mode or try to run tests I get the following error:

com.google.inject.CreationException: Unable to create injector, see the following errors:

  1. Error injecting constructor, java.io.FileNotFoundException: File 'conf/routes' does not exist

I have been banging my head against the wall on this for a couple of days now and cannot figure it out.

Any hints would be appreciated.

Swagger 2.0/Play 2.4 does not support routes file with different names

In Play if you want to use a module in an another Play module, you must namespace your routes file to e.g. common.routes and your application.conf to e.g. common.application.conf.

However Swagger Play assumes the routes file is called "routes" - this results in a NullPointerException.

To fix this Swagger Play should check the play.http.router from the application conf.

IllegalArgumentException in 2.4 using stage task

I’m having trouble upgrading with swagger Play Java from 2.3 to 2.4. It worked fine for me with 2.3.

The issue I’m having is accessing the routes file. In SwaggerPlugin.scala line 119 there is this line, where the routes file is parsed.

val parsedRoutes = RoutesFileParser.parse(new File(app.classloader.getResource(routesFile).toURI))

This is running fine for me in the IDE (IntelliJ) or via activator run. However, after running activator compile stage, and then executing it via the generated launcher script in target/universal/stage/bin it fails. The error I’m getting is thrown from the Guice at startup, but the nested exception is this. Line numbers are slightly off due to my adding some println statements.

Caused by: java.lang.IllegalArgumentException: URI is not hierarchical
    at java.io.File.<init>(File.java:418)
    at play.modules.swagger.SwaggerPluginImpl.play$modules$swagger$SwaggerPluginImpl$$parseRoutesHelper$1(SwaggerPlugin.scala:122)
    at play.modules.swagger.SwaggerPluginImpl.parseRoutes(SwaggerPlugin.scala:137)
    at play.modules.swagger.SwaggerPluginImpl.<init>(SwaggerPlugin.scala:104)
    at play.modules.swagger.SwaggerPluginImpl$$FastClassByGuice$$de7219b8.newInstance(<generated>)
    at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)

I’ve hacked into SwaggerPlugin and added a print statement. The URL begin passed to the File constructor is
jar:file:/Users/lanceo/heroku/dev/target/universal/stage/lib/server.server-1.0-SNAPSHOT.jar!/routes
That looks to me like a valid jar: protocol, but this SO indicates that is not allowed with the File contractor. http://stackoverflow.com/questions/10144210/java-jar-file-use-resource-errors-uri-is-not-hierarchical

Running the app with the stage command is a supported deployment method (https://www.playframework.com/documentation/2.4.x/Production). It is how Heroku runs a Play app. Any ideas on work arounds?

Unable to force API host

Due to the way swagger-play is coded, (it appears as though) you are unable to force a host in the configuration. The host is always pulled from the request which makes life difficult for people who have CDNs in front of their swagger.json. As a result of how the host is set, origin information is leaked which would defeat one of the purposes of using a CDN (DDoS) protection.

I would love some sort of configuration value that forced a host and ignored the host in a request.

Submodule Route throw java.lang.IllegalArgumentException: URI is not hierarchical

When my route file include a submodule, my playframework throw a exception.

Route file
~> /admin admin.Routes
then
Caused by: java.lang.IllegalArgumentException: URI is not hierarchical at java.io.File.<init>(File.java:418) ~[na:1.8.0_51] at play.modules.swagger.SwaggerPluginImpl.play$modules$swagger$SwaggerPluginImpl$$parseRoutesHelper$1(SwaggerPlugin.scala:119) ~[swagger-play2_2.11.jar:1.5.1] at play.modules.swagger.SwaggerPluginImpl$$anonfun$1.applyOrElse(SwaggerPlugin.scala:127) ~[swagger-play2_2.11.jar:1.5.1] at play.modules.swagger.SwaggerPluginImpl$$anonfun$1.applyOrElse(SwaggerPlugin.scala:120) ~[swagger-play2_2.11.jar:1.5.1] at scala.collection.immutable.List.collect(List.scala:303) ~[scala-library-2.11.7.jar:na] at play.modules.swagger.SwaggerPluginImpl.play$modules$swagger$SwaggerPluginImpl$$parseRoutesHelper$1(SwaggerPlugin.scala:120) ~[swagger-play2_2.11.jar:1.5.1]

Install instructions missing a step

I tried setting up the play-2.4 version on a Play Java app and it failed with a NullPointerException.

The reason is the docs are missing the instructions to add play.modules.enabled += "play.modules.swagger.SwaggerModule" to application.conf.

Custom ApplicationLoader

Is it possible to use swagger-play with a custom ApplicationLoader.
I need to get a reference to ApiHelpController to instantiate the Routes object manually.

I've tried :

override lazy val router = new Routes(httpErrorHandler, applicationController, assets, new ApiHelpController())

but I've encountered this error .

Caused by: java.lang.NullPointerException: null
    at play.modules.swagger.ApiListingCache$$anonfun$listing$1.apply(ApiListingCache.scala:15) ~[swagger-play2_2.11-1.5.0.jar:1.5.0]
    at play.modules.swagger.ApiListingCache$$anonfun$listing$1.apply(ApiListingCache.scala:11) ~[swagger-play2_2.11-1.5.0.jar:1.5.0]
    at scala.Option.orElse(Option.scala:289) ~[scala-library-2.11.7.jar:na]
    at play.modules.swagger.ApiListingCache$.listing(ApiListingCache.scala:11) ~[swagger-play2_2.11-1.5.0.jar:1.5.0]
    at controllers.SwaggerBaseApiController.getResourceListing(ApiHelpController.scala:128) ~[swagger-play2_2.11-1.5.0.jar:2.4.6]
    at controllers.ApiHelpController$$anonfun$getResources$1.apply(ApiHelpController.scala:74) ~[swagger-play2_2.11-1.5.0.jar:2.4.6]
    at controllers.ApiHelpController$$anonfun$getResources$1.apply(ApiHelpController.scala:71) ~[swagger-play2_2.11-1.5.0.jar:2.4.6]
    at play.api.mvc.ActionBuilder$$anonfun$apply$16.apply(Action.scala:408) ~[play_2.11-2.4.6.jar:2.4.6]
    at play.api.mvc.ActionBuilder$$anonfun$apply$16.apply(Action.scala:407) ~[play_2.11-2.4.6.jar:2.4.6]
    at play.api.mvc.Action$.invokeBlock(Action.scala:533) ~[play_2.11-2.4.6.jar:2.4.6]

Swagger-play simple usage advice required - limitations or bug?

Hi there,
Thanks for developing swagger-play, it is quite useful. We are using 1.3.13 version with play 2.4.4.

I have issue trying to generate correct swagger code for the following simple model. It is likely I am missing something but since I couldn't figure out what, I thought of posting it here for advice.

case class Application2(
@(ApiModelProperty @field)(required=true) audit:Audit2
)

case class Audit2(
@(ApiModelProperty @field)(required=true) createdAt:String
)

@Api(value="/rest/applications", description="Applications")
class ApplicationController extends Controller {
@ApiOperation(
nickname = "getApplication",
produces = "application/json",
response = classOf[Application2],
value = "Gets an application"
)
def application = Action{r=>Ok("test")}
}

For the route /rest/applications above, this is producing:

Application2 {
audit (object, optional)
}

in other words:
{
"audit": {}
}

Issues:

  • it shows the attribute as object, I was expecting to see swagger-play to also show the structure of Audit2 case class.
  • It is uses optional while I clearly set the required attribute to true

Could you please advise how these issues can be fixed. Are these bugs or limitation of swagger-play library?

Thanks,
Ali

Play 2.5 and Unable to create injector

I added swagger-play2 - 1.5.1 as described on this page: https://github.com/swagger-api/swagger-play/tree/master/play-2.4/swagger-play2

BUT, I am getting this error, and can't get rid of it - does anyone else have this problem?

CreationException: Unable to create injector, see the following errors:

1) Error injecting constructor, java.lang.AbstractMethodError: controllers.ApiHelpController.play$api$mvc$Results$_setter_$TooManyRequests_$eq(Lplay/api/mvc/Results$Status;)V
  at controllers.ApiHelpController.<init>(ApiHelpController.scala:68)
  at play.modules.swagger.SwaggerModule.bindings(SwaggerModule.scala:12):
Binding(class controllers.ApiHelpController to self eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
  while locating controllers.ApiHelpController
    for parameter 4 at router.Routes.<init>(Routes.scala:52)
  while locating router.Routes
  while locating play.api.inject.RoutesProvider
  while locating play.api.routing.Router
    for parameter 1 at play.modules.swagger.SwaggerPluginImpl.<init>(SwaggerPlugin.scala:33)
  while locating play.modules.swagger.SwaggerPluginImpl
  at play.modules.swagger.SwaggerModule.bindings(SwaggerModule.scala:11):
Binding(interface play.modules.swagger.SwaggerPlugin to ConstructionTarget(class play.modules.swagger.SwaggerPluginImpl) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
  while locating play.modules.swagger.SwaggerPlugin
Caused by: java.lang.AbstractMethodError: controllers.ApiHelpController.play$api$mvc$Results$_setter_$TooManyRequests_$eq(Lplay/api/mvc/Results$Status;)V
    at play.api.mvc.Results$class.$init$(Results.scala:605)
    at controllers.SwaggerBaseApiController.<init>(ApiHelpController.scala:105)
    at controllers.ApiHelpController.<init>(ApiHelpController.scala:68)
    at controllers.ApiHelpController$$FastClassByGuice$$855b6c80.newInstance(<generated>)
    at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
    at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051)
    at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:405)
    at play.api.inject.RoutesProvider$$anonfun$2.apply(BuiltinModule.scala:82)
    at play.api.inject.RoutesProvider$$anonfun$2.apply(BuiltinModule.scala:82)
    at scala.Option.fold(Option.scala:158)
    at play.api.inject.RoutesProvider.get$lzycompute(BuiltinModule.scala:82)
    at play.api.inject.RoutesProvider.get(BuiltinModule.scala:78)
    at play.api.inject.RoutesProvider.get(BuiltinModule.scala:77)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
    at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
    at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
    at com.google.inject.Guice.createInjector(Guice.java:96)
    at com.google.inject.Guice.createInjector(Guice.java:84)
    at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
    at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
    at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:158)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:155)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:155)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:126)
    at scala.Option.map(Option.scala:146)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:126)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:124)
    at scala.util.Success.flatMap(Try.scala:231)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:124)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:116)
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
    at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

2) Error injecting constructor, java.lang.AbstractMethodError
  at controllers.ApiHelpController.<init>(ApiHelpController.scala:68)
  at play.modules.swagger.SwaggerModule.bindings(SwaggerModule.scala:12):
Binding(class controllers.ApiHelpController to self eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
  while locating controllers.ApiHelpController
    for parameter 4 at router.Routes.<init>(Routes.scala:52)
  while locating router.Routes
  while locating play.api.inject.RoutesProvider
  while locating play.api.routing.Router
    for parameter 0 at play.api.http.JavaCompatibleHttpRequestHandler.<init>(HttpRequestHandler.scala:200)
  while locating play.api.http.JavaCompatibleHttpRequestHandler
  while locating play.api.http.HttpRequestHandler
    for parameter 4 at play.api.DefaultApplication.<init>(Application.scala:220)
  at play.api.DefaultApplication.class(Application.scala:220)
  while locating play.api.DefaultApplication
  while locating play.api.Application
    for parameter 2 at play.modules.swagger.SwaggerPluginImpl.<init>(SwaggerPlugin.scala:33)
  while locating play.modules.swagger.SwaggerPluginImpl
  at play.modules.swagger.SwaggerModule.bindings(SwaggerModule.scala:11):
Binding(interface play.modules.swagger.SwaggerPlugin to ConstructionTarget(class play.modules.swagger.SwaggerPluginImpl) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
  while locating play.modules.swagger.SwaggerPlugin
Caused by: java.lang.AbstractMethodError
    at play.api.mvc.Results$class.$init$(Results.scala:605)
    at controllers.SwaggerBaseApiController.<init>(ApiHelpController.scala:105)
    at controllers.ApiHelpController.<init>(ApiHelpController.scala:68)
    at controllers.ApiHelpController$$FastClassByGuice$$855b6c80.newInstance(<generated>)
    at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
    at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051)
    at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:405)
    at play.api.inject.RoutesProvider$$anonfun$2.apply(BuiltinModule.scala:82)
    at play.api.inject.RoutesProvider$$anonfun$2.apply(BuiltinModule.scala:82)
    at scala.Option.fold(Option.scala:158)
    at play.api.inject.RoutesProvider.get$lzycompute(BuiltinModule.scala:82)
    at play.api.inject.RoutesProvider.get(BuiltinModule.scala:78)
    at play.api.inject.RoutesProvider.get(BuiltinModule.scala:77)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
    at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
    at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
    at com.google.inject.Guice.createInjector(Guice.java:96)
    at com.google.inject.Guice.createInjector(Guice.java:84)
    at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
    at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
    at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:158)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:155)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:155)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:126)
    at scala.Option.map(Option.scala:146)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:126)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:124)
    at scala.util.Success.flatMap(Try.scala:231)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:124)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:116)
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
    at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

3) Error injecting constructor, java.lang.AbstractMethodError
  at controllers.ApiHelpController.<init>(ApiHelpController.scala:68)
  at play.modules.swagger.SwaggerModule.bindings(SwaggerModule.scala:12):
Binding(class controllers.ApiHelpController to self eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
  while locating controllers.ApiHelpController
Caused by: java.lang.AbstractMethodError
    at play.api.mvc.Results$class.$init$(Results.scala:605)
    at controllers.SwaggerBaseApiController.<init>(ApiHelpController.scala:105)
    at controllers.ApiHelpController.<init>(ApiHelpController.scala:68)
    at controllers.ApiHelpController$$FastClassByGuice$$855b6c80.newInstance(<generated>)
    at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
    at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
    at com.google.inject.Guice.createInjector(Guice.java:96)
    at com.google.inject.Guice.createInjector(Guice.java:84)
    at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
    at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
    at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:158)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:155)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:155)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:126)
    at scala.Option.map(Option.scala:146)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:126)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:124)
    at scala.util.Success.flatMap(Try.scala:231)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:124)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:116)
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
    at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

3 errors

Cannot resolve swagger-play2 1.5.0

I noticed you guys recently added Swagger 2.0 support for Play. Great work!

I changed my build.sbt to use "io.swagger" %% "swagger-play2" % "1.5.0"as described in the README (I am using Scala 2.11.6) but the dependency was not resolved.

Have you guys published this yet?

Exclude logback.xml from the jar

Having logback.xml inside io.swagger.swagger-play2_2.11 jar causes a multiple copies error:

10:33:58,778 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/C:/.../gatewayservice/conf/logback.xml]
10:33:58,779 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs multiple times on the classpath.
10:33:58,779 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [file:/C:/...gatewayservice/conf/logback.xml]
10:33:58,779 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/C:/.../GatewayService/target/universal/gatewayservice/lib/io.swagger.swagger-play2_2.11-1.5.1.jar!/logback.xml]

references:
https://groups.google.com/forum/#!topic/clojure/jeVTo0aWWb4
http://stackoverflow.com/questions/3401051/suppress-all-logback-output-to-console

Is there a java version for ApiHelpController.scala?

My project is based on play-java 2.4 that caused the error: "Compilation error[object ApiHelpController is not a member of package controllers
Note: class ApiHelpController exists, but it has no companion object", if I put the ApiHelpController.scala into the app folder. That seems to be the problem that play-java can't recognize the scala controller.
So is there a java version instead of this controller? For I'm not familiar with scala.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.