io.swagger.jaxrs.config.BeanConfig Java Examples

The following examples show how to use io.swagger.jaxrs.config.BeanConfig. 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: EmoService.java    From emodb with Apache License 2.0 6 votes vote down vote up
private void evaluateSwagger()
        throws Exception {
    if (!runPerServiceMode(swagger)) {
        return;
    }

    // Add swagger providers
    _environment.jersey().register(io.swagger.jaxrs.listing.ApiListingResource.class);
    _environment.jersey().register(io.swagger.jaxrs.listing.SwaggerSerializers.class);

    // Configure and initialize swagger
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("1.0");
    beanConfig.setTitle("EMO REST Resources");
    beanConfig.setSchemes(new String[] {"http"});
    beanConfig.setHost("localhost:8080");
    beanConfig.setBasePath("/");
    // add the packages that swagger should scan to pick up the resources
    beanConfig.setResourcePackage("com.bazaarvoice.emodb.web.resources");
    // this is a MUST and should be the last property - this creates a new SwaggerContextService and initialize the scanner.
    beanConfig.setScan(true);
}
 
Example #3
Source File: MainApplication.java    From SciGraph with Apache License 2.0 6 votes vote down vote up
/***
 * The context path must be set before configuring swagger
 * @param environment
 */
void configureSwagger(Environment environment, String basePath) {
  environment.jersey().register(new ApiListingResource());
  environment.jersey().register(new SwaggerJsonBareService());
  environment.jersey().register(new SwaggerSerializers());
  ScannerFactory.setScanner(new DefaultJaxrsScanner());
  environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
  BeanConfig config = new BeanConfig();

  // api specific configuration
  config.setTitle("SciGraph");
  config.setVersion("1.0.1");
  config.setResourcePackage("io.scigraph.services.resources");
  config.setScan(true);
  // TODO: Fix this so the swagger client generator can work correctly
  config.setBasePath("/" + basePath);
}
 
Example #4
Source File: SwaggerBootstrapServlet.java    From render with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void init(final ServletConfig config) throws ServletException {
    super.init(config);

    final BeanConfig beanConfig = loadConfig(new File("resources/swagger.properties"));
    beanConfig.setVersion("v1");
    beanConfig.setSchemes(new String[]{"http"});
    beanConfig.setBasePath("/render-ws");
    beanConfig.setResourcePackage("org.janelia.render.service");
    beanConfig.setScan(true);
    beanConfig.setPrettyPrint(true);

    // Needed to register these modules to get Swagger to use JAXB annotations
    // (see https://github.com/swagger-api/swagger-core/issues/960 for explanation)
    Json.mapper().registerModule(new JaxbAnnotationModule());
    Yaml.mapper().registerModule(new JaxbAnnotationModule());
}
 
Example #5
Source File: PinotServiceManagerAdminApiApplication.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
private void setupSwagger() {
  BeanConfig beanConfig = new BeanConfig();
  beanConfig.setTitle("Pinot Starter API");
  beanConfig.setDescription("APIs for accessing Pinot Starter information");
  beanConfig.setContact("https://github.com/apache/incubator-pinot");
  beanConfig.setVersion("1.0");
  beanConfig.setSchemes(new String[]{"http"});
  beanConfig.setBasePath(_baseUri.getPath());
  beanConfig.setResourcePackage(RESOURCE_PACKAGE);
  beanConfig.setScan(true);

  HttpHandler httpHandler =
      new CLStaticHttpHandler(PinotServiceManagerAdminApiApplication.class.getClassLoader(), "/api/");
  // map both /api and /help to swagger docs. /api because it looks nice. /help for backward compatibility
  _httpServer.getServerConfiguration().addHttpHandler(httpHandler, "/api/", "/help/");

  URL swaggerDistLocation = PinotServiceManagerAdminApiApplication.class.getClassLoader()
      .getResource("META-INF/resources/webjars/swagger-ui/2.2.2/");
  CLStaticHttpHandler swaggerDist = new CLStaticHttpHandler(new URLClassLoader(new URL[]{swaggerDistLocation}));
  _httpServer.getServerConfiguration().addHttpHandler(swaggerDist, "/swaggerui-dist/");
}
 
