Swagger api list is empty

I recently set up swagger with one of my projects. Its using jersey2 and JAX-WS for tomcat for a soothing API. I used the following guide to configure

https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5

$ {basepath} /swagger.json answer with the following

{"swagger": "2.0", "information": {"version": "1.0.0", "name": "}," host ":" local: 8080 "," BasePath ":" / MyAPI "," schemes ": [" HTTP "]}

Unfortunately, it does not contain api, which is under my resource pack. I tried to answer the following question.

swagger - empty list without API

But that didn't help either. The above answer using the com.wordnik.swagger package. * (S) But with the manual I got io.swagger. * Package (s) that does not have a JaxrsApiReader Class

My guess is that swagger was not able to track the api list from the Resource package. But it was not possible to figure out which configuration or which piece of code I missed.

Any help? ....

+4
source share
2 answers

Looks like you forgot to mark the rest of the endpoints with @Api

+4
source

I had the same problem, I used a different approach that worked for me, by adding information only to my Application class. If you have one, this may help you:

public class MyApi extends Application {

    public MyApi() {
        super();
        BeanConfig beanConfig = new BeanConfig();
        beanConfig.setTitle("MyApi");
        beanConfig.setVersion("0.0.1");
        beanConfig.setSchemes(new String[]{"http", "https"});
        beanConfig.setHost("localhost:8080");
        beanConfig.setBasePath("/mypath");

        //putting only the path to my api unblocked me, I removed "io.swagger.resources"
        beanConfig.setResourcePackage("system.organization.api"); 
        beanConfig.setScan(true);
        beanConfig.setPrettyPrint(true);
    }

    @Override
    public Set<Class<?>> getClasses() {
        Set<Class<?>> s = new HashSet<>();

        s.add(MyApis);

        //for swagger
        s.add(ApiListingResource.class);
        s.add(SwaggerSerializers.class);

        return s;
    }
}

Then class references with @ API annotation appeared in swagger.json

, : https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-1.X-Project-Setup-1.5

+2

All Articles