io.swagger.annotations.Info#io.swagger.models.Contact源码实例Demo

下面列出了io.swagger.annotations.Info#io.swagger.models.Contact 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dorado   文件: ApiContextBuilderImpl.java
@Override
// 这里定制Api全局信息,如文档描述、license,contact等信息
public ApiContext buildApiContext() {
	Info info = new Info()
			.contact(new Contact().email("[email protected]").name("weiping wang")
					.url("http://github.com/javagossip/dorado"))
			.license(new License().name("apache v2.0").url("http://www.apache.org"))
			.termsOfService("http://swagger.io/terms/").description("Dorado服务框架api接口文档")
			.title("dorado demo api接口文档").version("1.0.0");

	//构造api访问授权的apiKey
	ApiKey apiKey = ApiKey.builder().withName("Authorization").withIn("header").build();
	ApiContext apiContext = ApiContext.builder().withApiKey(apiKey)
			.withInfo(info).build();

	return apiContext;
}
 
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;
}
 
源代码3 项目: Resource   文件: ServiceModelToSwagger2.java
@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;
}
 
源代码4 项目: swagger2markup   文件: ContactInfoComponent.java
@Override
public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, Parameters params) {
    Contact contact = params.contact;
    if (isNotBlank(contact.getName()) || isNotBlank(contact.getEmail())) {
        markupDocBuilder.sectionTitleLevel(params.titleLevel, labels.getLabel(SwaggerLabels.CONTACT_INFORMATION));
        MarkupDocBuilder paragraphBuilder = copyMarkupDocBuilder(markupDocBuilder);
        if (isNotBlank(contact.getName())) {
            paragraphBuilder.italicText(labels.getLabel(SwaggerLabels.CONTACT_NAME))
                    .textLine(COLON + contact.getName());
        }
        if (isNotBlank(contact.getEmail())) {
            paragraphBuilder.italicText(labels.getLabel(SwaggerLabels.CONTACT_EMAIL))
                    .textLine(COLON + contact.getEmail());
        }
        markupDocBuilder.paragraph(paragraphBuilder.toString(), true);
    }
    return markupDocBuilder;
}
 
源代码5 项目: cxf   文件: Java2SwaggerMojo.java
private void configureSwagger() {
    swagger = new Swagger();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    Info info = new Info();
    Contact swaggerContact = new Contact();
    License swaggerLicense = new License();
    swaggerLicense.name(this.license)
        .url(this.licenseUrl);
    swaggerContact.name(this.contact);
    info.version(this.version)
        .description(this.description)
        .contact(swaggerContact)
        .license(swaggerLicense)
        .title(this.title);
    swagger.setInfo(info);
    if (this.schemes != null) {
        for (String scheme : this.schemes) {
            swagger.scheme(Scheme.forValue(scheme));
        }
    }
    swagger.setHost(this.host);
    swagger.setBasePath(this.basePath);
}
 
源代码6 项目: jboot   文件: JbootSwaggerManager.java
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);

}
 
源代码7 项目: swagger2markup   文件: ContactInfoComponentTest.java
@Test
public void testVersionInfoComponent() throws URISyntaxException {
    Contact contact = new Contact().name("TestName").email("[email protected]");

    Swagger2MarkupConverter.SwaggerContext context = createContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    markupDocBuilder = new ContactInfoComponent(context).apply(markupDocBuilder, ContactInfoComponent.parameters(
            contact, OverviewDocument.SECTION_TITLE_LEVEL));
    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));

}
 
源代码8 项目: msf4j   文件: MSF4JBeanConfig.java
private void updateInfoFromConfig() {
    if (getSwagger().getInfo() == null) {
        setInfo(new Info());
    }

    if (StringUtils.isNotBlank(getDescription())) {
        getSwagger().getInfo().setDescription(getDescription());
    }

    if (StringUtils.isNotBlank(getTitle())) {
        getSwagger().getInfo().setTitle(getTitle());
    }

    if (StringUtils.isNotBlank(getVersion())) {
        getSwagger().getInfo().setVersion(getVersion());
    }

    if (StringUtils.isNotBlank(getTermsOfServiceUrl())) {
        getSwagger().getInfo().setTermsOfService(getTermsOfServiceUrl());
    }

    if (getContact() != null) {
        getSwagger().getInfo().setContact((new Contact()).name(getContact()));
    }

    if (getLicense() != null && getLicenseUrl() != null) {
        getSwagger().getInfo().setLicense((new License()).name(getLicense()).url(getLicenseUrl()));
    }

    if (getSchemes() != null) {
        for (String scheme : getSchemes()) {
            reader.getSwagger().scheme(Scheme.forValue(scheme));
        }
    }

    reader.getSwagger().setInfo(getInfo());
}
 
