Skip to content

Commit

Permalink
Merge pull request #30 from SWM-WeLike2Coding/feat/swagger
Browse files Browse the repository at this point in the history
feat: Swagger에 JWT 토큰 인증을 할 수 있는 편의 기능 추가
  • Loading branch information
kjungw1025 authored Jul 25, 2024
2 parents 212068d + 07ce8a9 commit 1863e59
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
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 io.swagger.v3.oas.models.servers.Server;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Collections;


@Configuration
@RequiredArgsConstructor
Expand All @@ -28,7 +33,14 @@ public class SwaggerConfig {

@Bean
public OpenAPI openAPI() {
SecurityScheme securityScheme = new SecurityScheme()
.type(SecurityScheme.Type.HTTP).scheme("bearer").bearerFormat("JWT")
.in(SecurityScheme.In.HEADER).name("Authorization");
SecurityRequirement securityRequirement = new SecurityRequirement().addList("bearerAuth");

return new OpenAPI()
.components(new Components().addSecuritySchemes("bearerAuth", securityScheme))
.security(Collections.singletonList(securityRequirement))
.addServersItem(new Server().url(developmentServerUrl).description("개발 서버"))
.addServersItem(new Server().url(localServerUrl).description("로컬 서버"));
}
Expand Down

0 comments on commit 1863e59

Please sign in to comment.