Skip to content

Commit 884b47a

Browse files
committed
Avoid error when doc path has spaces and server is relative
1 parent f5cf9cd commit 884b47a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -701,10 +701,14 @@ public Server getServer(ObjectNode obj, String location, ParseResult result, Str
701701
value = absURI.resolve(new URI(value)).toString();
702702
}
703703
} catch (URISyntaxException e) {
704-
String variable = value.substring(value.indexOf("{") + 1, value.indexOf("}"));
705-
if (server.getVariables() != null) {
706-
if (!server.getVariables().containsKey(variable)) {
707-
result.warning(location, "invalid url : " + value);
704+
final int openBrace = value.indexOf("{");
705+
final int closeBrace = value.indexOf("}");
706+
if (openBrace > -1 && closeBrace > -1) {
707+
String variable = value.substring(openBrace + 1, closeBrace);
708+
if (server.getVariables() != null) {
709+
if (!server.getVariables().containsKey(variable)) {
710+
result.warning(location, "invalid url : " + value);
711+
}
708712
}
709713
}
710714
}

0 commit comments

Comments
 (0)