Java Code Examples for io.swagger.jaxrs.config.BeanConfig#setLicenseUrl()

The following examples show how to use io.swagger.jaxrs.config.BeanConfig#setLicenseUrl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApiDocConfig.java    From ambari-logsearch with Apache License 2.0 8 votes vote down vote up
@Bean
public BeanConfig swaggerConfig() {
  BeanConfig beanConfig = new BeanConfig();
  beanConfig.setSchemes(new String[]{"http", "https"});
  beanConfig.setBasePath(BASE_PATH);
  beanConfig.setTitle(TITLE);
  beanConfig.setDescription(DESCRIPTION);
  beanConfig.setLicense(LICENSE);
  beanConfig.setLicenseUrl(LICENSE_URL);
  beanConfig.setScan(true);
  beanConfig.setVersion(VERSION);
  beanConfig.setResourcePackage(ServiceLogsResource.class.getPackage().getName());

  License license = new License();
  license.setName(LICENSE);
  license.setUrl(LICENSE_URL);

  Info info = new Info();
  info.setDescription(DESCRIPTION);
  info.setTitle(TITLE);
  info.setVersion(VERSION);
  info.setLicense(license);
  beanConfig.setInfo(info);
  return beanConfig;
}
 
Example 2
Source File: SwaggerListener.java    From hola with Apache License 2.0 5 votes vote down vote up
@Override
public void contextInitialized(ServletContextEvent sce) {
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("1.0.0");
    beanConfig.setSchemes(new String[] { "http" });
    beanConfig.setTitle("Hola microservices REST API");
    beanConfig.setDescription("Operations that can be invoked in the hola microservices");
    beanConfig.setResourcePackage("com.redhat.developers.msa.hola");
    beanConfig.setLicense("Apache 2.0");
    beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
    beanConfig.setContact("[email protected]");
    beanConfig.setBasePath("/api");
    beanConfig.setPrettyPrint(true);
    beanConfig.setScan(true);
}
 
Example 3
Source File: SwaggerServletContextListener.java    From EDDI with Apache License 2.0 5 votes vote down vote up
private BeanConfig getBeanConfig() {
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setHost(getConfig("swagger.host"));
    beanConfig.setSchemes(getConfig("swagger.schemes").split(","));
    beanConfig.setTitle(getConfig("swagger.title"));
    beanConfig.setVersion(getConfig("swagger.version"));
    beanConfig.setContact(getConfig("swagger.contact"));
    beanConfig.setLicense(getConfig("swagger.license"));
    beanConfig.setBasePath(getConfig("swagger.base_path"));
    beanConfig.setLicenseUrl(getConfig("swagger.licenseUrl"));
    beanConfig.setDescription(getConfig("swagger.description"));
    beanConfig.setPrettyPrint(getConfig("swagger.pretty_print"));
    beanConfig.setTermsOfServiceUrl(getConfig("swagger.terms_of_service_url"));

    // Must be called last
    beanConfig.setResourcePackage(resourcePackages());
    beanConfig.setScan(true);

    Swagger swagger = beanConfig.getSwagger();

    if ("basic".equals(getConfig("webServer.securityHandlerType"))) {
        swagger.securityDefinition("eddi_auth", new BasicAuthDefinition());
    } else if ("keycloak".equals(getConfig("webServer.securityHandlerType"))) {
        OAuth2Definition oAuth2Definition = new OAuth2Definition()
                .implicit(getConfig("swagger.oauth2.implicitAuthorizationUrl"));
        oAuth2Definition.setDescription("client_id is 'eddi-engine'");
        swagger.securityDefinition("eddi_auth", oAuth2Definition);
    }

    return beanConfig;
}
 
