use of io.swagger.config.SwaggerConfig in project swagger-core by swagger-api.
the class ApiDeclarationServlet method init.
@Override
public void init(ServletConfig servletConfig) throws javax.servlet.ServletException {
super.init(servletConfig);
final ServletContext servletContext = servletConfig.getServletContext();
final Scanner scanner = (Scanner) servletContext.getAttribute("scanner");
if (scanner != null) {
Swagger swagger = (Swagger) servletContext.getAttribute("swagger");
if (swagger == null) {
swagger = new Swagger();
}
final SwaggerConfig configurator = (SwaggerConfig) servletContext.getAttribute("reader");
if (configurator != null) {
configurator.configure(swagger);
}
final Set<Class<?>> classes = scanner.classes();
if (classes != null) {
Reader.read(swagger, classes);
}
servletContext.setAttribute("swagger", swagger);
}
}
use of io.swagger.config.SwaggerConfig 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