From 95732ab6f2ecc3f151f93e6152d09aef7e92569f Mon Sep 17 00:00:00 2001 From: gracekarina Date: Mon, 21 Sep 2020 15:53:07 -0500 Subject: [PATCH] adding redirect response codes to remote url --- .../main/java/io/swagger/v3/parser/util/RemoteUrl.java | 3 ++- .../src/test/resources/relativeTest.yaml | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 modules/swagger-parser-v3/src/test/resources/relativeTest.yaml diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/RemoteUrl.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/RemoteUrl.java index cc2e7dee76..74ad60eba1 100644 --- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/RemoteUrl.java +++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/RemoteUrl.java @@ -150,7 +150,8 @@ public static String urlToString(String url, List auths) thr conn.setRequestProperty("User-Agent", USER_AGENT_HEADER_VALUE); conn.connect(); url = ((HttpURLConnection) conn).getHeaderField("Location"); - } while (301 == ((HttpURLConnection) conn).getResponseCode()); + } while ((301 == ((HttpURLConnection) conn).getResponseCode())||(302 == ((HttpURLConnection) conn).getResponseCode()) + || (307 == ((HttpURLConnection) conn).getResponseCode())||(308 == ((HttpURLConnection) conn).getResponseCode())); InputStream in = conn.getInputStream(); StringBuilder contents = new StringBuilder(); diff --git a/modules/swagger-parser-v3/src/test/resources/relativeTest.yaml b/modules/swagger-parser-v3/src/test/resources/relativeTest.yaml new file mode 100644 index 0000000000..f443410244 --- /dev/null +++ b/modules/swagger-parser-v3/src/test/resources/relativeTest.yaml @@ -0,0 +1,10 @@ +RelativeObj: + type: object + properties: + lorem: + type: object + properties: + firstName: + type: string + lastName: + type: string \ No newline at end of file