Search in sources :

Example 31 with BeanConfig

use of io.swagger.jaxrs.config.BeanConfig in project ff4j by ff4j.

the class FF4jApiApplicationJersey2x method init.

/**
 * Initialisation of Jersey2 application.
 *
 * @param serviceLocator
 */
public void init() {
    packages(FF4jResource.class.getPackage().getName());
    register(new FF4jBinder());
    register(JerseyApplicationEventListener.class);
    register(JerseyRequestEventListener.class);
    apiConfig = getWebApiConfiguration();
    if (apiConfig != null) {
        if (apiConfig.isAutorize()) {
            enableAuthenticationFilter();
            enableAuthorizationFilter();
        } else if (apiConfig.isAuthenticate()) {
            enableAuthenticationFilter();
        } else {
            log.info("No authentication nor authorization");
        }
        // Swagger configuration
        if (apiConfig.isDocumentation()) {
            BeanConfig beanConfig = new BeanConfig();
            beanConfig.setTitle("FF4J (ff4j.org) WebAPI");
            beanConfig.setDescription("Administrate and operate all tasks on your features through this api");
            beanConfig.setResourcePackage("org.ff4j.web.api.resources");
            beanConfig.setContact("@clunven");
            beanConfig.setLicense("Apache 2.0");
            beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
            beanConfig.setVersion(apiConfig.getVersion());
            beanConfig.setSchemes(new String[] { "http" });
            beanConfig.setHost(apiConfig.getHost() + ":" + apiConfig.getPort());
            beanConfig.setBasePath("/" + apiConfig.getWebContext() + "/api");
            beanConfig.setScan(true);
            ScannerFactory.setScanner(beanConfig);
            register(io.swagger.jaxrs.listing.ApiListingResource.class);
            register(io.swagger.jaxrs.listing.SwaggerSerializers.class);
            log.info("Initialisation Swagger [OK]");
        }
    } else {
    }
    log.info("Initialisation WebAPI [OK]");
}
Also used : BeanConfig(io.swagger.jaxrs.config.BeanConfig)

Aggregations

BeanConfig (io.swagger.jaxrs.config.BeanConfig)31 Swagger (io.swagger.models.Swagger)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 DefaultClassResolver (org.apache.camel.impl.DefaultClassResolver)7 Test (org.junit.Test)7 Test (org.testng.annotations.Test)3 ApiListingResource (io.swagger.jaxrs.listing.ApiListingResource)2 SplitResourceImpl (com.splitresourcesTestImpl.SplitResourceImpl)1 RootResource (com.subresourcesTest.RootResource)1 SwaggerResource (gov.ca.cwds.rest.resources.SwaggerResource)1 TokenResource (gov.ca.cwds.rest.resources.TokenResource)1 AssetsBundle (io.dropwizard.assets.AssetsBundle)1 DefaultJaxrsScanner (io.swagger.jaxrs.config.DefaultJaxrsScanner)1 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)1 ServletInfo (io.undertow.servlet.api.ServletInfo)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1