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

The following examples show how to use io.swagger.jaxrs.config.BeanConfig#setVersion() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
Source File: ServerModule.java    From digdag with Apache License 2.0 5 votes vote down vote up
protected void enableSwagger(ApplicationBindingBuilder builder) {
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setTitle("Digdag");
    beanConfig.setDescription("Digdag server API");
    beanConfig.setVersion(DigdagVersion.buildVersion().toString());
    beanConfig.setResourcePackage(VersionResource.class.getPackage().getName());
    beanConfig.setScan();

    builder.addProvider(SwaggerSerializers.class)
            .addProvider(CorsFilter.class)
            .addResources(SwaggerApiListingResource.class);
    logger.info("swagger api enabled on: /api/swagger.{json,yaml}");
}
 
Example 8
Source File: ServiceApp.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Override
public void run(AlertDropWizardConfiguration configuration, Environment environment) throws Exception {
    if (StringUtils.isNotEmpty(configuration.getApplicationConfPath())) {
        // setup config if given
        System.setProperty("config.resource", configuration.getApplicationConfPath());
        ConfigFactory.invalidateCaches();
        ConfigFactory.load();
    }

    environment.getApplicationContext().setContextPath("/rest");
    environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);

    environment.jersey().register(MetadataResource.class);
    environment.jersey().register(CoordinatorResource.class);

    // swagger resources
    environment.jersey().register(new ApiListingResource());
    BeanConfig swaggerConfig = new BeanConfig();
    swaggerConfig.setTitle("Alert engine service: metadata and coordinator");
    swaggerConfig.setVersion("v1.2");
    swaggerConfig.setBasePath("/rest");
    swaggerConfig
        .setResourcePackage("org.apache.eagle.alert.coordinator.resource,org.apache.eagle.service.metadata.resource");
    swaggerConfig.setScan(true);

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

    // context listener
    environment.servlets().addServletListeners(new CoordinatorListener());
}
 
Example 9
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 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() {
    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 12
Source File: SwaggerParser.java    From james-project with Apache License 2.0 5 votes vote down vote up
private static BeanConfig getBeanConfig(String packageName, WebAdminConfiguration configuration) {
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setResourcePackage(packageName);
    beanConfig.setVersion(API_DOC_VERSION);
    beanConfig.setTitle(API_DOC_TITLE);
    beanConfig.setDescription(API_DOC_DESCRIPTION);
    beanConfig.setHost(configuration.getHost() + HOST_PORT_SEPARATOR + configuration.getPort().get().getValue());
    beanConfig.setSchemes(SCHEMES);
    beanConfig.setScan(true);
    beanConfig.scanAndRead();
    return beanConfig;
}
 
Example 13
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 14
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 15
Source File: RestApplication.java    From microprofile-samples with Apache License 2.0 5 votes vote down vote up
public RestApplication() {
    final BeanConfig beanConfig = new BeanConfig();
    beanConfig.setTitle("TOP CDs");
    beanConfig.setDescription("Gives the TOP selling CDs");
    beanConfig.setVersion("1.0.0");
    beanConfig.setSchemes(new String[] { "http" });
    beanConfig.setHost("localhost:8080/msTopCDs");
    beanConfig.setBasePath("/");
    beanConfig.setResourcePackage("org.eclipse.microprofile.sample.swagger.rest");
    beanConfig.setPrettyPrint(true);
    beanConfig.setScan(true);
}
 
Example 16
Source File: ManagementApplication.java    From graviteeio-access-management with Apache License 2.0 5 votes vote down vote up
public ManagementApplication() {

        BeanConfig beanConfig = new BeanConfig();
        beanConfig.setVersion(Version.RUNTIME_VERSION.MAJOR_VERSION);
        beanConfig.setResourcePackage("io.gravitee.am.management.handlers.management.api.resources");
        beanConfig.setTitle("Gravitee.io - Access Management API");
        beanConfig.setBasePath("/management");
        beanConfig.setScan(true);

        register(OrganizationsResource.class);
        register(PlatformResource.class);
        register(CurrentUserResource.class);

        register(ObjectMapperResolver.class);
        register(ManagementExceptionMapper.class);
        register(UnrecognizedPropertyExceptionMapper.class);
        register(ThrowableMapper.class);
        register(ClientErrorExceptionMapper.class);
        register(Oauth2ExceptionMapper.class);
        register(ValidationExceptionMapper.class);
        register(JsonMappingExceptionMapper.class);
        register(WebApplicationExceptionMapper.class);

        register(UriBuilderRequestFilter.class);
        register(ByteArrayOutputStreamWriter.class);

        register(ApiListingResource.class);
        register(SwaggerSerializers.class);

        property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
    }
 
Example 17
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");
}
 
