@@ -43,25 +43,28 @@ public static void withResourceClassLoader(ClassLoader resourceClassLoader) {
43
43
44
44
public static ExtendedJsonContext parse (URI uri ) throws IOException {
45
45
if ("classpath" .contentEquals (uri .getScheme ())) {
46
- return parse (resourceClassLoader .getResourceAsStream (uri .getPath ().replaceFirst ("^/" , "" )));
46
+ return parse (resourceClassLoader .getResourceAsStream (uri .getPath ().replaceFirst ("^/" , "" )), uri );
47
47
}
48
48
// TODO: it does not support yet parsing http/https files directly
49
- return parse (new FileInputStream (new File (uri )));
49
+ return parse (new FileInputStream (new File (uri )), uri );
50
50
}
51
51
52
52
public static ExtendedJsonContext parse (File file ) throws IOException {
53
- return parse (new FileInputStream (file ));
53
+ return parse (new FileInputStream (file ), file );
54
54
}
55
55
56
56
public static ExtendedJsonContext parse (String content ) {
57
57
try {
58
- return parse (new ByteArrayInputStream (content .getBytes ()));
58
+ return parse (new ByteArrayInputStream (content .getBytes ()), "string" );
59
59
} catch (IOException e ) {
60
60
throw new RuntimeException (e );
61
61
}
62
62
}
63
63
64
- public static ExtendedJsonContext parse (InputStream inputStream ) throws IOException {
64
+ public static ExtendedJsonContext parse (InputStream inputStream , Object source ) throws IOException {
65
+ if (inputStream == null ) {
66
+ throw new IllegalArgumentException ("$RefParser.parse(): InputStream not found [" + source + "]" );
67
+ }
65
68
ObjectMapper mapper = new ObjectMapper (new CustomYAMLFactory ());
66
69
mapper .configure (DeserializationFeature .FAIL_ON_UNKNOWN_PROPERTIES , false );
67
70
mapper .configure (SerializationFeature .FAIL_ON_EMPTY_BEANS , false );
0 commit comments