4
4
import org .apache .commons .lang3 .StringUtils ;
5
5
import org .springdoc .core .OpenAPIBuilder ;
6
6
import org .springdoc .core .SwaggerUiConfigProperties ;
7
+ import org .springframework .beans .factory .InitializingBean ;
7
8
import org .springframework .beans .factory .annotation .Autowired ;
8
9
import org .springframework .beans .factory .annotation .Value ;
9
10
import org .springframework .boot .autoconfigure .condition .ConditionalOnBean ;
15
16
import org .springframework .web .servlet .support .ServletUriComponentsBuilder ;
16
17
import org .springframework .web .util .UriComponentsBuilder ;
17
18
18
- import javax .annotation .PostConstruct ;
19
19
import javax .servlet .http .HttpServletRequest ;
20
20
import java .util .Map ;
21
21
26
26
@ Controller
27
27
@ ConditionalOnProperty (name = SPRINGDOC_SWAGGER_UI_ENABLED , matchIfMissing = true )
28
28
@ ConditionalOnBean (OpenAPIBuilder .class )
29
- class SwaggerWelcome {
29
+ class SwaggerWelcome implements InitializingBean {
30
30
31
31
@ Value (API_DOCS_URL )
32
32
private String apiDocsUrl ;
@@ -42,8 +42,13 @@ class SwaggerWelcome {
42
42
43
43
private String uiRootPath ;
44
44
45
- @ PostConstruct
46
- public void calculateUiRootPath () {
45
+
46
+ @ Override
47
+ public void afterPropertiesSet () {
48
+ calculateUiRootPath ();
49
+ }
50
+
51
+ private void calculateUiRootPath () {
47
52
StringBuilder sbUrl = new StringBuilder ();
48
53
if (StringUtils .isNotBlank (mvcServletPath ))
49
54
sbUrl .append (mvcServletPath );
@@ -95,4 +100,4 @@ private void buildConfigUrl(HttpServletRequest request) {
95
100
}
96
101
}
97
102
98
- }
103
+ }
0 commit comments