Skip to content

Commit e9918fa

Browse files
authored
Merge pull request #1575 from cdestombes/issue-1511
fix 1511 for windows build
2 parents d184a6d + 16e499c commit e9918fa

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/processors/ExternalRefProcessor.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,16 @@ public String processRefToExternalSchema(String $ref, RefFormat refFormat) {
125125
if (isAnExternalRefFormat(ref)) {
126126
if (!ref.equals(RefFormat.URL)) {
127127
String schemaFullRef = schema.get$ref();
128-
String parent = file.substring(0, file.lastIndexOf(File.separatorChar));
128+
String parent = file.substring(0, file.lastIndexOf('/'));
129129
if (!parent.isEmpty()) {
130-
schemaFullRef = Paths.get(parent, schemaFullRef).normalize().toString();
130+
if (schemaFullRef.contains("#/")) {
131+
String[] parts = schemaFullRef.split("#/");
132+
String schemaFullRefFilePart = parts[0];
133+
String schemaFullRefInternalRefPart = parts[1];
134+
schemaFullRef = Paths.get(parent, schemaFullRefFilePart).normalize().toString() + "#/" + schemaFullRefInternalRefPart;
135+
} else {
136+
schemaFullRef = Paths.get(parent, schemaFullRef).normalize().toString();
137+
}
131138
}
132139
schema.set$ref(processRefToExternalSchema(schemaFullRef, ref));
133140
}

0 commit comments

Comments
 (0)