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 6edc05d5cc..8be30f63f2 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 @@ -79,7 +79,14 @@ private String finalNameRec(Map schemas, String possiblyConflict return tryName; } + private String normalizeRelativeRef(String $ref, RefFormat refFormat) { + if (refFormat == RefFormat.RELATIVE && !$ref.startsWith("./")) { + return "./" + $ref; + } + return $ref; + } public String processRefToExternalSchema(String $ref, RefFormat refFormat) { + $ref = normalizeRelativeRef($ref, refFormat); String renamedRef = cache.getRenamedRef($ref); if(renamedRef != null) { return renamedRef;