Search in sources :

Example 1 with WsdlParser

use of io.gravitee.rest.api.service.impl.swagger.parser.WsdlParser 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();
}
Also used : OAIDescriptor(io.gravitee.rest.api.service.swagger.OAIDescriptor) SwaggerDescriptorException(io.gravitee.rest.api.service.exceptions.SwaggerDescriptorException) OAIParser(io.gravitee.rest.api.service.impl.swagger.parser.OAIParser) WsdlParser(io.gravitee.rest.api.service.impl.swagger.parser.WsdlParser) OpenAPI(io.swagger.v3.oas.models.OpenAPI)

Aggregations

SwaggerDescriptorException (io.gravitee.rest.api.service.exceptions.SwaggerDescriptorException)1 OAIParser (io.gravitee.rest.api.service.impl.swagger.parser.OAIParser)1 WsdlParser (io.gravitee.rest.api.service.impl.swagger.parser.WsdlParser)1 OAIDescriptor (io.gravitee.rest.api.service.swagger.OAIDescriptor)1 OpenAPI (io.swagger.v3.oas.models.OpenAPI)1