use of io.swagger.jaxrs.config.JaxrsScanner in project swagger-core by swagger-api.
the class BaseApiListingResource method scan.
private static synchronized Swagger scan(Application app, ServletContext context, ServletConfig sc, UriInfo uriInfo) {
Swagger swagger = null;
SwaggerContextService ctxService = new SwaggerContextService().withServletConfig(sc).withBasePath(getBasePath(uriInfo));
Scanner scanner = ctxService.getScanner();
if (scanner != null) {
SwaggerSerializers.setPrettyPrint(scanner.getPrettyPrint());
swagger = new SwaggerContextService().withServletConfig(sc).withBasePath(getBasePath(uriInfo)).getSwagger();
Set<Class<?>> classes;
if (scanner instanceof JaxrsScanner) {
JaxrsScanner jaxrsScanner = (JaxrsScanner) scanner;
classes = jaxrsScanner.classesFromContext(app, sc);
} else {
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 swaggerConfig = ctxService.getConfig();
if (swaggerConfig != null) {
LOGGER.debug("configuring swagger with " + swaggerConfig);
swaggerConfig.configure(swagger);
} else {
LOGGER.debug("no configurator");
}
}
new SwaggerContextService().withServletConfig(sc).withBasePath(getBasePath(uriInfo)).updateSwagger(swagger);
}
}
if (SwaggerContextService.isScannerIdInitParamDefined(sc)) {
initializedScanner.put(sc.getServletName() + "_" + SwaggerContextService.getScannerIdFromInitParam(sc), true);
} else if (SwaggerContextService.isConfigIdInitParamDefined(sc)) {
initializedConfig.put(sc.getServletName() + "_" + SwaggerContextService.getConfigIdFromInitParam(sc), true);
} else if (SwaggerContextService.isUsePathBasedConfigInitParamDefined(sc)) {
initializedConfig.put(sc.getServletName() + "_" + ctxService.getBasePath(), true);
} else {
initialized = true;
}
return swagger;
}
Aggregations