Skip to content

Commit 9eb797b

Browse files
committed
feat(swagger): 토큰 인증 추가
1 parent 7bbb7c1 commit 9eb797b

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.somemore.global.configure;
2+
3+
import io.swagger.v3.oas.models.Components;
4+
import io.swagger.v3.oas.models.OpenAPI;
5+
import io.swagger.v3.oas.models.info.Info;
6+
import io.swagger.v3.oas.models.security.SecurityRequirement;
7+
import io.swagger.v3.oas.models.security.SecurityScheme;
8+
import org.springframework.context.annotation.Bean;
9+
import org.springframework.context.annotation.Configuration;
10+
11+
@Configuration
12+
public class SwaggerConfig {
13+
14+
@Bean
15+
public OpenAPI customOpenAPI() {
16+
SecurityScheme securityScheme = new SecurityScheme()
17+
.type(SecurityScheme.Type.HTTP)
18+
.scheme("bearer")
19+
.bearerFormat("JWT")
20+
.description("JWT 토큰을 이용한 인증");
21+
22+
SecurityRequirement securityRequirement = new SecurityRequirement()
23+
.addList("AccessToken");
24+
25+
return new OpenAPI()
26+
.info(new Info()
27+
.title("Somemore API")
28+
.version("1.0")
29+
.description("Somemore swagger-ui 화면입니다.")
30+
)
31+
.components(new Components()
32+
.addSecuritySchemes("AccessToken", securityScheme)
33+
)
34+
.addSecurityItem(securityRequirement);
35+
}
36+
}

0 commit comments

Comments
 (0)