@Test public void testFindBasePath() { OpenApiEndpointSource source = new OpenApiEndpointSource(); String basePath = source.findBasePath(); Assert.assertEquals("/v1", basePath); }
public String findBasePath() { List<Server> servers = OpenApiHelper.openApi3.getServers(); if(servers.isEmpty()) { log.warn("No server found in OpenApi spec. Using empty base path for API."); return ""; } Server server = servers.get(0); String url = null; try { url = server.getUrl(); URL urlObj = new URL(url); String basePath = urlObj.getPath(); while (basePath.endsWith("/")) { basePath = basePath.substring(0, basePath.length() - 1); } return basePath; } catch (Exception e) { throw new RuntimeException("Malformed servers[0].url in OpenApi spec: " + url, e); } }
OpenApiEndpointSource implements EndpointSource { public String findBasePath() { List<Server> servers = OpenApiHelper.openApi3.getServers(); if(servers.isEmpty()) { log.warn("No server found in OpenApi spec. Using empty base path for API."); return ""; } Server server = servers.get(0); String url = null; try { url = server.getUrl(); URL urlObj = new URL(url); String basePath = urlObj.getPath(); while (basePath.endsWith("/")) { basePath = basePath.substring(0, basePath.length() - 1); } return basePath; } catch (Exception e) { throw new RuntimeException("Malformed servers[0].url in OpenApi spec: " + url, e); } } }
OpenApiEndpointSource implements EndpointSource { public String findBasePath() { List<Server> servers = OpenApiHelper.openApi3.getServers(); if(servers.isEmpty()) { log.warn("No server found in OpenApi spec. Using empty base path for API."); return ""; } Server server = servers.get(0); String url = null; try { url = server.getUrl(); URL urlObj = new URL(url); String basePath = urlObj.getPath(); while (basePath.endsWith("/")) { basePath = basePath.substring(0, basePath.length() - 1); } return basePath; } catch (Exception e) { throw new RuntimeException("Malformed servers[0].url in OpenApi spec: " + url, e); } }  }
OpenApiEndpointSource implements EndpointSource { public String findBasePath() { List<Server> servers = OpenApiHelper.openApi3.getServers(); if(servers.isEmpty()) { log.warn("No server found in OpenApi spec. Using empty base path for API."); return ""; } Server server = servers.get(0); String url = null; try { url = server.getUrl(); URL urlObj = new URL(url); String basePath = urlObj.getPath(); while (basePath.endsWith("/")) { basePath = basePath.substring(0, basePath.length() - 1); } return basePath; } catch (Exception e) { throw new RuntimeException("Malformed servers[0].url in OpenApi spec: " + url, e); } }  @Override Iterable<Endpoint> listEndpoints(); String findBasePath(); }
OpenApiEndpointSource implements EndpointSource { public String findBasePath() { List<Server> servers = OpenApiHelper.openApi3.getServers(); if(servers.isEmpty()) { log.warn("No server found in OpenApi spec. Using empty base path for API."); return ""; } Server server = servers.get(0); String url = null; try { url = server.getUrl(); URL urlObj = new URL(url); String basePath = urlObj.getPath(); while (basePath.endsWith("/")) { basePath = basePath.substring(0, basePath.length() - 1); } return basePath; } catch (Exception e) { throw new RuntimeException("Malformed servers[0].url in OpenApi spec: " + url, e); } }  @Override Iterable<Endpoint> listEndpoints(); String findBasePath();  }