Search in sources :

Example 1 with OAIToAPIConverter

use of io.gravitee.rest.api.service.impl.swagger.converter.api.OAIToAPIConverter in project gravitee-management-rest-api by gravitee-io.

the class SwaggerServiceImpl method createAPI.

@Override
public SwaggerApiEntity createAPI(ImportSwaggerDescriptorEntity swaggerDescriptor, DefinitionVersion definitionVersion) {
    ParseOptions options = new ParseOptions();
    // In the context of an import, we need to fully resolve $ref which are required for OAIDescriptorVisitors (ie. policies).
    options.setResolveFully(true);
    boolean wsdlImport = Format.WSDL.equals(swaggerDescriptor.getFormat());
    SwaggerDescriptor descriptor = parse(swaggerDescriptor.getPayload(), wsdlImport, options);
    if (wsdlImport) {
        overridePayload(swaggerDescriptor, descriptor);
        populateXmlToJsonPolicy(swaggerDescriptor);
    }
    if (descriptor != null) {
        if (definitionVersion.equals(DefinitionVersion.V2)) {
            return new OAIToAPIV2Converter(swaggerDescriptor, policyOperationVisitorManager, groupService, tagService).convert((OAIDescriptor) descriptor);
        } else {
            return new OAIToAPIConverter(swaggerDescriptor, policyOperationVisitorManager, groupService, tagService).convert((OAIDescriptor) descriptor);
        }
    }
    throw new SwaggerDescriptorException();
}
Also used : OAIToAPIConverter(io.gravitee.rest.api.service.impl.swagger.converter.api.OAIToAPIConverter) OAIToAPIV2Converter(io.gravitee.rest.api.service.impl.swagger.converter.api.OAIToAPIV2Converter) SwaggerDescriptorException(io.gravitee.rest.api.service.exceptions.SwaggerDescriptorException) SwaggerDescriptor(io.gravitee.rest.api.service.swagger.SwaggerDescriptor) ParseOptions(io.swagger.v3.parser.core.models.ParseOptions)

Aggregations

SwaggerDescriptorException (io.gravitee.rest.api.service.exceptions.SwaggerDescriptorException)1 OAIToAPIConverter (io.gravitee.rest.api.service.impl.swagger.converter.api.OAIToAPIConverter)1 OAIToAPIV2Converter (io.gravitee.rest.api.service.impl.swagger.converter.api.OAIToAPIV2Converter)1 SwaggerDescriptor (io.gravitee.rest.api.service.swagger.SwaggerDescriptor)1 ParseOptions (io.swagger.v3.parser.core.models.ParseOptions)1