源代码9 项目: carbon-apimgt   文件: OAS2Parser.java
/**
 * 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);
}
 
源代码10 项目: swagger-maven-plugin   文件: ApiSource.java
private Contact from(io.swagger.annotations.Contact contactAnnotation) {
    Contact contact = new Contact()
            .name(emptyToNull(contactAnnotation.name()))
            .email(emptyToNull(contactAnnotation.email()))
            .url(emptyToNull(contactAnnotation.url()));
    if (contact.getName() == null && contact.getEmail() == null && contact.getUrl() == null) {
        contact = null;
    }
    return contact;
}
 
@Override
public void preprocessSwagger(Swagger swagger) {
    super.preprocessSwagger(swagger);

    if (additionalProperties.containsKey(PROJECT_NAME)) {
        projectName = ((String) additionalProperties.get(PROJECT_NAME));
    }
    if (additionalProperties.containsKey(PROJECT_DESCRIPTION)) {
        projectDescription = ((String) additionalProperties.get(PROJECT_DESCRIPTION));
    }
    if (additionalProperties.containsKey(PROJECT_VERSION)) {
        projectVersion = ((String) additionalProperties.get(PROJECT_VERSION));
    }
    if (additionalProperties.containsKey(BASE_NAMESPACE)) {
        baseNamespace = ((String) additionalProperties.get(BASE_NAMESPACE));
    }

    if (swagger.getInfo() != null) {
        Info info = swagger.getInfo();
        if (projectName == null &&  info.getTitle() != null) {
            // when projectName is not specified, generate it from info.title
            projectName = dashize(info.getTitle());
        }
        if (projectVersion == null) {
            // when projectVersion is not specified, use info.version
            projectVersion = info.getVersion();
        }
        if (projectDescription == null) {
            // when projectDescription is not specified, use info.description
            projectDescription = info.getDescription();
        }

        if (info.getContact() != null) {
            Contact contact = info.getContact();
            if (additionalProperties.get(PROJECT_URL) == null) {
                additionalProperties.put(PROJECT_URL, contact.getUrl());
            }
        }
        if (info.getLicense() != null) {
            License license = info.getLicense();
            if (additionalProperties.get(PROJECT_LICENSE_NAME) == null) {
                additionalProperties.put(PROJECT_LICENSE_NAME, license.getName());
            }
            if (additionalProperties.get(PROJECT_LICENSE_URL) == null) {
                additionalProperties.put(PROJECT_LICENSE_URL, license.getUrl());
            }
        }
    }

    // default values
    if (projectName == null) {
        projectName = "swagger-clj-client";
    }
    if (projectVersion == null) {
        projectVersion = "1.0.0";
    }
    if (projectDescription == null) {
        projectDescription = "Client library of " + projectName;
    }
    if (baseNamespace == null) {
        baseNamespace = dashize(projectName);
    }
    apiPackage = baseNamespace + ".api";

    additionalProperties.put(PROJECT_NAME, projectName);
    additionalProperties.put(PROJECT_DESCRIPTION, escapeText(projectDescription));
    additionalProperties.put(PROJECT_VERSION, projectVersion);
    additionalProperties.put(BASE_NAMESPACE, baseNamespace);
    additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);

    final String baseNamespaceFolder = sourceFolder + File.separator + namespaceToFolder(baseNamespace);
    supportingFiles.add(new SupportingFile("project.mustache", "", "project.clj"));
    supportingFiles.add(new SupportingFile("core.mustache", baseNamespaceFolder, "core.clj"));
    supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
    supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
}
 
源代码12 项目: swagger2markup   文件: ContactInfoComponent.java
public static ContactInfoComponent.Parameters parameters(Contact contact,
                                                         int titleLevel) {
    return new ContactInfoComponent.Parameters(contact, titleLevel);
}
 
源代码13 项目: swagger2markup   文件: ContactInfoComponent.java
public Parameters(Contact contact,
                  int titleLevel) {
    this.contact = Validate.notNull(contact, "Contact must not be null");
    this.titleLevel = titleLevel;
}