Example 4
Source File: ServerApplication.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Override
public void run(ServerConfig configuration, Environment environment) throws Exception {
    environment.getApplicationContext().setContextPath(ServerConfig.getContextPath());
    environment.jersey().register(RESTExceptionMapper.class);
    environment.jersey().setUrlPattern(ServerConfig.getApiBasePath());
    environment.getObjectMapper().setFilters(TaggedLogAPIEntity.getFilterProvider());
    environment.getObjectMapper().registerModule(new EntityJsonModule());

    // Automatically scan all REST resources
    new PackagesResourceConfig(ServerConfig.getResourcePackage()).getClasses().forEach(environment.jersey()::register);

    // Swagger resources
    environment.jersey().register(ApiListingResource.class);

    BeanConfig swaggerConfig = new BeanConfig();
    swaggerConfig.setTitle(ServerConfig.getServerName());
    swaggerConfig.setVersion(ServerConfig.getServerVersion().version);
    swaggerConfig.setBasePath(ServerConfig.getApiBasePath());
    swaggerConfig.setResourcePackage(ServerConfig.getResourcePackage());
    swaggerConfig.setLicense(ServerConfig.getLicense());
    swaggerConfig.setLicenseUrl(ServerConfig.getLicenseUrl());
    swaggerConfig.setDescription(Version.str());
    swaggerConfig.setScan(true);

    // Simple CORS filter
    environment.servlets().addFilter(SimpleCORSFiler.class.getName(), new SimpleCORSFiler())
        .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");

    // Register authentication provider
    BasicAuthBuilder authBuilder = new BasicAuthBuilder(configuration.getAuthConfig(), environment);
    environment.jersey().register(authBuilder.getBasicAuthProvider());
    if (configuration.getAuthConfig().isEnabled()) {
        environment.jersey().getResourceConfig().getResourceFilterFactories()
            .add(new BasicAuthResourceFilterFactory(authBuilder.getBasicAuthenticator()));
    }
    registerAppServices(environment);
}
 
