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;
}
}
Aggregations