@Test public void shouldGetHostFromServerDefinition() { Assertions.assertThat(Oas30ModelHelper.getHost(getOpenApiDocWithUrl(null))).isNull(); Assertions.assertThat(Oas30ModelHelper.getHost(getOpenApiDocWithUrl(""))).isNull(); Assertions.assertThat(Oas30ModelHelper.getHost(getOpenApiDocWithUrl("http: Assertions.assertThat(Oas30ModelHelper.getHost(getOpenApiDocWithUrl("http: Assertions.assertThat(Oas30ModelHelper.getHost(getOpenApiDocWithUrl("https: Assertions.assertThat(Oas30ModelHelper.getHost(getOpenApiDocWithUrl("/v1"))).isNull(); Assertions.assertThat(Oas30ModelHelper.getHost(getOpenApiDocWithUrl("http is awesome!"))).isNull(); Assertions.assertThat(Oas30ModelHelper.getHost(getOpenApiDocWithUrl("Something completely different"))).isNull(); Assertions.assertThat(Oas30ModelHelper.getHost(getOpenApiDocWithUrl("{scheme}: Assertions.assertThat(Oas30ModelHelper.getHost(getOpenApiDocWithUrl("{scheme}: variable("scheme", "http", "https"), variable("host", "syndesis.io"), variable("basePath", "v1", "v2")))).isEqualTo("syndesis.io"); }
static String getHost(Oas30Document openApiDoc) { if (openApiDoc.servers == null || openApiDoc.servers.isEmpty()) { return null; } String serverUrl = resolveUrl(openApiDoc.servers.get(0)); if (serverUrl.startsWith(HTTP)) { try { return new URL(serverUrl).getHost(); } catch (MalformedURLException e) { LOG.warn(String.format("Unable to determine base path from server URL: %s", serverUrl)); } } return null; }
Oas30ModelHelper { static String getHost(Oas30Document openApiDoc) { if (openApiDoc.servers == null || openApiDoc.servers.isEmpty()) { return null; } String serverUrl = resolveUrl(openApiDoc.servers.get(0)); if (serverUrl.startsWith(HTTP)) { try { return new URL(serverUrl).getHost(); } catch (MalformedURLException e) { LOG.warn(String.format("Unable to determine base path from server URL: %s", serverUrl)); } } return null; } }
Oas30ModelHelper { static String getHost(Oas30Document openApiDoc) { if (openApiDoc.servers == null || openApiDoc.servers.isEmpty()) { return null; } String serverUrl = resolveUrl(openApiDoc.servers.get(0)); if (serverUrl.startsWith(HTTP)) { try { return new URL(serverUrl).getHost(); } catch (MalformedURLException e) { LOG.warn(String.format("Unable to determine base path from server URL: %s", serverUrl)); } } return null; } private  Oas30ModelHelper(); }
Oas30ModelHelper { static String getHost(Oas30Document openApiDoc) { if (openApiDoc.servers == null || openApiDoc.servers.isEmpty()) { return null; } String serverUrl = resolveUrl(openApiDoc.servers.get(0)); if (serverUrl.startsWith(HTTP)) { try { return new URL(serverUrl).getHost(); } catch (MalformedURLException e) { LOG.warn(String.format("Unable to determine base path from server URL: %s", serverUrl)); } } return null; } private  Oas30ModelHelper();  }
Oas30ModelHelper { static String getHost(Oas30Document openApiDoc) { if (openApiDoc.servers == null || openApiDoc.servers.isEmpty()) { return null; } String serverUrl = resolveUrl(openApiDoc.servers.get(0)); if (serverUrl.startsWith(HTTP)) { try { return new URL(serverUrl).getHost(); } catch (MalformedURLException e) { LOG.warn(String.format("Unable to determine base path from server URL: %s", serverUrl)); } } return null; } private  Oas30ModelHelper();  static final String HTTP; }