use of io.swagger.v3.oas.models.info.Contact in project swagger-core by swagger-api.
the class AnnotationsUtils method getContact.
public static Optional<Contact> getContact(io.swagger.v3.oas.annotations.info.Contact contact) {
if (contact == null) {
return Optional.empty();
}
boolean isEmpty = true;
Contact contactObject = new Contact();
if (StringUtils.isNotBlank(contact.email())) {
contactObject.setEmail(contact.email());
isEmpty = false;
}
if (StringUtils.isNotBlank(contact.name())) {
contactObject.setName(contact.name());
isEmpty = false;
}
if (StringUtils.isNotBlank(contact.url())) {
contactObject.setUrl(contact.url());
isEmpty = false;
}
if (contact.extensions() != null && contact.extensions().length > 0) {
Map<String, Object> extensions = AnnotationsUtils.getExtensions(contact.extensions());
if (extensions != null) {
extensions.forEach(contactObject::addExtension);
isEmpty = false;
}
}
if (isEmpty) {
return Optional.empty();
}
return Optional.of(contactObject);
}
Aggregations