Java Code Examples for io.swagger.models.Contact#setEmail()

The following examples show how to use io.swagger.models.Contact#setEmail() . 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: SwaggerDefinitionProcessor.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
private Contact convertContact(io.swagger.annotations.Contact contactAnnotation) {
  Contact contact = new Contact();

  if (StringUtils.isNotEmpty(contactAnnotation.name())) {
    contact.setName(contactAnnotation.name());
  }
  if (StringUtils.isNotEmpty(contactAnnotation.url())) {
    contact.setUrl(contactAnnotation.url());
  }
  if (StringUtils.isNotEmpty(contactAnnotation.email())) {
    contact.setEmail(contactAnnotation.email());
  }

  if (StringUtils.isEmpty(contact.getName()) &&
      StringUtils.isEmpty(contact.getUrl()) &&
      StringUtils.isEmpty(contact.getEmail())) {
    return null;
  }

  return contact;
}
 
Example 2
Source File: ServiceModelToSwagger2.java    From Resource with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Contact map(springfox.documentation.service.Contact from)
{
    if (from == null)
    {
        return null;
    }

    Contact contact = new Contact();

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

    return contact;
}
 
Example 3
Source File: JbootSwaggerManager.java    From jboot with Apache License 2.0 5 votes vote down vote up
public void init() {
    if (!config.isConfigOk()) {
        return;
    }

    swagger = new Swagger();
    swagger.setHost(config.getHost());
    swagger.setBasePath("/");
    swagger.addScheme(HTTP);
    swagger.addScheme(HTTPS);


    Info swaggerInfo = new Info();
    swaggerInfo.setDescription(config.getDescription());
    swaggerInfo.setVersion(config.getVersion());
    swaggerInfo.setTitle(config.getTitle());
    swaggerInfo.setTermsOfService(config.getTermsOfService());

    Contact contact = new Contact();
    contact.setName(config.getContactName());
    contact.setEmail(config.getContactEmail());
    contact.setUrl(config.getContactUrl());
    swaggerInfo.setContact(contact);

    License license = new License();
    license.setName(config.getLicenseName());
    license.setUrl(config.getLicenseUrl());
    swaggerInfo.setLicense(license);


    swagger.setInfo(swaggerInfo);

    List<Class> classes = ClassScanner.scanClassByAnnotation(RequestMapping.class, false);

    Reader.read(swagger, classes);

}
 
Example 4
Source File: OAS2Parser.java    From carbon-apimgt with Apache License 2.0 5 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 {
    Swagger swagger = new Swagger();

    //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());
    swagger.setInfo(info);
    updateSwaggerSecurityDefinition(swagger, swaggerData, "https://test.com");
    updateLegacyScopesFromSwagger(swagger, swaggerData);
    for (SwaggerData.Resource resource : swaggerData.getResources()) {
        addOrUpdatePathToSwagger(swagger, resource);
    }

    return getSwaggerJsonString(swagger);
}