use of io.swagger.models.License in project java-chassis by ServiceComb.
the class SwaggerDefinitionProcessor method convertLicense.
private License convertLicense(io.swagger.annotations.License licenseAnnotation) {
License license = new License();
license.setName(licenseAnnotation.name());
license.setUrl(licenseAnnotation.url());
return license;
}
use of io.swagger.models.License in project swagger-core by swagger-api.
the class BeanConfig method updateInfoFromConfig.
private void updateInfoFromConfig() {
info = getSwagger().getInfo();
if (info == null) {
info = new Info();
}
if (StringUtils.isNotBlank(description)) {
info.description(description);
}
if (StringUtils.isNotBlank(title)) {
info.title(title);
}
if (StringUtils.isNotBlank(version)) {
info.version(version);
}
if (StringUtils.isNotBlank(termsOfServiceUrl)) {
info.termsOfService(termsOfServiceUrl);
}
if (contact != null) {
this.info.contact(new Contact().name(contact));
}
if (license != null && licenseUrl != null) {
this.info.license(new License().name(license).url(licenseUrl));
}
if (schemes != null) {
for (String scheme : schemes) {
reader.getSwagger().scheme(Scheme.forValue(scheme));
}
}
reader.getSwagger().setInfo(info);
}
use of io.swagger.models.License in project apiee by phillip-kruger.
the class SwaggerCache method getSwaggerLicense.
private License getSwaggerLicense() {
String name = whiteLabel.getProperty(INFO_LICENSE_NAME, null);
String url = whiteLabel.getProperty(INFO_LICENSE_URL, null);
if (isSet(name, url)) {
License license = new License();
if (isSet(name))
license.setName(name);
if (isSet(url))
license.setUrl(url);
return license;
}
return null;
}
use of io.swagger.models.License in project camel by apache.
the class RestSwaggerSupport method initSwagger.
public void initSwagger(BeanConfig swaggerConfig, Map<String, Object> config) {
// configure swagger options
String s = (String) config.get("swagger.version");
if (s != null) {
swaggerConfig.setVersion(s);
}
s = (String) config.get("base.path");
if (s != null) {
swaggerConfig.setBasePath(s);
}
s = (String) config.get("host");
if (s != null) {
swaggerConfig.setHost(s);
}
s = (String) config.get("cors");
if (s != null) {
cors = "true".equalsIgnoreCase(s);
}
s = (String) config.get("schemes");
if (s == null) {
// deprecated due typo
s = (String) config.get("schemas");
}
if (s != null) {
String[] schemes = s.split(",");
swaggerConfig.setSchemes(schemes);
} else {
// assume http by default
swaggerConfig.setSchemes(new String[] { "http" });
}
String version = (String) config.get("api.version");
String title = (String) config.get("api.title");
String description = (String) config.get("api.description");
String termsOfService = (String) config.get("api.termsOfService");
String licenseName = (String) config.get("api.license.name");
String licenseUrl = (String) config.get("api.license.url");
String contactName = (String) config.get("api.contact.name");
String contactUrl = (String) config.get("api.contact.url");
String contactEmail = (String) config.get("api.contact.email");
Info info = new Info();
info.setVersion(version);
info.setTitle(title);
info.setDescription(description);
info.setTermsOfService(termsOfService);
if (licenseName != null || licenseUrl != null) {
License license = new License();
license.setName(licenseName);
license.setUrl(licenseUrl);
info.setLicense(license);
}
if (contactName != null || contactUrl != null || contactEmail != null) {
Contact contact = new Contact();
contact.setName(contactName);
contact.setUrl(contactUrl);
contact.setEmail(contactEmail);
info.setContact(contact);
}
swaggerConfig.setInfo(info);
}
use of io.swagger.models.License in project swagger-core by swagger-api.
the class Reader method readInfoConfig.
protected void readInfoConfig(SwaggerDefinition config) {
Info infoConfig = config.info();
io.swagger.models.Info info = swagger.getInfo();
if (info == null) {
info = new io.swagger.models.Info();
swagger.setInfo(info);
}
if (!infoConfig.description().isEmpty()) {
info.setDescription(infoConfig.description());
}
if (!infoConfig.termsOfService().isEmpty()) {
info.setTermsOfService(infoConfig.termsOfService());
}
if (!infoConfig.title().isEmpty()) {
info.setTitle(infoConfig.title());
}
if (!infoConfig.version().isEmpty()) {
info.setVersion(infoConfig.version());
}
if (!infoConfig.contact().name().isEmpty()) {
Contact contact = info.getContact();
if (contact == null) {
contact = new Contact();
info.setContact(contact);
}
contact.setName(infoConfig.contact().name());
if (!infoConfig.contact().email().isEmpty()) {
contact.setEmail(infoConfig.contact().email());
}
if (!infoConfig.contact().url().isEmpty()) {
contact.setUrl(infoConfig.contact().url());
}
}
if (!infoConfig.license().name().isEmpty()) {
License license = info.getLicense();
if (license == null) {
license = new License();
info.setLicense(license);
}
license.setName(infoConfig.license().name());
if (!infoConfig.license().url().isEmpty()) {
license.setUrl(infoConfig.license().url());
}
}
info.getVendorExtensions().putAll(BaseReaderUtils.parseExtensions(infoConfig.extensions()));
}
Aggregations