diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/processors/ExternalRefProcessor.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/processors/ExternalRefProcessor.java index 8f9c92c77e..d1175c267b 100644 --- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/processors/ExternalRefProcessor.java +++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/processors/ExternalRefProcessor.java @@ -34,6 +34,7 @@ import io.swagger.v3.parser.ResolverCache; import io.swagger.v3.parser.models.RefFormat; import io.swagger.v3.parser.models.RefType; +import io.swagger.v3.parser.util.RefUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; @@ -92,6 +93,18 @@ public String processRefToExternalSchema(String $ref, RefFormat refFormat) { return renamedRef; } + RefFormat format = computeRefFormat($ref); + if (format.equals(RefFormat.RELATIVE)) { + String normalizedRef = Paths.get($ref).normalize().toString(); + System.out.println("Normalized " + $ref + " to " + normalizedRef); + renamedRef = cache.getRenamedRef($ref); + if (renamedRef != null) { + return renamedRef; + } else { + $ref = normalizedRef; + } + } + final Schema schema = cache.loadRef($ref, refFormat, Schema.class); if(schema == null) {