Repository: swagger-api/swagger-parser
Pull request #1380 (2020-05-23 17:23:14)

Improvement for issue #1303 
Includes and replaces #1377 


Patch:
diff --git a/modules/swagger-parser-core/src/main/java/io/swagger/v3/parser/core/models/SwaggerParseResult.java b/modules/swagger-parser-core/src/main/java/io/swagger/v3/parser/core/models/SwaggerParseResult.java
index 6e47f4db..0619758a 100644
--- a/modules/swagger-parser-core/src/main/java/io/swagger/v3/parser/core/models/SwaggerParseResult.java
+++ b/modules/swagger-parser-core/src/main/java/io/swagger/v3/parser/core/models/SwaggerParseResult.java
@@ -1,6 +1,8 @@
 package io.swagger.v3.parser.core.models;
 
 import io.swagger.v3.oas.models.OpenAPI;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 public class SwaggerParseResult {
@@ -27,4 +29,10 @@ public class SwaggerParseResult {
     public void setOpenAPI(OpenAPI openAPI) {
         this.openAPI = openAPI;
     }
+
+    public static SwaggerParseResult ofError(String message){
+        final SwaggerParseResult result = new SwaggerParseResult();
+        result.setMessages(Collections.singletonList(message));
+        return result;
+    }
 }
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 ebeee304..8b063260 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
@@ -1,6 +1,6 @@
 package io.swagger.v3.parser;
 
-import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import io.swagger.v3.oas.models.OpenAPI;
@@ -8,259 +8,240 @@ import io.swagger.v3.parser.core.extensions.SwaggerParserExtension;
 import io.swagger.v3.parser.core.models.AuthorizationValue;
 import io.swagger.v3.parser.core.models.ParseOptions;
 import io.swagger.v3.parser.core.models.SwaggerParseResult;
+import io.swagger.v3.parser.exception.EncodingNotSupportedException;
+import io.swagger.v3.parser.exception.ReadContentException;
 import io.swagger.v3.parser.util.ClasspathHelper;
 import io.swagger.v3.parser.util.InlineModelResolver;
 import io.swagger.v3.parser.util.OpenAPIDeserializer;
 import io.swagger.v3.parser.util.RemoteUrl;
 import io.swagger.v3.parser.util.ResolverFully;
-import org.apache.commons.io.FileUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.net.ssl.SSLHandshakeException;
 import java.net.URI;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
+import java.util.Collections;
 import java.util.List;
+import java.util.Objects;
 import java.util.ServiceLoader;
+import javax.net.ssl.SSLHandshakeException;
+import org.apache.commons.io.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class OpenAPIV3Parser implements SwaggerParserExtension {
-    private static ObjectMapper JSON_MAPPER, YAML_MAPPER;
     private static final Logger LOGGER = LoggerFactory.getLogger(OpenAPIV3Parser.class);
-    private static String encoding = "UTF-8";
+    private static ObjectMapper JSON_MAPPER, YAML_MAPPER;
+    /**
+     * Encoding of the resource content with OpenAPI spec to parse.
+     */
+    private static String encoding = StandardCharsets.UTF_8.displayName();
 
     static {
         JSON_MAPPER = ObjectMapperFactory.createJson();
         YAML_MAPPER = ObjectMapperFactory.createYaml();
     }
 
+    /**
+     * Locates extensions on the current thread class loader and then, if it differs from this class classloader (as in
+     * OSGi), locates extensions from this class classloader as well.
+     * @return a list of extensions
+     */
+    public static List<SwaggerParserExtension> getExtensions() {
+        final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+        final List<SwaggerParserExtension> extensions = getExtensions(tccl);
+        final ClassLoader cl = SwaggerParserExtension.class.getClassLoader();
+        if (cl != tccl) {
+            extensions.addAll(getExtensions(cl));
+        }
+        extensions.add(0, new OpenAPIV3Parser());
+        return extensions;
+    }
+
+    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;
+    }
+
     public static String getEncoding() {
         return encoding;
     }
 
     public static void setEncoding(String encoding) {
-        if (Charset.isSupported(encoding)) {
-            OpenAPIV3Parser.encoding = encoding;
+        if (!Charset.isSupported(encoding)) {
+            throw new EncodingNotSupportedException(encoding);
         }
+        OpenAPIV3Parser.encoding = encoding;
     }
 
     @Override
     public SwaggerParseResult readLocation(String url, List<AuthorizationValue> auth, ParseOptions options) {
-        SwaggerParseResult result = new SwaggerParseResult();
         try {
-            if (auth == null) {
-                auth = new ArrayList<>();
-            }
-            result = readWithInfo(url,auth);
-
-            if (result.getOpenAPI() != null) {
-                String version = result.getOpenAPI().getOpenapi();
-                if (version != null && version.startsWith("3.0")) {
-                    if (options != null) {
-                        OpenAPIResolver resolver = new OpenAPIResolver(result.getOpenAPI(), auth, url);
-                        if (options.isResolve()) {
-                            result.setOpenAPI(resolver.resolve());
-                        }
-                        if (options.isResolveFully()) {
-                            result.setOpenAPI(resolver.resolve());
-                            new ResolverFully(options.isResolveCombinators()).resolveFully(result.getOpenAPI());
-                        } else if (options.isFlatten()) {
-                            InlineModelResolver inlineModelResolver = new InlineModelResolver(options.isFlattenComposedSchemas(), options.isCamelCaseFlattenNaming());
-                            inlineModelResolver.setSkipMatches(options.isSkipMatches());
-                            inlineModelResolver.flatten(result.getOpenAPI());
-                        }
-                    }
-                }
-            }
-
-        }
-
-        catch (Exception e) {
+            final String content = readContentFromLocation(url, emptyListIfNull(auth));
+            LOGGER.debug("Loaded raw data: {}", content);
+            return readContents(content, auth, options, url);
+        } catch (ReadContentException e) {
             LOGGER.warn("Exception while reading:", e);
-            result.setMessages(Arrays.asList(e.getMessage()));
+            return SwaggerParseResult.ofError(e.getMessage());
         }
-        return result;
+    }
+
+    @Override
+    public SwaggerParseResult readContents(String swaggerAsString, List<AuthorizationValue> auth,
+                                           ParseOptions options) {
+        return readContents(swaggerAsString, auth, options, null);
     }
 
     public OpenAPI read(String location) {
-        ParseOptions options = new ParseOptions();
+        final ParseOptions options = new ParseOptions();
         options.setResolve(true);
-        return read(location,  null, options);
+        return read(location, null, options);
     }
+
     public OpenAPI read(String location, List<AuthorizationValue> auths, ParseOptions resolve) {
         if (location == null) {
             return null;
         }
-        location = location.replaceAll("\\\\","/");
-        OpenAPI output;
 
-        List<SwaggerParserExtension> parserExtensions = getExtensions();
+        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);
             }
-            output = parsed.getOpenAPI();
-            if (output != null) {
-                return output;
+            final OpenAPI result = parsed.getOpenAPI();
+            if (result != null) {
+                return result;
             }
         }
         return null;
     }
 
