Repository: swagger-api/swagger-parser
Pull request #847 (2018-09-26 05:49:34)

Fix for issue 844
Hi team,

This PR is to solve the issue #844 (parser not honoring redirect responses in swagger 2.0)

Please review the PR and merge the same.

Thanks,
Mohammed


Patch:
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 00000000..48f647e0
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,13 @@
+sudo: false
+language: java
+script: mvn verify
+jdk:
+  - openjdk7
+after_success:
+  - if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ $TRAVIS_PULL_REQUEST == false ]; then
+      mvn clean deploy --settings .travis/settings.xml;
+    fi;
+branches:
+  only:
+  - master
+  - 2.0
diff --git a/.travis/settings.xml b/.travis/settings.xml
new file mode 100644
index 00000000..a0855c34
--- /dev/null
+++ b/.travis/settings.xml
@@ -0,0 +1,18 @@
+<settings>
+    <localRepository/>
+    <interactiveMode/>
+    <usePluginRegistry/>
+    <offline/>
+    <pluginGroups/>
+    <servers>
+        <server>
+            <id>sonatype-nexus-snapshots</id>
+            <username>${env.SONATYPE_USERNAME}</username>
+            <password>${env.SONATYPE_PASSWORD}</password>
+        </server>
+    </servers>
+    <mirrors/>
+    <proxies/>
+    <profiles/>
+    <activeProfiles/>
+</settings>
\ No newline at end of file
diff --git a/README.md b/README.md
index baac6c6c..4494c105 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,10 @@
 # Swagger Parser
 
