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/"); }
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/"); }
private void setupSwagger(HttpServer httpServer) { 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 (_useHttps) { beanConfig.setSchemes(new String[]{"https"}); } else { beanConfig.setSchemes(new String[]{"http"}); } beanConfig.setBasePath(baseUri.getPath()); 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/"); }
theContact = props.getProperty(CONTACT_PROPERTY); beanConfig.setContact(theContact);
beanConfig.setContact((String) config.get(SwaggerConfig.Key.CONTACT)); beanConfig.setDescription((String) config.get(SwaggerConfig.Key.DESCRIPTION)); beanConfig.setTitle((String) config.get(SwaggerConfig.Key.TITLE));
@Bean @Autowired public BeanConfig gpSwaggerBeanConfig(@Qualifier( value = "gpSwaggerConfiguration") final SwaggerConfiguration gpSwaggerConfiguration) { logger.debug("######################INITIALIZING SWAGGER WITH " + "PARAMETERS : {}\n\n", gpSwaggerConfiguration); return new BeanConfig() { { super.setResourcePackage( gpSwaggerConfiguration.getResourcePackage()); super.setVersion(gpSwaggerConfiguration.getVersion()); super.setSchemes(gpSwaggerConfiguration.getSchemes()); super.setHost(gpSwaggerConfiguration.getHost()); super.setBasePath(gpSwaggerConfiguration.getBasePath()); super.setTitle(gpSwaggerConfiguration.getTitle()); super.setDescription(gpSwaggerConfiguration.getDescription()); super.setContact(gpSwaggerConfiguration.getContact()); super.setLicense(gpSwaggerConfiguration.getLicense()); super.setLicenseUrl(gpSwaggerConfiguration.getLicenseUrl()); super.setScan(gpSwaggerConfiguration.isScan()); } }; }
@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); } }
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");
private void bildSwaggerConfig() { BeanConfig beanConfig = new BeanConfig(); //beanConfig.setConfigId("configId: " + contextId++); beanConfig.setTitle("Bagri REST server"); beanConfig.setDescription("goto http://bagridb.com for more info"); beanConfig.setContact("support@bagridb.com"); beanConfig.setLicense("Apache 2.0"); beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html"); beanConfig.setVersion(bg_version); beanConfig.setSchemes(new String[] {"http", "https"}); // TODO: get host info somehow.. //jettyServer.getConnectors()[0].getConnectedEndPoints().iterator().next().getRemoteAddress() beanConfig.setHost("localhost:" + port); beanConfig.setBasePath("/"); // /api beanConfig.setResourcePackage("com.bagri.rest.service"); beanConfig.setPrettyPrint(true); // force Swagger to re-scan the package mentioned above and use // custom ReaderListener from that package beanConfig.setScan(true); }
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); return beanConfig; }