Skip to content

Commit e22e55a

Browse files
authored
Merge pull request #714 from overture-stack/rc/4.5.0
rc 4.5.0 Configurable swagger to run behind reverse proxy
2 parents 52fe057 + 295e8f6 commit e22e55a

File tree

7 files changed

+31
-10
lines changed

7 files changed

+31
-10
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<groupId>bio.overture</groupId>
2222
<artifactId>song</artifactId>
2323
<packaging>pom</packaging>
24-
<version>4.4.0</version>
24+
<version>4.5.0</version>
2525
<modules>
2626
<module>song-core</module>
2727
<module>song-java-sdk</module>

song-client/pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<parent>
1919
<artifactId>song</artifactId>
2020
<groupId>bio.overture</groupId>
21-
<version>4.4.0</version>
21+
<version>4.5.0</version>
2222
</parent>
2323
<modelVersion>4.0.0</modelVersion>
2424

@@ -35,12 +35,12 @@
3535
<dependency>
3636
<groupId>bio.overture</groupId>
3737
<artifactId>song-java-sdk</artifactId>
38-
<version>4.4.0</version>
38+
<version>4.5.0</version>
3939
</dependency>
4040
<dependency>
4141
<groupId>bio.overture</groupId>
4242
<artifactId>song-core</artifactId>
43-
<version>4.4.0</version>
43+
<version>4.5.0</version>
4444
</dependency>
4545

4646
<!-- CLI -->

song-core/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<artifactId>song</artifactId>
2121
<groupId>bio.overture</groupId>
22-
<version>4.4.0</version>
22+
<version>4.5.0</version>
2323
</parent>
2424
<modelVersion>4.0.0</modelVersion>
2525

song-java-sdk/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<parent>
1919
<artifactId>song</artifactId>
2020
<groupId>bio.overture</groupId>
21-
<version>4.4.0</version>
21+
<version>4.5.0</version>
2222
</parent>
2323
<modelVersion>4.0.0</modelVersion>
2424

song-server/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<artifactId>song</artifactId>
2121
<groupId>bio.overture</groupId>
22-
<version>4.4.0</version>
22+
<version>4.5.0</version>
2323
</parent>
2424
<modelVersion>4.0.0</modelVersion>
2525

@@ -37,7 +37,7 @@
3737
<dependency>
3838
<groupId>bio.overture</groupId>
3939
<artifactId>song-core</artifactId>
40-
<version>4.4.0</version>
40+
<version>4.5.0</version>
4141
</dependency>
4242

4343
<!-- Spring -->

song-server/src/main/java/bio/overture/song/server/config/SwaggerConfig.java

+18-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import springfox.documentation.builders.ApiInfoBuilder;
2828
import springfox.documentation.service.ApiInfo;
2929
import springfox.documentation.spi.DocumentationType;
30+
import springfox.documentation.spring.web.paths.RelativePathProvider;
3031
import springfox.documentation.spring.web.plugins.Docket;
3132
import springfox.documentation.swagger.web.UiConfiguration;
3233
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@@ -42,15 +43,30 @@ public class SwaggerConfig {
4243
@Getter
4344
private String alternateSwaggerUrl;
4445

46+
// default is empty
47+
@Value("${swagger.host:}")
48+
private String swaggerHost;
49+
50+
// default is empty
51+
@Value("${swagger.basePath:}")
52+
private String basePath;
53+
4554
@Bean
4655
public Docket api() {
4756
return new Docket(DocumentationType.SWAGGER_2)
4857
.apiInfo(apiInfo())
4958
.select()
5059
.apis(basePackage("bio.overture.song.server.controller"))
51-
.paths(any())
5260
.build()
53-
.pathMapping("/");
61+
.host(swaggerHost)
62+
.pathProvider(
63+
new RelativePathProvider(null) {
64+
@Override
65+
public String getApplicationBasePath() {
66+
return basePath;
67+
}
68+
}
69+
);
5470
}
5571

5672
@Bean

song-server/src/main/resources/application.yml

+5
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ management:
8080

8181
swagger:
8282
alternateUrl: "/api-docs"
83+
# host and base url are needed if you run song behind a reverse proxy
84+
# and rewrite the url eg: http://mydomain.com/song/swagger-ui.html
85+
# in this case host = mydomain.com, baseUrl = /song
86+
host: ""
87+
basePath: ""
8388

8489
security.basic.enabled: false
8590

0 commit comments

Comments
 (0)