Description
While using swagger-parser-v3 with Spring Boot 4, relative $ref resolution fails when OpenAPI files are loaded from inside a fat/uber JAR.
This issue appears to be caused by RefUtils.readAll(Path path) method:
private static String readAll(Path path) throws IOException {
try (InputStream inputStream = new FileInputStream(path.toFile())) {
return IOUtils.toString(inputStream, UTF_8);
}
}
Here path.toFile() only works with the default filesystem and fails for paths backed by non-default filesystem providers e.g ZipPath provider
Proposed solution
Replace path.toFile() with Files.newInputStream(path) which is more robust and file system agnostic and will work with local file system as well as zip file system
private static String readAll(Path path) throws IOException {
try (InputStream inputStream = Files.newInputStream(path)) {
return IOUtils.toString(inputStream, UTF_8);
}
}
Affected Version
2.1.39