use of io.gravitee.rest.api.service.impl.swagger.parser.OAIParser in project gravitee-management-rest-api by gravitee-io.
the class SwaggerServiceImpl method parse.
public SwaggerDescriptor parse(String content, boolean wsdl, ParseOptions options) {
OpenAPI descriptor;
if (isUrl(content)) {
UrlSanitizerUtils.checkAllowed(content, importConfiguration.getImportWhitelist(), importConfiguration.isAllowImportFromPrivate());
}
if (wsdl) {
// try to read wsdl
logger.debug("Trying to load a Wsdl descriptor");
descriptor = new WsdlParser().parse(content);
if (descriptor != null) {
return new OAIDescriptor(descriptor);
}
} else {
OAIDescriptor oaiDescriptor = new OAIParser().parse(content, options);
if (oaiDescriptor == null || oaiDescriptor.getSpecification() == null) {
throw new SwaggerDescriptorException();
}
return oaiDescriptor;
}
throw new SwaggerDescriptorException();
}
Aggregations