Java Code Examples for io.swagger.v3.oas.models.info.Contact#setName()

The following examples show how to use io.swagger.v3.oas.models.info.Contact#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SwaggerContact.java    From swagger-maven-plugin with MIT License 6 votes vote down vote up
public Contact createContactModel() {
    Contact contact = new Contact();

    if (name != null) {
        contact.setName(name);
    }

    if (url != null) {
        contact.setUrl(url);
    }

    if (email != null) {
        contact.setEmail(email);
    }

    return contact;
}
 
Example 2
Source File: SwaggerConverter.java    From swagger-parser with Apache License 2.0 5 votes vote down vote up
public Contact convert(io.swagger.models.Contact v2Contact) {
    if (v2Contact == null) {
        return null;
    }

    Contact contact = new Contact();

    contact.setUrl(v2Contact.getUrl());
    contact.setName(v2Contact.getName());
    contact.setEmail(v2Contact.getEmail());

    // TODO - treat this process after adding extensions to v2Contact object

    return contact;
}
 
Example 3
Source File: OpenAPIDeserializer.java    From swagger-parser with Apache License 2.0 4 votes vote down vote up
public Contact getContact(ObjectNode node, String location, ParseResult result) {
    if (node == null)
        return null;

    Contact contact = new Contact();

    String value = getString("name", node, false, location, result);
    if(StringUtils.isNotBlank(value)) {
        contact.setName(value);
    }

    value = getString("url", node, false, location, result);
    if(StringUtils.isNotBlank(value)) {
        try {
            new URL(value);
        }
        catch (Exception e) {
            result.warning(location,value);
        }
        contact.setUrl(value);
    }

    value = getString("email", node, false, location, result);
    if(StringUtils.isNotBlank(value)) {
        contact.setEmail(value);
    }

    Map <String,Object> extensions = getExtensions(node);
    if(extensions != null && extensions.size() > 0) {
        contact.setExtensions(extensions);
    }

    Set<String> keys = getKeys(node);
    for(String key : keys) {
        if(!CONTACT_KEYS.contains(key) && !key.startsWith("x-")) {
            result.extra(location, key, node.get(key));
        }
    }

    return contact;
}
 
Example 4
Source File: OAS3Parser.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
/**
 * This method generates API definition to the given api
 *
 * @param swaggerData api
 * @return API definition in string format
 * @throws APIManagementException
 */
@Override
public String generateAPIDefinition(SwaggerData swaggerData) throws APIManagementException {
    OpenAPI openAPI = new OpenAPI();

    // create path if null
    if (openAPI.getPaths() == null) {
        openAPI.setPaths(new Paths());
    }

    //Create info object
    Info info = new Info();
    info.setTitle(swaggerData.getTitle());
    if (swaggerData.getDescription() != null) {
        info.setDescription(swaggerData.getDescription());
    }

    Contact contact = new Contact();
    //Create contact object and map business owner info
    if (swaggerData.getContactName() != null) {
        contact.setName(swaggerData.getContactName());
    }
    if (swaggerData.getContactEmail() != null) {
        contact.setEmail(swaggerData.getContactEmail());
    }
    if (swaggerData.getContactName() != null || swaggerData.getContactEmail() != null) {
        //put contact object to info object
        info.setContact(contact);
    }

    info.setVersion(swaggerData.getVersion());
    openAPI.setInfo(info);
    updateSwaggerSecurityDefinition(openAPI, swaggerData, "https://test.com");
    updateLegacyScopesFromSwagger(openAPI, swaggerData);
    if (APIConstants.GRAPHQL_API.equals(swaggerData.getTransportType())) {
        modifyGraphQLSwagger(openAPI);
    } else {
        for (SwaggerData.Resource resource : swaggerData.getResources()) {
            addOrUpdatePathToSwagger(openAPI, resource);
        }
    }
    return Json.pretty(openAPI);
}