Skip to content

Commit

Permalink
Merge pull request swagger-api#1819 from snaggedagge/patch-1
Browse files Browse the repository at this point in the history
Update ReferenceUtils to better support windows filesystem
  • Loading branch information
gracekarina authored Oct 4, 2022
2 parents 99457c2 + ec6bd80 commit 1d9b4b9
Showing 1 changed file with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,26 @@ public static boolean isAnchor(String ref) {

public static String readURI(String absoluteUri, List<AuthorizationValue> auths) throws Exception {
URI resolved = new URI(absoluteUri);
if (StringUtils.isBlank(resolved.getScheme())) {
// try file
String content = null;
try {
content = readFile(absoluteUri);
} catch (Exception e) {
//
if (StringUtils.isNotBlank(resolved.getScheme())) {
if (resolved.getScheme().startsWith("http")) {
return readHttp(absoluteUri, auths);
} else if (resolved.getScheme().startsWith("file")) {
return readFile(absoluteUri);
} else if (resolved.getScheme().startsWith("classpath")) {
return readClasspath(absoluteUri);
}
if (StringUtils.isBlank(content)) {
content = readClasspath(absoluteUri);
}
return content;
} else if (resolved.getScheme().startsWith("http")) {
return readHttp(absoluteUri, auths);
} else if (resolved.getScheme().startsWith("file")) {
return readFile(absoluteUri);
} else if (resolved.getScheme().startsWith("classpath")) {
return readClasspath(absoluteUri);
}
throw new RuntimeException("scheme not supported for uri: " + absoluteUri);
// If no matches exists, try file
String content = null;
try {
content = readFile(absoluteUri);
} catch (Exception e) {
//
}
if (StringUtils.isBlank(content)) {
content = readClasspath(absoluteUri);
}
return content;
}

public static JsonNode deserializeIntoTree(String content) throws Exception {
Expand Down

0 comments on commit 1d9b4b9

Please sign in to comment.