Search in sources :

Example 11 with Scanner

use of io.swagger.config.Scanner in project ORCID-Source by ORCID.

the class SwaggerJSONResource method scan.

protected synchronized Swagger scan(Application app) {
    Swagger swagger = null;
    Scanner scanner = ScannerFactory.getScanner();
    ModelConverters.getInstance().addConverter(new SwaggerModelConverter());
    LOGGER.debug("[SWAGGER] using scanner " + scanner);
    if (scanner != null) {
        SwaggerSerializers.setPrettyPrint(scanner.getPrettyPrint());
        swagger = (Swagger) context.getAttribute("swagger");
        Set<Class<?>> classes = scanner.classes();
        if (classes != null) {
            Reader reader = new Reader(swagger, ReaderConfigUtils.getReaderConfig(context));
            swagger = reader.read(classes);
            if (scanner instanceof SwaggerConfig) {
                swagger = ((SwaggerConfig) scanner).configure(swagger);
            } else {
                SwaggerConfig configurator = (SwaggerConfig) context.getAttribute("reader");
                if (configurator != null) {
                    LOGGER.debug("configuring swagger with " + configurator);
                    configurator.configure(swagger);
                } else {
                    LOGGER.debug("no configurator");
                }
            }
            context.setAttribute("swagger", swagger);
        }
    }
    initialized = true;
    return swagger;
}
Also used : Scanner(io.swagger.config.Scanner) SwaggerConfig(io.swagger.config.SwaggerConfig) Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader)

Aggregations

Scanner (io.swagger.config.Scanner)11 Test (org.testng.annotations.Test)5 SwaggerConfig (io.swagger.config.SwaggerConfig)4 SwaggerContextService (io.swagger.jaxrs.config.SwaggerContextService)4 Reader (io.swagger.jaxrs.Reader)3 DefaultJaxrsScanner (io.swagger.jaxrs.config.DefaultJaxrsScanner)3 Swagger (io.swagger.models.Swagger)3 JaxrsScanner (io.swagger.jaxrs.config.JaxrsScanner)1 ServletContext (javax.servlet.ServletContext)1