All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.swagger.servlet.config.ServletScanner Maven / Gradle / Ivy

There is a newer version: 1.6.14
Show newest version
package io.swagger.servlet.config;

import io.swagger.annotations.Api;
import io.swagger.config.Scanner;
import org.reflections.Reflections;

import javax.servlet.ServletConfig;
import java.util.Set;

public class ServletScanner implements Scanner {

    private boolean prettyPrint = false;
    private String resourcePackage;

    public ServletScanner(ServletConfig servletConfig) {
        resourcePackage = servletConfig.getInitParameter("swagger.resource.package");
        final String shouldPrettyPrint = servletConfig.getInitParameter("swagger.pretty.print");
        if (shouldPrettyPrint != null) {
            prettyPrint = Boolean.parseBoolean(shouldPrettyPrint);
        }
    }

    public String getResourcePackage() {
        return resourcePackage;
    }

    public void setResourcePackage(String resourcePackage) {
        this.resourcePackage = resourcePackage;
    }

    @Override
    public Set> classes() {
        return new Reflections(resourcePackage).getTypesAnnotatedWith(Api.class);
    }

    @Override
    public boolean getPrettyPrint() {
        return prettyPrint;
    }

    @Override
    public void setPrettyPrint(boolean shouldPrettyPrint) {
        this.prettyPrint = shouldPrettyPrint;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy