File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
src/main/java/com/book/backend/global Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -34,9 +34,6 @@ dependencies {
34
34
// swagger
35
35
implementation ' org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'
36
36
37
- // swagger
38
- implementation ' org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'
39
-
40
37
// modelmapper
41
38
implementation ' org.modelmapper:modelmapper:3.1.0'
42
39
Original file line number Diff line number Diff line change 1
1
package com .book .backend .global ;
2
2
3
3
import io .swagger .v3 .oas .annotations .info .Info ;
4
+ import io .swagger .v3 .oas .models .Components ;
5
+ import io .swagger .v3 .oas .models .OpenAPI ;
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 ;
4
9
import org .springframework .context .annotation .Configuration ;
5
10
import io .swagger .v3 .oas .annotations .OpenAPIDefinition ;
6
11
7
12
@ OpenAPIDefinition (info = @ Info (title = "북토크 서버 API" , description = "설명" , version = "1.0" )) // 상단 제목 커스텀
8
13
@ Configuration
9
- public class SwaggerConfig { }
14
+ public class SwaggerConfig {
15
+
16
+ @ Bean
17
+ public OpenAPI api () {
18
+ SecurityScheme apiKey = new SecurityScheme ()
19
+ .type (SecurityScheme .Type .HTTP )
20
+ .in (SecurityScheme .In .HEADER )
21
+ .name ("Authorization" )
22
+ .scheme ("bearer" )
23
+ .bearerFormat ("JWT" );
24
+
25
+ SecurityRequirement securityRequirement = new SecurityRequirement ()
26
+ .addList ("Bearer Token" );
27
+
28
+ return new OpenAPI ()
29
+ .components (new Components ().addSecuritySchemes ("Bearer Token" , apiKey ))
30
+ .addSecurityItem (securityRequirement );
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments