Search in sources :

Example 1 with SwaggerParserExtension

use of io.swagger.v3.parser.core.extensions.SwaggerParserExtension in project swagger-parser by swagger-api.

the class OpenAPIV3Parser method read.

public OpenAPI read(String location, List<AuthorizationValue> auths, ParseOptions resolve) {
    if (location == null) {
        return null;
    }
    final List<SwaggerParserExtension> parserExtensions = getExtensions();
    SwaggerParseResult parsed;
    for (SwaggerParserExtension extension : parserExtensions) {
        parsed = extension.readLocation(location, auths, resolve);
        for (String message : parsed.getMessages()) {
            LOGGER.info("{}: {}", extension, message);
        }
        final OpenAPI result = parsed.getOpenAPI();
        if (result != null) {
            return result;
        }
    }
    return null;
}
Also used : SwaggerParserExtension(io.swagger.v3.parser.core.extensions.SwaggerParserExtension) SwaggerParseResult(io.swagger.v3.parser.core.models.SwaggerParseResult) OpenAPI(io.swagger.v3.oas.models.OpenAPI)

Example 2 with SwaggerParserExtension

use of io.swagger.v3.parser.core.extensions.SwaggerParserExtension in project swagger-parser by swagger-api.

the class OpenAPIV3Parser method getExtensions.

protected static List<SwaggerParserExtension> getExtensions(ClassLoader cl) {
    final List<SwaggerParserExtension> extensions = new ArrayList<>();
    final ServiceLoader<SwaggerParserExtension> loader = ServiceLoader.load(SwaggerParserExtension.class, cl);
    for (SwaggerParserExtension extension : loader) {
        extensions.add(extension);
    }
    return extensions;
}
Also used : ArrayList(java.util.ArrayList) SwaggerParserExtension(io.swagger.v3.parser.core.extensions.SwaggerParserExtension)

Aggregations

SwaggerParserExtension (io.swagger.v3.parser.core.extensions.SwaggerParserExtension)2 OpenAPI (io.swagger.v3.oas.models.OpenAPI)1 SwaggerParseResult (io.swagger.v3.parser.core.models.SwaggerParseResult)1 ArrayList (java.util.ArrayList)1