Example #6
Source File: ControllerAdminApiApplication.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
private void setupSwagger(HttpServer httpServer, boolean advertiseHttps) {
  BeanConfig beanConfig = new BeanConfig();
  beanConfig.setTitle("Pinot Controller API");
  beanConfig.setDescription("APIs for accessing Pinot Controller information");
  beanConfig.setContact("https://github.com/apache/incubator-pinot");
  beanConfig.setVersion("1.0");
  if (advertiseHttps) {
    beanConfig.setSchemes(new String[]{"https"});
  } else {
    beanConfig.setSchemes(new String[]{"http"});
  }
  beanConfig.setBasePath("/");
  beanConfig.setResourcePackage(RESOURCE_PACKAGE);
  beanConfig.setScan(true);

  ClassLoader loader = this.getClass().getClassLoader();
  CLStaticHttpHandler apiStaticHttpHandler = new CLStaticHttpHandler(loader, "/api/");
  // map both /api and /help to swagger docs. /api because it looks nice. /help for backward compatibility
  httpServer.getServerConfiguration().addHttpHandler(apiStaticHttpHandler, "/api/");
  httpServer.getServerConfiguration().addHttpHandler(apiStaticHttpHandler, "/help/");

  URL swaggerDistLocation = loader.getResource("META-INF/resources/webjars/swagger-ui/2.2.2/");
  CLStaticHttpHandler swaggerDist = new CLStaticHttpHandler(new URLClassLoader(new URL[]{swaggerDistLocation}));
  httpServer.getServerConfiguration().addHttpHandler(swaggerDist, "/swaggerui-dist/");
}
 
Example #7
Source File: BrokerAdminApiApplication.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
private void setupSwagger() {
  BeanConfig beanConfig = new BeanConfig();
  beanConfig.setTitle("Pinot Broker API");
  beanConfig.setDescription("APIs for accessing Pinot broker information");
  beanConfig.setContact("https://github.com/apache/incubator-pinot");
  beanConfig.setVersion("1.0");
  beanConfig.setSchemes(new String[]{"http"});
  beanConfig.setBasePath(_baseUri.getPath());
  beanConfig.setResourcePackage(RESOURCE_PACKAGE);
  beanConfig.setScan(true);

  HttpHandler httpHandler = new CLStaticHttpHandler(BrokerAdminApiApplication.class.getClassLoader(), "/api/");
  // map both /api and /help to swagger docs. /api because it looks nice. /help for backward compatibility
  _httpServer.getServerConfiguration().addHttpHandler(httpHandler, "/api/", "/help/");

  URL swaggerDistLocation =
      BrokerAdminApiApplication.class.getClassLoader().getResource("META-INF/resources/webjars/swagger-ui/2.2.2/");
  CLStaticHttpHandler swaggerDist = new CLStaticHttpHandler(new URLClassLoader(new URL[]{swaggerDistLocation}));
  _httpServer.getServerConfiguration().addHttpHandler(swaggerDist, "/swaggerui-dist/");
}
 
Example #8
Source File: AdminApiApplication.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
private void setupSwagger(HttpServer httpServer) {
  BeanConfig beanConfig = new BeanConfig();
  beanConfig.setTitle("Pinot Server API");
  beanConfig.setDescription("APIs for accessing Pinot server information");
  beanConfig.setContact("https://github.com/apache/incubator-pinot");
  beanConfig.setVersion("1.0");
  beanConfig.setSchemes(new String[]{"http"});
  beanConfig.setBasePath(baseUri.getPath());
  beanConfig.setResourcePackage(RESOURCE_PACKAGE);
  beanConfig.setScan(true);

  CLStaticHttpHandler staticHttpHandler =
      new CLStaticHttpHandler(AdminApiApplication.class.getClassLoader(), "/api/");
  // map both /api and /help to swagger docs. /api because it looks nice. /help for backward compatibility
  httpServer.getServerConfiguration().addHttpHandler(staticHttpHandler, "/api/");
  httpServer.getServerConfiguration().addHttpHandler(staticHttpHandler, "/help/");

  URL swaggerDistLocation =
      AdminApiApplication.class.getClassLoader().getResource("META-INF/resources/webjars/swagger-ui/2.2.2/");
  CLStaticHttpHandler swaggerDist = new CLStaticHttpHandler(new URLClassLoader(new URL[]{swaggerDistLocation}));
  httpServer.getServerConfiguration().addHttpHandler(swaggerDist, "/swaggerui-dist/");
}
 
