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); }
@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.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.setLicense(theLicense);
@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.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"); beanConfig.setVersion(apiConfig.getVersion());
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; }