+    @Deprecated
     public SwaggerParseResult readWithInfo(String path, JsonNode node) {
-        OpenAPIDeserializer ser = new OpenAPIDeserializer();
-        return ser.deserialize(node, path);
+        return parseJsonNode(path, node);
     }
 
-    private ObjectMapper getRightMapper(String data) {
-      ObjectMapper mapper;
-      if(data.trim().startsWith("{")) {
-          mapper = JSON_MAPPER;
-      } else {
-          mapper = YAML_MAPPER;
-      }
-      return mapper;
+    public SwaggerParseResult parseJsonNode(String path, JsonNode node) {
+        return new OpenAPIDeserializer().deserialize(node, path);
     }
 
-    public SwaggerParseResult readWithInfo(String location, List<AuthorizationValue> auths) {
-        String data;
+    public SwaggerParseResult readContents(String yaml) {
+        final ParseOptions options = new ParseOptions();
+        options.setResolve(true);
+        return readContents(yaml, null, options);
+    }
 
-        try {
-            location = location.replaceAll("\\\\","/");
-            if (location.toLowerCase().startsWith("http")) {
-                data = RemoteUrl.urlToString(location, auths);
-            } else {
-                final String fileScheme = "file:";
-                Path path;
-                if (location.toLowerCase().startsWith(fileScheme)) {
-                    path = Paths.get(URI.create(location));
-                } else {
-                    path = Paths.get(location);
-                }
-                if (Files.exists(path)) {
-                    data = FileUtils.readFileToString(path.toFile(), encoding);
-                } else {
-                    data = ClasspathHelper.loadFileFromClasspath(location);
-                }
-            }
-            LOGGER.debug("Loaded raw data: {}", data);
-            ObjectMapper mapper = getRightMapper(data);
-            JsonNode rootNode = mapper.readTree(data);
-            LOGGER.debug("Parsed rootNode: {}", rootNode);
-            return readWithInfo(location, rootNode);
-        }
-        catch (SSLHandshakeException e) {
-            SwaggerParseResult output = new SwaggerParseResult();
-            output.setMessages(Arrays.asList("unable to read location `" + location + "` due to a SSL configuration error.  " +
-                    "It is possible that the server SSL certificate is invalid, self-signed, or has an untrusted " +
-                    "Certificate Authority."));
-            return output;
+    private SwaggerParseResult readContents(String swaggerAsString, List<AuthorizationValue> auth, ParseOptions options,
+                                            String location) {
+        if (swaggerAsString == null || swaggerAsString.trim().isEmpty()) {
+            return SwaggerParseResult.ofError("Null or empty definition");
         }
-        catch (JsonParseException e) {
+
+        try {
+            final ObjectMapper mapper = getRightMapper(swaggerAsString);
+            final JsonNode rootNode = mapper.readTree(swaggerAsString);
+            final SwaggerParseResult result = parseJsonNode(location, rootNode);
+            return resolve(result, auth, options, location);
+        } catch (JsonProcessingException e) {
             LOGGER.warn("Exception while parsing:", e);
-            SwaggerParseResult output = new SwaggerParseResult();
-            String message = e.getOriginalMessage();
-            if ((message != null) && (message.startsWith("Duplicate field"))) {
-                output.setMessages(Arrays.asList(message + " in `" + location + "`"));
-            } else {
-                output.setMessages(Arrays.asList("unable to parse `" + location + "`"));
-            }
-            return output;
-        }
-        catch (Exception e) {
-            LOGGER.warn("Exception while reading:", e);
-            SwaggerParseResult output = new SwaggerParseResult();
-            output.setMessages(Arrays.asList("unable to read location `" + location + "`"));
-            return output;
+            final String message = getParseErrorMessage(e.getOriginalMessage(), location);
+            return SwaggerParseResult.ofError(message);
         }
     }
 
-    @Override
-    public SwaggerParseResult readContents(String swaggerAsString, List<AuthorizationValue> auth, ParseOptions options) {
-        SwaggerParseResult result = new SwaggerParseResult();
-        if(swaggerAsString != null && !"".equals(swaggerAsString.trim())) {
-            ObjectMapper mapper = getRightMapper(swaggerAsString);
+    @Deprecated
+    public SwaggerParseResult readWithInfo(String location, List<AuthorizationValue> auths) {
+        return readContents(readContentFromLocation(location, auths), auths, null);
+    }
 
-            if(auth == null) {
-                auth = new ArrayList<>();
-            }
-            try{
-                if(options != null) {
-                    if (options.isResolve()) {
-                        OpenAPIDeserializer deserializer = new OpenAPIDeserializer();
-                        JsonNode rootNode = mapper.readTree(swaggerAsString);
-                        result = deserializer.deserialize(rootNode);
-                        OpenAPIResolver resolver = new OpenAPIResolver(result.getOpenAPI(), auth, null);
-                        result.setOpenAPI(resolver.resolve());
-                    }else{
-                        JsonNode rootNode = mapper.readTree(swaggerAsString);
-                        result = new OpenAPIDeserializer().deserialize(rootNode);
-                    }
+    private SwaggerParseResult resolve(SwaggerParseResult result, List<AuthorizationValue> auth, ParseOptions options,
+            String location) {
+        try {
+            if (options != null) {
+                if (options.isResolve() || options.isResolveFully()) {
+                    result.setOpenAPI(new OpenAPIResolver(result.getOpenAPI(), emptyListIfNull(auth),
+                            location).resolve());
                     if (options.isResolveFully()) {
-                        result.setOpenAPI(new OpenAPIResolver(result.getOpenAPI(), auth, null).resolve());
                         new ResolverFully(options.isResolveCombinators()).resolveFully(result.getOpenAPI());
-                    } else if (options.isFlatten()) {
-                        InlineModelResolver inlineModelResolver = new InlineModelResolver(options.isFlattenComposedSchemas(), options.isCamelCaseFlattenNaming());
-                        inlineModelResolver.setSkipMatches(options.isSkipMatches());
-                        inlineModelResolver.flatten(result.getOpenAPI());
                     }
-                }else{
-                    JsonNode rootNode = mapper.readTree(swaggerAsString);
-                    result = new OpenAPIDeserializer().deserialize(rootNode);
                 }
-            } catch (Exception e) {
-                result.setMessages(Arrays.asList(e.getMessage()));
+                if (options.isFlatten()) {
+                    final InlineModelResolver inlineModelResolver =
+                            new InlineModelResolver(options.isFlattenComposedSchemas(),
+                                    options.isCamelCaseFlattenNaming(), options.isSkipMatches());
+                    inlineModelResolver.flatten(result.getOpenAPI());
+                }
             }
-        }
-        else {
-            result.setMessages(Arrays.asList("No swagger supplied"));
+        } catch (Exception e) {
+            LOGGER.warn("Exception while resolving:", e);
+            result.setMessages(Collections.singletonList(e.getMessage()));
         }
         return result;
     }
 
-    /**
-     * Locates extensions on the current thread class loader and then, if it differs
-     * from this class classloader (as in OSGi), locates extensions from this
-     * class classloader as well.
-     *
-     * @return a list of extensions
-     */
-    public static List<SwaggerParserExtension> getExtensions() {
-        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
-        List<SwaggerParserExtension> extensions = getExtensions(tccl);
-        ClassLoader cl = SwaggerParserExtension.class.getClassLoader();
-        if (cl != tccl) {
-            extensions.addAll(getExtensions(cl));
+    private String getParseErrorMessage(String originalMessage, String location) {
+        if (Objects.isNull(originalMessage)) {
+            return String.format("Unable to parse `%s`", location);
         }
-        extensions.add(0, new OpenAPIV3Parser());
-        return extensions;
+        if (originalMessage.startsWith("Duplicate field")) {
+            return String.format(originalMessage + " in `%s`", location);
+        }
+        return originalMessage;
     }
 
-    protected static List<SwaggerParserExtension> getExtensions(ClassLoader cl) {
-        List<SwaggerParserExtension> extensions = new ArrayList<>();
+    private <T> List<T> emptyListIfNull(List<T> list) {
+        return Objects.isNull(list) ? new ArrayList<>() : list;
+    }
 
-        ServiceLoader<SwaggerParserExtension> loader = ServiceLoader.load(SwaggerParserExtension.class, cl);
-        Iterator<SwaggerParserExtension> itr = loader.iterator();
-        while (itr.hasNext()) {
-            extensions.add(itr.next());
+    private ObjectMapper getRightMapper(String data) {
+        if (data.trim().startsWith("{")) {
+            return JSON_MAPPER;
         }
-        return extensions;
+        return YAML_MAPPER;
     }
 
-   /**
+    private String readContentFromLocation(String location, List<AuthorizationValue> auth) {
+        final String adjustedLocation = location.replaceAll("\\\\", "/");
+        try {
+            if (adjustedLocation.toLowerCase().startsWith("http")) {
+                return RemoteUrl.urlToString(adjustedLocation, auth);
+            } else {
+                final String fileScheme = "file:";
+                final Path path = adjustedLocation.toLowerCase().startsWith(fileScheme) ?
+                        Paths.get(URI.create(adjustedLocation)) : Paths.get(adjustedLocation);
+                if (Files.exists(path)) {
+                    return FileUtils.readFileToString(path.toFile(), encoding);
+                } else {
+                    return ClasspathHelper.loadFileFromClasspath(adjustedLocation);
+                }
+            }
+        } catch (SSLHandshakeException e) {
+            final String message = String.format(
+                    "Unable to read location `%s` due to a SSL configuration error. It is possible that the server SSL certificate is invalid, self-signed, or has an untrusted Certificate Authority.",
+                    adjustedLocation);
+            throw new ReadContentException(message, e);
+        } catch (Exception e) {
+            throw new ReadContentException(String.format("Unable to read location `%s`", adjustedLocation), e);
+        }
+    }
+
+    /**
      * Transform the swagger-model version of AuthorizationValue into a parser-specific one, to avoid
      * dependencies across extensions
      *
      * @param input
      * @return
      */
+    @Deprecated
     protected List<AuthorizationValue> transform(List<AuthorizationValue> input) {
         if(input == null) {
             return null;
@@ -282,9 +263,5 @@ public class OpenAPIV3Parser implements SwaggerParserExtension {
         return output;
     }
 
-    public SwaggerParseResult readContents(String yaml) {
-        ParseOptions options = new ParseOptions();
-        options.setResolve(true);
-        return readContents(yaml,null, options);
-    }
+
 }
diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/exception/EncodingNotSupportedException.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/exception/EncodingNotSupportedException.java
new file mode 100644
index 00000000..0195db06
--- /dev/null
+++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/exception/EncodingNotSupportedException.java
@@ -0,0 +1,9 @@
+package io.swagger.v3.parser.exception;
+
+public class EncodingNotSupportedException extends RuntimeException {
+    private static final long serialVersionUID = 3686905713011188803L;
+
+    public EncodingNotSupportedException(String encoding) {
+        super(String.format("Encoding `%s` is not supported by JRE", encoding));
+    }
+}
diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/exception/ReadContentException.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/exception/ReadContentException.java
new file mode 100644
index 00000000..402e8d43
--- /dev/null
+++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/exception/ReadContentException.java
@@ -0,0 +1,12 @@
+package io.swagger.v3.parser.exception;
+
+/**
+ * Happens when it's unable to read content from file or other resource
+ */
+public class ReadContentException extends RuntimeException {
+    private static final long serialVersionUID = 4720926576862628428L;
+
+    public ReadContentException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}
diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/InlineModelResolver.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/InlineModelResolver.java
index 3f18d9d0..2669c23d 100644
--- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/InlineModelResolver.java
+++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/InlineModelResolver.java
@@ -26,20 +26,25 @@ import java.util.Map;
 
 public class InlineModelResolver {
     private OpenAPI openAPI;
-    private boolean skipMatches;
     static Logger LOGGER = LoggerFactory.getLogger(InlineModelResolver.class);
 
     Map<String, Schema> addedModels = new HashMap<>();
     Map<String, String> generatedSignature = new HashMap<>();
 
-    private boolean flattenComposedSchemas;
-    private boolean camelCaseFlattenNaming;
+    private final boolean flattenComposedSchemas;
+    private final boolean camelCaseFlattenNaming;
+    private boolean skipMatches;
 
-    public InlineModelResolver(){this(false,false);}
+    public InlineModelResolver(){this(false, false, false);}
 
     public InlineModelResolver(boolean flattenComposedSchemas, boolean camelCaseFlattenNaming) {
+        this(flattenComposedSchemas, camelCaseFlattenNaming, false);
+    }
+
+    public InlineModelResolver(boolean flattenComposedSchemas, boolean camelCaseFlattenNaming, boolean skipMatches) {
         this.flattenComposedSchemas = flattenComposedSchemas;
         this.camelCaseFlattenNaming = camelCaseFlattenNaming;
+        this.skipMatches = skipMatches;
     }
 
     public void flatten(OpenAPI openAPI) {
@@ -319,7 +324,7 @@ public class InlineModelResolver {
     }
 
     public String matchGenerated(Schema model) {
-        if (this.skipMatches) {
+        if (skipMatches) {
             return null;
         }
         String json = Json.pretty(model);
@@ -585,6 +590,12 @@ public class InlineModelResolver {
         }
     }
 
+    private boolean isObjectSchema(Schema schema) {
+        return schema instanceof ObjectSchema
+                || "object".equalsIgnoreCase(schema.getType())
+                || (schema.getType() == null && schema.getProperties() != null && !schema.getProperties().isEmpty());
+    }
+
     public boolean isSkipMatches() {
         return skipMatches;
     }
@@ -592,10 +603,4 @@ public class InlineModelResolver {
     public void setSkipMatches(boolean skipMatches) {
         this.skipMatches = skipMatches;
     }
-
-    private boolean isObjectSchema(Schema schema) {
-        return schema instanceof ObjectSchema
-                || "object".equalsIgnoreCase(schema.getType())
-                || (schema.getType() == null && schema.getProperties() != null && !schema.getProperties().isEmpty());
-    }
 }


Test patch:
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
index 6d593127..fb2994f9 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java
@@ -1924,7 +1924,7 @@ public class OpenAPIV3ParserTest {
         String yaml = Files.readFile(new File("src/test/resources/over-quoted-example.yaml"));
         JsonNode rootNode = Yaml.mapper().readValue(yaml, JsonNode.class);
         OpenAPIV3Parser parser = new OpenAPIV3Parser();
-        OpenAPI openAPI = (parser.readWithInfo(null, rootNode)).getOpenAPI();
+        OpenAPI openAPI = (parser.parseJsonNode(null, rootNode)).getOpenAPI();
 
         Map<String, Schema> definitions = openAPI.getComponents().getSchemas();
         assertEquals("NoQuotePlease", definitions.get("CustomerType").getExample());
diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/InlineModelResolverTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/InlineModelResolverTest.java
index df8d69e3..b4ad9d70 100644
--- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/InlineModelResolverTest.java
+++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/InlineModelResolverTest.java
@@ -432,7 +432,6 @@ public class InlineModelResolverTest {
         final OpenAPI openAPI = new OpenAPI();
 
         final InlineModelResolver inlineModelResolver = new InlineModelResolver();
-        inlineModelResolver.setSkipMatches(false);
 
         final Schema operationAlphaInAsset = new ObjectSchema();
         operationAlphaInAsset.setTitle("operationAlphaInAsset");
@@ -484,8 +483,7 @@ public class InlineModelResolverTest {
     public void testSkipInlineMatchesTrue() {
         final OpenAPI openAPI = new OpenAPI();
 
-        final InlineModelResolver inlineModelResolver = new InlineModelResolver();
-        inlineModelResolver.setSkipMatches(true);
+        final InlineModelResolver inlineModelResolver = new InlineModelResolver(false, false, true);
 
         final Schema operationAlphaInAsset = new ObjectSchema();
         operationAlphaInAsset.setTitle("operationAlphaInAsset");