Example #9
Source File: WebServicesConfiguration.java    From microservices-transactions-tcc with Apache License 2.0 6 votes vote down vote up
private void configureSwagger() {
	// Available at localhost:port/swagger.json
	this.register(ApiListingResource.class);
	this.register(SwaggerSerializers.class);

	BeanConfig config = new BeanConfig();
	// config.setConfigId(title);
	config.setTitle(title);
	config.setDescription(description);
	config.setVersion(version);
	config.setContact(contact);
	config.setSchemes(schemes.split(","));
	config.setBasePath(basePath);
	config.setResourcePackage(resourcePackage);
	config.setPrettyPrint(prettyPrint);
	config.setScan(scan);	
}
 
Example #10
Source File: GatewayMicroServiceApplication.java    From apiman with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor.
 */
public GatewayMicroServiceApplication() {
    //add swagger 2.0 config
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setBasePath("/api"); //$NON-NLS-1$
    beanConfig.setResourcePackage("io.apiman.gateway.api.rest.contract"); //$NON-NLS-1$
    //TODO set more info in the beanConfig (title,description, version, etc)
    beanConfig.setScan(true);
    
    classes.add(SystemResourceImpl.class);
    classes.add(ApiResourceImpl.class);
    classes.add(ClientResourceImpl.class);
    classes.add(OrgResourceImpl.class);

    //add swagger 2.0 resource
    classes.add(io.swagger.jaxrs.listing.ApiListingResource.class);
    classes.add(io.swagger.jaxrs.listing.SwaggerSerializers.class);
    
    classes.add(RestExceptionMapper.class);
}
 
Example #11
Source File: WebServicesConfiguration.java    From microservices-transactions-tcc with Apache License 2.0 6 votes vote down vote up
private void configureSwagger() {
	// Available at localhost:port/swagger.json
	this.register(ApiListingResource.class);
	this.register(SwaggerSerializers.class);

	BeanConfig config = new BeanConfig();
	// config.setConfigId(title);
	config.setTitle(title);
	config.setDescription(description);
	config.setVersion(version);
	config.setContact(contact);
	config.setSchemes(schemes.split(","));
	config.setBasePath(basePath);
	config.setResourcePackage(resourcePackage);
	config.setPrettyPrint(prettyPrint);
	config.setScan(scan);	
}
 
Example #12
Source File: RestServer.java    From Cheddar with Apache License 2.0 5 votes vote down vote up
private void enableAutoGenerationOfSwaggerSpecification() {
    // The main scanner class used to scan the classes for swagger + jax-rs annoatations
    final BeanConfig beanConfig = new BeanConfig();
    beanConfig.setResourcePackage("com.clicktravel.services,com.clicktravel.services.*");
    beanConfig.setSchemes(new String[] { "https" });
    beanConfig.setBasePath("/");
    final Info info = new Info();
    info.setVersion("2.0.0");
    beanConfig.setInfo(info);
    beanConfig.setTitle("Swagger Specification");
    beanConfig.setVersion("0.0.0");
    beanConfig.setScan(true);
}
 
Example #13
Source File: ApiManagerApplication.java    From apiman with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 */
public ApiManagerApplication() {
    //add swagger 2.0 config
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion(new Version().getVersionString());
    beanConfig.setBasePath("/apiman"); //$NON-NLS-1$
    beanConfig.setResourcePackage("io.apiman.manager.api.rest"); //$NON-NLS-1$
    beanConfig.setTitle("API Manager REST API");
    beanConfig.setDescription("The API Manager REST API is used by the API Manager UI to get stuff done. You can use it to automate any API Management task you wish. For example, create new Organizations, Plans, Clients, and APIs.");
    beanConfig.setScan(true);

    classes.add(SystemResourceImpl.class);
    classes.add(SearchResourceImpl.class);
    classes.add(RoleResourceImpl.class);
    classes.add(UserResourceImpl.class);
    classes.add(OrganizationResourceImpl.class);
    classes.add(PolicyDefinitionResourceImpl.class);
    classes.add(GatewayResourceImpl.class);
    classes.add(PluginResourceImpl.class);
    classes.add(ActionResourceImpl.class);
    classes.add(DownloadResourceImpl.class);

    //add swagger 2.0 resource
    classes.add(io.swagger.jaxrs.listing.ApiListingResource.class);
    classes.add(io.swagger.jaxrs.listing.SwaggerSerializers.class);

    classes.add(RestExceptionMapper.class);
}
 
