Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger with Resteasty 3 + Jetty 9.2 + JAX-RS 3

I am trying to configure an existing application to use Swagger. This application uses Resteasy 3 and Jetty 9.2 along with JAX-RS 3.

My changes are based on the explanations given on the Swagger wiki.

I have first added swagger 1.5.0 in my build.gradle before adding annotations @Api and @ApiOperation on a resource named SchedulerStateRest.

The next step was to edit my web.xml in order to hook up Swagger-Core in my Application and Initialize Swagger using Swagger's Servlet.

My issue is that when I launch my application, no resource is found when I browse /swagger.json or /swagger.yaml from http://localhost:8080. However, I get no error while starting Jetty and existing services are running and available.

I have enabled Jetty logs but I found no information relevant to me (the class in charge to launch Jetty embedded is JettyStarter).

By looking for similar problems, I found people who say that swagger content should be available at /v1/api-docs, so I tried different URLs but I always get a 404 error.

Recently, I found a gist from ben-manes for configuring swagger with Resteasy 3 + Guice 4. I tried to mimic its configuration and deduce the configuration for web.xml based on Guice-servlet explanations but I end up with the same problem as for the configuration explained above (no resource available are the expected address).

Since there is no error while starting embedded Jetty, I wonder if the issue is not related to a wrong address. Do you know how to list "resources" that are available on a Jetty instance?

I noticed that explanations on Swagger wiki are for Resteasy 2.X. Does it mean that Swagger is not compatible with Resteasy 3.x?

Ideas, suggestions, etc. to debug, solve the issue are welcome ;)

like image 454
Laurent Avatar asked Jul 12 '15 14:07

Laurent


1 Answers

I actually figured it out yesterday. I'm going to post a sample application on git hub sometime this week since I can't find an example anywhere

like image 101
mad_fox Avatar answered Nov 06 '22 12:11

mad_fox