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/"); }
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/"); }
beanConfig.setSchemes(new String[]{"http", "https"}); beanConfig.setDescription("<a href='https://github.com/scouter-project/scouter/blob/master/scouter.document/tech/Web-API-Guide.md' target='_blank'> [Scouter document page] Scouter Web API Guide</a>"); beanConfig.setTitle("Scouter HTTP APIs");
public V1Application() { BeanConfig beanConfig = new BeanConfig(); beanConfig.setVersion("v1"); beanConfig.setTitle("Syndesis Rest API"); beanConfig.setSchemes(new String[]{"http", "https"}); beanConfig.setBasePath("/api/v1"); beanConfig.setResourcePackage(getClass().getPackage().getName()); beanConfig.setScan(true); }
public class SwaggerBootstrap extends DefaultJaxrsConfig { /** * */ private static final long serialVersionUID = myAutoGeneratedID; @Override public void init(ServletConfig config) throws ServletException { super.init(config); //contextPath will be null for host2 and /xyz for host1. String contextPath = config.getServletContext().getContextPath(); BeanConfig beanConfig = new BeanConfig(); beanConfig.setVersion("1.0.0"); beanConfig.setTitle("My API Documentation"); beanConfig.setSchemes(new String[] { "http", "https" }); beanConfig .setResourcePackage("com.example.my.rest.api.package"); beanConfig.setBasePath(contextPath + "/rest"); beanConfig.setScan(true); } }
register(ApiListingResource.class); register(SwaggerSerializers.class); BeanConfig beanConfig = new BeanConfig(); beanConfig.setVersion("1.0.0"); beanConfig.setSchemes(new String[]{"http"}); beanConfig.setBasePath("/api"); //or insert your base path (see main Jersey app class) beanConfig.setResourcePackage("com.xxx.where.your.endpoints"); beanConfig.setScan(true); beanConfig.setPrettyPrint(true);
@ApplicationPath("/api") public class MyApplication extends Application { public MyApplication() { BeanConfig beanConfig = new BeanConfig(); beanConfig.setVersion("1.0"); beanConfig.setSchemes(new String[]{"http"}); beanConfig.setHost("localhost:8080"); beanConfig.setBasePath("/api"); beanConfig.setResourcePackage("io.swagger.resources,com.example.project"); beanConfig.setScan(true); } }
public class SampleApplication extends Application { public SampleApplication() { BeanConfig beanConfig = new BeanConfig(); beanConfig.setVersion("1.0.2"); beanConfig.setSchemes(new String[]{"http"}); beanConfig.setHost("localhost:8002"); beanConfig.setBasePath("/api"); beanConfig.setResourcePackage("io.swagger.resources"); beanConfig.setScan(true); } @Override public Set<Class<?>> getClasses() { // set your resources here } }
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));
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); }
... ApplicationConfig.initializeSwaggerConfiguration(); // call from app config ... /* Swagger configuratoin */ @PostConstruct public static void initializeSwaggerConfiguration() { BeanConfig beanConfig = new BeanConfig(); beanConfig.setSchemes(new String[] { "http" }); String host = PropertyHandler.getInstance().getValue(PARAM_API_HOST) + ":" + PropertyHandler.getInstance().getValue(PARAM_PORT); beanConfig.setHost(host); beanConfig.setBasePath(PropertyHandler.getInstance().getValue(PARAM_API_BASEPATH)); beanConfig.setVersion(PropertyHandler.getInstance().getValue(PARAM_VERSION) + " Profile: " + App.getProfile()); beanConfig.setTitle("SOD Services"); beanConfig.setDescription("Services for handlign the be"); beanConfig.setResourcePackage(SERVICES_PACKAGE); beanConfig.setScan(true); Json.mapper().setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); }
@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()); } }; }
beanConfig.setSchemes(new String[]{"http", "https"}); beanConfig.setDescription("<a href='https://github.com/scouter-project/scouter/blob/master/scouter.document/tech/Web-API-Guide.md' target='_blank'> [Scouter document page] Scouter Web API Guide</a>"); beanConfig.setTitle("Scouter HTTP APIs");
swaggerConfig.setSchemes(new String[]{"http"}); swaggerConfig.setHost("localhost:"+AppGlobals.get().getConfig().getInteger("http_port", 9000)); swaggerConfig.setBasePath("/");
@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.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");
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); }
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; }