Example #14
Source File: SwaggerSpecResource.java    From Cheddar with Apache License 2.0 5 votes vote down vote up
/**
 * Will get the swagger configuration from the scanner, if it is of type BeanConfig and return the object. This will
 * be used in the parsing and formating of the resulting swagger specification.
 *
 * @return swagger configuration. If the scanner is not of type io.swagger.jaxrs.config.BeanConfig then null will be
 *         returned.
 */

private Swagger getSwagger() {
    final Scanner scanner = ScannerFactory.getScanner();
    if (scanner instanceof BeanConfig) {
        return ((BeanConfig) scanner).getSwagger();
    }
    return null;
}
 
Example #15
Source File: LogSearchDocumentationGenerator.java    From ambari-logsearch with Apache License 2.0 5 votes vote down vote up
private static String generateSwaggerYaml() throws Exception {
  ApiDocConfig apiDocConfig = new ApiDocConfig();
  BeanConfig beanConfig = apiDocConfig.swaggerConfig();
  Swagger swagger = beanConfig.getSwagger();
  swagger.addSecurityDefinition("basicAuth", new BasicAuthDefinition());
  beanConfig.configure(swagger);
  beanConfig.scanAndRead();
  return Yaml.mapper().writeValueAsString(swagger);
}
 
Example #16
Source File: DeviceHiveFrontendApplication.java    From devicehive-java-server with Apache License 2.0 5 votes vote down vote up
@Bean
@Lazy(false)
public BeanConfig swaggerConfig(@Value("${server.context-path}") String contextPath,
                                @Value("${build.version}") String buildVersion) {

    String basePath = contextPath.equals("/") ? JerseyConfig.REST_PATH : contextPath + JerseyConfig.REST_PATH;
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setTitle("Device Hive REST API");
    beanConfig.setVersion(buildVersion);
    beanConfig.setBasePath(basePath);
    beanConfig.setResourcePackage("com.devicehive.resource");
    beanConfig.setScan(true);
    return beanConfig;
}
 
Example #17
Source File: SwaggerBootstrapServlet.java    From render with GNU General Public License v2.0 5 votes vote down vote up
public static BeanConfig loadConfig(final File file)
        throws IllegalArgumentException {

    final BeanConfig beanConfig = new BeanConfig();
    final Properties properties = new Properties();

    final String path = file.getAbsolutePath();
    if (file.exists()) {

        try (final FileInputStream in = new FileInputStream(file)) {
            properties.load(in);
        } catch (final Exception e) {
            throw new IllegalArgumentException("failed to load properties from " + path, e);
        }

        LOG.info("loaded swagger properties from {}", path);

    } else {
        LOG.warn("{} not found, using default configuration for swagger", path);
    }

    beanConfig.setTitle(properties.getProperty("title", "Render Web Service APIs"));

    // default to empty contact so that swagger-ui will hide created by line
    beanConfig.setContact(properties.getProperty("contact", ""));

    // default to empty host so that swagger-ui will use same host for try-it-out requests
    beanConfig.setHost(properties.getProperty("host", ""));

    beanConfig.setBasePath(properties.getProperty("basePath", "/render-ws"));

    return beanConfig;
}
 
Example #18
Source File: DeviceHiveAuthApplication.java    From devicehive-java-server with Apache License 2.0 5 votes vote down vote up
@Bean
@Lazy(false)
public BeanConfig swaggerConfig(@Value("${server.context-path}") String contextPath,
                                @Value("${build.version}") String buildVersion) {

    String basePath = contextPath.equals("/") ? JerseyConfig.REST_PATH : contextPath + JerseyConfig.REST_PATH;
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setTitle("Device Hive REST API");
    beanConfig.setVersion(buildVersion);
    beanConfig.setBasePath(basePath);
    beanConfig.setResourcePackage("com.devicehive.resource");
    beanConfig.setScan(true);
    return beanConfig;
}
 
