Hi everybody, as the title suggests I experience a NPE while using BeanConfig for generating Swagger documentation for a Jersey project I'm developing.
In particular, my setting and workflow followed are as follows (please, do not hesitate to ask for further clarification if I am missing anything): - I followed the documentation at https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5 - but, I am using Gradle, not Maven - thus my only Gradle dependency is compile 'io.swagger:swagger-jersey2-jaxrs:1.5.16' - also, I do not have any web.xml nor Application subclass - nevertheless, I am using Jersey ResourceConfig, which should offer the same functionalities - My only (atm) REST resource is annotated with (dummy fields for hiding details) - @Singleton @javax.ws.rs.Path("foo") @Api(value = "foo") @Produces({ "application/json", "application/xml" }) @SwaggerDefinition(info = @Info(description = "A foo service", version = "0.0.1", title = "The Foo Service", contact = @Contact(name = "Stefano Mariani", email = "[email protected]", url = "https://fake.address.com/"), license = @License(name = "Apache 2.0", url = "http://www.apache.org/licenses/LICENSE-2.0")), consumes = { "application/json", "application/xml" }, produces = { "application/json", "application/xml" }, schemes = { SwaggerDefinition.Scheme.HTTPS }) - and lives in package "fake.package.path" - To start my Grizzly 2 embedded server I use - BeanConfig beanConfig = new BeanConfig(); beanConfig.setHost(this.adaptedIp + ":" + this.endpointTcp); beanConfig.setBasePath("/api-docs"); beanConfig.setResourcePackage("fake.package.path"); beanConfig.setScan(true); final ResourceConfig config = new ResourceConfig(this.resourceClazz, io.swagger.jaxrs.listing.ApiListingResource.class, io.swagger.jaxrs.listing.SwaggerSerializers.class) .packages("org.glassfish.jersey.examples.jackson" ).register(JacksonFeature.class) .register(MultiPartFeature.class); this.server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config); this.server.start(); In the above configuration I get the mentioned exception. FYI, I tried a few changes based on open/closed issues found on Github issue tracker for Swagger core: - Adding before BeanConfig set up the following code - ReflectiveJaxrsScanner scanner = new ReflectiveJaxrsScanner(); scanner.setResourcePackage("eu.connecare.cdss.hadrian.rest"); ScannerFactory.setScanner(scanner); - based on https://github.com/swagger-api/swagger-core/issues/927 - Wrapping the server in a ServletContainer - ServletContainer sc = new ServletContainer(config); this.server = GrizzlyWebContainerFactory.create(baseUri, sc, null, null); - based on https://stackoverflow.com/questions/33681371/swagger-documentation-with- jax-rs-jersey-2-and-grizzly but none of them worked. Also fyi, it is worth mentioning that besides the exception stack trace I get no log messages whatsoever indicating that Swagger is doing anything. BUT, if I add the following dependencies to my Gradle build script compile 'io.swagger:swagger-annotations:1.5.16' compile 'io.swagger:swagger-codegen:2.2.3' I get the following log line (without changing anything else) INFO org.reflections.Reflections - Reflections took 92 ms to scan 1 urls, producing 65 keys and 77 values Any idea of what I am doing wrong? :) -- You received this message because you are subscribed to the Google Groups "Swagger" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
