Skip to content

Commit 5424df1

Browse files
committed
added fix for issue 1236
1 parent af7ee43 commit 5424df1

File tree

6 files changed

+4285
-0
lines changed

6 files changed

+4285
-0
lines changed

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,12 @@ public Server getServer(ObjectNode obj, String location, ParseResult result, Str
413413
if("http".equals(absURI.getScheme()) || "https".equals(absURI.getScheme())){
414414
value = absURI.resolve(new URI(value)).toString();
415415
}
416+
else {
417+
result.warning(location," invalid url : "+value);
418+
}
419+
416420
} catch (URISyntaxException e) {
421+
result.warning(location,"invalid url : "+value);
417422
e.printStackTrace();
418423
}
419424

modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,4 +2192,14 @@ public void testParseOptionsSkipMatchesTrue() {
21922192
private static int getDynamicPort() {
21932193
return new Random().ints(10000, 20000).findFirst().getAsInt();
21942194
}
2195+
2196+
@Test
2197+
public void testIssue1236() {
2198+
final ParseOptions options = new ParseOptions();
2199+
options.setResolve(true);
2200+
2201+
SwaggerParseResult result = new OpenAPIV3Parser()
2202+
.readLocation("src/test/resources/issue-1236/petstore.json",null,options);
2203+
assertEquals(result.getMessages().get(0),"attribute .servers. invalid url : /te st/sample.yaml");
2204+
}
21952205
}

0 commit comments

Comments
 (0)