diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/OpenAPIV3Parser.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/OpenAPIV3Parser.java index c377e9bd2a..ac3a7f2c41 100644 --- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/OpenAPIV3Parser.java +++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/OpenAPIV3Parser.java @@ -33,10 +33,13 @@ import javax.net.ssl.SSLHandshakeException; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class OpenAPIV3Parser implements SwaggerParserExtension { + + public static final String DISABLE_OAS31_RESOLVE = "disableOas31Resolve"; private static final Logger LOGGER = LoggerFactory.getLogger(OpenAPIV3Parser.class); private static ObjectMapper JSON_MAPPER, YAML_MAPPER; /** @@ -206,28 +209,38 @@ private SwaggerParseResult resolve(SwaggerParseResult result, List dereferencers = DereferencersFactory.getInstance().getDereferencers(); - if (dereferencers.iterator().hasNext()) { - OpenAPIDereferencer dereferencer = dereferencers.iterator().next(); - dereferencer.dereference(dereferencerContext, dereferencers.iterator()); + if (StringUtils.isBlank(System.getenv(DISABLE_OAS31_RESOLVE))) { + DereferencerContext dereferencerContext = new DereferencerContext( + result, + auth, + location, + options, + null, + null, + true + ); + List dereferencers = DereferencersFactory.getInstance().getDereferencers(); + if (dereferencers.iterator().hasNext()) { + OpenAPIDereferencer dereferencer = dereferencers.iterator().next(); + dereferencer.dereference(dereferencerContext, dereferencers.iterator()); + } + if (options.isResolveFully()) { + new ResolverFully(options.isResolveCombinators()).resolveFully(result.getOpenAPI()); + } + } else { + String msg = "Resolution of OAS 3.1 spec disabled by 'disableOas31Resolve' env variable"; + LOGGER.warn(msg); + result.getMessages().add(msg); } } else { OpenAPIResolver resolver = new OpenAPIResolver(result.getOpenAPI(), emptyListIfNull(auth), location, null, options); resolver.resolve(result); + if (options.isResolveFully()) { + new ResolverFully(options.isResolveCombinators()).resolveFully(result.getOpenAPI()); + } } - if (options.isResolveFully()) { - new ResolverFully(options.isResolveCombinators()).resolveFully(result.getOpenAPI()); - } + } if (options.isFlatten()) { final InlineModelResolver inlineModelResolver = diff --git a/pom.xml b/pom.xml index 25ec9ffc87..df591a4e35 100644 --- a/pom.xml +++ b/pom.xml @@ -406,7 +406,7 @@ 1.0.64 2.11.0 1.7.30 - 2.2.8-SNAPSHOT + 2.2.8 1.6.9 4.13.2 6.14.2