本文整理汇总了Java中io.swagger.jaxrs.config.BeanConfig.setLicense方法的典型用法代码示例。如果您正苦于以下问题:Java BeanConfig.setLicense方法的具体用法?Java BeanConfig.setLicense怎么用?Java BeanConfig.setLicense使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.swagger.jaxrs.config.BeanConfig
的用法示例。
在下文中一共展示了BeanConfig.setLicense方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activate
import io.swagger.jaxrs.config.BeanConfig; //导入方法依赖的package包/类
@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);
}
示例2: swaggerConfig
import io.swagger.jaxrs.config.BeanConfig; //导入方法依赖的package包/类
@Bean
public BeanConfig swaggerConfig() {
final BeanConfig beanConfig = new BeanConfig();
beanConfig.setResourcePackage("com.github.sbugat.samplerest.resource");
beanConfig.setVersion("1.0.0");
beanConfig.setHost("localhost:8080");
beanConfig.setBasePath(servletContext.getContextPath());
beanConfig.setTitle("Swagger CXF, JAX-RS 2.0 sample");
beanConfig.setDescription("This is a Swagger CXF, JAX-RS 2.0 sample API.");
beanConfig.setContact("Sylvain Bugat");
beanConfig.setLicense("Apache 2.0");
beanConfig.setLicenseUrl("https://github.com/Sylvain-Bugat/swagger-cxf-rest-skeleton/blob/master/LICENSE");
beanConfig.getSwagger().addSecurityDefinition("api_token", new ApiKeyAuthDefinition("api_token", In.HEADER));
beanConfig.setScan(true);
return beanConfig;
}
示例3: getBeanConfig
import io.swagger.jaxrs.config.BeanConfig; //导入方法依赖的package包/类
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;
}
示例4: bildSwaggerConfig
import io.swagger.jaxrs.config.BeanConfig; //导入方法依赖的package包/类
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("[email protected]");
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..
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);
}
示例5: setUpSwagger
import io.swagger.jaxrs.config.BeanConfig; //导入方法依赖的package包/类
private void setUpSwagger() {
BeanConfig beanConfig = new BeanConfig();
beanConfig.setTitle("Sample Jersey 2.x RESTful Web Application");
beanConfig.setDescription(
"Sample Jersey 2.x Web Application that can be deployed in a Servlet Container"
);
beanConfig.setLicense("Unlicense");
beanConfig.setLicenseUrl("http://unlicense.org");
beanConfig.setVersion("1.0.0");
beanConfig.setSchemes(new String[]{"http"});
beanConfig.setBasePath("api");
beanConfig.setResourcePackage("com.programmingskillz.samplejerseywebapp.web");
beanConfig.setScan(true);
beanConfig.setPrettyPrint(true);
}
示例6: JaxRsActivator
import io.swagger.jaxrs.config.BeanConfig; //导入方法依赖的package包/类
public JaxRsActivator() {
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.0");
beanConfig.setSchemes(new String[] { "http" });
beanConfig.setTitle("Hola microservices REST API");
beanConfig.setDescription("Operations that can be invoked in the hola microservices");
beanConfig.setResourcePackage("com.redhat.developers.msa.hola");
beanConfig.setLicense("Apache 2.0");
beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
beanConfig.setContact("[email protected]");
beanConfig.setBasePath("/api");
beanConfig.setPrettyPrint(true);
beanConfig.setScan(true);
}
示例7: JaxRsActivator
import io.swagger.jaxrs.config.BeanConfig; //导入方法依赖的package包/类
public JaxRsActivator() {
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.0");
beanConfig.setSchemes(new String[] { "http" });
beanConfig.setTitle("The Deploy Master demo REST API");
beanConfig.setDescription("Operations that can be invoked in this demo");
beanConfig.setResourcePackage("com.redhat.developers.rest");
beanConfig.setLicense("Apache 2.0");
beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
beanConfig.setContact("[email protected]");
beanConfig.setBasePath("/demo/api");
beanConfig.setPrettyPrint(true);
beanConfig.setScan(true);
}
示例8: contextInitialized
import io.swagger.jaxrs.config.BeanConfig; //导入方法依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.0");
beanConfig.setSchemes(new String[] { "http" });
beanConfig.setTitle("Hola microservices REST API");
beanConfig.setDescription("Operations that can be invoked in the hola microservices");
beanConfig.setResourcePackage("com.redhat.developers.msa.hola");
beanConfig.setLicense("Apache 2.0");
beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
beanConfig.setContact("[email protected]");
beanConfig.setBasePath("/api");
beanConfig.setPrettyPrint(true);
beanConfig.setScan(true);
}
示例9: contextInitialized
import io.swagger.jaxrs.config.BeanConfig; //导入方法依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.0");
beanConfig.setSchemes(new String[] { "http" });
beanConfig.setTitle("Hello microservices REST API");
beanConfig.setDescription("Operations that can be invoked in the hello microservices");
beanConfig.setResourcePackage("com.redhat.developers.msa.hello");
beanConfig.setLicense("Apache 2.0");
beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
beanConfig.setContact("[email protected]");
beanConfig.setBasePath("/api");
beanConfig.setPrettyPrint(true);
beanConfig.setScan(true);
}
示例10: testReaderRead
import io.swagger.jaxrs.config.BeanConfig; //导入方法依赖的package包/类
@Test
public void testReaderRead() throws Exception {
BeanConfig config = new BeanConfig();
config.setHost("localhost:8080");
config.setSchemes(new String[]{"http"});
config.setBasePath("/api");
config.setTitle("Camel User store");
config.setLicense("Apache 2.0");
config.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
RestSwaggerReader reader = new RestSwaggerReader();
Swagger swagger = reader.read(context.getRestDefinitions(), null, config, context.getName(), new DefaultClassResolver());
assertNotNull(swagger);
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = mapper.writeValueAsString(swagger);
log.info(json);
assertTrue(json.contains("\"host\" : \"localhost:8080\""));
assertTrue(json.contains("\"description\" : \"The user returned\""));
assertTrue(json.contains("\"$ref\" : \"#/definitions/User\""));
assertTrue(json.contains("\"x-className\""));
assertTrue(json.contains("\"format\" : \"org.apache.camel.swagger.User\""));
assertFalse(json.contains("\"enum\""));
context.stop();
}
示例11: testReaderRead
import io.swagger.jaxrs.config.BeanConfig; //导入方法依赖的package包/类
@Test
public void testReaderRead() throws Exception {
BeanConfig config = new BeanConfig();
config.setHost("localhost:8080");
config.setSchemes(new String[]{"http"});
config.setBasePath("/api");
config.setTitle("Day");
config.setLicense("Apache 2.0");
config.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
RestSwaggerReader reader = new RestSwaggerReader();
Swagger swagger = reader.read(context.getRestDefinitions(), null, config, context.getName(), new DefaultClassResolver());
assertNotNull(swagger);
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = mapper.writeValueAsString(swagger);
log.info(json);
assertTrue(json.contains("\"host\" : \"localhost:8080\""));
assertTrue(json.contains("\"default\" : \"friday\""));
assertTrue(json.contains("\"enum\" : [ \"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\" ]"));
assertTrue(json.contains("\"$ref\" : \"#/definitions/DayResponse\""));
assertTrue(json.contains("\"format\" : \"org.apache.camel.swagger.DayResponse\""));
assertTrue(json.contains("\"X-Rate-Limit-Limit\" : {"));
assertTrue(json.contains("\"description\" : \"The number of allowed requests in the current period\""));
context.stop();
}
示例12: testReaderRead
import io.swagger.jaxrs.config.BeanConfig; //导入方法依赖的package包/类
@Test
public void testReaderRead() throws Exception {
BeanConfig config = new BeanConfig();
config.setHost("localhost:8080");
config.setSchemes(new String[]{"http"});
config.setBasePath("/api");
config.setTitle("Camel User store");
config.setLicense("Apache 2.0");
config.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
RestSwaggerReader reader = new RestSwaggerReader();
Swagger swagger = reader.read(context.getRestDefinitions(), null, config, context.getName(), new DefaultClassResolver());
assertNotNull(swagger);
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = mapper.writeValueAsString(swagger);
log.info(json);
assertTrue(json.contains("\"host\" : \"localhost:8080\""));
assertTrue(json.contains("\"description\" : \"The order returned\""));
assertTrue(json.contains("\"BookOrder\""));
assertTrue(json.contains("\"LineItem\""));
assertTrue(json.contains("\"$ref\" : \"#/definitions/BookOrder\""));
assertTrue(json.contains("\"$ref\" : \"#/definitions/LineItem\""));
assertTrue(json.contains("\"x-className\""));
assertTrue(json.contains("\"format\" : \"org.apache.camel.swagger.BookOrder\""));
// TODO: we do not yet have the classname of nested types
// assertTrue(json.contains("\"format\" : \"org.apache.camel.swagger.LineItem\""));
context.stop();
}
示例13: activate
import io.swagger.jaxrs.config.BeanConfig; //导入方法依赖的package包/类
@Override
public void activate(ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException {
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(SwaggerArchive.SWAGGER_CONFIGURATION_PATH);
if (in == null) {
// try again, we must go deeper.
in = Thread.currentThread().getContextClassLoader().getResourceAsStream("WEB-INF/classes/" + SwaggerArchive.SWAGGER_CONFIGURATION_PATH);
}
if (in == null) {
// No config available. Print a warning and return
SwaggerMessages.MESSAGES.noConfigurationFound();
return;
}
try {
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));
// some type inconsistencies in the API (String vs String[])
String[] packages = (String[]) config.get(SwaggerConfig.Key.PACKAGES);
if (packages != null) {
StringBuffer sb = new StringBuffer();
for (String s : packages) {
sb.append(s).append(',');
}
beanConfig.setResourcePackage(sb.toString());
}
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);
} catch (IOException e) {
throw new ServiceRegistryException(e);
}
}