wkennedy / swagger4spring-web

Swagger support for Spring MVC
89 stars 46 forks source link

Filter will not called when Controller is annotated with @API #83

Open derlinuxer opened 9 years ago

derlinuxer commented 9 years ago

My custom filter will not be called when Controller is annotated with @Api. Based on your current example it is reproduceable with following code.

package com.knappsack.swagger4springweb.controllers;
import java.lang.reflect.Method;
import com.knappsack.swagger4springweb.filter.Filter;

public class TestFilter implements Filter{
    private static final Logger LOGGER = LoggerFactory.getLogger(TestFilter.class);
    @Override
    public boolean isApplicable(Method method) {
        LOGGER.debug("### MethodName isApplicable: " + method.getName());
        return true;
    }
    @Override
    public boolean ignore(Method method) {
        LOGGER.debug("### MethodName ignore: " + method.getName());
        return false;
    }
}
public class ExampleDocumentationController extends ApiDocumentationController {

    public ExampleDocumentationController() {
        ....
        List<Filter> filters = new ArrayList<Filter>();
        filters.add(new TestFilter());
        setFilters(filters);
        ....
}

Only the methods of User & Category Controller can be handled by the filter. Removing @Api the other controller also call the Filter Inteface. Is that works as designed a bug or a mistake of me.

thanks

stephan