From d9babf9bf611d9b9e70249e0ad7be24f2674c6e0 Mon Sep 17 00:00:00 2001 From: rathnapandi Date: Thu, 7 Mar 2024 23:00:57 -0700 Subject: [PATCH] - issue #460 --- .github/workflows/integration-test.yml | 2 +- .../api/specification/OAS3xSpecification.java | 26 +++++++------------ .../apiimport/APIImportConfigAdapter.java | 1 + 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 408174369..f20e363c5 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -8,7 +8,7 @@ env: CACHE_FILE_APIM: api-manager_7_7_20240228.cache.tar CACHE_FILE_CASSANDRA: cassandra_4_0_11.cache.tar FED_FILE: swagger-promote-7.7-20240228.fed - LOG_LEVEL: debug + LOG_LEVEL: info jobs: build: diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/OAS3xSpecification.java b/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/OAS3xSpecification.java index 2df0de269..8d30b56b3 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/OAS3xSpecification.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/OAS3xSpecification.java @@ -93,22 +93,16 @@ public void configureBasePath(String backendBasePath, API api) throws AppExcepti try { if (openApiNode.has(SERVERS)) { ArrayNode servers = (ArrayNode) openApiNode.get(SERVERS); - if (!servers.isEmpty()) { - // Remove remaining server nodes as currently not handling multiple URLs - for (int i = 1; i < servers.size(); i++) { - servers.remove(i); - } - if (backendBasePath != null && !backendBasePath.contains("${env")) { // issue #332 - JsonNode server = servers.get(0); - JsonNode urlJsonNode = server.get("url"); - if (urlJsonNode != null) { - String serverUrl = urlJsonNode.asText(); - if (CoreParameters.getInstance().isOverrideSpecBasePath()) { - overrideServerSection(backendBasePath); // override openapi url with backendBaseapath - } else if (!serverUrl.startsWith("http")) { // If url does not have hostname, add hostname from backendBasepath - LOG.info("servers.url does not contain host name hence updating host value from backendBasepath : {}", backendBasePath); - updateServerSection(backendBasePath, serverUrl); - } + if (backendBasePath != null && !backendBasePath.contains("${env")) { // issue #332 + JsonNode server = servers.get(0); + JsonNode urlJsonNode = server.get("url"); + if (urlJsonNode != null) { + String serverUrl = urlJsonNode.asText(); + if (CoreParameters.getInstance().isOverrideSpecBasePath()) { + overrideServerSection(backendBasePath); // override openapi url with backendBaseapath + } else if (!serverUrl.startsWith("http")) { // If url does not have hostname, add hostname from backendBasepath + LOG.info("servers.url does not contain host name hence updating host value from backendBasepath : {}", backendBasePath); + updateServerSection(backendBasePath, serverUrl); } } } diff --git a/modules/apis/src/main/java/com/axway/apim/apiimport/APIImportConfigAdapter.java b/modules/apis/src/main/java/com/axway/apim/apiimport/APIImportConfigAdapter.java index 4d9cbb566..e759eb880 100644 --- a/modules/apis/src/main/java/com/axway/apim/apiimport/APIImportConfigAdapter.java +++ b/modules/apis/src/main/java/com/axway/apim/apiimport/APIImportConfigAdapter.java @@ -193,6 +193,7 @@ private void addAPISpecification(API apiConfig) throws IOException { } else { throw new AppException("No API Specification configured", ErrorCode.NO_API_DEFINITION_CONFIGURED); } + apiSpecification.configureBasePath(((DesiredAPI) apiConfig).getBackendBasepath(), apiConfig); apiConfig.setApiDefinition(apiSpecification); }