use of org.apache.geronimo.microprofile.openapi.impl.model.PathsImpl in project tomee by apache.
the class TomEEOpenAPIExtension method createOpenApi.
private OpenAPI createOpenApi(final Class<?> application, final Stream<Class<?>> beans) {
final CDI<Object> current = CDI.current();
final OpenAPI api = ofNullable(config.read(OASConfig.MODEL_READER, null)).map(value -> newInstance(current, value)).map(it -> OASModelReader.class.cast(it).buildModel()).orElseGet(() -> current.select(DefaultLoader.class).get().loadDefaultApi());
final BeanManager beanManager = current.getBeanManager();
processor.processApplication(api, new ElementImpl(beanManager.createAnnotatedType(application)));
if (skipScan) {
return api.paths(new PathsImpl());
}
// adds the context path to the base
final Instance<ServletContext> servletContextInstance = current.select(ServletContext.class);
final boolean appendContextPath = Boolean.valueOf(config.read("application.append-context-path", "true"));
String contextPath = "";
if (appendContextPath && !servletContextInstance.isAmbiguous() && !servletContextInstance.isUnsatisfied()) {
contextPath = servletContextInstance.get().getContextPath();
}
final String base = contextPath + processor.getApplicationBinding(application);
processor.beforeProcessing();
beans.filter(c -> (excludeClasses == null || !excludeClasses.contains(c.getName()))).filter(c -> (excludePackages == null || excludePackages.stream().noneMatch(it -> c.getName().startsWith(it)))).map(beanManager::createAnnotatedType).forEach(at -> processor.processClass(base, api, new ElementImpl(at), at.getMethods().stream().map(MethodElementImpl::new)));
return ofNullable(config.read(OASConfig.FILTER, null)).map(it -> newInstance(current, it)).map(i -> new FilterImpl(OASFilter.class.cast(i)).filter(api)).orElse(api);
}
Aggregations