Skip to content

Commit e177bb2

Browse files
author
Robert Diers
committed
using relative path for swagger ui
1 parent 07ffc3a commit e177bb2

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.opentesting.util;
2+
3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.context.annotation.Bean;
5+
import org.springframework.context.annotation.Configuration;
6+
7+
import io.swagger.v3.oas.models.OpenAPI;
8+
import io.swagger.v3.oas.models.servers.Server;
9+
10+
/**
11+
* fix https server URL in swagger when using a dispatcher
12+
*/
13+
@Configuration
14+
public class OpenApiConfig {
15+
16+
@Bean
17+
public OpenAPI openAPI(@Value("${server.servlet.context-path}") String contextPath) {
18+
return new OpenAPI()
19+
.addServersItem(new Server().url(contextPath));
20+
}
21+
22+
}

src/main/resources/application.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ app:
2323

2424
server:
2525
port: 50000
26+
servlet:
27+
context-path: /
2628
shutdown: graceful
2729

2830
spring:

src/test/resources/application.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ app:
1616

1717
server:
1818
port: 50000
19+
servlet:
20+
context-path: /
1921
shutdown: graceful
2022

2123
spring:

0 commit comments

Comments
 (0)