File tree 4 files changed +18
-2
lines changed
main/java/io/zenwave360/jsonrefparser
test/java/io/zenwave360/jsonrefparser 4 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,12 @@ public class $RefParser {
85
85
if (file != null ) {
86
86
refs = new $Refs (Parser .parse (file ), uri );
87
87
} else if (uri != null ) {
88
- refs = new $Refs (Parser .parse (uri ), uri );
88
+ if (uri .getScheme () != null && ("http" .equals (uri .getScheme ()) || "https" .equals (uri .getScheme ()))) {
89
+ var text = this .resolvers .get (RefFormat .URL ).resolve ($Ref .of (uri .toURL ().toExternalForm (), uri ));
90
+ refs = new $Refs (Parser .parse (text ), uri );
91
+ } else {
92
+ refs = new $Refs (Parser .parse (uri ), uri );
93
+ }
89
94
} else {
90
95
refs = new $Refs (Parser .parse (json ));
91
96
}
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ public static ExtendedJsonContext parse(URI uri) throws IOException {
47
47
return parse (inputStream , uri );
48
48
}
49
49
}
50
- // TODO: it does not support yet parsing http/https files directly
50
+ // It does not support parsing http/https files directly: use `$RefParser(uri).parse()` instead
51
51
try (var inputStream = new FileInputStream (new File (uri ))) {
52
52
return parse (inputStream , uri );
53
53
}
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ public String resolve($Ref $ref) {
57
57
throw new RuntimeException (e );
58
58
}
59
59
}
60
+
60
61
protected String downloadUrlToString (String url , List <AuthenticationValue > auths ) throws Exception {
61
62
InputStream is = null ;
62
63
BufferedReader br = null ;
Original file line number Diff line number Diff line change @@ -166,6 +166,16 @@ public void testDereferenceAndMergeAllOf() throws IOException {
166
166
assertNoRefs (refs .schema ());
167
167
}
168
168
169
+ @ Test
170
+ public void testDereferenceAndMergeAllOfHttp () throws IOException {
171
+ var uri = URI .create ("https://raw.githubusercontent.com/ZenWave360/json-schema-ref-parser-jvm/refs/heads/main/src/test/resources/openapi/allOf.yml" );
172
+ $RefParser parser = new $RefParser (uri ).parse ();
173
+ $Refs refs = parser .dereference ().mergeAllOf ().getRefs ();
174
+ // Assert.assertFalse(refs.circular);
175
+ // System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(refs.schema()));
176
+ assertNoRefs (refs .schema ());
177
+ }
178
+
169
179
@ Test
170
180
public void testDereferenceAndMerge_MultipleAllOf () throws IOException {
171
181
File file = new File ("src/test/resources/asyncapi/multiple-allOf.yml" );
You can’t perform that action at this time.
0 commit comments