javajboss7.xresteasyswagger

Why Can't Swagger + RESTEasy use @ApplicationPath("")


Environment = JBoss 7.2.0.Final + RESTEasy 2.3.5.Final + Swagger 1.3.10

Trying to set up a WAR with no web.xml and use Swagger. It works if there is any value in the ApplicationPath

@javax.ws.rs.ApplicationPath("test")

@WebServlet(name = "RestEasy-1", loadOnStartup = 1)

@Path("/message")
@Api(value="/message",description="hello api")

Works for URL

http://localhost:8080/RestEasy-1/test/message/xyz (THE SERVICE)
http://localhost:8080/RestEasy-1/test/api-docs (SHOWS SWAGGER JSON)
http://localhost:8080/RestEasy-1/ (RUNS SWAGGER UI)

However if I change to:

@javax.ws.rs.ApplicationPath("") (also tried /* or * or /)

The service and api-docs work, but Swagger doesn't seem to be available.

I guess it is a collision with listeners on the root of the servlet, but I have a pre-existing constraint that the services run at the root + path, so I need a blank ApplicationPath.

Any idea if Swagger can be set to run of a different path manually?


Solution

  • The problem is that you're trying to serve both the application and static context from the same resource root, and there are some technical issues behind it.

    I believe this SO question - JAX-RS Application on the root context - how can it be done? - refers to the same thing and contains an extensive solution to the problem.