Example 18
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 19
Source File: Server.java    From redpipe with Apache License 2.0 4 votes vote down vote up
protected void setupSwagger(VertxResteasyDeployment deployment) {
	ModelConverters.getInstance().addConverter(new RxModelConverter());
	
	// Swagger
	ServletContext servletContext = new RedpipeServletContext();
	AppGlobals.get().setGlobal(ServletContext.class, servletContext);

	ServletConfig servletConfig = new ServletConfig(){

		@Override
		public String getServletName() {
			return "pretend-servlet";
		}

		@Override
		public ServletContext getServletContext() {
			return servletContext;
		}

		@Override
		public String getInitParameter(String name) {
			return getServletContext().getInitParameter(name);
		}

		@Override
		public Enumeration<String> getInitParameterNames() {
			return getServletContext().getInitParameterNames();
		}
	};
	AppGlobals.get().setGlobal(ServletConfig.class, servletConfig);

	ReaderConfigUtils.initReaderConfig(servletConfig);

	BeanConfig swaggerConfig = new MyBeanConfig();
	swaggerConfig.setVersion("1.0");
	swaggerConfig.setSchemes(new String[]{"http"});
	swaggerConfig.setHost("localhost:"+AppGlobals.get().getConfig().getInteger("http_port", 9000));
	swaggerConfig.setBasePath("/");
	Set<String> resourcePackages = new HashSet<>();
	for (Class<?> klass : deployment.getActualResourceClasses()) {
		resourcePackages.add(klass.getPackage().getName());
	}
	swaggerConfig.setResourcePackage(String.join(",", resourcePackages));
	swaggerConfig.setServletConfig(servletConfig);
	swaggerConfig.setPrettyPrint(true);
	swaggerConfig.setScan(true);
	
	deployment.getRegistry().addPerInstanceResource(ApiListingResource.class);
	deployment.getProviderFactory().register(SwaggerSerializers.class);
}
 
Example 20
Source File: RestAPIResourceConfig.java    From datacollector with Apache License 2.0 4 votes vote down vote up
public RestAPIResourceConfig() {
  register(new AbstractBinder() {
    @Override
    protected void configure() {
      bindFactory(PipelineStoreInjector.class).to(PipelineStoreTask.class);
      bindFactory(AclStoreInjector.class).to(AclStoreTask.class);
      bindFactory(StageLibraryInjector.class).to(StageLibraryTask.class);
      bindFactory(PrincipalInjector.class).to(Principal.class);
      bindFactory(URIInjector.class).to(URI.class);
      bindFactory(ConfigurationInjector.class).to(Configuration.class);
      bindFactory(RuntimeInfoInjector.class).to(RuntimeInfo.class);
      bindFactory(BuildInfoInjector.class).to(BuildInfo.class);
      bindFactory(StatsCollectorInjector.class).to(StatsCollector.class);
      bindFactory(StandAndClusterManagerInjector.class).to(Manager.class);
      bindFactory(SupportBundleInjector.class).to(SupportBundleManager.class);
      bindFactory(EventHandlerTaskInjector.class).to(EventHandlerTask.class);
      bindFactory(BlobStoreTaskInjector.class).to(BlobStoreTask.class);
      bindFactory(CredentialStoreTaskInjector.class).to(CredentialStoresTask.class);

      bindFactory(UserGroupManagerInjector.class).to(UserGroupManager.class);
      bindFactory(UsersManagerInjector.class).to(UsersManager.class);
      bindFactory(ActivationInjector.class).to(Activation.class);
    }
  });
  register(new PaginationInfoInjectorBinder());

  register(RolesAnnotationFilter.class);
  register(CsrfProtectionFilter.class);
  register(MultiPartFeature.class);

  //Hooking up Swagger-Core
  register(ApiListingResource.class);
  register(SwaggerSerializers.class);

  register(RestResponseFilter.class);

  //Configure and Initialize Swagger
  BeanConfig beanConfig = new BeanConfig();
  beanConfig.setVersion("1.0.0");
  beanConfig.setBasePath("/rest");
  beanConfig.setResourcePackage(RestAPI.class.getPackage().getName());
  beanConfig.setScan(true);
  beanConfig.setTitle("Data Collector RESTful API");

  Info info = new Info();
  info.setTitle("Data Collector RESTful API");
  info.setDescription("An Enterprise-Grade Approach to Managing Big Data in Motion");
  info.setVersion("1.0.0");
  beanConfig.setInfo(info);
}