[cxf] branch master updated: CXF-7856 - Switch description-microprofile-openapi OpenApiFeature to use the new DelegatingFeature

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[cxf] branch master updated: CXF-7856 - Switch description-microprofile-openapi OpenApiFeature to use the new DelegatingFeature

coheigea
Administrator
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new 3cc41b3  CXF-7856 - Switch description-microprofile-openapi OpenApiFeature to use the new DelegatingFeature
3cc41b3 is described below

commit 3cc41b3ec06795e4589f3caaa6c085d73aa047d5
Author: Colm O hEigeartaigh <[hidden email]>
AuthorDate: Wed Jun 24 17:16:21 2020 +0100

    CXF-7856 - Switch description-microprofile-openapi OpenApiFeature to use the new DelegatingFeature
---
 .../jaxrs/microprofile/openapi/OpenApiFeature.java | 665 ++++++++++++++-------
 1 file changed, 450 insertions(+), 215 deletions(-)

diff --git a/rt/rs/description-microprofile-openapi/src/main/java/org/apache/cxf/jaxrs/microprofile/openapi/OpenApiFeature.java b/rt/rs/description-microprofile-openapi/src/main/java/org/apache/cxf/jaxrs/microprofile/openapi/OpenApiFeature.java
index 2ad6bdc..9c80359 100644
--- a/rt/rs/description-microprofile-openapi/src/main/java/org/apache/cxf/jaxrs/microprofile/openapi/OpenApiFeature.java
+++ b/rt/rs/description-microprofile-openapi/src/main/java/org/apache/cxf/jaxrs/microprofile/openapi/OpenApiFeature.java
@@ -36,7 +36,8 @@ import org.apache.cxf.annotations.Provider.Scope;
 import org.apache.cxf.annotations.Provider.Type;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.feature.AbstractPortableFeature;
+import org.apache.cxf.feature.DelegatingFeature;
 import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
 import org.apache.cxf.jaxrs.common.openapi.DefaultApplicationFactory;
 import org.apache.cxf.jaxrs.common.openapi.SwaggerProperties;
@@ -57,399 +58,633 @@ import org.eclipse.microprofile.openapi.models.OpenAPI;
 
 
 @Provider(value = Type.Feature, scope = Scope.Server)
