Search in sources :

Example 1 with License

use of io.swagger.models.License in project java-chassis by ServiceComb.

the class SwaggerDefinitionProcessor method convertLicense.

private License convertLicense(io.swagger.annotations.License licenseAnnotation) {
    License license = new License();
    license.setName(licenseAnnotation.name());
    license.setUrl(licenseAnnotation.url());
    return license;
}
Also used : License(io.swagger.models.License)

Example 2 with License

use of io.swagger.models.License in project swagger-core by swagger-api.

the class BeanConfig method updateInfoFromConfig.

private void updateInfoFromConfig() {
    info = getSwagger().getInfo();
    if (info == null) {
        info = new Info();
    }
    if (StringUtils.isNotBlank(description)) {
        info.description(description);
    }
    if (StringUtils.isNotBlank(title)) {
        info.title(title);
    }
    if (StringUtils.isNotBlank(version)) {
        info.version(version);
    }
    if (StringUtils.isNotBlank(termsOfServiceUrl)) {
        info.termsOfService(termsOfServiceUrl);
    }
    if (contact != null) {
        this.info.contact(new Contact().name(contact));
    }
    if (license != null && licenseUrl != null) {
        this.info.license(new License().name(license).url(licenseUrl));
    }
    if (schemes != null) {
        for (String scheme : schemes) {
            reader.getSwagger().scheme(Scheme.forValue(scheme));
        }
    }
    reader.getSwagger().setInfo(info);
}
Also used : License(io.swagger.models.License) Info(io.swagger.models.Info) Contact(io.swagger.models.Contact)

Example 3 with License

use of io.swagger.models.License in project apiee by phillip-kruger.

the class SwaggerCache method getSwaggerLicense.

private License getSwaggerLicense() {
    String name = whiteLabel.getProperty(INFO_LICENSE_NAME, null);
    String url = whiteLabel.getProperty(INFO_LICENSE_URL, null);
    if (isSet(name, url)) {
        License license = new License();
        if (isSet(name))
            license.setName(name);
        if (isSet(url))
            license.setUrl(url);
        return license;
    }
    return null;
}
Also used : License(io.swagger.models.License)

Example 4 with License

use of io.swagger.models.License in project camel by apache.

the class RestSwaggerSupport method initSwagger.

public void initSwagger(BeanConfig swaggerConfig, Map<String, Object> config) {
    // configure swagger options
    String s = (String) config.get("swagger.version");
    if (s != null) {
        swaggerConfig.setVersion(s);
    }
    s = (String) config.get("base.path");
    if (s != null) {
        swaggerConfig.setBasePath(s);
    }
    s = (String) config.get("host");
    if (s != null) {
        swaggerConfig.setHost(s);
    }
    s = (String) config.get("cors");
    if (s != null) {
        cors = "true".equalsIgnoreCase(s);
    }
    s = (String) config.get("schemes");
    if (s == null) {
        // deprecated due typo
        s = (String) config.get("schemas");
    }
    if (s != null) {
        String[] schemes = s.split(",");
        swaggerConfig.setSchemes(schemes);
    } else {
        // assume http by default
        swaggerConfig.setSchemes(new String[] { "http" });
    }
    String version = (String) config.get("api.version");
    String title = (String) config.get("api.title");
    String description = (String) config.get("api.description");
    String termsOfService = (String) config.get("api.termsOfService");
    String licenseName = (String) config.get("api.license.name");
    String licenseUrl = (String) config.get("api.license.url");
    String contactName = (String) config.get("api.contact.name");
    String contactUrl = (String) config.get("api.contact.url");
    String contactEmail = (String) config.get("api.contact.email");
    Info info = new Info();
    info.setVersion(version);
    info.setTitle(title);
    info.setDescription(description);
    info.setTermsOfService(termsOfService);
    if (licenseName != null || licenseUrl != null) {
        License license = new License();
        license.setName(licenseName);
        license.setUrl(licenseUrl);
        info.setLicense(license);
    }
    if (contactName != null || contactUrl != null || contactEmail != null) {
        Contact contact = new Contact();
        contact.setName(contactName);
        contact.setUrl(contactUrl);
        contact.setEmail(contactEmail);
        info.setContact(contact);
    }
    swaggerConfig.setInfo(info);
}
Also used : License(io.swagger.models.License) Info(io.swagger.models.Info) Contact(io.swagger.models.Contact)

Example 5 with License

use of io.swagger.models.License in project swagger-core by swagger-api.

the class Reader method readInfoConfig.

protected void readInfoConfig(SwaggerDefinition config) {
    Info infoConfig = config.info();
    io.swagger.models.Info info = swagger.getInfo();
    if (info == null) {
        info = new io.swagger.models.Info();
        swagger.setInfo(info);
    }
    if (!infoConfig.description().isEmpty()) {
        info.setDescription(infoConfig.description());
    }
    if (!infoConfig.termsOfService().isEmpty()) {
        info.setTermsOfService(infoConfig.termsOfService());
    }
    if (!infoConfig.title().isEmpty()) {
        info.setTitle(infoConfig.title());
    }
    if (!infoConfig.version().isEmpty()) {
        info.setVersion(infoConfig.version());
    }
    if (!infoConfig.contact().name().isEmpty()) {
        Contact contact = info.getContact();
        if (contact == null) {
            contact = new Contact();
            info.setContact(contact);
        }
        contact.setName(infoConfig.contact().name());
        if (!infoConfig.contact().email().isEmpty()) {
            contact.setEmail(infoConfig.contact().email());
        }
        if (!infoConfig.contact().url().isEmpty()) {
            contact.setUrl(infoConfig.contact().url());
        }
    }
    if (!infoConfig.license().name().isEmpty()) {
        License license = info.getLicense();
        if (license == null) {
            license = new License();
            info.setLicense(license);
        }
        license.setName(infoConfig.license().name());
        if (!infoConfig.license().url().isEmpty()) {
            license.setUrl(infoConfig.license().url());
        }
    }
    info.getVendorExtensions().putAll(BaseReaderUtils.parseExtensions(infoConfig.extensions()));
}
Also used : License(io.swagger.models.License) Info(io.swagger.annotations.Info) Contact(io.swagger.models.Contact)

Aggregations

License (io.swagger.models.License)15 Contact (io.swagger.models.Contact)10 Info (io.swagger.models.Info)7 Swagger (io.swagger.models.Swagger)4 Info (io.swagger.annotations.Info)3 ApiKeyAuthDefinition (io.swagger.models.auth.ApiKeyAuthDefinition)3 OAuth2Definition (io.swagger.models.auth.OAuth2Definition)3 Operation (io.swagger.models.Operation)2 BasicAuthDefinition (io.swagger.models.auth.BasicAuthDefinition)2 SecuritySchemeDefinition (io.swagger.models.auth.SecuritySchemeDefinition)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 AnnotationAttachmentNode (org.ballerinalang.model.tree.AnnotationAttachmentNode)2 AnnotationAttachmentAttributeValueNode (org.ballerinalang.model.tree.expressions.AnnotationAttachmentAttributeValueNode)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Lists (com.google.common.collect.Lists)1 ArrayModel (io.swagger.models.ArrayModel)1 AuthorizationScope (io.swagger.models.AuthorizationScope)1