Added support for jar: URLs to readContentFromLocation(String,List<AuthorizationValue> auth).
@@ -15,6 +15,7 @@ import io.swagger.v3.parser.util.InlineModelResolver;
import io.swagger.v3.parser.util.OpenAPIDeserializer;
import io.swagger.v3.parser.util.RemoteUrl;
import io.swagger.v3.parser.util.ResolverFully;
+import java.io.InputStream;
import java.net.URI;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
@@ -28,6 +29,7 @@ import java.util.Objects;
import java.util.ServiceLoader;
import javax.net.ssl.SSLHandshakeException;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -219,6 +221,9 @@ public class OpenAPIV3Parser implements SwaggerParserExtension {
try {
if (adjustedLocation.toLowerCase().startsWith("http")) {
return RemoteUrl.urlToString(adjustedLocation, auth);
+ } else if (adjustedLocation.toLowerCase().startsWith("jar:")) {
+ final InputStream in = new URI(adjustedLocation).toURL().openStream();
+ return IOUtils.toString(in, encoding);
} else {
final String fileScheme = "file:";
final Path path = adjustedLocation.toLowerCase().startsWith(fileScheme) ?
