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;
}
Aggregations