Skip to content

Commit ce0f975

Browse files
committed
feat: swagger https
1 parent 60dddb0 commit ce0f975

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/main/java/spring/memewikibe/config/SwaggerConfig.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,45 @@
22

33
import io.swagger.v3.oas.models.OpenAPI;
44
import io.swagger.v3.oas.models.info.Info;
5+
import io.swagger.v3.oas.models.servers.Server;
6+
import org.springframework.beans.factory.annotation.Value;
57
import org.springframework.context.annotation.Bean;
68
import org.springframework.context.annotation.Configuration;
79

10+
import java.util.List;
11+
812
@Configuration
913
public class SwaggerConfig {
1014

15+
@Value("${spring.profiles.active:local}")
16+
private String activeProfile;
17+
1118
@Bean
1219
public OpenAPI openAPI() {
13-
return new OpenAPI()
20+
OpenAPI openAPI = new OpenAPI()
1421
.info(new Info()
1522
.title("MemeWikiBE API")
1623
.version("v0.0.1")
1724
.description("MemeWikiBE API 명세서"));
25+
26+
if ("prod".equals(activeProfile)) {
27+
openAPI.servers(List.of(
28+
new Server()
29+
.url("https://meme-wiki.net")
30+
.description("Production Server (HTTPS)")
31+
));
32+
} else {
33+
openAPI.servers(List.of(
34+
new Server()
35+
.url("http://localhost:8080")
36+
.description("Local Development Server (HTTP)"),
37+
new Server()
38+
.url("https://localhost:8080")
39+
.description("Local Development Server (HTTPS)")
40+
));
41+
}
42+
43+
return openAPI;
1844
}
1945

2046
}

0 commit comments

Comments
 (0)