use of io.swagger.models.License in project elastest-instrumentation-manager by elastest.
the class Bootstrap method init.
@Override
public void init(ServletConfig config) throws ServletException {
Info info = new Info().title("Swagger Server").description("RESTful API specification for the ElasTest Instrumentation Manager (EIM)").termsOfService("TBD").contact(new Contact().email("david.rojoa@atos.net")).license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0.html"));
ServletContext context = config.getServletContext();
Swagger swagger = new Swagger().info(info);
// load properties
String propertiesFile = "/WEB-INF/bootstrap.properties";
Properties.load(config.getServletContext().getResourceAsStream(propertiesFile), propertiesFile);
// create database schema
EimDbCreator dbCreator = new EimDbCreator();
dbCreator.createSchema();
new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
}
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()));
}
use of io.swagger.models.License in project swagger-core by swagger-api.
the class Reader method readInfoConfig.
private void readInfoConfig(SwaggerDefinition config) {
final Info infoConfig = config.info();
io.swagger.models.Info info = swagger.getInfo();
if (info == null) {
info = new io.swagger.models.Info();
swagger.setInfo(info);
}
if (StringUtils.isNotBlank(infoConfig.description())) {
info.setDescription(infoConfig.description());
}
if (StringUtils.isNotBlank(infoConfig.termsOfService())) {
info.setTermsOfService(infoConfig.termsOfService());
}
if (StringUtils.isNotBlank(infoConfig.title())) {
info.setTitle(infoConfig.title());
}
if (StringUtils.isNotBlank(infoConfig.version())) {
info.setVersion(infoConfig.version());
}
if (StringUtils.isNotBlank(infoConfig.contact().name())) {
Contact contact = info.getContact();
if (contact == null) {
contact = new Contact();
info.setContact(contact);
}
contact.setName(infoConfig.contact().name());
if (StringUtils.isNotBlank(infoConfig.contact().email())) {
contact.setEmail(infoConfig.contact().email());
}
if (StringUtils.isNotBlank(infoConfig.contact().url())) {
contact.setUrl(infoConfig.contact().url());
}
}
if (StringUtils.isNotBlank(infoConfig.license().name())) {
License license = info.getLicense();
if (license == null) {
license = new License();
info.setLicense(license);
}
license.setName(infoConfig.license().name());
if (StringUtils.isNotBlank(infoConfig.license().url())) {
license.setUrl(infoConfig.license().url());
}
}
info.getVendorExtensions().putAll(BaseReaderUtils.parseExtensions(infoConfig.extensions()));
}
use of io.swagger.models.License in project ballerina by ballerina-lang.
the class SwaggerServiceMapper method parseServiceInfoAnnotationAttachment.
/**
* Parses the 'ServiceInfo' annotation and build the swagger definition for it.
* @param service The ballerina service which has the 'ServiceInfo' annotation attachment.
* @param swagger The swagger definition to be built up.
*/
private void parseServiceInfoAnnotationAttachment(ServiceNode service, Swagger swagger) {
Optional<? extends AnnotationAttachmentNode> swaggerInfoAnnotation = service.getAnnotationAttachments().stream().filter(a -> null != swaggerAlias && this.swaggerAlias.equals(a.getPackageAlias().getValue()) && "ServiceInfo".equals(a.getAnnotationName().getValue())).findFirst();
Info info = new Info().version("1.0.0").title(service.getName().getValue());
if (swaggerInfoAnnotation.isPresent()) {
Map<String, AnnotationAttachmentAttributeValueNode> attributes = this.listToMap(swaggerInfoAnnotation.get());
if (attributes.containsKey("serviceVersion")) {
info.version(this.getStringLiteralValue(attributes.get("serviceVersion")));
}
if (attributes.containsKey("title")) {
info.title(this.getStringLiteralValue(attributes.get("title")));
}
if (attributes.containsKey("description")) {
info.description(this.getStringLiteralValue(attributes.get("description")));
}
if (attributes.containsKey("termsOfService")) {
info.termsOfService(this.getStringLiteralValue(attributes.get("termsOfService")));
}
this.createContactModel(attributes.get("contact"), info);
this.createLicenseModel(attributes.get("license"), info);
this.createExternalDocModel(attributes.get("externalDoc"), swagger);
this.createTagModel(attributes.get("tags"), swagger);
this.createOrganizationModel(attributes.get("organization"), info);
this.createDevelopersModel(attributes.get("developers"), info);
}
swagger.setInfo(info);
}
Aggregations