-public class OpenApiFeature extends AbstractFeature implements SwaggerUiSupport, SwaggerProperties {
-    private static final Logger LOG = LogUtils.getL7dLogger(OpenApiFeature.class);
-
-    private String version;
-    private String title;
-    private String description;
-    private String contactName;
-    private String contactEmail;
-    private String contactUrl;
-    private String license;
-    private String licenseUrl;
-    private String termsOfServiceUrl;
-    // Read all operations also with no @Operation
-    private boolean readAllResources = true;
-    // Scan all JAX-RS resources automatically
-    private boolean scan = true;
-    private boolean prettyPrint = true;
-    private boolean runAsFilter;
-    private Collection<String> ignoredRoutes;
-    private Set<String> resourcePackages;
-    private Set<String> resourceClasses;
-    private String filterClass;
-
-    private Boolean supportSwaggerUi;
-    private String swaggerUiVersion;
-    private String swaggerUiMavenGroupAndArtifact;
-    private Map<String, String> swaggerUiMediaTypes;
-
-    // Allows to pass the configuration location, usually openapi-configuration.json
-    // or openapi-configuration.yml file.
-    private String configLocation;
-    // Allows to pass the properties location, by default swagger.properties
-    private String propertiesLocation = DEFAULT_PROPS_LOCATION;
-    // Allows to disable automatic scan of known configuration locations (enabled by default)
-    private boolean scanKnownConfigLocations = true;
-    // Swagger UI configuration parameters (to be passed as query string).
-    private SwaggerUiConfig swaggerUiConfig;
+public class OpenApiFeature extends DelegatingFeature<OpenApiFeature.Portable>
+        implements SwaggerUiSupport, SwaggerProperties {
 
-    @Override
-    public void initialize(Server server, Bus bus) {
-        final JAXRSServiceFactoryBean sfb = (JAXRSServiceFactoryBean)server
-            .getEndpoint()
-            .get(JAXRSServiceFactoryBean.class.getName());
-
-        final ServerProviderFactory factory = (ServerProviderFactory)server
-            .getEndpoint()
-            .get(ServerProviderFactory.class.getName());
-
-        final Set<String> packages = new HashSet<>();
-        if (resourcePackages != null) {
-            packages.addAll(resourcePackages);
-        }
-
-        final Application application = DefaultApplicationFactory.createApplicationOrDefault(server, factory,
-            sfb, bus, resourcePackages, isScan());
-
-        final AnnotationProcessor processor = new AnnotationProcessor(GeronimoOpenAPIConfig.create(),
-            new NamingStrategy.Http(), null /* default JsonReaderFactory */);
-
-        final OpenAPIImpl api = new OpenAPIImpl();
-
-        if (isScan()) {
-            packages.addAll(scanResourcePackages(sfb));
-        }
-        
-        final Set<Class<?>> resources = new HashSet<>();
-        if (application != null) {
-            processor.processApplication(api, new ClassElement(application.getClass()));
-            LOG.fine("Processed application " + application);
-            
-            if (application.getClasses() != null) {
-                resources.addAll(application.getClasses());
-            }
-        }
-
-        resources.addAll(sfb
-            .getClassResourceInfo()
-            .stream()
-            .map(AbstractResourceInfo::getServiceClass)
-            .filter(cls -> filterByPackage(cls, packages))
-            .filter(cls -> filterByClassName(cls, resourceClasses))
-            .collect(Collectors.toSet()));
-        
-        if (!resources.isEmpty()) {
-            final String binding = (application == null) ? ""
-                : processor.getApplicationBinding(application.getClass());
-            
-            resources
-                .stream()
-                .peek(c -> LOG.info("Processing class " + c.getName()))
-                .forEach(c -> processor.processClass(binding, api, new ClassElement(c),
-                    Stream.of(c.getMethods()).map(MethodElement::new)));
-        } else {
-            LOG.warning("No resource classes registered, the OpenAPI will not contain any endpoints.");
-        }
-        
-        Properties swaggerProps = getSwaggerProperties(propertiesLocation, bus);
-        if (api.getInfo() == null) {
-            api.setInfo(getInfo(swaggerProps));
-        }
-
-        registerOpenApiResources(sfb, api);
-        registerSwaggerUiResources(sfb, swaggerProps, factory, bus);
+    public OpenApiFeature() {
+        super(new Portable());
     }
 
     public boolean isScan() {
-        return scan;
+        return delegate.isScan();
     }
 
     public void setScan(boolean scan) {
-        this.scan = scan;
+        delegate.setScan(scan);
     }
 
     public String getFilterClass() {
-        return filterClass;
+        return delegate.getFilterClass();
     }
 
     public void setFilterClass(String filterClass) {
-        this.filterClass = filterClass;
+        delegate.setFilterClass(filterClass);
     }
     
     public Set<String> getResourcePackages() {
-        return resourcePackages;
+        return delegate.getResourcePackages();
     }
     
     public void setResourcePackages(Set<String> resourcePackages) {
-        this.resourcePackages = (resourcePackages == null) ? null : new HashSet<>(resourcePackages);
+        delegate.setResourcePackages(resourcePackages);
     }
 
     public String getVersion() {
-        return version;
+        return delegate.getVersion();
     }
 
     public void setVersion(String version) {
-        this.version = version;
+        delegate.setVersion(version);
     }
 
     public String getTitle() {
-        return title;
+        return delegate.getTitle();
     }
 
     public void setTitle(String title) {
-        this.title = title;
+        delegate.setTitle(title);
     }
 
     public String getDescription() {
-        return description;
+        return delegate.getDescription();
     }
 
     public void setDescription(String description) {
-        this.description = description;
+        delegate.setDescription(description);
     }
 
     public String getContactName() {
-        return contactName;
+        return delegate.getContactName();
     }
 
     public void setContactName(String contactName) {
-        this.contactName = contactName;
+        delegate.setContactName(contactName);
     }
 
     public String getContactEmail() {
-        return contactEmail;
+        return delegate.getContactEmail();
     }
 
     public void setContactEmail(String contactEmail) {
-        this.contactEmail = contactEmail;
+        delegate.setContactEmail(contactEmail);
     }
 
     public String getContactUrl() {
-        return contactUrl;
+        return delegate.getContactUrl();
     }
 
     public void setContactUrl(String contactUrl) {
-        this.contactUrl = contactUrl;
+        delegate.setContactUrl(contactUrl);
     }
 
     public String getLicense() {
-        return license;
+        return delegate.getLicense();
     }
 
     public void setLicense(String license) {
-        this.license = license;
+        delegate.setLicense(license);
     }
 
     public String getLicenseUrl() {
-        return licenseUrl;
+        return delegate.getLicenseUrl();
     }
 
     public void setLicenseUrl(String licenseUrl) {
-        this.licenseUrl = licenseUrl;
+        delegate.setLicenseUrl(licenseUrl);
     }
 
     public String getTermsOfServiceUrl() {
-        return termsOfServiceUrl;
+        return delegate.getTermsOfServiceUrl();
     }
 
     public void setTermsOfServiceUrl(String termsOfServiceUrl) {
-        this.termsOfServiceUrl = termsOfServiceUrl;
+        delegate.setTermsOfServiceUrl(termsOfServiceUrl);
     }
 
     public boolean isReadAllResources() {
-        return readAllResources;
+        return delegate.isReadAllResources();
     }
 
     public void setReadAllResources(boolean readAllResources) {
-        this.readAllResources = readAllResources;
+        delegate.setReadAllResources(readAllResources);
     }
 
     public Set<String> getResourceClasses() {
-        return resourceClasses;
+        return delegate.getResourceClasses();
     }
 
     public void setResourceClasses(Set<String> resourceClasses) {
-        this.resourceClasses = (resourceClasses == null) ? null : new HashSet<>(resourceClasses);
+        delegate.setResourceClasses(resourceClasses);
     }
 
     public Collection<String> getIgnoredRoutes() {
-        return ignoredRoutes;
+        return delegate.getIgnoredRoutes();
     }
 
     public void setIgnoredRoutes(Collection<String> ignoredRoutes) {
-        this.ignoredRoutes = (ignoredRoutes == null) ? null : new HashSet<>(ignoredRoutes);
+        delegate.setIgnoredRoutes(ignoredRoutes);
     }
 
     public boolean isPrettyPrint() {
-        return prettyPrint;
+        return delegate.isPrettyPrint();
     }
 
     public void setPrettyPrint(boolean prettyPrint) {
-        this.prettyPrint = prettyPrint;
+        delegate.setPrettyPrint(prettyPrint);
     }
     
     public boolean isRunAsFilter() {
-        return runAsFilter;
+        return delegate.isRunAsFilter();
     }
     
     @Override
     public Boolean isSupportSwaggerUi() {
-        return supportSwaggerUi;
+        return delegate.isSupportSwaggerUi();
     }
 
     public void setSupportSwaggerUi(Boolean supportSwaggerUi) {
-        this.supportSwaggerUi = supportSwaggerUi;
+        delegate.setSupportSwaggerUi(supportSwaggerUi);
     }
 
     public String getSwaggerUiVersion() {
-        return swaggerUiVersion;
+        return delegate.getSwaggerUiVersion();
     }
 
     public void setSwaggerUiVersion(String swaggerUiVersion) {
-        this.swaggerUiVersion = swaggerUiVersion;
+        delegate.setSwaggerUiVersion(swaggerUiVersion);
     }
 
     public String getSwaggerUiMavenGroupAndArtifact() {
-        return swaggerUiMavenGroupAndArtifact;
+        return delegate.getSwaggerUiMavenGroupAndArtifact();
     }
 
     public void setSwaggerUiMavenGroupAndArtifact(
             String swaggerUiMavenGroupAndArtifact) {
-        this.swaggerUiMavenGroupAndArtifact = swaggerUiMavenGroupAndArtifact;
+        delegate.setSwaggerUiMavenGroupAndArtifact(swaggerUiMavenGroupAndArtifact);
     }
 
     @Override
     public Map<String, String> getSwaggerUiMediaTypes() {
-        return swaggerUiMediaTypes;
+        return delegate.getSwaggerUiMediaTypes();
     }
 
     public void setSwaggerUiMediaTypes(Map<String, String> swaggerUiMediaTypes) {
-        this.swaggerUiMediaTypes = swaggerUiMediaTypes;
+        delegate.setSwaggerUiMediaTypes(swaggerUiMediaTypes);
     }
 
     public String getConfigLocation() {
-        return configLocation;
+        return delegate.getConfigLocation();
     }
 
     public void setConfigLocation(String configLocation) {
-        this.configLocation = configLocation;
+        delegate.setConfigLocation(configLocation);
     }
 
     public String getPropertiesLocation() {
-        return propertiesLocation;
+        return delegate.getPropertiesLocation();
     }
 
     public void setPropertiesLocation(String propertiesLocation) {
-        this.propertiesLocation = propertiesLocation;
+        delegate.setPropertiesLocation(propertiesLocation);
     }
 
     public void setRunAsFilter(boolean runAsFilter) {
-        this.runAsFilter = runAsFilter;
+        delegate.setRunAsFilter(runAsFilter);
     }
 
     public void setScanKnownConfigLocations(boolean scanKnownConfigLocations) {
-        this.scanKnownConfigLocations = scanKnownConfigLocations;
+        delegate.setScanKnownConfigLocations(scanKnownConfigLocations);
     }
     
     public boolean isScanKnownConfigLocations() {
-        return scanKnownConfigLocations;
+        return delegate.isScanKnownConfigLocations();
     }
     
     public void setSwaggerUiConfig(final SwaggerUiConfig swaggerUiConfig) {
-        this.swaggerUiConfig = swaggerUiConfig;
+        delegate.setSwaggerUiConfig(swaggerUiConfig);
     }
     
     @Override
     public SwaggerUiConfig getSwaggerUiConfig() {
-        return swaggerUiConfig;
+        return delegate.getSwaggerUiConfig();
     }
 
     @Override
     public String findSwaggerUiRoot() {
-        return SwaggerUi.findSwaggerUiRoot(swaggerUiMavenGroupAndArtifact, swaggerUiVersion);
+        return delegate.findSwaggerUiRoot();
     }
     
     protected Properties getUserProperties(final Map<String, Object> userDefinedOptions) {
-        final Properties properties = new Properties();
-        
-        if (userDefinedOptions != null) {
-            userDefinedOptions
-                .entrySet()
-                .stream()
-                .filter(entry -> entry.getValue() != null)
-                .forEach(entry -> properties.setProperty(entry.getKey(), entry.getValue().toString()));
-        }
-        
-        return properties;
+        return delegate.getUserProperties(userDefinedOptions);
     }
 
     protected void registerOpenApiResources(
             final JAXRSServiceFactoryBean sfb,
             final OpenAPI openApiDefinition) {
 
-        sfb.setResourceClassesFromBeans(Collections.singletonList(new OpenApiEndpoint(openApiDefinition)));
+        delegate.registerOpenApiResources(sfb, openApiDefinition);
     }
 
     protected void registerSwaggerUiResources(JAXRSServiceFactoryBean sfb, Properties properties,
             ServerProviderFactory factory, Bus bus) {
         
-        final Registration swaggerUiRegistration = getSwaggerUi(bus, properties, isRunAsFilter());
-        
-        if (!isRunAsFilter()) {
-            sfb.setResourceClassesFromBeans(swaggerUiRegistration.getResources());
-        }
+        delegate.registerSwaggerUiResources(sfb, properties, factory, bus);
+    }
+
+    public static class Portable implements AbstractPortableFeature, SwaggerUiSupport, SwaggerProperties {
+        private static final Logger LOG = LogUtils.getL7dLogger(OpenApiFeature.class);
+
+        private String version;
+        private String title;
+        private String description;
+        private String contactName;
+        private String contactEmail;
+        private String contactUrl;
+        private String license;
+        private String licenseUrl;
+        private String termsOfServiceUrl;
+        // Read all operations also with no @Operation
+        private boolean readAllResources = true;
+        // Scan all JAX-RS resources automatically
+        private boolean scan = true;
+        private boolean prettyPrint = true;
+        private boolean runAsFilter;
+        private Collection<String> ignoredRoutes;
+        private Set<String> resourcePackages;
+        private Set<String> resourceClasses;
+        private String filterClass;
+
+        private Boolean supportSwaggerUi;
+        private String swaggerUiVersion;
+        private String swaggerUiMavenGroupAndArtifact;
+        private Map<String, String> swaggerUiMediaTypes;
+
+        // Allows to pass the configuration location, usually openapi-configuration.json
+        // or openapi-configuration.yml file.
+        private String configLocation;
+        // Allows to pass the properties location, by default swagger.properties
+        private String propertiesLocation = DEFAULT_PROPS_LOCATION;
+        // Allows to disable automatic scan of known configuration locations (enabled by default)
+        private boolean scanKnownConfigLocations = true;
+        // Swagger UI configuration parameters (to be passed as query string).
+        private SwaggerUiConfig swaggerUiConfig;
+
+        @Override
+        public void initialize(Server server, Bus bus) {
+            final JAXRSServiceFactoryBean sfb = (JAXRSServiceFactoryBean)server
+                    .getEndpoint()
+                    .get(JAXRSServiceFactoryBean.class.getName());
+
+            final ServerProviderFactory factory = (ServerProviderFactory)server
+                    .getEndpoint()
+                    .get(ServerProviderFactory.class.getName());
+
+            final Set<String> packages = new HashSet<>();
+            if (resourcePackages != null) {
+                packages.addAll(resourcePackages);
+            }
 
-        factory.setUserProviders(swaggerUiRegistration.getProviders());
-    }
+            final Application application = DefaultApplicationFactory.createApplicationOrDefault(server, factory,
+                    sfb, bus, resourcePackages, isScan());
+
+            final AnnotationProcessor processor = new AnnotationProcessor(GeronimoOpenAPIConfig.create(),
+                    new NamingStrategy.Http(), null /* default JsonReaderFactory */);
+
+            final OpenAPIImpl api = new OpenAPIImpl();
+
+            if (isScan()) {
+                packages.addAll(scanResourcePackages(sfb));
+            }
+
+            final Set<Class<?>> resources = new HashSet<>();
+            if (application != null) {
+                processor.processApplication(api, new ClassElement(application.getClass()));
+                LOG.fine("Processed application " + application);
+
+                if (application.getClasses() != null) {
+                    resources.addAll(application.getClasses());
+                }
+            }
+
+            resources.addAll(sfb
+                    .getClassResourceInfo()
+                    .stream()
+                    .map(AbstractResourceInfo::getServiceClass)
+                    .filter(cls -> filterByPackage(cls, packages))
+                    .filter(cls -> filterByClassName(cls, resourceClasses))
+                    .collect(Collectors.toSet()));
+
+            if (!resources.isEmpty()) {
+                final String binding = (application == null) ? ""
+                        : processor.getApplicationBinding(application.getClass());
+
+                resources
+                        .stream()
+                        .peek(c -> LOG.info("Processing class " + c.getName()))
+                        .forEach(c -> processor.processClass(binding, api, new ClassElement(c),
+                                Stream.of(c.getMethods()).map(MethodElement::new)));
+            } else {
+                LOG.warning("No resource classes registered, the OpenAPI will not contain any endpoints.");
+            }
 
-    /**
-     * The info will be used only if there is no @OpenAPIDefinition annotation is present.
-     */
-    private org.eclipse.microprofile.openapi.models.info.Info getInfo(final Properties properties) {
-        org.eclipse.microprofile.openapi.models.info.Info info = new InfoImpl()
-            .title(getOrFallback(getTitle(), properties, TITLE_PROPERTY))
-            .version(getOrFallback(getVersion(), properties, VERSION_PROPERTY))
-            .description(getOrFallback(getDescription(), properties, DESCRIPTION_PROPERTY))
-            .termsOfService(getOrFallback(getTermsOfServiceUrl(), properties, TERMS_URL_PROPERTY))
-            .contact(new ContactImpl()
-                .name(getOrFallback(getContactName(), properties, CONTACT_PROPERTY))
-                .email(getContactEmail())
-                .url(getContactUrl()));
+            Properties swaggerProps = getSwaggerProperties(propertiesLocation, bus);
+            if (api.getInfo() == null) {
+                api.setInfo(getInfo(swaggerProps));
+            }
 
-        String licenseName = getOrFallback(getLicense(), properties, LICENSE_PROPERTY);
-        if (licenseName != null) {
-            info = info.license(new LicenseImpl()
-                    .name(getOrFallback(getLicense(), properties, LICENSE_PROPERTY))
-                    .url(getOrFallback(getLicenseUrl(), properties, LICENSE_URL_PROPERTY)));
+            registerOpenApiResources(sfb, api);
+            registerSwaggerUiResources(sfb, swaggerProps, factory, bus);
         }
-        return info;
-    }
 
-    private String getOrFallback(String value, Properties properties, String property) {
-        if (value == null && properties != null) {
-            return properties.getProperty(property);
-        } else {
-            return value;
+        public boolean isScan() {
+            return scan;
         }
-    }
 
-    private Collection<String> scanResourcePackages(JAXRSServiceFactoryBean sfb) {
-        return sfb
-            .getClassResourceInfo()
-            .stream()
-            .map(cri -> cri.getServiceClass().getPackage().getName())
-            .collect(Collectors.toSet());
-    }
-    
-    private static boolean filterByPackage(final Class<?> cls, final Set<String> packages) {
-        return (packages == null || packages.isEmpty())
-            || packages.stream().anyMatch(pkg -> cls.getPackage().getName().startsWith(pkg));
-    }
-    
-    private static boolean filterByClassName(final Class<?> cls, final Set<String> classes) {
-        return (classes == null || classes.isEmpty())
-            || classes.stream().anyMatch(cls.getName()::equalsIgnoreCase);
+        public void setScan(boolean scan) {
+            this.scan = scan;
+        }
+
+        public String getFilterClass() {
+            return filterClass;
+        }
+
+        public void setFilterClass(String filterClass) {
+            this.filterClass = filterClass;
+        }
+
+        public Set<String> getResourcePackages() {
+            return resourcePackages;
+        }
+
+        public void setResourcePackages(Set<String> resourcePackages) {
+            this.resourcePackages = (resourcePackages == null) ? null : new HashSet<>(resourcePackages);
+        }
+
+        public String getVersion() {
+            return version;
+        }
+
+        public void setVersion(String version) {
+            this.version = version;
+        }
+
+        public String getTitle() {
+            return title;
+        }
+
+        public void setTitle(String title) {
+            this.title = title;
+        }
+
+        public String getDescription() {
+            return description;
+        }
+
+        public void setDescription(String description) {
+            this.description = description;
+        }
+
+        public String getContactName() {
+            return contactName;
+        }
+
+        public void setContactName(String contactName) {
+            this.contactName = contactName;
+        }
+
+        public String getContactEmail() {
+            return contactEmail;
+        }
+
+        public void setContactEmail(String contactEmail) {
+            this.contactEmail = contactEmail;
+        }
+
+        public String getContactUrl() {
+            return contactUrl;
+        }
+
+        public void setContactUrl(String contactUrl) {
+            this.contactUrl = contactUrl;
+        }
+
+        public String getLicense() {
+            return license;
+        }
+
+        public void setLicense(String license) {
+            this.license = license;
+        }
+
+        public String getLicenseUrl() {
+            return licenseUrl;
+        }
+
+        public void setLicenseUrl(String licenseUrl) {
+            this.licenseUrl = licenseUrl;
+        }
+
+        public String getTermsOfServiceUrl() {
+            return termsOfServiceUrl;
+        }
+
+        public void setTermsOfServiceUrl(String termsOfServiceUrl) {
+            this.termsOfServiceUrl = termsOfServiceUrl;
+        }
+
+        public boolean isReadAllResources() {
+            return readAllResources;
+        }
+
+        public void setReadAllResources(boolean readAllResources) {
+            this.readAllResources = readAllResources;
+        }
+
+        public Set<String> getResourceClasses() {
+            return resourceClasses;
+        }
+
+        public void setResourceClasses(Set<String> resourceClasses) {
+            this.resourceClasses = (resourceClasses == null) ? null : new HashSet<>(resourceClasses);
+        }
+
+        public Collection<String> getIgnoredRoutes() {
+            return ignoredRoutes;
+        }
+
+        public void setIgnoredRoutes(Collection<String> ignoredRoutes) {
+            this.ignoredRoutes = (ignoredRoutes == null) ? null : new HashSet<>(ignoredRoutes);
+        }
+
+        public boolean isPrettyPrint() {
+            return prettyPrint;
+        }
+
+        public void setPrettyPrint(boolean prettyPrint) {
+            this.prettyPrint = prettyPrint;
+        }
+
+        public boolean isRunAsFilter() {
+            return runAsFilter;
+        }
+
+        @Override
+        public Boolean isSupportSwaggerUi() {
+            return supportSwaggerUi;
+        }
+
+        public void setSupportSwaggerUi(Boolean supportSwaggerUi) {
+            this.supportSwaggerUi = supportSwaggerUi;
+        }
+
+        public String getSwaggerUiVersion() {
+            return swaggerUiVersion;
+        }
+
+        public void setSwaggerUiVersion(String swaggerUiVersion) {
+            this.swaggerUiVersion = swaggerUiVersion;
+        }
+
+        public String getSwaggerUiMavenGroupAndArtifact() {
+            return swaggerUiMavenGroupAndArtifact;
+        }
+
+        public void setSwaggerUiMavenGroupAndArtifact(
+                String swaggerUiMavenGroupAndArtifact) {
+            this.swaggerUiMavenGroupAndArtifact = swaggerUiMavenGroupAndArtifact;
+        }
+
+        @Override
+        public Map<String, String> getSwaggerUiMediaTypes() {
+            return swaggerUiMediaTypes;
+        }
+
+        public void setSwaggerUiMediaTypes(Map<String, String> swaggerUiMediaTypes) {
+            this.swaggerUiMediaTypes = swaggerUiMediaTypes;
+        }
+
+        public String getConfigLocation() {
+            return configLocation;
+        }
+
+        public void setConfigLocation(String configLocation) {
+            this.configLocation = configLocation;
+        }
+
+        public String getPropertiesLocation() {
+            return propertiesLocation;
+        }
+
+        public void setPropertiesLocation(String propertiesLocation) {
+            this.propertiesLocation = propertiesLocation;
+        }
+
+        public void setRunAsFilter(boolean runAsFilter) {
+            this.runAsFilter = runAsFilter;
+        }
+
+        public void setScanKnownConfigLocations(boolean scanKnownConfigLocations) {
+            this.scanKnownConfigLocations = scanKnownConfigLocations;
+        }
+
+        public boolean isScanKnownConfigLocations() {
+            return scanKnownConfigLocations;
+        }
+
+        public void setSwaggerUiConfig(final SwaggerUiConfig swaggerUiConfig) {
+            this.swaggerUiConfig = swaggerUiConfig;
+        }
+
+        @Override
+        public SwaggerUiConfig getSwaggerUiConfig() {
+            return swaggerUiConfig;
+        }
+
+        @Override
+        public String findSwaggerUiRoot() {
+            return SwaggerUi.findSwaggerUiRoot(swaggerUiMavenGroupAndArtifact, swaggerUiVersion);
+        }
+
+        protected Properties getUserProperties(final Map<String, Object> userDefinedOptions) {
+            final Properties properties = new Properties();
+
+            if (userDefinedOptions != null) {
+                userDefinedOptions
+                        .entrySet()
+                        .stream()
+                        .filter(entry -> entry.getValue() != null)
+                        .forEach(entry -> properties.setProperty(entry.getKey(), entry.getValue().toString()));
+            }
+
+            return properties;
+        }
+
+        protected void registerOpenApiResources(
+                final JAXRSServiceFactoryBean sfb,
+                final OpenAPI openApiDefinition) {
+
+            sfb.setResourceClassesFromBeans(Collections.singletonList(new OpenApiEndpoint(openApiDefinition)));
+        }
+
+        protected void registerSwaggerUiResources(JAXRSServiceFactoryBean sfb, Properties properties,
+                                                  ServerProviderFactory factory, Bus bus) {
+
+            final Registration swaggerUiRegistration = getSwaggerUi(bus, properties, isRunAsFilter());
+
+            if (!isRunAsFilter()) {
+                sfb.setResourceClassesFromBeans(swaggerUiRegistration.getResources());
+            }
+
+            factory.setUserProviders(swaggerUiRegistration.getProviders());
+        }
+
+        /**
+         * The info will be used only if there is no @OpenAPIDefinition annotation is present.
+         */
+        private org.eclipse.microprofile.openapi.models.info.Info getInfo(final Properties properties) {
+            org.eclipse.microprofile.openapi.models.info.Info info = new InfoImpl()
+                    .title(getOrFallback(getTitle(), properties, TITLE_PROPERTY))
+                    .version(getOrFallback(getVersion(), properties, VERSION_PROPERTY))
+                    .description(getOrFallback(getDescription(), properties, DESCRIPTION_PROPERTY))
+                    .termsOfService(getOrFallback(getTermsOfServiceUrl(), properties, TERMS_URL_PROPERTY))
+                    .contact(new ContactImpl()
+                            .name(getOrFallback(getContactName(), properties, CONTACT_PROPERTY))
+                            .email(getContactEmail())
+                            .url(getContactUrl()));
+
+            String licenseName = getOrFallback(getLicense(), properties, LICENSE_PROPERTY);
+            if (licenseName != null) {
+                info = info.license(new LicenseImpl()
+                        .name(getOrFallback(getLicense(), properties, LICENSE_PROPERTY))
+                        .url(getOrFallback(getLicenseUrl(), properties, LICENSE_URL_PROPERTY)));
+            }
+            return info;
+        }
+
+        private String getOrFallback(String value, Properties properties, String property) {
+            if (value == null && properties != null) {
+                return properties.getProperty(property);
+            } else {
+                return value;
+            }
+        }
+
+        private Collection<String> scanResourcePackages(JAXRSServiceFactoryBean sfb) {
+            return sfb
+                    .getClassResourceInfo()
+                    .stream()
+                    .map(cri -> cri.getServiceClass().getPackage().getName())
+                    .collect(Collectors.toSet());
+        }
+
+        private static boolean filterByPackage(final Class<?> cls, final Set<String> packages) {
+            return (packages == null || packages.isEmpty())
+                    || packages.stream().anyMatch(pkg -> cls.getPackage().getName().startsWith(pkg));
+        }
+
+        private static boolean filterByClassName(final Class<?> cls, final Set<String> classes) {
+            return (classes == null || classes.isEmpty())
+                    || classes.stream().anyMatch(cls.getName()::equalsIgnoreCase);
+        }
     }
 }