Skip to content

Commit 993b837

Browse files
authored
Merge pull request #195 from overture-stack/feat/custom-swagger-servers
add ability to customize server url
2 parents 556bf28 + f3dc941 commit 993b837

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

maestro-app/src/main/java/bio/overture/maestro/app/infra/config/RootConfiguration.java

+14
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,18 @@
2929
import bio.overture.maestro.app.infra.config.properties.PropertiesConfig;
3030
import bio.overture.maestro.domain.api.DomainApiConfig;
3131
import com.fasterxml.jackson.databind.ObjectMapper;
32+
import io.swagger.v3.oas.models.OpenAPI;
33+
import io.swagger.v3.oas.models.servers.Server;
34+
import org.springframework.beans.factory.annotation.Value;
35+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
3236
import org.springframework.context.annotation.Bean;
3337
import org.springframework.context.annotation.Configuration;
3438
import org.springframework.context.annotation.Import;
3539
import org.springframework.context.annotation.Primary;
3640
import org.springframework.web.reactive.function.client.WebClient;
3741

42+
import java.util.List;
43+
3844
/** Aggregates all configuration in one place */
3945
@Configuration
4046
@Import({
@@ -97,4 +103,12 @@ class WebConfig {
97103
public ObjectMapper objectMapper() {
98104
return new ObjectMapper();
99105
}
106+
107+
@Bean
108+
@ConditionalOnProperty(name = "springdoc.serverOverride.enabled", havingValue = "true")
109+
public OpenAPI maestroOpenApi(@Value("${springdoc.serverOverride.value}") String serverOverride) {
110+
return new OpenAPI()
111+
.servers(List.of(new Server().url(serverOverride)));
112+
}
113+
100114
}

maestro-app/src/main/resources/config/application.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,13 @@ spring:
172172
maxAttempts: 1
173173

174174
springdoc:
175+
## The reason this was added to support reverse proxy url rewrites like: http://xyz.com/maestro
176+
## otherwise the swagger urls will not be sent to the correct url since swagger ui depends
177+
## on the server definition and springdoc needs forward headers to be enabled by spring
178+
## enabling forward headers in maestro caused it to conflict with disabling kafka
179+
## and forced an autoconfigure for kafka client.
180+
serverOverride:
181+
enabled: false
182+
value: http://localhost:11235/custom
175183
swagger-ui:
176-
path: /api-docs
184+
path: /api-docs

0 commit comments

Comments
 (0)