Example 5
Source File: SwaggerActivator.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public void activate(ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException {

    InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(SwaggerArchive.SWAGGER_CONFIGURATION_PATH);

    if (in == null) {
        // No config available. Print a warning and return
        System.err.println("WARN: No swagger configuration found. Swagger not activated.");
        return;
    }
    SwaggerConfig config = new SwaggerConfig(in);

    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setHost((String) config.get(SwaggerConfig.Key.HOST));
    beanConfig.setLicense((String) config.get(SwaggerConfig.Key.LICENSE));
    beanConfig.setLicenseUrl((String) config.get(SwaggerConfig.Key.LICENSE_URL));
    beanConfig.setTermsOfServiceUrl((String) config.get(SwaggerConfig.Key.TERMS_OF_SERVICE_URL));
    beanConfig.setResourcePackage((String) config.get(SwaggerConfig.Key.PACKAGES));
    beanConfig.setVersion((String) config.get(SwaggerConfig.Key.VERSION));
    beanConfig.setBasePath((String) config.get(SwaggerConfig.Key.ROOT));
    beanConfig.setContact((String) config.get(SwaggerConfig.Key.CONTACT));
    beanConfig.setDescription((String) config.get(SwaggerConfig.Key.DESCRIPTION));
    beanConfig.setTitle((String) config.get(SwaggerConfig.Key.TITLE));
    beanConfig.setPrettyPrint((String) config.get(SwaggerConfig.Key.PRETTY_PRINT));
    beanConfig.setSchemes((String[]) config.get(SwaggerConfig.Key.SCHEMES));

    beanConfig.setScan(true);

}
 
Example 6
Source File: SwaggerConfig.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@PostConstruct
private void registerSwagger() {
    BeanConfig swaggerConfig = new BeanConfig();
    swaggerConfig.setTitle("Redbeams API");
    swaggerConfig.setDescription("API for working with databases and database servers");
    swaggerConfig.setVersion(applicationVersion);
    swaggerConfig.setSchemes(new String[]{"http", "https"});
    swaggerConfig.setBasePath(contextPath + RedbeamsApi.API_ROOT_CONTEXT);
    swaggerConfig.setLicenseUrl("https://github.com/sequenceiq/cloudbreak/blob/master/LICENSE");
    swaggerConfig.setResourcePackage("com.sequenceiq.redbeams.api,com.sequenceiq.flow.api,com.sequenceiq.authorization");
    swaggerConfig.setScan(true);
    swaggerConfig.setContact("https://hortonworks.com/contact-sales/");
    swaggerConfig.setPrettyPrint(true);
    SwaggerConfigLocator.getInstance().putConfig(SwaggerContextService.CONFIG_ID_DEFAULT, swaggerConfig);
}
 
Example 7
Source File: EndpointConfig.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@PostConstruct
private void registerSwagger() {
    BeanConfig swaggerConfig = new BeanConfig();
    swaggerConfig.setTitle("Datalake API");
    swaggerConfig.setDescription("");
    swaggerConfig.setVersion(applicationVersion);
    swaggerConfig.setSchemes(new String[]{"http", "https"});
    swaggerConfig.setBasePath(SdxApi.API_ROOT_CONTEXT);
    swaggerConfig.setLicenseUrl("https://github.com/sequenceiq/cloudbreak/blob/master/LICENSE");
    swaggerConfig.setResourcePackage("com.sequenceiq.sdx.api,com.sequenceiq.flow.api,com.sequenceiq.authorization");
    swaggerConfig.setScan(true);
    swaggerConfig.setContact("https://hortonworks.com/contact-sales/");
    swaggerConfig.setPrettyPrint(true);
    SwaggerConfigLocator.getInstance().putConfig(SwaggerContextService.CONFIG_ID_DEFAULT, swaggerConfig);
}
 
Example 8
Source File: EndpointConfig.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@PostConstruct
private void registerSwagger() {
    BeanConfig swaggerConfig = new BeanConfig();
    swaggerConfig.setTitle("FreeIPA API");
    swaggerConfig.setDescription("");
    swaggerConfig.setVersion(applicationVersion);
    swaggerConfig.setSchemes(new String[]{"http", "https"});
    swaggerConfig.setBasePath(FreeIpaApi.API_ROOT_CONTEXT);
    swaggerConfig.setLicenseUrl("https://github.com/sequenceiq/cloudbreak/blob/master/LICENSE");
    swaggerConfig.setResourcePackage("com.sequenceiq.freeipa.api,com.sequenceiq.flow.api,com.sequenceiq.authorization");
    swaggerConfig.setScan(true);
    swaggerConfig.setContact("https://hortonworks.com/contact-sales/");
    swaggerConfig.setPrettyPrint(true);
    SwaggerConfigLocator.getInstance().putConfig(SwaggerContextService.CONFIG_ID_DEFAULT, swaggerConfig);
}
 
Example 9
Source File: EndpointConfig.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private void registerSwagger() {
    BeanConfig swaggerConfig = new BeanConfig();
    swaggerConfig.setTitle("Environment API");
    swaggerConfig.setDescription("Environment operation related API.");
    swaggerConfig.setVersion(applicationVersion);
    swaggerConfig.setSchemes(new String[]{"http", "https"});
    swaggerConfig.setBasePath(EnvironmentApi.API_ROOT_CONTEXT);
    swaggerConfig.setLicenseUrl("https://github.com/sequenceiq/cloudbreak/blob/master/LICENSE");
    swaggerConfig.setResourcePackage("com.sequenceiq.environment.api,com.sequenceiq.flow.api,com.sequenceiq.authorization");
    swaggerConfig.setScan(true);
    swaggerConfig.setContact("https://hortonworks.com/contact-sales/");
    swaggerConfig.setPrettyPrint(true);
    SwaggerConfigLocator.getInstance().putConfig(SwaggerContextService.CONFIG_ID_DEFAULT, swaggerConfig);
}
 
Example 10
Source File: EndpointConfig.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private void registerSwagger() throws IOException {
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setTitle("Auto-scaling API");
    beanConfig.setDescription(FileReaderUtils.readFileFromClasspath("swagger/auto-scaling-introduction"));
    beanConfig.setVersion(applicationVersion);
    beanConfig.setSchemes(new String[]{"http", "https"});
    beanConfig.setBasePath(AutoscaleApi.API_ROOT_CONTEXT);
    beanConfig.setLicenseUrl("https://github.com/sequenceiq/cloudbreak/blob/master/LICENSE");
    beanConfig.setResourcePackage("com.sequenceiq.periscope.api,com.sequenceiq.authorization");
    beanConfig.setScan(true);
    beanConfig.setContact("https://hortonworks.com/contact-sales/");
    beanConfig.setPrettyPrint(true);
    SwaggerConfigLocator.getInstance().putConfig(SwaggerContextService.CONFIG_ID_DEFAULT, beanConfig);
}
 
Example 11
Source File: EndpointConfig.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@PostConstruct
private void registerSwagger() throws IOException {
    BeanConfig swaggerConfig = new BeanConfig();
    swaggerConfig.setTitle("Cloudbreak API");
    swaggerConfig.setDescription(FileReaderUtils.readFileFromClasspath("swagger/cloudbreak-introduction"));
    swaggerConfig.setVersion(cbVersion);
    swaggerConfig.setSchemes(new String[]{"http", "https"});
    swaggerConfig.setBasePath(CoreApi.API_ROOT_CONTEXT);
    swaggerConfig.setLicenseUrl("https://github.com/hortonworks/cloudbreak/blob/master/LICENSE");
    swaggerConfig.setResourcePackage("com.sequenceiq.cloudbreak.api,com.sequenceiq.distrox.api,com.sequenceiq.flow.api,com.sequenceiq.authorization");
    swaggerConfig.setScan(true);
    swaggerConfig.setContact("https://hortonworks.com/contact-sales/");
    swaggerConfig.setPrettyPrint(true);
    SwaggerConfigLocator.getInstance().putConfig(SwaggerContextService.CONFIG_ID_DEFAULT, swaggerConfig);
}
 
Example 12
Source File: SwaggerServiceActivator.java    From thorntail with Apache License 2.0 4 votes vote down vote up
@Override
public void activate(ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException {

    InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(SwaggerArchive.SWAGGER_CONFIGURATION_PATH);

    if (in == null) {
        // try again, we must go deeper.
        in = Thread.currentThread().getContextClassLoader().getResourceAsStream("WEB-INF/classes/" + SwaggerArchive.SWAGGER_CONFIGURATION_PATH);
    }

    if (in == null) {
        // No config available. Print a warning and return
        SwaggerMessages.MESSAGES.noConfigurationFound();
        return;
    }

    try {
        SwaggerConfig config = new SwaggerConfig(in);

        BeanConfig beanConfig = new BeanConfig();
        beanConfig.setHost((String) config.get(SwaggerConfig.Key.HOST));
        beanConfig.setLicense((String) config.get(SwaggerConfig.Key.LICENSE));
        beanConfig.setLicenseUrl((String) config.get(SwaggerConfig.Key.LICENSE_URL));
        beanConfig.setTermsOfServiceUrl((String) config.get(SwaggerConfig.Key.TERMS_OF_SERVICE_URL));

        // some type inconsistencies in the API (String vs String[])
        String[] packages = (String[]) config.get(SwaggerConfig.Key.PACKAGES);

        if (packages != null) {
            StringBuffer sb = new StringBuffer();
            for (String s : packages) {
                sb.append(s).append(',');
            }

            beanConfig.setResourcePackage(sb.toString());
        }

        beanConfig.setVersion((String) config.get(SwaggerConfig.Key.VERSION));
        beanConfig.setBasePath((String) config.get(SwaggerConfig.Key.ROOT));
        beanConfig.setContact((String) config.get(SwaggerConfig.Key.CONTACT));
        beanConfig.setDescription((String) config.get(SwaggerConfig.Key.DESCRIPTION));
        beanConfig.setTitle((String) config.get(SwaggerConfig.Key.TITLE));
        beanConfig.setPrettyPrint((String) config.get(SwaggerConfig.Key.PRETTY_PRINT));
        beanConfig.setSchemes((String[]) config.get(SwaggerConfig.Key.SCHEMES));

        beanConfig.setScan(true);
    } catch (IOException e) {
        throw new ServiceRegistryException(e);
    }

}