-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#56 add swagger header
- Loading branch information
Showing
2 changed files
with
24 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,32 @@ | ||
package com.book.backend.global; | ||
|
||
import io.swagger.v3.oas.annotations.info.Info; | ||
import io.swagger.v3.oas.models.Components; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.security.SecurityRequirement; | ||
import io.swagger.v3.oas.models.security.SecurityScheme; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
|
||
@OpenAPIDefinition(info = @Info(title = "북토크 서버 API", description = "설명", version = "1.0")) // 상단 제목 커스텀 | ||
@Configuration | ||
public class SwaggerConfig { } | ||
public class SwaggerConfig { | ||
|
||
@Bean | ||
public OpenAPI api() { | ||
SecurityScheme apiKey = new SecurityScheme() | ||
.type(SecurityScheme.Type.HTTP) | ||
.in(SecurityScheme.In.HEADER) | ||
.name("Authorization") | ||
.scheme("bearer") | ||
.bearerFormat("JWT"); | ||
|
||
SecurityRequirement securityRequirement = new SecurityRequirement() | ||
.addList("Bearer Token"); | ||
|
||
return new OpenAPI() | ||
.components(new Components().addSecuritySchemes("Bearer Token", apiKey)) | ||
.addSecurityItem(securityRequirement); | ||
} | ||
} |