beanConfig.setHost(serverIp + ":" + String.valueOf(scouterConf.getNetHttpPort()));
/** * Returns a newly configured {@code BeanConfig} using the provided {@code swaggerConfig} * * @param swaggerConfig The configuration to use * @return a newly configured {@code BeanConfig} */ static BeanConfig createBeanConfig(SwaggerConfig swaggerConfig) { BeanConfig beanConfig = new BeanConfig(); beanConfig.setHost(swaggerConfig.getHost()); beanConfig.setBasePath(swaggerConfig.getBasePath()); beanConfig.setPrettyPrint(swaggerConfig.isPrettyPrint()); // Must be called last! List<String> resourcePackages = swaggerConfig.getResourcePackages(); beanConfig.setResourcePackage(Joiner.on(",").join(resourcePackages)); if (resourcePackages.isEmpty()) { log.warn("No resource packages configured"); } else { log.debug("Added resource packages {} to swagger bean config", resourcePackages); } // setScan() actually performs it! (must go last. beanConfig.setScan(true); return beanConfig; }
beanConfig.setVersion(conf.getVersion()); beanConfig.setSchemes(new String[] {"http"}); beanConfig.setHost(conf.getHost() + ":" + conf.getPort()); beanConfig.setBasePath("/" + conf.getWebContext() + "/api"); beanConfig.setScan(true);
@Component @ApplicationPath(Pathes.APPLICATION_PATH) public class JerseyConfig extends ResourceConfig { @Autowired public JerseyConfig(@Value("${server.port}") int port) { final BeanConfig beanConfig = new BeanConfig(); beanConfig.setVersion("1.0.0"); beanConfig.setHost("localhost:" + port); beanConfig.setBasePath(Pathes.APPLICATION_PATH); beanConfig.setResourcePackage(myPackages); beanConfig.setScan(true); register(ApiListingResource.class); register(SwaggerSerializers.class); } }
@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 } }
theHost = props.getProperty(HOST_PROPERTY); beanConfig.setHost(theHost);
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.setHost(host + ":" + port); beanConfig.setBasePath("/"); beanConfig.setResourcePackage(ApplicationRoot.class.getPackage().getName());
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.setHost(serverIp + ":" + String.valueOf(scouterConf.getNetHttpPort()));
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<>();
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<>();
@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.setVersion(apiConfig.getVersion()); beanConfig.setSchemes(new String[] {"http"}); beanConfig.setHost(apiConfig.getHost() + ":" + apiConfig.getPort()); beanConfig.setBasePath("/" + apiConfig.getWebContext() + "/api"); beanConfig.setScan(true);
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; }