Skip to content

Commit 1d9b4b9

Browse files
authored
Merge pull request #1819 from snaggedagge/patch-1
Update ReferenceUtils to better support windows filesystem
2 parents 99457c2 + ec6bd80 commit 1d9b4b9

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/reference/ReferenceUtils.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,26 @@ public static boolean isAnchor(String ref) {
7070

7171
public static String readURI(String absoluteUri, List<AuthorizationValue> auths) throws Exception {
7272
URI resolved = new URI(absoluteUri);
73-
if (StringUtils.isBlank(resolved.getScheme())) {
74-
// try file
75-
String content = null;
76-
try {
77-
content = readFile(absoluteUri);
78-
} catch (Exception e) {
79-
//
73+
if (StringUtils.isNotBlank(resolved.getScheme())) {
74+
if (resolved.getScheme().startsWith("http")) {
75+
return readHttp(absoluteUri, auths);
76+
} else if (resolved.getScheme().startsWith("file")) {
77+
return readFile(absoluteUri);
78+
} else if (resolved.getScheme().startsWith("classpath")) {
79+
return readClasspath(absoluteUri);
8080
}
81-
if (StringUtils.isBlank(content)) {
82-
content = readClasspath(absoluteUri);
83-
}
84-
return content;
85-
} else if (resolved.getScheme().startsWith("http")) {
86-
return readHttp(absoluteUri, auths);
87-
} else if (resolved.getScheme().startsWith("file")) {
88-
return readFile(absoluteUri);
89-
} else if (resolved.getScheme().startsWith("classpath")) {
90-
return readClasspath(absoluteUri);
9181
}
92-
throw new RuntimeException("scheme not supported for uri: " + absoluteUri);
82+
// If no matches exists, try file
83+
String content = null;
84+
try {
85+
content = readFile(absoluteUri);
86+
} catch (Exception e) {
87+
//
88+
}
89+
if (StringUtils.isBlank(content)) {
90+
content = readClasspath(absoluteUri);
91+
}
92+
return content;
9393
}
9494

9595
public static JsonNode deserializeIntoTree(String content) throws Exception {

0 commit comments

Comments
 (0)