-[![Build Status](https://img.shields.io/jenkins/s/https/jenkins.swagger.io/view/OSS%20-%20Java/job/oss-swagger-parser-master.svg)](https://jenkins.swagger.io/view/OSS%20-%20Java/job/oss-swagger-parser-master)
+[![Build Status](https://travis-ci.org/swagger-api/swagger-parser.svg)](https://travis-ci.org/swagger-api/swagger-parser)
 [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-parser/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-parser)
-[![PR Stats](https://img.shields.io/github/issues-pr/swagger-api/swagger-parser.svg)](https://github.com/swagger-api/swagger-parser/pulls)
-[![Issue Stats](https://img.shields.io/github/issues/swagger-api/swagger-parser.svg)](https://github.com/swagger-api/swagger-parser/issues)
+[![Windows Test](https://ci.appveyor.com/api/projects/status/github/swagger-api/swagger-parser?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/swagger-codegen-wh2wu)
+[![PR Stats](http://issuestats.com/github/swagger-api/swagger-parser/badge/pr)](http://issuestats.com/github/swagger-api/swagger-parser) [![Issue Stats](http://issuestats.com/github/swagger-api/swagger-parser/badge/issue)](http://issuestats.com/github/swagger-api/swagger-parser)
+
 
 ## Overview 
 This is the swagger parser project, which reads OpenAPI Specifications into current Java POJOs.  It also provides a simple framework to add additional converters from different formats into the Swagger objects, making the entire toolchain available.
@@ -115,7 +116,7 @@ You can include this library from Sonatype OSS for SNAPSHOTS, or Maven central f
 <dependency>
   <groupId>io.swagger</groupId>
   <artifactId>swagger-parser</artifactId>
-  <version>1.0.39-SNAPSHOT</version>
+  <version>1.0.37-SNAPSHOT</version>
 </dependency>
 
 ```
@@ -125,7 +126,7 @@ To add swagger parsing support for older versions of swagger, add the `compat` m
 <dependency>
   <groupId>io.swagger</groupId>
   <artifactId>swagger-compat-spec-parser</artifactId>
-  <version>1.0.39-SNAPSHOT</version>
+  <version>1.0.37-SNAPSHOT</version>
 </dependency>
 
 ```
diff --git a/modules/swagger-compat-spec-parser/pom.xml b/modules/swagger-compat-spec-parser/pom.xml
index e21f24f2..a59f10fa 100644
--- a/modules/swagger-compat-spec-parser/pom.xml
+++ b/modules/swagger-compat-spec-parser/pom.xml
@@ -4,7 +4,7 @@
     <parent>
         <groupId>io.swagger</groupId>
         <artifactId>swagger-parser-project</artifactId>
-        <version>1.0.39-SNAPSHOT</version>
+        <version>1.0.37-SNAPSHOT</version>
         <relativePath>../..</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>
diff --git a/modules/swagger-compat-spec-parser/src/main/java/io/swagger/parser/SwaggerCompatConverter.java b/modules/swagger-compat-spec-parser/src/main/java/io/swagger/parser/SwaggerCompatConverter.java
index ac28712d..36b2dbb4 100644
--- a/modules/swagger-compat-spec-parser/src/main/java/io/swagger/parser/SwaggerCompatConverter.java
+++ b/modules/swagger-compat-spec-parser/src/main/java/io/swagger/parser/SwaggerCompatConverter.java
@@ -44,7 +44,6 @@ import io.swagger.models.properties.PropertyBuilder;
 import io.swagger.models.properties.RefProperty;
 import io.swagger.models.properties.StringProperty;
 import io.swagger.models.properties.UntypedProperty;
-import io.swagger.models.refs.RefFormat;
 import io.swagger.models.resourcelisting.ApiInfo;
 import io.swagger.models.resourcelisting.ApiKeyAuthorization;
 import io.swagger.models.resourcelisting.ApiListingReference;
@@ -347,9 +346,9 @@ public class SwaggerCompatConverter implements SwaggerParserExtension {
                     am.setItems(innerType);
                 }
                 if (items.getRef() != null) {
-                    am.setItems(new RefProperty(items.getRef(),RefFormat.INTERNAL));
+                    am.setItems(new RefProperty(items.getRef()));
                 } else {
-                    am.setItems(new RefProperty(type,RefFormat.INTERNAL));
+                    am.setItems(new RefProperty(type));
                 }
                 output = am;
             } else {
@@ -395,9 +394,9 @@ public class SwaggerCompatConverter implements SwaggerParserExtension {
             if (innerType != null && !(innerType instanceof UntypedProperty)) {
                 am.setItems(innerType);
             } else if (items.getRef() != null) {
-                am.setItems(new RefProperty(items.getRef(),RefFormat.INTERNAL));
+                am.setItems(new RefProperty(items.getRef()));
             } else {
-                am.setItems(new RefProperty(type,RefFormat.INTERNAL));
+                am.setItems(new RefProperty(type));
             }
             output = am;
         } else {
@@ -417,9 +416,9 @@ public class SwaggerCompatConverter implements SwaggerParserExtension {
                 output = i;
             } else {
                 if (obj.getRef() != null) {
-                    output = new RefProperty(obj.getRef(),RefFormat.INTERNAL);
+                    output = new RefProperty(obj.getRef());
                 } else if (type != null && !type.equals("void")) {
-                    output = new RefProperty(type,RefFormat.INTERNAL);
+                    output = new RefProperty(type);
                 }
             }
         }
@@ -474,16 +473,16 @@ public class SwaggerCompatConverter implements SwaggerParserExtension {
 
             Model responseModel = null;
             if (message.getResponseModel() != null) {
-                response.setResponseSchema(new RefModel().asDefault(message.getResponseModel()));
+                response.schema(new RefProperty(message.getResponseModel()));
             }
             output.response(message.getCode(), response);
         }
 
         // default response type
-        Model responseProperty = modelFromExtendedTypedObject(operation);
+        Property responseProperty = propertyFromTypedObject(operation);
         Response response = new Response()
                 .description("success")
-                .responseSchema(responseProperty);
+                .schema(responseProperty);
         if (output.getResponses() == null) {
             output.defaultResponse(response);
         } else if (responseProperty != null) {
diff --git a/modules/swagger-parser/pom.xml b/modules/swagger-parser/pom.xml
index 0918e9dd..993f6083 100644
--- a/modules/swagger-parser/pom.xml
+++ b/modules/swagger-parser/pom.xml
@@ -4,7 +4,7 @@
     <parent>
         <groupId>io.swagger</groupId>
         <artifactId>swagger-parser-project</artifactId>
-        <version>1.0.39-SNAPSHOT</version>
+        <version>1.0.37-SNAPSHOT</version>
         <relativePath>../..</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>
diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/ResolverCache.java b/modules/swagger-parser/src/main/java/io/swagger/parser/ResolverCache.java
index fc4dab93..f5a7faea 100644
--- a/modules/swagger-parser/src/main/java/io/swagger/parser/ResolverCache.java
+++ b/modules/swagger-parser/src/main/java/io/swagger/parser/ResolverCache.java
@@ -19,8 +19,6 @@ import io.swagger.parser.util.SwaggerDeserializer;
 import org.apache.commons.lang3.StringUtils;
 
 import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
 import java.nio.file.Path;
 import java.util.Collections;
 import java.util.HashMap;
@@ -49,7 +47,6 @@ public class ResolverCache {
     private final Swagger swagger;
     private final List<AuthorizationValue> auths;
     private final Path parentDirectory;
-    private final String parentUrl;
     private final String rootPath;
     private Map<String, Object> resolutionCache = new HashMap<>();
     private Map<String, String> externalFileCache = new HashMap<>();
@@ -75,7 +72,6 @@ public class ResolverCache {
             File file = new File(".");
             parentDirectory = file.toPath();
         }
-        parentUrl = parentFileLocation;
 
     }
 
@@ -216,12 +212,6 @@ public class ResolverCache {
     }
 
     private String unescapePointer(String jsonPathElement) {
-        // URL decode the fragment
-        try {
-            jsonPathElement = URLDecoder.decode(jsonPathElement, "UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            //
-        }
         // Unescape the JSON Pointer segment using the algorithm described in RFC 6901, section 4:
         // https://tools.ietf.org/html/rfc6901#section-4
         // First transform any occurrence of the sequence '~1' to '/'
diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/SwaggerParser.java b/modules/swagger-parser/src/main/java/io/swagger/parser/SwaggerParser.java
index 5041c0cf..45ae3be2 100644
--- a/modules/swagger-parser/src/main/java/io/swagger/parser/SwaggerParser.java
+++ b/modules/swagger-parser/src/main/java/io/swagger/parser/SwaggerParser.java
@@ -95,7 +95,7 @@ public class SwaggerParser {
     }
 
     public SwaggerDeserializationResult readWithInfo(String swaggerAsString, boolean resolve) {
-        if (swaggerAsString == null || swaggerAsString.trim().isEmpty()) {
+        if (swaggerAsString == null) {
             return new SwaggerDeserializationResult().message("empty or null swagger supplied");
         }
         try {
diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ExternalRefProcessor.java b/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ExternalRefProcessor.java
index 8d91d897..a1ff6a7b 100644
--- a/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ExternalRefProcessor.java
+++ b/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ExternalRefProcessor.java
@@ -7,7 +7,6 @@ import io.swagger.models.properties.Property;
 import io.swagger.models.properties.RefProperty;
 import io.swagger.models.refs.RefFormat;
 import io.swagger.parser.ResolverCache;
-import io.swagger.parser.util.RefUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.LoggerFactory;
 
@@ -108,10 +107,7 @@ public final class ExternalRefProcessor {
                         if (isAnExternalRefFormat(refModel.getRefFormat())) {
                             String joinedRef = join(file, refModel.get$ref());
                             refModel.set$ref(processRefToExternalDefinition(joinedRef, refModel.getRefFormat()));
-                        }/*else if (isAnExternalRefFormat(refModel.getOriginalRefFormat())) {
-                            String joinedRef = join(file, refModel.getOriginalRef());
-                            refModel.set$ref(processRefToExternalDefinition(joinedRef, refModel.getOriginalRefFormat()));
-                        }*/else {
+                        } else {
                             processRefToExternalDefinition(file + refModel.get$ref(), RefFormat.RELATIVE);
                         }
                     } else if (allOfModel instanceof ModelImpl) {
@@ -154,58 +150,6 @@ public final class ExternalRefProcessor {
         return newRef;
     }
 
-
-    public String processRefToExternalResponse(String $ref, RefFormat refFormat) {
-
-        String renamedRef = cache.getRenamedRef($ref);
-        if(renamedRef != null) {
-            return renamedRef;
-        }
-        final Response response = cache.loadRef($ref, refFormat, Response.class);
-
-        String newRef;
-
-
-        Map<String, Response> responses = swagger.getResponses();
-
-        if (responses == null) {
-            responses = new LinkedHashMap<>();
-        }
-
-        final String possiblyConflictingDefinitionName = computeDefinitionName($ref);
-
-        Response existingResponse = responses.get(possiblyConflictingDefinitionName);
-
-        if (existingResponse != null) {
-            LOGGER.debug("A model for " + existingResponse + " already exists");
-            if(existingResponse instanceof RefResponse) {
-                // use the new model
-                existingResponse = null;
-            }
-        }
-        newRef = possiblyConflictingDefinitionName;
-        cache.putRenamedRef($ref, newRef);
-
-        if(response != null) {
-
-            String file = $ref.split("#/")[0];
-
-            Model model = null;
-            if (response.getResponseSchema() != null) {
-                model = response.getResponseSchema();
-                if (model instanceof RefModel) {
-                    RefModel refModel = (RefModel) model;
-                    if (RefUtils.isAnExternalRefFormat(refFormat)) {
-                        processRefModel(refModel, $ref);
-                    } else {
-                        processRefToExternalDefinition(file + refModel.get$ref(), RefFormat.RELATIVE);
-                    }
-                }
-            }
-        }
-        return newRef;
-    }
-
     private void processProperties(final Map<String, Property> subProps, final String file) {
         if (subProps == null || 0 == subProps.entrySet().size() ) {
             return;
@@ -240,16 +184,6 @@ public final class ExternalRefProcessor {
             processRefToExternalDefinition(externalFile + subRef.get$ref(), RefFormat.RELATIVE);
         }
     }
-
-    private void processRefModel(RefModel subRef, String externalFile) {
-
-        if (isAnExternalRefFormat(subRef.getRefFormat())) {
-            String joinedRef = join(externalFile, subRef.get$ref());
-            subRef.set$ref(processRefToExternalDefinition(joinedRef, subRef.getRefFormat()));
-        } else {
-            processRefToExternalDefinition(externalFile + subRef.get$ref(), RefFormat.RELATIVE);
-        }
-    }
     
 
     public static String join(String source, String fragment) {
diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ModelProcessor.java b/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ModelProcessor.java
index 2bcca672..cda0864f 100644
--- a/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ModelProcessor.java
+++ b/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ModelProcessor.java
@@ -87,21 +87,15 @@ public class ModelProcessor {
         2) shove it into the #/definitions
         3) update the RefModel to point to its location in #/definitions
      */
-        String newRef = null;
 
         if (isAnExternalRefFormat(refModel.getRefFormat())) {
+            final String newRef = externalRefProcessor.processRefToExternalDefinition(refModel.get$ref(), refModel.getRefFormat());
 
-            newRef    = externalRefProcessor.processRefToExternalDefinition(refModel.get$ref(), refModel.getRefFormat());
-
-        }
-
-        if (newRef != null) {
-            refModel.set$ref(newRef);
+            if (newRef != null) {
+                refModel.set$ref(newRef);
+            }
         }
-
     }
 
 
-
-
 }
diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/processors/OperationProcessor.java b/modules/swagger-parser/src/main/java/io/swagger/parser/processors/OperationProcessor.java
index 073afdbd..1272fe45 100644
--- a/modules/swagger-parser/src/main/java/io/swagger/parser/processors/OperationProcessor.java
+++ b/modules/swagger-parser/src/main/java/io/swagger/parser/processors/OperationProcessor.java
@@ -35,8 +35,6 @@ public class OperationProcessor {
                 if(response != null) {
                     if (response instanceof RefResponse) {
                         RefResponse refResponse = (RefResponse) response;
-                        responseProcessor.processResponse(response);
-
                         Response resolvedResponse = cache.loadRef(refResponse.get$ref(), refResponse.getRefFormat(), Response.class);
 
                         if (resolvedResponse != null) {
diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ParameterProcessor.java b/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ParameterProcessor.java
index 7bfe97f9..a8f2d23d 100644
--- a/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ParameterProcessor.java
+++ b/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ParameterProcessor.java
@@ -34,7 +34,7 @@ public class ParameterProcessor {
         for (Parameter parameter : parameters) {
             if (parameter instanceof RefParameter) {
                 RefParameter refParameter = (RefParameter) parameter;
-                 Parameter resolvedParameter = cache.loadRef(refParameter.get$ref(), refParameter.getRefFormat(), Parameter.class);
+                final Parameter resolvedParameter = cache.loadRef(refParameter.get$ref(), refParameter.getRefFormat(), Parameter.class);
 
                 if(resolvedParameter == null) {
                     // can't resolve it!
diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/processors/PathsProcessor.java b/modules/swagger-parser/src/main/java/io/swagger/parser/processors/PathsProcessor.java
index 6e37fe8f..b966367d 100644
--- a/modules/swagger-parser/src/main/java/io/swagger/parser/processors/PathsProcessor.java
+++ b/modules/swagger-parser/src/main/java/io/swagger/parser/processors/PathsProcessor.java
@@ -81,10 +81,9 @@ public class PathsProcessor {
                 // TODO: update references to the parent location
 
                 String pathRef = refPath.get$ref().split("#")[0];
-
+                updateLocalRefs(resolvedPath, pathRef);
 
                 if (resolvedPath != null) {
-                    updateLocalRefs(resolvedPath, pathRef);
                     //we need to put the resolved path into swagger object
                     swagger.path(pathStr, resolvedPath);
                     path = resolvedPath;
@@ -146,9 +145,7 @@ public class PathsProcessor {
             RefModel refModel = (RefModel) model;
             if(isLocalRef(refModel.get$ref())) {
                 refModel.set$ref(computeLocalRef(refModel.get$ref(), pathRef));
-            }/*else if(isLocalRef(refModel.getOriginalRef())) {
-                    refModel.set$ref(computeLocalRef(refModel.getOriginalRef(), pathRef));
-            }*/
+            }
         }
         else if(model instanceof ModelImpl) {
             // process properties
@@ -178,9 +175,7 @@ public class PathsProcessor {
             RefProperty ref = (RefProperty) property;
             if(isLocalRef(ref.get$ref())) {
                 ref.set$ref(computeLocalRef(ref.get$ref(), pathRef));
-            }/*else if(isLocalRef(ref.getOriginalRef())) {
-                ref.set$ref(computeLocalRef(ref.getOriginalRef(), pathRef));
-            }*/
+            }
         }
     }
 
diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ResponseProcessor.java b/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ResponseProcessor.java
index b4dde6f6..c117f976 100644
--- a/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ResponseProcessor.java
+++ b/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ResponseProcessor.java
@@ -1,22 +1,17 @@
 package io.swagger.parser.processors;
 
 import io.swagger.models.Model;
-import io.swagger.models.RefResponse;
 import io.swagger.models.Response;
 import io.swagger.models.Swagger;
 import io.swagger.models.properties.Property;
-import io.swagger.models.refs.RefFormat;
 import io.swagger.parser.ResolverCache;
-import io.swagger.parser.util.RefUtils;
 
 public class ResponseProcessor {
 
     private final ModelProcessor modelProcessor;
-    private final ExternalRefProcessor externalRefProcessor;
 
     public ResponseProcessor(ResolverCache cache, Swagger swagger) {
         modelProcessor = new ModelProcessor(cache, swagger);
-        externalRefProcessor = new ExternalRefProcessor(cache, swagger);
 
     }
 
@@ -24,12 +19,6 @@ public class ResponseProcessor {
         //process the response body
         final Model schema = response.getResponseSchema();
 
-        if (response instanceof RefResponse) {
-            RefResponse refResponse = (RefResponse) response;
-            processReferenceResponse(refResponse);
-        }
-
-
         if (schema != null) {
             modelProcessor.processModel(schema);
         }
@@ -40,12 +29,4 @@ public class ResponseProcessor {
           */
 
     }
-
-    public void processReferenceResponse(RefResponse refResponse){
-        RefFormat refFormat = refResponse.getRefFormat();
-        String $ref = refResponse.get$ref();
-        if (RefUtils.isAnExternalRefFormat(refFormat)){
-            externalRefProcessor.processRefToExternalResponse($ref, refFormat);
-        }
-    }
 }
diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/util/DeserializationUtils.java b/modules/swagger-parser/src/main/java/io/swagger/parser/util/DeserializationUtils.java
index dd665edb..c1dc478b 100644
--- a/modules/swagger-parser/src/main/java/io/swagger/parser/util/DeserializationUtils.java
+++ b/modules/swagger-parser/src/main/java/io/swagger/parser/util/DeserializationUtils.java
@@ -1,12 +1,8 @@
 package io.swagger.parser.util;
 
 import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import io.swagger.models.Swagger;
 import io.swagger.util.Json;
 import io.swagger.util.Yaml;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import org.yaml.snakeyaml.constructor.SafeConstructor;
 
 import java.io.IOException;
diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/util/PathUtils.java b/modules/swagger-parser/src/main/java/io/swagger/parser/util/PathUtils.java
index 2d87033d..40b7ef4c 100644
--- a/modules/swagger-parser/src/main/java/io/swagger/parser/util/PathUtils.java
+++ b/modules/swagger-parser/src/main/java/io/swagger/parser/util/PathUtils.java
@@ -1,35 +1,21 @@
 package io.swagger.parser.util;
 
 import java.net.URI;
-import java.net.URL;
-import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
 public class PathUtils {
 
-    public static Path getParentDirectoryOfFile(String location) {
-        Path file = null;
-        try {
-            location = location.replaceAll("\\\\","/");
-            final String fileScheme = "file:";
-            if (location.toLowerCase().startsWith(fileScheme)) {
-                file = Paths.get(URI.create(location)).toAbsolutePath();
-            } else {
-                file = Paths.get(location).toAbsolutePath();
-            }
-            if (!Files.exists(file)) {
-                URL url = PathUtils.class.getClassLoader().getResource(location);
-                file = Paths.get((URI.create(url.toExternalForm())));
-                return file.getParent();
-            }
 
-
-
-        } catch (Exception e) {
-            e.getMessage();
+    public static Path getParentDirectoryOfFile(String fileStr) {
+        final String fileScheme = "file:";
+        Path file;
+        fileStr = fileStr.replaceAll("\\\\","/");
+        if (fileStr.toLowerCase().startsWith(fileScheme)) {
+            file = Paths.get(URI.create(fileStr)).toAbsolutePath();
+        } else {
+            file = Paths.get(fileStr).toAbsolutePath();
         }
-
         return file.toAbsolutePath().getParent();
     }
 }
diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/util/RefUtils.java b/modules/swagger-parser/src/main/java/io/swagger/parser/util/RefUtils.java
index 42f9dd01..4c32695e 100644
--- a/modules/swagger-parser/src/main/java/io/swagger/parser/util/RefUtils.java
+++ b/modules/swagger-parser/src/main/java/io/swagger/parser/util/RefUtils.java
@@ -5,14 +5,9 @@ import io.swagger.models.refs.RefFormat;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 
-import java.io.File;
 import java.io.FileInputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.file.FileSystem;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.List;
 import java.util.Set;
 
@@ -119,8 +114,6 @@ public class RefUtils {
         return StringUtils.join(outputParts, "/");
     }
 
-
-
     public static String readExternalRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
                                          Path parentDirectory) {
 
@@ -128,7 +121,7 @@ public class RefUtils {
             throw new RuntimeException("Ref is not external");
         }
 
-        String result = null;
+        String result;
 
         try {
             if (refFormat == RefFormat.URL) {
@@ -140,23 +133,9 @@ public class RefUtils {
                 if(Files.exists(pathToUse)) {
                     result = IOUtils.toString(new FileInputStream(pathToUse.toFile()), "UTF-8");
                 } else {
-                    String url = file;
-                    if(url.contains("..")) {
-                        url = parentDirectory + url.substring(url.indexOf(".") + 2);
-                    }else{
-                        url = parentDirectory + url.substring(url.indexOf(".") + 1);
-                    }
-                    final Path pathToUse2 = parentDirectory.resolve(url).normalize();
-
-                    if(Files.exists(pathToUse2)) {
-                        result = IOUtils.toString(new FileInputStream(pathToUse2.toFile()), "UTF-8");
-                    }
-                }
-                if (result == null){
                     result = ClasspathHelper.loadFileFromClasspath(file);
                 }
 
-
             }
         } catch (Exception e) {
             throw new RuntimeException("Unable to load " + refFormat + " ref: " + file + " path: "+parentDirectory, e);
diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/util/RemoteUrl.java b/modules/swagger-parser/src/main/java/io/swagger/parser/util/RemoteUrl.java
index 6835b7c9..05256d0e 100644
--- a/modules/swagger-parser/src/main/java/io/swagger/parser/util/RemoteUrl.java
+++ b/modules/swagger-parser/src/main/java/io/swagger/parser/util/RemoteUrl.java
@@ -8,10 +8,7 @@ import javax.net.ssl.*;
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.net.URI;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLEncoder;
+import java.net.*;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.security.KeyManagementException;
@@ -95,42 +92,47 @@ public class RemoteUrl {
         BufferedReader br = null;
 
         try {
-            final URL inUrl = new URL(cleanUrl(url));
-            final List<AuthorizationValue> query = new ArrayList<>();
-            final List<AuthorizationValue> header = new ArrayList<>();
-            if (auths != null) {
-                for (AuthorizationValue auth : auths) {
-                    if ("query".equals(auth.getType())) {
-                        appendValue(inUrl, auth, query);
-                    } else if ("header".equals(auth.getType())) {
-                        appendValue(inUrl, auth, header);
+            URLConnection conn;
+            do {
+                final URL inUrl = new URL(cleanUrl(url));
+                final List<AuthorizationValue> query = new ArrayList<>();
+                final List<AuthorizationValue> header = new ArrayList<>();
+                if (auths != null) {
+                    for (AuthorizationValue auth : auths) {
+                        if ("query".equals(auth.getType())) {
+                            appendValue(inUrl, auth, query);
+                        } else if ("header".equals(auth.getType())) {
+                            appendValue(inUrl, auth, header);
+                        }
                     }
                 }
-            }
-            final URLConnection conn;
-            if (!query.isEmpty()) {
-                final URI inUri = inUrl.toURI();
-                final StringBuilder newQuery = new StringBuilder(inUri.getQuery() == null ? "" : inUri.getQuery());
-                for (AuthorizationValue item : query) {
-                    if (newQuery.length() > 0) {
-                        newQuery.append("&");
+                if (!query.isEmpty()) {
+                    final URI inUri = inUrl.toURI();
+                    final StringBuilder newQuery = new StringBuilder(inUri.getQuery() == null ? "" : inUri.getQuery());
+                    for (AuthorizationValue item : query) {
+                        if (newQuery.length() > 0) {
+                            newQuery.append("&");
+                        }
+                        newQuery.append(URLEncoder.encode(item.getKeyName(), UTF_8.name())).append("=")
+                                .append(URLEncoder.encode(item.getValue(), UTF_8.name()));
                     }
-                    newQuery.append(URLEncoder.encode(item.getKeyName(), UTF_8.name())).append("=")
-                            .append(URLEncoder.encode(item.getValue(), UTF_8.name()));
+                    conn = new URI(inUri.getScheme(), inUri.getAuthority(), inUri.getPath(), newQuery.toString(),
+                            inUri.getFragment()).toURL().openConnection();
+                } else {
+                    conn = inUrl.openConnection();
                 }
-                conn = new URI(inUri.getScheme(), inUri.getAuthority(), inUri.getPath(), newQuery.toString(),
-                        inUri.getFragment()).toURL().openConnection();
-            } else {
-                conn = inUrl.openConnection();
-            }
-            CONNECTION_CONFIGURATOR.process(conn);
-            for (AuthorizationValue item : header) {
-                conn.setRequestProperty(item.getKeyName(), item.getValue());
-            }
+                CONNECTION_CONFIGURATOR.process(conn);
+                for (AuthorizationValue item : header) {
+                    conn.setRequestProperty(item.getKeyName(), item.getValue());
+                }
+
+                conn.setRequestProperty("Accept", ACCEPT_HEADER_VALUE);
+                conn.setRequestProperty("User-Agent", USER_AGENT_HEADER_VALUE);
+
+                conn.connect();
+                url = ((HttpURLConnection) conn).getHeaderField("Location");
+            } while (301 == ((HttpURLConnection) conn).getResponseCode());
 
-            conn.setRequestProperty("Accept", ACCEPT_HEADER_VALUE);
-            conn.setRequestProperty("User-Agent", USER_AGENT_HEADER_VALUE);
-            conn.connect();
             InputStream in = conn.getInputStream();
 
             StringBuilder contents = new StringBuilder();
diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/util/SwaggerDeserializer.java b/modules/swagger-parser/src/main/java/io/swagger/parser/util/SwaggerDeserializer.java
index 8c36b3dc..03d656bd 100644
--- a/modules/swagger-parser/src/main/java/io/swagger/parser/util/SwaggerDeserializer.java
+++ b/modules/swagger-parser/src/main/java/io/swagger/parser/util/SwaggerDeserializer.java
@@ -199,7 +199,6 @@ public class SwaggerDeserializer {
         if(obj.get("$ref") != null) {
             JsonNode ref = obj.get("$ref");
             if(ref.getNodeType().equals(JsonNodeType.STRING)) {
-
                 return pathRef((TextNode)ref, location, result);
             }
 
@@ -426,6 +425,21 @@ public class SwaggerDeserializer {
         return output;
     }
 
+    // Refs may need to be massaged slightly to ensure that swagger-core (specifically GenericRef) recognizes
+    // relative refs properly.  This should be done anywhere refs could appear (properties, parameters, schema, etc),
+    // so we have this function to ensure it is done consistently (and hopefully correctly) for all these occurrences.
+    //
+    // Returns a new ref string is change is needed, else returns null
+    public String mungedRef(String refString) {
+        // Ref: IETF RFC 3966, Section 5.2.2
+        if (!refString.contains(":") &&   // No scheme
+                !refString.startsWith("#") && // Path is not empty
+                !refString.startsWith("/") && // Path is not absolute
+                 refString.indexOf(".") > 0) { // Path does not start with dot but contains "." (file extension)
+            return "./" + refString;
+        }
+        return null;
+    }
 
     public Parameter parameter(ObjectNode obj, String location, ParseResult result) {
         if(obj == null) {
@@ -436,6 +450,12 @@ public class SwaggerDeserializer {
         JsonNode ref = obj.get("$ref");
         if(ref != null) {
             if(ref.getNodeType().equals(JsonNodeType.STRING)) {
+                // work-around for https://github.com/swagger-api/swagger-core/issues/2138
+                String mungedRef = mungedRef(ref.textValue());
+                if (mungedRef != null) {
+                    obj.put("$ref", mungedRef);
+                    ref = obj.get("$ref");
+                }
                 return refParameter((TextNode) ref, location, result);
             }
             else {
@@ -671,7 +691,6 @@ public class SwaggerDeserializer {
 
     public Path pathRef(TextNode ref, String location, ParseResult result) {
         RefPath output = new RefPath();
-
         output.set$ref(ref.textValue());
         return output;
     }
@@ -1004,6 +1023,14 @@ public class SwaggerDeserializer {
             }
         }
 
+        // work-around for https://github.com/swagger-api/swagger-core/issues/1977
+        if(node.get("$ref") != null && node.get("$ref").isTextual()) {
+            // check if it's a relative ref
+            String mungedRef = mungedRef(node.get("$ref").textValue());
+            if(mungedRef != null) {
+                node.put("$ref", mungedRef);
+            }
+        }
         return Json.mapper().convertValue(node, Property.class);
     }
 
@@ -1091,7 +1118,6 @@ public class SwaggerDeserializer {
         JsonNode ref = node.get("$ref");
         if(ref != null) {
             if(ref.getNodeType().equals(JsonNodeType.STRING)) {
-
                 return refResponse((TextNode) ref, location, result);
             }
             else {
@@ -1108,6 +1134,14 @@ public class SwaggerDeserializer {
             JsonNode schemaRef = schema.get("$ref");
             if (schemaRef != null) {
                 if (schemaRef.getNodeType().equals(JsonNodeType.STRING)) {
+
+                    // work-around for https://github.com/swagger-api/swagger-core/issues/2138
+                    String mungedRef = mungedRef(schemaRef.textValue());
+                    if (mungedRef != null) {
+                        schema.put("$ref", mungedRef);
+                        schemaRef = schema.get("$ref");
+                    }
+
                     Model schemaProp = new RefModel(schemaRef.textValue());
                     output.responseSchema(schemaProp);
                 } else {
diff --git a/pom.xml b/pom.xml
index 2e963f01..74a94b33 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>io.swagger</groupId>
     <artifactId>swagger-parser-project</artifactId>
-    <version>1.0.39-SNAPSHOT</version>
+    <version>1.0.37-SNAPSHOT</version>
     <packaging>pom</packaging>
     <name>swagger-parser-project</name>
     <developers>
@@ -241,7 +241,7 @@
     <properties>
         <commons-io-version>2.4</commons-io-version>
         <slf4j-version>1.6.3</slf4j-version>
-        <swagger-core-version>1.5.22-SNAPSHOT</swagger-core-version>
+        <swagger-core-version>1.5.20</swagger-core-version>
         <junit-version>4.8.1</junit-version>
         <testng-version>6.9.6</testng-version>
         <jmockit-version>1.19</jmockit-version>


Test patch:
diff --git a/modules/swagger-compat-spec-parser/src/test/java/io/swagger/converter/LegacyConverterTest.java b/modules/swagger-compat-spec-parser/src/test/java/io/swagger/converter/LegacyConverterTest.java
index c894224a..74bad457 100644
--- a/modules/swagger-compat-spec-parser/src/test/java/io/swagger/converter/LegacyConverterTest.java
+++ b/modules/swagger-compat-spec-parser/src/test/java/io/swagger/converter/LegacyConverterTest.java
@@ -14,13 +14,11 @@ import io.swagger.models.auth.AuthorizationValue;
 import io.swagger.models.auth.In;
 import io.swagger.models.auth.OAuth2Definition;
 import io.swagger.models.auth.SecuritySchemeDefinition;
-import io.swagger.models.parameters.BodyParameter;
 import io.swagger.models.parameters.Parameter;
 import io.swagger.models.parameters.PathParameter;
 import io.swagger.models.parameters.QueryParameter;
 import io.swagger.models.properties.ArrayProperty;
 import io.swagger.models.properties.Property;
-import io.swagger.models.properties.RefProperty;
 import io.swagger.models.properties.StringProperty;
 import io.swagger.parser.SwaggerCompatConverter;
 import io.swagger.parser.SwaggerParser;
@@ -32,7 +30,6 @@ import mockit.Mocked;
 import org.junit.Assert;
 import org.testng.annotations.Test;
 
-import javax.validation.constraints.AssertFalse;
 import java.io.File;
 import java.io.IOException;
 import java.nio.charset.Charset;
@@ -261,25 +258,4 @@ public class LegacyConverterTest {
 
         assertEquals(actual, expected);
     }
-
-    @Test
-    public void testIssue799() throws Exception {
-
-        Swagger swagger = converter.read("src/test/resources/specs/v1_2/issue799.json");
-        Assert.assertEquals( swagger.getPaths().get("/api/v1beta3/namespaces/{namespaces}/bindings").getPost().getResponses().get("200").getResponseSchema().getReference(), "#/definitions/v1beta3.Binding");
-        Parameter bodyParameter = swagger.getPaths().get("/api/v1beta3/namespaces/{namespaces}/bindings").getPost().getParameters().get(1);
-        Assert.assertEquals( bodyParameter.getName(), "body");
-        Assert.assertTrue( bodyParameter instanceof BodyParameter);
-        Assert.assertEquals( ((BodyParameter)bodyParameter).getSchema().getReference(), "#/definitions/v1beta3.Binding");
-        Assert.assertEquals( swagger.getPaths().get("/api/v1beta3/namespaces/{namespaces}/componentstatuses/{name}").getGet().getResponses().get("200").getResponseSchema().getReference(), "#/definitions/v1beta3.ComponentStatus");
-        Assert.assertEquals( swagger.getPaths().get("/api/v1beta3/namespaces/{namespaces}/componentstatuses").getGet().getResponses().get("200").getResponseSchema().getReference(), "#/definitions/v1beta3.ComponentStatusList");
-        Property conditionsProperty = swagger.getDefinitions().get("v1beta3.ComponentStatus").getProperties().get("conditions");
-        Assert.assertTrue( conditionsProperty instanceof ArrayProperty);
-        Property items = ((ArrayProperty)conditionsProperty).getItems();
-        Assert.assertTrue( items instanceof RefProperty);
-        Assert.assertEquals( ((RefProperty)items).get$ref(), "#/definitions/v1beta3.ObjectReference");
-        Property metadataProperty = swagger.getDefinitions().get("v1beta3.ComponentStatus").getProperties().get("metadata");
-        Assert.assertTrue( metadataProperty instanceof RefProperty);
-        Assert.assertEquals( ((RefProperty)metadataProperty).get$ref(), "#/definitions/v1beta3.ObjectMeta");
-    }
 }
diff --git a/modules/swagger-compat-spec-parser/src/test/resources/specs/v1_2/issue799.json b/modules/swagger-compat-spec-parser/src/test/resources/specs/v1_2/issue799.json
deleted file mode 100644
index eb874ab3..00000000
--- a/modules/swagger-compat-spec-parser/src/test/resources/specs/v1_2/issue799.json
+++ /dev/null
@@ -1,316 +0,0 @@
-{
-  "swaggerVersion": "1.2",
-  "apiVersion": "v1beta3",
-  "basePath": "https://127.0.0.1:6443",
-  "resourcePath": "/api/v1beta3",
-  "apis": [
-    {
-      "path": "/api/v1beta3/namespaces/{namespaces}/bindings",
-      "description": "API at /api/v1beta3 version v1beta3",
-      "operations": [
-        {
-          "type": "v1beta3.Binding",
-          "method": "POST",
-          "summary": "create a Binding",
-          "nickname": "createBinding",
-          "parameters": [
-            {
-              "type": "string",
-              "paramType": "path",
-              "name": "namespaces",
-              "description": "object name and auth scope, such as for teams and projects",
-              "required": true,
-              "allowMultiple": false
-            },
-            {
-              "type": "v1beta3.Binding",
-              "paramType": "body",
-              "name": "body",
-              "description": "",
-              "required": true,
-              "allowMultiple": false
-            }
-          ],
-          "responseMessages": [
-            {
-              "code": 200,
-              "message": "OK",
-              "responseModel": "v1beta3.Binding"
-            }
-          ],
-          "produces": [
-            "application/json"
-          ],
-          "consumes": [
-            "*/*"
-          ]
-        }
-      ]
-    },
-    {
-      "path": "/api/v1beta3/namespaces/{namespaces}/componentstatuses",
-      "description": "API at /api/v1beta3 version v1beta3",
-      "operations": [
-        {
-          "type": "v1beta3.ComponentStatusList",
-          "method": "GET",
-          "summary": "list objects of kind ComponentStatus",
-          "nickname": "listComponentStatus",
-          "parameters": [
-            {
-              "type": "string",
-              "paramType": "path",
-              "name": "namespaces",
-              "description": "object name and auth scope, such as for teams and projects",
-              "required": true,
-              "allowMultiple": false
-            },
-            {
-              "type": "string",
-              "paramType": "query",
-              "name": "fieldSelector",
-              "description": "a selector to restrict the list of returned objects by their fields; defaults to everything",
-              "required": false,
-              "allowMultiple": false
-            },
-            {
-              "type": "string",
-              "paramType": "query",
-              "name": "labelSelector",
-              "description": "a selector to restrict the list of returned objects by their labels; defaults to everything",
-              "required": false,
-              "allowMultiple": false
-            },
-            {
-              "type": "string",
-              "paramType": "query",
-              "name": "resourceVersion",
-              "description": "when specified with a watch call, shows changes that occur after that particular version of a resource; defaults to changes from the beginning of history",
-              "required": false,
-              "allowMultiple": false
-            },
-            {
-              "type": "boolean",
-              "paramType": "query",
-              "name": "watch",
-              "description": "watch for changes to the described resources and return them as a stream of add, update, and remove notifications; specify resourceVersion",
-              "required": false,
-              "allowMultiple": false
-            }
-          ],
-          "responseMessages": [
-            {
-              "code": 200,
-              "message": "OK",
-              "responseModel": "v1beta3.ComponentStatusList"
-            }
-          ],
-          "produces": [
-            "application/json"
-          ],
-          "consumes": [
-            "*/*"
-          ]
-        }
-      ]
-    },
-    {
-      "path": "/api/v1beta3/namespaces/{namespaces}/componentstatuses/{name}",
-      "description": "API at /api/v1beta3 version v1beta3",
-      "operations": [
-        {
-          "type": "v1beta3.ComponentStatus",
-          "method": "GET",
-          "summary": "read the specified ComponentStatus",
-          "nickname": "readComponentStatus",
-          "parameters": [
-            {
-              "type": "string",
-              "paramType": "path",
-              "name": "name",
-              "description": "name of the ComponentStatus",
-              "required": true,
-              "allowMultiple": false
-            },
-            {
-              "type": "string",
-              "paramType": "path",
-              "name": "namespaces",
-              "description": "object name and auth scope, such as for teams and projects",
-              "required": true,
-              "allowMultiple": false
-            }
-          ],
-          "responseMessages": [
-            {
-              "code": 200,
-              "message": "OK",
-              "responseModel": "v1beta3.ComponentStatus"
-            }
-          ],
-          "produces": [
-            "application/json"
-          ],
-          "consumes": [
-            "*/*"
-          ]
-        }
-      ]
-    }
-  ],
-  "models": {
-    "v1beta3.ComponentStatus": {
-      "id": "v1beta3.ComponentStatus",
-      "properties": {
-        "apiVersion": {
-          "type": "string",
-          "description": "version of the schema the object should have"
-        },
-        "conditions": {
-          "type": "array",
-          "items": {
-            "$ref": "v1beta3.ObjectReference"
-          },
-          "description": "list of component conditions observed"
-        },
-        "kind": {
-          "type": "string",
-          "description": "kind of object, in CamelCase; cannot be updated"
-        },
-        "metadata": {
-          "$ref": "v1beta3.ObjectMeta",
-          "description": "standard object metadata; see http://docs.k8s.io/api-conventions.md#metadata"
-        }
-      }
-    },
-    "v1beta3.ComponentStatusList": {
-      "id": "v1beta3.ComponentStatusList",
-      "required": [
-        "items"
-      ],
-      "properties": {
-        "apiVersion": {
-          "type": "string",
-          "description": "version of the schema the object should have"
-        },
-        "items": {
-          "type": "array",
-          "items": {
-            "$ref": "v1beta3.ComponentStatus"
-          },
-          "description": "list of component status objects"
-        },
-        "kind": {
-          "type": "string",
-          "description": "kind of object, in CamelCase; cannot be updated"
-        },
-        "metadata": {
-          "$ref": "v1beta3.ObjectMeta",
-          "description": "standard list metadata; see http://docs.k8s.io/api-conventions.md#metadata"
-        }
-      }
-    },
-    "v1beta3.Binding": {
-      "id": "v1beta3.Binding",
-      "required": [
-        "target"
-      ],
-      "properties": {
-        "apiVersion": {
-          "type": "string",
-          "description": "version of the schema the object should have"
-        },
-        "kind": {
-          "type": "string",
-          "description": "kind of object, in CamelCase; cannot be updated"
-        },
-        "metadata": {
-          "$ref": "v1beta3.ObjectMeta",
-          "description": "standard object metadata; see http://docs.k8s.io/api-conventions.md#metadata"
-        },
-        "target": {
-          "$ref": "v1beta3.ObjectReference",
-          "description": "an object to bind to"
-        }
-      }
-    },
-    "v1beta3.ObjectReference": {
-      "id": "v1beta3.ObjectReference",
-      "properties": {
-        "apiVersion": {
-          "type": "string",
-          "description": "API version of the referent"
-        },
-        "fieldPath": {
-          "type": "string",
-          "description": "if referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]"
-        },
-        "kind": {
-          "type": "string",
-          "description": "kind of the referent"
-        },
-        "name": {
-          "type": "string",
-          "description": "name of the referent"
-        },
-        "namespace": {
-          "type": "string",
-          "description": "namespace of the referent"
-        },
-        "resourceVersion": {
-          "type": "string",
-          "description": "specific resourceVersion to which this reference is made, if any: http://docs.k8s.io/api-conventions.md#concurrency-control-and-consistency"
-        },
-        "uid": {
-          "type": "string",
-          "description": "uid of the referent"
-        }
-      }
-    },
-    "v1beta3.ObjectMeta": {
-      "id": "v1beta3.ObjectMeta",
-      "properties": {
-        "annotations": {
-          "type": "any",
-          "description": "map of string keys and values that can be used by external tooling to store and retrieve arbitrary metadata about objects"
-        },
-        "creationTimestamp": {
-          "type": "string",
-          "description": "RFC 3339 date and time at which the object was created; populated by the system, read-only; null for lists"
-        },
-        "deletionTimestamp": {
-          "type": "string",
-          "description": "RFC 3339 date and time at which the object will be deleted; populated by the system when a graceful deletion is requested, read-only; if not set, graceful deletion of the object has not been requested"
-        },
-        "generateName": {
-          "type": "string",
-          "description": "an optional prefix to use to generate a unique name; has the same validation rules as name; optional, and is applied only name if is not specified"
-        },
-        "labels": {
-          "type": "any",
-          "description": "map of string keys and values that can be used to organize and categorize objects; may match selectors of replication controllers and services"
-        },
-        "name": {
-          "type": "string",
-          "description": "string that identifies an object. Must be unique within a namespace; cannot be updated"
-        },
-        "namespace": {
-          "type": "string",
-          "description": "namespace of the object; cannot be updated"
-        },
-        "resourceVersion": {
-          "type": "string",
-          "description": "string that identifies the internal version of this object that can be used by clients to determine when objects have changed; populated by the system, read-only; value must be treated as opaque by clients and passed unmodified back to the server: http://docs.k8s.io/api-conventions.md#concurrency-control-and-consistency"
-        },
-        "selfLink": {
-          "type": "string",
-          "description": "URL for the object; populated by the system, read-only"
-        },
-        "uid": {
-          "type": "string",
-          "description": "unique UUID across space and time; populated by the system; read-only"
-        }
-      }
-    }
-  }
-}
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/java/io/swagger/parser/FileReferenceTest.java b/modules/swagger-parser/src/test/java/io/swagger/parser/FileReferenceTest.java
index c7607bbf..63d6e224 100644
--- a/modules/swagger-parser/src/test/java/io/swagger/parser/FileReferenceTest.java
+++ b/modules/swagger-parser/src/test/java/io/swagger/parser/FileReferenceTest.java
@@ -28,7 +28,7 @@ public class FileReferenceTest {
 
         Swagger swagger = result.getSwagger();
 
-        assertTrue(swagger.getDefinitions().size() == 6);
+        assertTrue(swagger.getDefinitions().size() == 5);
         // resolved from `$ref: './book.yaml'`
         assertNotNull(swagger.getDefinitions().get("Inventory"));
         // resolved from `$ref: 'book.yaml'`
@@ -139,22 +139,6 @@ public class FileReferenceTest {
         assertNotNull(swagger.getPath("/foo").getGet());
     }
 
-    @Test
-    public void testIssue822() {
-        SwaggerDeserializationResult result = new SwaggerParser().readWithInfo("./src/test/resources/issue-enc.yaml", null, true);
-        assertNotNull(result.getSwagger());
-
-        Swagger swagger = result.getSwagger();
-
-        assertNotNull(swagger.getPath("/foo").getGet());
-        assertNotNull(swagger.getPath("/bar/wtf").getGet());
-        assertNull(swagger.getPath("/bar/haha").getGet());
-        assertNotNull(swagger.getPath("/wtf/{bar}").getGet());
-        assertNotNull(swagger.getPath("/haha/{bar}").getGet());
-        assertNull(swagger.getPath("/haha2/{bar}").getGet());
-
-    }
-
     @Test
     public void testIssue336() {
         SwaggerDeserializationResult result = new SwaggerParser().readWithInfo("./src/test/resources/nested-file-references/issue-336.json", null, true);
diff --git a/modules/swagger-parser/src/test/java/io/swagger/parser/SwaggerParserTest.java b/modules/swagger-parser/src/test/java/io/swagger/parser/SwaggerParserTest.java
index 22f97e24..17bfd1d0 100644
--- a/modules/swagger-parser/src/test/java/io/swagger/parser/SwaggerParserTest.java
+++ b/modules/swagger-parser/src/test/java/io/swagger/parser/SwaggerParserTest.java
@@ -54,76 +54,6 @@ import static org.testng.Assert.fail;
 
 public class SwaggerParserTest {
 
-    @Test
-    public void testIssue845() {
-        SwaggerDeserializationResult swaggerDeserializationResult = new SwaggerParser().readWithInfo("");
-        assertEquals(swaggerDeserializationResult.getMessages().get(0), "empty or null swagger supplied");
-    }
-  
-    @Test
-    public void testIssue834() {
-        Swagger swagger = new SwaggerParser().read("issue-834/index.yaml", null, true);
-        assertNotNull(swagger);
-
-        Response foo200 =swagger.getPaths().get("/foo").getGet().getResponses().get("200");
-        assertNotNull(foo200);
-        RefModel model200 = (RefModel) foo200.getResponseSchema();
-        String foo200SchemaRef = model200.get$ref();
-        assertEquals(foo200SchemaRef, "#/definitions/schema");
-
-        Response foo300 = swagger.getPaths().get("/foo").getGet().getResponses().get("300");
-        assertNotNull(foo300);
-        RefModel model300 = (RefModel) foo300.getResponseSchema();
-        String foo300SchemaRef = model300.get$ref();
-        assertEquals(foo300SchemaRef, "#/definitions/schema");
-
-        Response bar200 = swagger.getPaths().get("/bar").getGet().getResponses().get("200");
-        assertNotNull(bar200);
-        RefModel modelBar200 = (RefModel) bar200.getResponseSchema();
-        String bar200SchemaRef = modelBar200.get$ref();
-        assertEquals(bar200SchemaRef, "#/definitions/schema");
-    }
-
-    @Test
-    public void testIssue811_RefSchema_ToRefSchema() {
-        final Swagger swagger = new SwaggerParser().read("oapi-reference-test2/index.yaml", null, true);
-        Assert.assertNotNull(swagger);
-        RefModel model = (RefModel) swagger.getPaths().get("/").getGet().getResponses().get("200").getResponseSchema();
-        Assert.assertEquals(model.get$ref() ,"#/definitions/schema-with-reference");
-    }
-
-    @Test
-    public void testIssue811() throws Exception {
-        SwaggerParser parser = new SwaggerParser();
-        final Swagger swagger = parser.read("src/test/resources/oapi-reference-test/index.yaml");
-        Assert.assertNotNull(swagger);
-        assertTrue(swagger.getPaths().get("/").getGet().getResponses().get("200").getResponseSchema() instanceof RefModel);
-        RefModel model = (RefModel) swagger.getPaths().get("/").getGet().getResponses().get("200").getResponseSchema();
-        Assert.assertEquals(model.get$ref(),"#/definitions/schema-with-reference");
-
-    }
-
-    @Test
-    public void testIssue727() throws Exception {
-        SwaggerParser parser = new SwaggerParser();
-        final Swagger swagger = parser.read("src/test/resources/issue-714/serviceA.yaml");
-        Assert.assertNotNull(swagger);
-        assertNotNull(swagger.getPaths().get("/test").getGet().getParameters().get(0));
-        assertTrue(swagger.getDefinitions().size() == 1);
-        assertNotNull(swagger.getDefinitions().get("refA"));
-    }
-
-    @Test
-    public void testIssue704() throws Exception {
-        SwaggerParser parser = new SwaggerParser();
-        final Swagger swagger = parser.read("src/test/resources/sample/swagger.json");
-        Assert.assertNotNull(swagger);
-
-        assertNotNull(swagger.getPaths().get("/api/Address").getGet());
-        assertTrue(swagger.getDefinitions().size() == 1);
-        assertNotNull(swagger.getDefinitions().get("AddressEx"));
-    }
-
     @Test
     public void testIssue697() throws Exception {
         String yaml = "{\n" +
@@ -1234,7 +1164,7 @@ public class SwaggerParserTest {
 
     @Test
     public void testRefNameConflicts() throws Exception {
-        Swagger swagger = new SwaggerParser().read("name-conflicts/refs-name-conflict/a.yaml");
+        Swagger swagger = new SwaggerParser().read("./refs-name-conflict/a.yaml");
 
         assertTrue(swagger.getDefinitions().size() == 2);
 
@@ -1310,5 +1240,12 @@ public class SwaggerParserTest {
         assertEquals("k-definition", definitions.get("k_2").getTitle());
     }
 
+    @Test(description = "Parser not honoring redirect responses")
+    public void testIssue844() {
+        SwaggerParser parser = new SwaggerParser();
+        final SwaggerDeserializationResult swagger = parser.readWithInfo("src/test/resources/reusableParametersWithExternalRef.json", null, true);
+        assertNotNull(swagger.getSwagger());
+        assertEquals(swagger.getSwagger().getPath("/pets/{id}").getGet().getParameters().get(0).getIn(), "header");
+    }
 
 }
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/java/io/swagger/parser/processors/OperationProcessorTest.java b/modules/swagger-parser/src/test/java/io/swagger/parser/processors/OperationProcessorTest.java
index f7259ca0..b1d8abe0 100644
--- a/modules/swagger-parser/src/test/java/io/swagger/parser/processors/OperationProcessorTest.java
+++ b/modules/swagger-parser/src/test/java/io/swagger/parser/processors/OperationProcessorTest.java
@@ -42,7 +42,7 @@ public class OperationProcessorTest {
         operation.setParameters(inputParameterList);
 
         final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
-        final RefResponse refResponse = new RefResponse(ref);
+        RefResponse refResponse = new RefResponse(ref);
 
         operation.response(200, refResponse);
         operation.response(400, incomingResponse);
@@ -59,9 +59,6 @@ public class OperationProcessorTest {
             times = 1;
             result = outputParameterList;
 
-            responseProcessor.processResponse(refResponse);
-            times = 1;
-
             cache.loadRef(ref, RefFormat.URL, Response.class);
             times = 1;
             result = resolvedResponse;
diff --git a/modules/swagger-parser/src/test/java/io/swagger/parser/util/RefUtilsTest.java b/modules/swagger-parser/src/test/java/io/swagger/parser/util/RefUtilsTest.java
index fe5374cc..3eb7dc60 100644
--- a/modules/swagger-parser/src/test/java/io/swagger/parser/util/RefUtilsTest.java
+++ b/modules/swagger-parser/src/test/java/io/swagger/parser/util/RefUtilsTest.java
@@ -232,10 +232,8 @@ public class RefUtilsTest {
     public void testReadExternalRef_OnClasspath(@Mocked Files files,
                                                 @Mocked ClasspathHelper classpathHelper,
                                                 @Injectable final Path parentDirectory,
-                                                @Injectable final Path pathToUse,
-                                                @Injectable final Path pathToUse2) throws Exception {
+                                                @Injectable final Path pathToUse) throws Exception {
         final String filePath = "./path/to/file.json";
-        final String url = parentDirectory + "/path/to/file.json";
         final String expectedResult = "really good json";
 
         new StrictExpectations() {{
@@ -248,14 +246,6 @@ public class RefUtilsTest {
             times = 1;
             result = false;
 
-            parentDirectory.resolve(url).normalize();
-            times = 1;
-            result = pathToUse2;
-
-            Files.exists(pathToUse2);
-            times = 1;
-            result = false;
-
             ClasspathHelper.loadFileFromClasspath(filePath); times=1; result=expectedResult;
 
         }};
diff --git a/modules/swagger-parser/src/test/resources/additionalProperties.yaml b/modules/swagger-parser/src/test/resources/additionalProperties.yaml
index 38bf45a9..fb35e7d3 100644
--- a/modules/swagger-parser/src/test/resources/additionalProperties.yaml
+++ b/modules/swagger-parser/src/test/resources/additionalProperties.yaml
@@ -19,4 +19,4 @@ paths:
         200:
           description: Returns results.
           schema:
-              $ref: "globals.yaml#/definitions/result"
\ No newline at end of file
+              $ref: "./globals.yaml#/definitions/result"
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/resources/allOf-properties-ext-ref/models/purebred_pet.json b/modules/swagger-parser/src/test/resources/allOf-properties-ext-ref/models/purebred_pet.json
index d85c4e56..c1f9b469 100644
--- a/modules/swagger-parser/src/test/resources/allOf-properties-ext-ref/models/purebred_pet.json
+++ b/modules/swagger-parser/src/test/resources/allOf-properties-ext-ref/models/purebred_pet.json
@@ -1,7 +1,7 @@
 {
   "allOf": [
     {
-      "$ref": "pet.json"
+      "$ref": "./pet.json"
     },
     {
       "type": "object",
@@ -11,12 +11,12 @@
           "sample": "Labrador"
         },
         "mother": {
-          "$ref": "pet.json"
+          "$ref": "./pet.json"
         },
         "siblings": {
           "type": "array",
           "items": {
-            "$ref": "pet.json"
+            "$ref": "./pet.json"
           }
         }
       }
diff --git a/modules/swagger-parser/src/test/resources/allOf-properties-ext-ref/models/swagger.json b/modules/swagger-parser/src/test/resources/allOf-properties-ext-ref/models/swagger.json
index 6f5fcf85..80d9cba1 100644
--- a/modules/swagger-parser/src/test/resources/allOf-properties-ext-ref/models/swagger.json
+++ b/modules/swagger-parser/src/test/resources/allOf-properties-ext-ref/models/swagger.json
@@ -6,7 +6,7 @@
   },
   "definitions": {
     "record": {
-      "$ref": "purebred_pet.json"
+      "$ref": "./purebred_pet.json"
     }
   }
 }
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/resources/allOf-properties-ext-ref/swagger.json b/modules/swagger-parser/src/test/resources/allOf-properties-ext-ref/swagger.json
index 997b2b19..fb82fd34 100644
--- a/modules/swagger-parser/src/test/resources/allOf-properties-ext-ref/swagger.json
+++ b/modules/swagger-parser/src/test/resources/allOf-properties-ext-ref/swagger.json
@@ -6,7 +6,7 @@
   },
   "definitions": {
     "record": {
-      "$ref": "models/purebred_pet.json"
+      "$ref": "./models/purebred_pet.json"
     }
   }
 }
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/resources/issue-714/Parameters/paramA.yaml b/modules/swagger-parser/src/test/resources/issue-714/Parameters/paramA.yaml
deleted file mode 100755
index 6abd2438..00000000
--- a/modules/swagger-parser/src/test/resources/issue-714/Parameters/paramA.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-parameters:
-  PageSize:
-    name: r # r(esults-per-page); alternative: pageSize
-    description: maximum number of elements to be returned on a page
-    in: query
-    type: integer
-    default: 50
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/resources/issue-714/refA.yaml b/modules/swagger-parser/src/test/resources/issue-714/refA.yaml
deleted file mode 100755
index 9a90ee84..00000000
--- a/modules/swagger-parser/src/test/resources/issue-714/refA.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-properties:
-  helloworld:
-    type: string
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/resources/issue-714/serviceA.yaml b/modules/swagger-parser/src/test/resources/issue-714/serviceA.yaml
deleted file mode 100755
index a73379d4..00000000
--- a/modules/swagger-parser/src/test/resources/issue-714/serviceA.yaml
+++ /dev/null
@@ -1,25 +0,0 @@
-swagger: '2.0'
-info:
-  title: Service A
-  version: 1.0.0
-host: www.myhost.com
-schemes:
-  - https
-basePath: /rest/
-produces:
-  - application/json
-  - application/xml
-paths:
-  /test:
-    get:
-      summary: Summary
-      consumes:
-        - application/json
-        - application/xml
-      parameters:
-        - $ref : 'Parameters/paramA.yaml#/parameters/PageSize'
-      responses:
-        '200':
-          description: Clinics
-          schema:
-            $ref: 'refA.yaml'
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/resources/issue-834/components/response1.yaml b/modules/swagger-parser/src/test/resources/issue-834/components/response1.yaml
deleted file mode 100644
index ec9593fe..00000000
--- a/modules/swagger-parser/src/test/resources/issue-834/components/response1.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
----
-description: Response with schema containing reference
-schema:
-  $ref: "./schema.yaml"
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/resources/issue-834/components/response2.yaml b/modules/swagger-parser/src/test/resources/issue-834/components/response2.yaml
deleted file mode 100644
index ec9593fe..00000000
--- a/modules/swagger-parser/src/test/resources/issue-834/components/response2.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
----
-description: Response with schema containing reference
-schema:
-  $ref: "./schema.yaml"
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/resources/issue-834/components/schema.yaml b/modules/swagger-parser/src/test/resources/issue-834/components/schema.yaml
deleted file mode 100644
index 3be57c93..00000000
--- a/modules/swagger-parser/src/test/resources/issue-834/components/schema.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-type: object
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/resources/issue-834/index.yaml b/modules/swagger-parser/src/test/resources/issue-834/index.yaml
deleted file mode 100644
index b61fc74d..00000000
--- a/modules/swagger-parser/src/test/resources/issue-834/index.yaml
+++ /dev/null
@@ -1,30 +0,0 @@
----
-swagger: "2.0"
-externalDocs:
-  description: Test
-  url: http://test.com/test
-info:
-  version: 0.0.1
-  title: Test
-  license:
-    name: Test
-    url: http://test.com/test
-paths:
-  /foo:
-    get:
-      description: foo
-      summary: foo
-      operationId: foo
-      responses:
-        200:
-          $ref: "./components/response1.yaml"
-        300:
-          $ref: "./components/response2.yaml"
-  /bar:
-    get:
-      description: bar
-      summary: bar
-      operationId: bar
-      responses:
-        200:
-          $ref: "./components/response1.yaml"
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/resources/issue-enc-b.yaml b/modules/swagger-parser/src/test/resources/issue-enc-b.yaml
deleted file mode 100644
index 33a07aa5..00000000
--- a/modules/swagger-parser/src/test/resources/issue-enc-b.yaml
+++ /dev/null
@@ -1,37 +0,0 @@
-swagger: "2.0"
-
-info:
-  version: 1.0.0
-  title: Path include test case child
-
-paths:
-  /foo:
-    get:
-      responses:
-        200:
-          description: "Request successful"
-  /bar/wtf:
-    get:
-      responses:
-        200:
-          description: "Request successful"
-  /bar/haha:
-    get:
-      responses:
-        200:
-          description: "Request successful"
-  /wtf/{bar}:
-    get:
-      responses:
-        200:
-          description: "Request successful"
-  /haha/{bar}:
-    get:
-      responses:
-        200:
-          description: "Request successful"
-  /haha2/{bar}:
-    get:
-      responses:
-        200:
-          description: "Request successful"
diff --git a/modules/swagger-parser/src/test/resources/issue-enc.yaml b/modules/swagger-parser/src/test/resources/issue-enc.yaml
deleted file mode 100644
index 40f5aa26..00000000
--- a/modules/swagger-parser/src/test/resources/issue-enc.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-swagger: "2.0"
-
-info:
-  version: 1.0.0
-  title: Path include test case
-
-paths:
-  /foo:
-    $ref: './issue-enc-b.yaml#/paths/~1foo'
-  /wtf/{bar}:
-    $ref: './issue-enc-b.yaml#/paths/~1wtf~1%7Bbar%7D'
-  /bar/wtf:
-    $ref: './issue-enc-b.yaml#/paths/~1bar~1wtf'
-  /haha/{bar}:
-    $ref: './issue-enc-b.yaml#/paths/~1haha~1{bar}'
-  /haha2/{bar}:
-    $ref: './issue-enc-b.yaml#/paths/~1haha/{bar}'
-  /bar/haha:
-    $ref: './issue-enc-b.yaml#/paths/bar/haha'
-
diff --git a/modules/swagger-parser/src/test/resources/oapi-reference-test/components/referent.yaml b/modules/swagger-parser/src/test/resources/oapi-reference-test/components/referent.yaml
deleted file mode 100644
index 80ef5680..00000000
--- a/modules/swagger-parser/src/test/resources/oapi-reference-test/components/referent.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-type: object
diff --git a/modules/swagger-parser/src/test/resources/oapi-reference-test/components/response-with-reference.yaml b/modules/swagger-parser/src/test/resources/oapi-reference-test/components/response-with-reference.yaml
deleted file mode 100644
index 61e31e42..00000000
--- a/modules/swagger-parser/src/test/resources/oapi-reference-test/components/response-with-reference.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
----
-description: Response with schema containing reference
-schema:
-  $ref: "./schema-with-reference.yaml"
diff --git a/modules/swagger-parser/src/test/resources/oapi-reference-test/components/schema-with-reference.yaml b/modules/swagger-parser/src/test/resources/oapi-reference-test/components/schema-with-reference.yaml
deleted file mode 100644
index 4a896cc6..00000000
--- a/modules/swagger-parser/src/test/resources/oapi-reference-test/components/schema-with-reference.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
----
-type: object
-properties:
-  reference_array:
-    type: array
-    items:
-      $ref: "./referent.yaml"
diff --git a/modules/swagger-parser/src/test/resources/oapi-reference-test/index.yaml b/modules/swagger-parser/src/test/resources/oapi-reference-test/index.yaml
deleted file mode 100644
index d0950f02..00000000
--- a/modules/swagger-parser/src/test/resources/oapi-reference-test/index.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
----
-swagger: "2.0"
-
-info:
-  version: 1.0.0
-  title: Path include test case child
-
-paths:
-  /:
-    get:
-      description: Test
-      summary: Test
-      operationId: getTest
-      responses:
-        200:
-          $ref: "./components/response-with-reference.yaml"
diff --git a/modules/swagger-parser/src/test/resources/oapi-reference-test2/components/referent.yaml b/modules/swagger-parser/src/test/resources/oapi-reference-test2/components/referent.yaml
deleted file mode 100644
index 80ef5680..00000000
--- a/modules/swagger-parser/src/test/resources/oapi-reference-test2/components/referent.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-type: object
diff --git a/modules/swagger-parser/src/test/resources/oapi-reference-test2/components/schema-with-reference.yaml b/modules/swagger-parser/src/test/resources/oapi-reference-test2/components/schema-with-reference.yaml
deleted file mode 100644
index 4a896cc6..00000000
--- a/modules/swagger-parser/src/test/resources/oapi-reference-test2/components/schema-with-reference.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
----
-type: object
-properties:
-  reference_array:
-    type: array
-    items:
-      $ref: "./referent.yaml"
diff --git a/modules/swagger-parser/src/test/resources/oapi-reference-test2/index.yaml b/modules/swagger-parser/src/test/resources/oapi-reference-test2/index.yaml
deleted file mode 100644
index 66e37a25..00000000
--- a/modules/swagger-parser/src/test/resources/oapi-reference-test2/index.yaml
+++ /dev/null
@@ -1,22 +0,0 @@
----
-swagger: "2.0"
-externalDocs:
-  description: Test
-  url: http://test.com/test
-info:
-  version: 0.0.1
-  title: Test
-  license:
-    name: Test
-    url: http://test.com/test
-paths:
-  /:
-    get:
-      description: Test
-      summary: Test
-      operationId: getTest
-      responses:
-        200:
-          description: Response with schema containing reference
-          schema:
-            $ref: "./components/schema-with-reference.yaml"
diff --git a/modules/swagger-parser/src/test/resources/name-conflicts/refs-name-conflict/a.yaml b/modules/swagger-parser/src/test/resources/refs-name-conflict/a.yaml
similarity index 84%
rename from modules/swagger-parser/src/test/resources/name-conflicts/refs-name-conflict/a.yaml
rename to modules/swagger-parser/src/test/resources/refs-name-conflict/a.yaml
index b4bcc184..e1e37115 100644
--- a/modules/swagger-parser/src/test/resources/name-conflicts/refs-name-conflict/a.yaml
+++ b/modules/swagger-parser/src/test/resources/refs-name-conflict/a.yaml
@@ -23,7 +23,7 @@ paths:
       200:
        description: OK
        schema:
-         $ref: "../test-relative/b.yaml#/definitions/PersonObj"
+         $ref: "./refs-name-conflict/b.yaml#/definitions/PersonObj"
  /yetAnotherPerson:
   post:
     summary: Create yet another person
@@ -33,7 +33,7 @@ paths:
       200:
        description: OK
        schema:
-         $ref: "../test-relative/b.yaml#/definitions/PersonObj"
+         $ref: "./refs-name-conflict/b.yaml#/definitions/PersonObj"
 
 definitions:
  PersonObj:
diff --git a/modules/swagger-parser/src/test/resources/name-conflicts/refs-name-conflict/test-relative/b.yaml b/modules/swagger-parser/src/test/resources/refs-name-conflict/b.yaml
similarity index 100%
rename from modules/swagger-parser/src/test/resources/name-conflicts/refs-name-conflict/test-relative/b.yaml
rename to modules/swagger-parser/src/test/resources/refs-name-conflict/b.yaml
diff --git a/modules/swagger-parser/src/test/resources/relative-file-references/json/paths/healthPath.json b/modules/swagger-parser/src/test/resources/relative-file-references/json/paths/healthPath.json
index 243ef0a6..15395b4e 100644
--- a/modules/swagger-parser/src/test/resources/relative-file-references/json/paths/healthPath.json
+++ b/modules/swagger-parser/src/test/resources/relative-file-references/json/paths/healthPath.json
@@ -1,10 +1,10 @@
 {
   "parameters": [
     {
-      "$ref": "../parameters/params.json#/param1"
+      "$ref": "./parameters/params.json#/param1"
     },
     {
-      "$ref": "../parameters/params.json#/param2"
+      "$ref": "./parameters/params.json#/param2"
     }
   ],
   "get": {
@@ -15,17 +15,17 @@
     ],
     "parameters": [
       {
-        "$ref": "../parameters/params.json#/param3"
+        "$ref": "./parameters/params.json#/param3"
       },
       {
-        "$ref": "../parameters/params.json#/param4"
+        "$ref": "./parameters/params.json#/param4"
       },
       {
         "name": "body",
         "in": "body",
         "required": true,
         "schema": {
-          "$ref": "../models/health.json"
+          "$ref": "./models/health.json"
         }
       }
     ],
@@ -33,14 +33,14 @@
       "200": {
         "description": "Health information from the server",
         "schema": {
-          "$ref": "../models/health.json"
+          "$ref": "./models/health.json"
         }
       },
       "400": {
-        "$ref": "../responses/errorResponses.json#/bad-request"
+        "$ref": "./responses/errorResponses.json#/bad-request"
       },
       "500": {
-        "$ref": "../responses/errorResponses.json#/internal-server-error"
+        "$ref": "./responses/errorResponses.json#/internal-server-error"
       }
     }
   }
diff --git a/modules/swagger-parser/src/test/resources/relative-file-references/json/responses/errorResponses.json b/modules/swagger-parser/src/test/resources/relative-file-references/json/responses/errorResponses.json
index efa8c53f..ce17bf19 100644
--- a/modules/swagger-parser/src/test/resources/relative-file-references/json/responses/errorResponses.json
+++ b/modules/swagger-parser/src/test/resources/relative-file-references/json/responses/errorResponses.json
@@ -2,13 +2,13 @@
   "bad-request": {
     "description": "Your request was not valid",
     "schema": {
-      "$ref": "../models/error.json"
+      "$ref": "./models/error.json"
     }
   },
   "internal-server-error": {
     "description": "An unexpected error occur during processing",
     "schema": {
-      "$ref": "../models/error.json"
+      "$ref": "./models/error.json"
     }
   }
 }
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/resources/relative-file-references/yaml/paths/healthPath.yaml b/modules/swagger-parser/src/test/resources/relative-file-references/yaml/paths/healthPath.yaml
index 2840ec8f..436baf51 100644
--- a/modules/swagger-parser/src/test/resources/relative-file-references/yaml/paths/healthPath.yaml
+++ b/modules/swagger-parser/src/test/resources/relative-file-references/yaml/paths/healthPath.yaml
@@ -1,26 +1,26 @@
 ---
 parameters:
-- $ref: "../parameters/params.yaml#/param1"
-- $ref: "../parameters/params.yaml#/param2"
+- $ref: "./parameters/params.yaml#/param1"
+- $ref: "./parameters/params.yaml#/param2"
 get:
   summary: "Returns server health information"
   operationId: "getHealth"
   produces:
   - "application/json"
   parameters:
-  - $ref: "../parameters/params.yaml#/param3"
-  - $ref: "../parameters/params.yaml#/param4"
+  - $ref: "./parameters/params.yaml#/param3"
+  - $ref: "./parameters/params.yaml#/param4"
   - name: "body"
     in: "body"
     required: true
     schema:
-      $ref: "../models/health.yaml"
+      $ref: "./models/health.yaml"
   responses:
     200:
       description: "Health information from the server"
       schema:
-        $ref: "../models/health.yaml"
+        $ref: "./models/health.yaml"
     400:
-      $ref: "../responses/errorResponses.yaml#/bad-request"
+      $ref: "./responses/errorResponses.yaml#/bad-request"
     500:
-      $ref: "../responses/errorResponses.yaml#/internal-server-error"
+      $ref: "./responses/errorResponses.yaml#/internal-server-error"
diff --git a/modules/swagger-parser/src/test/resources/relative-file-references/yaml/responses/errorResponses.yaml b/modules/swagger-parser/src/test/resources/relative-file-references/yaml/responses/errorResponses.yaml
index 123e3eed..4e154c6a 100644
--- a/modules/swagger-parser/src/test/resources/relative-file-references/yaml/responses/errorResponses.yaml
+++ b/modules/swagger-parser/src/test/resources/relative-file-references/yaml/responses/errorResponses.yaml
@@ -2,8 +2,8 @@
 bad-request:
   description: "Your request was not valid"
   schema:
-    $ref: "../models/error.yaml"
+    $ref: "./models/error.yaml"
 internal-server-error:
   description: "An unexpected error occur during processing"
   schema:
-    $ref: "../models/error.yaml"
+    $ref: "./models/error.yaml"
diff --git a/modules/swagger-parser/src/test/resources/reusableParametersWithExternalRef.json b/modules/swagger-parser/src/test/resources/reusableParametersWithExternalRef.json
new file mode 100644
index 00000000..fbe337c9
--- /dev/null
+++ b/modules/swagger-parser/src/test/resources/reusableParametersWithExternalRef.json
@@ -0,0 +1,33 @@
+{
+  "swagger": "2.0",
+  "info": {
+    "version": "1.0.9-abcd",
+    "title": "Swagger Sample API Reusable Parameters"
+  },
+  "host": "my.api.com",
+  "basePath": "/v1",
+  "schemes": [
+    "http",
+    "https"
+  ],
+  "paths": {
+    "/pets/{id}": {
+      "get": {
+        "description": "Returns pets based on ID",
+        "summary": "Find pets by ID",
+        "operationId": "getPetsById",
+        "parameters": [
+          { "$ref": "http://docs.baikalplatform.com/common/v2.0/common.json#/parameters/x-correlator" }
+        ],
+        "responses": {
+          "200": {
+            "description": "pet response"
+          },
+          "default": {
+            "description": "error payload"
+          }
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/resources/sample/Paths/Address.json b/modules/swagger-parser/src/test/resources/sample/Paths/Address.json
deleted file mode 100755
index 9257105d..00000000
--- a/modules/swagger-parser/src/test/resources/sample/Paths/Address.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
-	"get": {
-		"tags": ["Address"],
-		"operationId": "Address_Get",
-		"consumes": [],
-		"produces": ["application/json",
-		"text/json",
-		"application/xml",
-		"text/xml"],
-		"responses": {
-			"200": {
-				"description": "OK",
-				"schema": {
-					"type": "array",
-					"items": {
-						"$ref": "../Schemas/schema.json#/definitions/AddressEx"
-					}
-				}
-			}
-		}
-	},
-	"post": {
-		"tags": ["Address"],
-		"operationId": "Address_Post",
-		"consumes": ["application/json",
-		"text/json",
-		"application/xml",
-		"text/xml",
-		"application/x-www-form-urlencoded"],
-		"produces": ["application/json",
-		"text/json",
-		"application/xml",
-		"text/xml"],
-		"parameters": [{
-			"name": "value",
-			"in": "body",
-			"required": true,
-			"schema": {
-				"$ref": "../Schemas/schema.json#/definitions/AddressEx"
-			}
-		}],
-		"responses": {
-			"200": {
-				"description": "OK",
-				"schema": {
-					"$ref": "../Schemas/schema.json#/definitions/AddressEx"
-				}
-			}
-		}
-	}
-}
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/resources/sample/Schemas/schema.json b/modules/swagger-parser/src/test/resources/sample/Schemas/schema.json
deleted file mode 100755
index 6613c2dd..00000000
--- a/modules/swagger-parser/src/test/resources/sample/Schemas/schema.json
+++ /dev/null
@@ -1,37 +0,0 @@
-{
-	"definitions": {
-		"AddressEx": {
-			"type": "object",
-			"properties": {
-				"Type": {
-					"enum": ["Residential",
-					"Business"],
-					"type": "string"
-				},
-				"Street": {
-					"type": "string"
-				},
-				"City": {
-					"type": "string"
-				},
-				"State": {
-					"type": "string"
-				}
-			}
-		},
-		"Address": {
-			"type": "object",
-			"properties": {
-				"Street": {
-					"type": "string"
-				},
-				"City": {
-					"type": "string"
-				},
-				"State": {
-					"type": "string"
-				}
-			}
-		}
-	}
-}
\ No newline at end of file
diff --git a/modules/swagger-parser/src/test/resources/sample/swagger.json b/modules/swagger-parser/src/test/resources/sample/swagger.json
deleted file mode 100755
index d08ad433..00000000
--- a/modules/swagger-parser/src/test/resources/sample/swagger.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
-	"swagger": "2.0",
-	"info": {
-		"version": "v1",
-		"title": "SwaggerTest",
-		"description": "Service for Swagger and JSON schema testing"
-	},
-	"host": "paeshin-w7",
-	"basePath": "/SwaggerTest",
-	"schemes": ["http",
-	"https"],
-	"paths": {
-		"/api/Address": {
-			"$ref": "Paths/Address.json"
-		}
-	}	
-}
\ No newline at end of file