0
votes

I followed the step to add Swagger to my already built Jersey REST API project in TOMCAT I follow the steps https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5#configure-and-initialize-swagger

Step 1: Added following

swagger-annotations_2.10-1.3.0

swagger-core_2.10-1.3.10

swagger-jaxrs_2.10-1.3.10

swagger-jersey2-jaxrs_2.10-1.3.10

Step 2: Added Swagger core provider in Application sub class

resources.add(com.wordnik.swagger.jersey.listing.ApiListingResource.class); 
resources.add(com.wordnik.swagger.jersey.listing.JerseyApiDeclarationProvider.class);
resources.add(com.wordnik.swagger.jersey.listing.ApiListingResourceJSON.class);
resources.add(com.wordnik.swagger.jersey.listing.JerseyResourceListingProvider.class);

Step 3. Used Application class constructor to setup Swagger:

 public ApplicationConfig() {
        BeanConfig beanConfig = new BeanConfig();
        beanConfig.setVersion("1.0.0");
        beanConfig.setBasePath("localhost:8080/api");
        beanConfig.setResourcePackage(RESOURCE_PACKAGE);
        beanConfig.setScan(true);
    }

However, when I navigate to:

http://localhost:8080/Test/api/partner/v1/swagger.json

I see:

HTTP Status 404 - page not found.

1

1 Answers

-1
votes

I see a couple things. First, from that guide, the dependencies should be:

<dependency>
  <groupId>io.swagger</groupId>
  <artifactId>swagger-jersey2-jaxrs</artifactId>
  <version>1.5.0</version>
</dependency>

Your post looks like they are not 1.5.0 (actually you can use 1.5.3 as of last week).