File tree Expand file tree Collapse file tree 4 files changed +18
-2
lines changed
main/java/io/zenwave360/jsonrefparser
test/java/io/zenwave360/jsonrefparser Expand file tree Collapse file tree 4 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,12 @@ public class $RefParser {
8585 if (file != null ) {
8686 refs = new $Refs (Parser .parse (file ), uri );
8787 } 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+ }
8994 } else {
9095 refs = new $Refs (Parser .parse (json ));
9196 }
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ public static ExtendedJsonContext parse(URI uri) throws IOException {
4747 return parse (inputStream , uri );
4848 }
4949 }
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
5151 try (var inputStream = new FileInputStream (new File (uri ))) {
5252 return parse (inputStream , uri );
5353 }
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ public String resolve($Ref $ref) {
5757 throw new RuntimeException (e );
5858 }
5959 }
60+
6061 protected String downloadUrlToString (String url , List <AuthenticationValue > auths ) throws Exception {
6162 InputStream is = null ;
6263 BufferedReader br = null ;
Original file line number Diff line number Diff line change @@ -166,6 +166,16 @@ public void testDereferenceAndMergeAllOf() throws IOException {
166166 assertNoRefs (refs .schema ());
167167 }
168168
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+
169179 @ Test
170180 public void testDereferenceAndMerge_MultipleAllOf () throws IOException {
171181 File file = new File ("src/test/resources/asyncapi/multiple-allOf.yml" );
You can’t perform that action at this time.
0 commit comments