11package kgu .developers .api .config ;
22
3- import static java .lang .String .format ;
4- import static org .springframework .security .config .Elements .JWT ;
5-
6- import java .util .Arrays ;
7- import java .util .HashMap ;
8- import java .util .List ;
9- import java .util .Map ;
10- import java .util .stream .Collectors ;
11-
12-
13- import org .springframework .beans .factory .annotation .Value ;
14- import org .springframework .context .annotation .Bean ;
15- import org .springframework .context .annotation .Configuration ;
16- import org .springframework .core .env .Environment ;
17-
183import io .swagger .v3 .oas .models .Components ;
194import io .swagger .v3 .oas .models .OpenAPI ;
205import io .swagger .v3 .oas .models .info .Info ;
238import io .swagger .v3 .oas .models .servers .Server ;
249import jakarta .annotation .PostConstruct ;
2510import lombok .RequiredArgsConstructor ;
11+ import org .springframework .beans .factory .annotation .Value ;
12+ import org .springframework .context .annotation .Bean ;
13+ import org .springframework .context .annotation .Configuration ;
14+ import org .springframework .core .env .Environment ;
15+
16+ import java .util .Arrays ;
17+ import java .util .HashMap ;
18+ import java .util .List ;
19+ import java .util .Map ;
20+ import java .util .stream .Collectors ;
21+
22+ import static java .lang .String .format ;
23+ import static org .springframework .security .config .Elements .JWT ;
2624
2725@ Configuration
2826@ RequiredArgsConstructor
@@ -39,6 +37,9 @@ public class SwaggerConfig {
3937 @ Value ("${profiles.admin-api-port}" )
4038 private int adminApiPort ;
4139
40+ @ Value ("${profiles.auth-api-port}" )
41+ private int authApiPort ;
42+
4243 private final Map <String , Map <String , Object >> profileServerConfig = new HashMap <>();
4344
4445 @ PostConstruct
@@ -96,16 +97,26 @@ private SecurityScheme securityScheme() {
9697 private String getDescription () {
9798 String activeProfile = getActiveProfile ();
9899 return format ("""
99- AI 컴퓨터공학부 커뮤니티, AICS-HOME API 입니다.\n \n
100- 로그인 API를 통해 액세스 토큰을 발급 받고 헤더에 값을 넣어주세요 . \n \n
101- 별다른 절차 없이 API를 사용하실 수 있습니다.\n \n
102-
103- 관리자 API 문서는 다음 링크에서 확인하실 수 있습니다.\n
104- <ul>
105- <li>AICS-HOME ADMIN API : <a href="%s" target="_blank">%s</a></li>
106- </ul>
107- """ ,
108- getAdminSwaggerByProfile (activeProfile ), getAdminSwaggerByProfile (activeProfile )
100+ AI 컴퓨터공학부 커뮤니티 관리자, AICS-HOME ADMIN API 입니다.
101+
102+ 로그인 API를 통해 액세스 토큰을 발급 받고 헤더에 값을 넣어주세요.
103+
104+ 별다른 절차 없이 API를 사용하실 수 있습니다.
105+
106+ 관리자 API 문서는 다음 링크에서 확인하실 수 있습니다.
107+ <ul>
108+ <li>AICS-HOME ADMIN API : <a href="%s" target="_blank">%s</a></li>
109+ </ul>
110+
111+ 인증 인가 API 문서는 다음 링크에서 확인하실 수 있습니다.
112+ <ul>
113+ <li>AICS-HOME AUTH API : <a href="%s" target="_blank">%s</a></li>
114+ </ul>
115+ """ ,
116+ getAdminSwaggerByProfile (activeProfile ),
117+ getAdminSwaggerByProfile (activeProfile ),
118+ getAuthSwaggerByProfile (activeProfile ),
119+ getAuthSwaggerByProfile (activeProfile )
109120 );
110121 }
111122
@@ -114,6 +125,11 @@ private String getAdminSwaggerByProfile(String profile) {
114125 return url + ":" + adminApiPort + "/swagger-ui/index.html" ;
115126 }
116127
128+ private String getAuthSwaggerByProfile (String profile ) {
129+ String url = (String ) profileServerConfig .get (profile ).get ("url" );
130+ return url + ":" + authApiPort + "/swagger-ui/index.html" ;
131+ }
132+
117133 private String getActiveProfile () {
118134 return Arrays .stream (environment .getActiveProfiles ())
119135 .findFirst ()
0 commit comments