Search in sources :

Example 6 with Contact

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);
}
Also used : ExampleObject(io.swagger.v3.oas.annotations.media.ExampleObject) Contact(io.swagger.v3.oas.models.info.Contact)

Aggregations

Contact (io.swagger.v3.oas.models.info.Contact)6 OpenAPI (io.swagger.v3.oas.models.OpenAPI)5 Info (io.swagger.v3.oas.models.info.Info)5 Test (org.testng.annotations.Test)5 Operation (io.swagger.v3.oas.models.Operation)4 PathItem (io.swagger.v3.oas.models.PathItem)4 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)4 Schema (io.swagger.v3.oas.models.media.Schema)4 StringSchema (io.swagger.v3.oas.models.media.StringSchema)4 Person (io.swagger.v3.core.oas.models.Person)3 Content (io.swagger.v3.oas.models.media.Content)3 MediaType (io.swagger.v3.oas.models.media.MediaType)3 Parameter (io.swagger.v3.oas.models.parameters.Parameter)3 QueryParameter (io.swagger.v3.oas.models.parameters.QueryParameter)3 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)3 ApiResponses (io.swagger.v3.oas.models.responses.ApiResponses)3 Server (io.swagger.v3.oas.models.servers.Server)3 Components (io.swagger.v3.oas.models.Components)2 Paths (io.swagger.v3.oas.models.Paths)2 Link (io.swagger.v3.oas.models.links.Link)2