Swagger Overrides Path-Annotations

I just got the swagger to create a valid swagger.json. I configured swagger using the Application-config method. However, as soon as I override getClasses-Method to add swagger variables, my JaX-RS Path-annotated classes stop working. The method is as follows

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

    resources.add(io.swagger.jaxrs.listing.ApiListingResource.class);
    resources.add(io.swagger.jaxrs.listing.SwaggerSerializers.class);

    return resources;
}

and calling super.getClasses () returns am empty set. In my project, I have too many resources that I would not want to add manually.

Is there any way that doesn't interfere with my previous configuration?

Thanks!

0
source share
1 answer

javax.ws.rs.core.Feature. FeatureContext. @Provider .

@Provider
public class SwaggerFeature implements Feature {

    @Override
    public boolean configure(FeatureContext context) {
        context.register(ApiListingResource.class);
        context.register(SwaggerSerializers.class);
        return true;
    }
}

, , , Swagger, @Path [ 1] @Provider [ 2]. , .

( [ 3]), ? - .

< > 1. io.swagger.jaxrs.listing.ApiListingResource
2. io.swagger.jaxrs.listing.SwaggerSerializers
3. JAX-RS >

+1

Source: https://habr.com/ru/post/1618088/


All Articles