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

The following examples show how to use io.swagger.v3.oas.models.info.License#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: SwaggerLicense.java    From swagger-maven-plugin with MIT License 5 votes vote down vote up
public License createLicenseModel() {
    License license = new License();

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

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

    return license;
}
 
Example 2
Source File: MCRRestV2App.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
private void setupOAS() {
    OpenAPI oas = new OpenAPI();
    Info oasInfo = new Info();
    oas.setInfo(oasInfo);
    oasInfo.setVersion(MCRCoreVersion.getVersion());
    oasInfo.setTitle(getApplicationName());
    License oasLicense = new License();
    oasLicense.setName("GNU General Public License, version 3");
    oasLicense.setUrl("http://www.gnu.org/licenses/gpl-3.0.txt");
    oasInfo.setLicense(oasLicense);
    URI baseURI = URI.create(MCRFrontendUtil.getBaseURL());
    Server oasServer = new Server();
    oasServer.setUrl(baseURI.resolve("api").toString());
    oas.addServersItem(oasServer);
    SwaggerConfiguration oasConfig = new SwaggerConfiguration()
        .openAPI(oas)
        .resourcePackages(Stream.of(getRestPackages()).collect(Collectors.toSet()))
        .ignoredRoutes(
            MCRConfiguration2.getString("MCR.RestAPI.V2.OpenAPI.IgnoredRoutes")
                .map(MCRConfiguration2::splitValue)
                .orElseGet(Stream::empty)
                .collect(Collectors.toSet()))
        .prettyPrint(true);
    try {
        new JaxrsOpenApiContextBuilder()
            .application(getApplication())
            .openApiConfiguration(oasConfig)
            .buildContext(true);
    } catch (OpenApiConfigurationException e) {
        throw new InternalServerErrorException(e);
    }
}
 
Example 3
Source File: SwaggerConverter.java    From swagger-parser with Apache License 2.0 5 votes vote down vote up
private License convert(io.swagger.models.License v2License) {
    if (v2License == null) {
        return null;
    }

    License license = new License();
    license.setExtensions(convert(v2License.getVendorExtensions()));
    license.setName(v2License.getName());
    license.setUrl(v2License.getUrl());

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

    License license = new License();

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

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

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

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

    return license;
}