Example #19
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 #20
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 #21
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 #22
Source File: DeviceHivePluginApplication.java    From devicehive-java-server with Apache License 2.0 5 votes vote down vote up
@Bean
@Lazy(false)
public BeanConfig swaggerConfig(@Value("${server.context-path}") String contextPath,
                                @Value("${build.version}") String buildVersion) {

    String basePath = contextPath.equals("/") ? JerseyConfig.REST_PATH : contextPath + JerseyConfig.REST_PATH;
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setTitle("Device Hive REST API");
    beanConfig.setVersion(buildVersion);
    beanConfig.setBasePath(basePath);
    beanConfig.setResourcePackage("com.devicehive.resource");
    beanConfig.setScan(true);
    return beanConfig;
}
 
Example #23
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 #24
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 #25
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 #26
Source File: JerseyConfig.java    From maintain with MIT License 5 votes vote down vote up
private void configureSwagger() {
		this.register(ApiListingResource.class);
		this.register(SwaggerSerializers.class);

		BeanConfig config = new BeanConfig();
		config.setTitle("基于Spring Boot,Jersey, Swagger的Restful API");
		config.setVersion("1.0.0");
		config.setContact("赵配");
//		config.setSchemes(new String[] { "http", "https" });
		config.setSchemes(new String[] { "http" });
		config.setBasePath(this.apiPath);
		config.setResourcePackage("online.zhaopei.myproject.jerseyservice");
		config.setPrettyPrint(true);
		config.setScan(true);
	}
 
Example #27
Source File: MaprMusicApp.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
public MaprMusicApp() {
    // Configure and Initialize Swagger
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("1.0.0");
    beanConfig.setSchemes(new String[]{"http"});
    beanConfig.setHost("localhost:8080");
    beanConfig.setBasePath("/mapr-music-rest/api/1.0/");
    beanConfig.setResourcePackage("com.mapr.music.api");
    beanConfig.setScan(true);
}
 
Example #28
Source File: SwaggerModule.java    From act-platform with ISC License 5 votes vote down vote up
@Override
protected void configure() {
  BeanConfig beanConfig = new BeanConfig();
  beanConfig.setBasePath("/");
  beanConfig.setResourcePackage(API_PACKAGE);
  beanConfig.setScan(true);

  SwaggerModelTransformer transformer = SwaggerModelTransformer.builder()
          .addTransformation(new ResultContainerTransformation(ResultStash.class, "data"))
          .build();

  bind(SwaggerApiListingResource.class).in(Scopes.SINGLETON);
  bind(SwaggerSerializers.class).in(Scopes.SINGLETON);
  bind(SwaggerModelTransformer.class).toInstance(transformer);
}
 
Example #29
Source File: Application.java    From ctsms with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Application() {
	super(Settings.WEB_ROOT_PACKAGE_NAME + ".jersey");
	BeanConfig beanConfig = new BeanConfig();
	beanConfig.setSchemes(new String[] { WebUtil.getHttpScheme() });
	beanConfig.setHost(WebUtil.getHttpHost());
	beanConfig.setBasePath("/" + WebUtil.REST_API_PATH);
	beanConfig.setTitle(Settings.getString(SettingCodes.API_TITLE, Bundle.SETTINGS, DefaultSettings.API_TITLE));
	beanConfig.setVersion(Settings.getString(SettingCodes.API_VERSION, Bundle.SETTINGS, DefaultSettings.API_VERSION));
	beanConfig.setContact(Settings.getContactEmail());
	beanConfig.setResourcePackage(Settings.WEB_ROOT_PACKAGE_NAME + ".jersey.resource");
	beanConfig.setScan(true);
}
 
Example #30
Source File: InventoryItemApi.java    From cqrs-eventsourcing-kafka with Apache License 2.0 5 votes vote down vote up
private void configureSwagger(Environment environment) {
    BeanConfig config = new BeanConfig();
    config.setTitle("Inventory Item API");
    config.setVersion("1.0.0");
    config.setResourcePackage(InventoryItemResource.class.getPackage().getName());
    config.setScan(true);

    FilterRegistration.Dynamic filter = environment.servlets().addFilter("CORSFilter", CrossOriginFilter.class);
    filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, environment.getApplicationContext().getContextPath() + "swagger.json");
    filter.setInitParameter(ALLOWED_METHODS_PARAM, "GET,OPTIONS");
    filter.setInitParameter(ALLOWED_HEADERS_PARAM, "Origin, Content-Type, Accept");
    filter.setInitParameter(ALLOWED_ORIGINS_PARAM, "*");
    filter.setInitParameter(ALLOW_CREDENTIALS_PARAM, "true");
}