Search in sources :

Example 1 with SwaggerParseResult

use of io.swagger.v3.parser.core.models.SwaggerParseResult in project gravitee-management-rest-api by gravitee-io.

the class SwaggerServiceImpl method transformV3.

private OpenAPI transformV3(String content, PageConfigurationEntity config) {
    SwaggerParseResult result = new OpenAPIV3Parser().readContents(content, null, null);
    if (result != null && config != null && config.getTryItURL() != null) {
        URI newURI = URI.create(config.getTryItURL());
        result.getOpenAPI().getServers().forEach(server -> {
            try {
                server.setUrl(new URI(newURI.getScheme(), newURI.getUserInfo(), newURI.getHost(), newURI.getPort(), newURI.getPath(), newURI.getQuery(), newURI.getFragment()).toString());
            } catch (URISyntaxException e) {
                logger.error(e.getMessage(), e);
            }
        });
    }
    if (result != null) {
        return result.getOpenAPI();
    } else {
        return null;
    }
}
Also used : SwaggerParseResult(io.swagger.v3.parser.core.models.SwaggerParseResult) URISyntaxException(java.net.URISyntaxException) OpenAPIV3Parser(io.swagger.v3.parser.OpenAPIV3Parser) URI(java.net.URI)

Aggregations

OpenAPIV3Parser (io.swagger.v3.parser.OpenAPIV3Parser)1 SwaggerParseResult (io.swagger.v3.parser.core.models.SwaggerParseResult)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1