Skip to content

Commit

Permalink
📝 Swagger UI의 Authorize 기능 추가
Browse files Browse the repository at this point in the history
access token과 refresh token 사용 가능
  • Loading branch information
min-0 committed Sep 5, 2024
1 parent edc5dcd commit d42578b
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/main/java/com/dnd/dndtravel/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.dnd.dndtravel.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
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;

Expand All @@ -14,6 +17,26 @@ public OpenAPI openAPI() {
.info(new Info()
.title("MAPDDANG API")
.description("맵땅 앱 관련 API")
.version("1.0.0"));
.version("1.0.0"))
.addSecurityItem(new SecurityRequirement()
.addList("Access Token")
.addList("Refresh Token"))
.components(new Components()
.addSecuritySchemes("Access Token", createAccessTokenScheme())
.addSecuritySchemes("Refresh Token", createRefreshTokenScheme()));
}

private SecurityScheme createAccessTokenScheme() {
return new SecurityScheme().type(SecurityScheme.Type.HTTP)
.bearerFormat("JWT")
.scheme("bearer")
.description("Access Token");
}

private SecurityScheme createRefreshTokenScheme() {
return new SecurityScheme().type(SecurityScheme.Type.HTTP)
.bearerFormat("JWT")
.scheme("bearer")
.description("Refresh Token");
}
}

0 comments on commit d42578b

Please sign in to comment.