|
|
@ -7,6 +7,7 @@ import io.swagger.v3.oas.models.info.Info;
|
|
|
|
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
|
|
|
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
|
|
|
import io.swagger.v3.oas.models.security.SecurityScheme;
|
|
|
|
import io.swagger.v3.oas.models.security.SecurityScheme;
|
|
|
|
import io.swagger.v3.oas.models.servers.Server;
|
|
|
|
import io.swagger.v3.oas.models.servers.Server;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import kr.xit.core.support.utils.Checks;
|
|
|
|
import kr.xit.core.support.utils.Checks;
|
|
|
@ -36,7 +37,7 @@ import org.springframework.context.annotation.Configuration;
|
|
|
|
@Configuration
|
|
|
|
@Configuration
|
|
|
|
public class SpringDocsConfig {
|
|
|
|
public class SpringDocsConfig {
|
|
|
|
@Value("${server.port}")
|
|
|
|
@Value("${server.port}")
|
|
|
|
private int SSL_PORT;
|
|
|
|
private int SERVER_PORT;
|
|
|
|
@Value("${server.http:0}")
|
|
|
|
@Value("${server.http:0}")
|
|
|
|
private int HTTP_PORT;
|
|
|
|
private int HTTP_PORT;
|
|
|
|
@Value("${app.swagger-url:}")
|
|
|
|
@Value("${app.swagger-url:}")
|
|
|
@ -58,8 +59,17 @@ public class SpringDocsConfig {
|
|
|
|
.email("admin@xit.co.kr"));
|
|
|
|
.email("admin@xit.co.kr"));
|
|
|
|
//.url("http://www.xerotech.co.kr/"));
|
|
|
|
//.url("http://www.xerotech.co.kr/"));
|
|
|
|
|
|
|
|
|
|
|
|
String url = Checks.isNotEmpty(swaggerUrl)? swaggerUrl : String.format("http://localhost:%d", HTTP_PORT != 0? HTTP_PORT: SSL_PORT);
|
|
|
|
// https enabled
|
|
|
|
List<Server> servers = Collections.singletonList(new Server().url(url).description(name + "(" + active + ")"));
|
|
|
|
List<Server> servers = new ArrayList<>();
|
|
|
|
|
|
|
|
if(HTTP_PORT != 0){
|
|
|
|
|
|
|
|
String httpsUrl = Checks.isNotEmpty(swaggerUrl)? swaggerUrl : String.format("https://localhost:%d", SERVER_PORT);
|
|
|
|
|
|
|
|
String httpUrl = Checks.isNotEmpty(swaggerUrl)? swaggerUrl : String.format("http://localhost:%d", HTTP_PORT);
|
|
|
|
|
|
|
|
servers.add(new Server().url(httpsUrl).description(name + "(" + active + ")"));
|
|
|
|
|
|
|
|
servers.add(new Server().url(httpUrl).description(name + "(" + active + ")"));
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
String httpUrl = Checks.isNotEmpty(swaggerUrl)? swaggerUrl : String.format("http://localhost:%d", SERVER_PORT);
|
|
|
|
|
|
|
|
servers.add(new Server().url(httpUrl).description(name + "(" + active + ")"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Security 스키마 설정
|
|
|
|
// Security 스키마 설정
|
|
|
|
SecurityScheme securityScheme = new SecurityScheme()
|
|
|
|
SecurityScheme securityScheme = new SecurityScheme()
|
|
|
@ -69,11 +79,13 @@ public class SpringDocsConfig {
|
|
|
|
.in(SecurityScheme.In.HEADER)
|
|
|
|
.in(SecurityScheme.In.HEADER)
|
|
|
|
// .name(HttpHeaders.AUTHORIZATION);
|
|
|
|
// .name(HttpHeaders.AUTHORIZATION);
|
|
|
|
.name("Authorization");
|
|
|
|
.name("Authorization");
|
|
|
|
|
|
|
|
|
|
|
|
SecurityRequirement securityRequirement = new SecurityRequirement().addList("bearerAuth");
|
|
|
|
SecurityRequirement securityRequirement = new SecurityRequirement().addList("bearerAuth");
|
|
|
|
|
|
|
|
|
|
|
|
return new OpenAPI()
|
|
|
|
return new OpenAPI()
|
|
|
|
// Security 인증 컴포넌트 설정
|
|
|
|
// Security 인증 컴포넌트 설정
|
|
|
|
.components(new Components().addSecuritySchemes("bearerAuth", securityScheme))
|
|
|
|
.components(new Components().addSecuritySchemes("bearerAuth", securityScheme))
|
|
|
|
|
|
|
|
.components(new Components().addSecuritySchemes("bearerAuth", securityScheme))
|
|
|
|
// API 마다 Security 인증 컴포넌트 설정
|
|
|
|
// API 마다 Security 인증 컴포넌트 설정
|
|
|
|
//.addSecurityItem(new SecurityRequirement().addList("JWT"))
|
|
|
|
//.addSecurityItem(new SecurityRequirement().addList("JWT"))
|
|
|
|
.security(Collections.singletonList(securityRequirement))
|
|
|
|
.security(Collections.singletonList(securityRequirement))
|
|
|
|