Shawn Lauzon
Shawn Lauzon

Reputation: 6282

Missing dependency with Swagger configured in Java

I'm trying to launch our API server using Swagger. We don't use a web.xml at all, and instead configure everything in Java. I'm attempting to follow the instructions from the Swagger JAX-RS tutorial, but still having problems. I'm using the latest code from Git (locally-installed 1.2.1-SNAPSHOT)

final Server jetty = injector.getInstance(Server.class);

ServletContextHandler sch = injector.getInstance(ServletContextHandler.class);
sch.setInitParameter("swagger.api.basepath", "http://localhost:8090");
sch.setInitParameter("api.version", "0.1");

JuiceContainer unprotected = new JuiceContainer(injector, ApiListingResource.class);
sch.addFilter(new FilterHolder(unprotected), "/*", null);
sch.addServlet(DefaultServlet.class, "/");

And the ApiListingResource is exactly how suggested in the tutorial:

@Path("/resources.json")
@Api("/resources")
@Produces(MediaType.APPLICATION_JSON)
public class ApiListingResource extends JavaApiListing { }

Unfortunately, when launching the server I get this error:

SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
  SEVERE: Missing dependency for method public javax.ws.rs.core.Response com.wordnik.swagger.jaxrs.JavaApiListing.getAllApis(javax.servlet.ServletConfig,javax.ws.rs.core.Application,javax.ws.rs.core.HttpHeaders,javax.ws.rs.core.UriInfo) at parameter at index 0
  SEVERE: Method, public javax.ws.rs.core.Response com.wordnik.swagger.jaxrs.JavaApiListing.getAllApis(javax.servlet.ServletConfig,javax.ws.rs.core.Application,javax.ws.rs.core.HttpHeaders,javax.ws.rs.core.UriInfo), annotated with GET of resource, class com.wordnik.swagger.jaxrs.JavaApiListing, is not recognized as valid resource method.

Upvotes: 2

Views: 1733

Answers (1)

Shawn Lauzon
Shawn Lauzon

Reputation: 6282

I fixed this myself in Swagger; there is a pull request open right now.

Upvotes: 2

Related Questions