From fcd3d0d446f2bc026076caf26a7d16251f78fa6f Mon Sep 17 00:00:00 2001
From: Lawrence Chan <lach@microsoft.com>
Date: Fri, 22 Dec 2023 12:07:58 -0800
Subject: [PATCH 1/2] Use full URL instead of relative path

---
 .../osdu/wd/core/swagger/SwaggerDocumentationConfig.java      | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/wd-core/src/main/java/org/opengroup/osdu/wd/core/swagger/SwaggerDocumentationConfig.java b/wd-core/src/main/java/org/opengroup/osdu/wd/core/swagger/SwaggerDocumentationConfig.java
index 07e532ca..5d2b2eb2 100644
--- a/wd-core/src/main/java/org/opengroup/osdu/wd/core/swagger/SwaggerDocumentationConfig.java
+++ b/wd-core/src/main/java/org/opengroup/osdu/wd/core/swagger/SwaggerDocumentationConfig.java
@@ -19,21 +19,17 @@ import io.swagger.v3.oas.models.OpenAPI;
 import io.swagger.v3.oas.models.info.Info;
 import io.swagger.v3.oas.models.security.SecurityRequirement;
 import io.swagger.v3.oas.models.security.SecurityScheme;
-import io.swagger.v3.oas.models.servers.Server;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Profile;
 
 import javax.servlet.ServletContext;
-import java.util.Collections;
 @Configuration
 @Profile("!noswagger")
 public class SwaggerDocumentationConfig {
     @Bean
     public OpenAPI openApi(ServletContext servletContext) {
-        Server server = new Server().url(servletContext.getContextPath());
         return new OpenAPI()
-            .servers(Collections.singletonList(server))
             .info(new Info()
                       .description("API Documetation")
                       .title("Well Delivery Service")
-- 
GitLab


From 1e9faf21f7742a51e19640745a8b5ebae8dc8d9c Mon Sep 17 00:00:00 2001
From: Anthony Ittiyera Vazhappilly <avazhappilly@microsoft.com>
Date: Sun, 28 Jan 2024 15:00:44 -0800
Subject: [PATCH 2/2] create feature flag to toggle
 enableFullSwaggerUrlProperty

---
 .../src/main/resources/application.properties |  3 ++
 .../swagger/SwaggerDocumentationConfig.java   | 48 ++++++++++++-------
 2 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/provider/wd-azure/src/main/resources/application.properties b/provider/wd-azure/src/main/resources/application.properties
index 600979f2..73b8278c 100644
--- a/provider/wd-azure/src/main/resources/application.properties
+++ b/provider/wd-azure/src/main/resources/application.properties
@@ -31,3 +31,6 @@ azure.cosmosdb.database=well-delivery
 #mongodb
 mongodb.database=well-delivery
 mongodb.api.cosmosdb=true
+
+# To enable the full server path url in OpenAPI Swagger
+api.server.fullUrl.enabled=${swaggerFullUrlEnabled:true}
\ No newline at end of file
diff --git a/wd-core/src/main/java/org/opengroup/osdu/wd/core/swagger/SwaggerDocumentationConfig.java b/wd-core/src/main/java/org/opengroup/osdu/wd/core/swagger/SwaggerDocumentationConfig.java
index 5d2b2eb2..df690595 100644
--- a/wd-core/src/main/java/org/opengroup/osdu/wd/core/swagger/SwaggerDocumentationConfig.java
+++ b/wd-core/src/main/java/org/opengroup/osdu/wd/core/swagger/SwaggerDocumentationConfig.java
@@ -19,31 +19,47 @@ import io.swagger.v3.oas.models.OpenAPI;
 import io.swagger.v3.oas.models.info.Info;
 import io.swagger.v3.oas.models.security.SecurityRequirement;
 import io.swagger.v3.oas.models.security.SecurityScheme;
+import io.swagger.v3.oas.models.servers.Server;
+
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Profile;
 
+import java.util.Collections;
+
 import javax.servlet.ServletContext;
+
 @Configuration
 @Profile("!noswagger")
 public class SwaggerDocumentationConfig {
+    
+    @Value("${api.server.fullUrl.enabled:false}")
+    private boolean isServerFullUrlEnabled;
+
     @Bean
     public OpenAPI openApi(ServletContext servletContext) {
-        return new OpenAPI()
-            .info(new Info()
-                      .description("API Documetation")
-                      .title("Well Delivery Service")
-                      .version("1.0"))
-            .components(new Components()
-                            .addSecuritySchemes("Authorization",
-                                                new SecurityScheme()
-                                                    .type(SecurityScheme.Type.HTTP)
-                                                    .scheme("bearer")
-                                                    .bearerFormat("Authorization")
-                                                    .in(SecurityScheme.In.HEADER)
-                                                    .name("Authorization")))
-            .addSecurityItem(
-                new SecurityRequirement()
-                    .addList("Authorization"));
+        Server server = new Server().url(servletContext.getContextPath());
+        OpenAPI openAPI = new OpenAPI()
+                .info(new Info()
+                        .description("API Documetation")
+                        .title("Well Delivery Service")
+                        .version("1.0"))
+                .components(new Components()
+                        .addSecuritySchemes("Authorization",
+                                new SecurityScheme()
+                                        .type(SecurityScheme.Type.HTTP)
+                                        .scheme("bearer")
+                                        .bearerFormat("Authorization")
+                                        .in(SecurityScheme.In.HEADER)
+                                        .name("Authorization")))
+                .addSecurityItem(
+                        new SecurityRequirement()
+                                .addList("Authorization"));
+        if (isServerFullUrlEnabled)
+            return openAPI;
+        return openAPI
+                .servers(Collections.singletonList(server));
+
     }
 }
-- 
GitLab