diff --git a/openapi-meta/src/main/java/com/networknt/openapi/OpenApiHelper.java b/openapi-meta/src/main/java/com/networknt/openapi/OpenApiHelper.java index b81f36b3..eabe3831 100644 --- a/openapi-meta/src/main/java/com/networknt/openapi/OpenApiHelper.java +++ b/openapi-meta/src/main/java/com/networknt/openapi/OpenApiHelper.java @@ -100,14 +100,18 @@ private static String getOAuth2Name() { } private static String getBasePath() { + String basePath = ""; - Server server = openApi3.getServer(0); - String url = server.getUrl(); - if(url != null) { + String url = null; + if (openApi3.getServers().size() > 0) { + Server server = openApi3.getServer(0); + url = server.getUrl(); + } + if (url != null) { // find "://" index int protocolIndex = url.indexOf("://"); int pathIndex = url.indexOf('/', protocolIndex + 3); - if(pathIndex > 0) { + if (pathIndex > 0) { basePath = url.substring(pathIndex); } }