From 2a71907bbfafe1354686c3abfd42330f29c87ab2 Mon Sep 17 00:00:00 2001 From: grapyju Date: Mon, 25 Mar 2024 23:45:13 +0900 Subject: [PATCH] feat: Add swagger --- .idea/modules.xml | 1 - JWT/build.gradle | 3 -- .../JWT/Swagger/config/SwaggerConfig.java | 34 +++++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 JWT/src/main/java/JWTLogIn/JWT/Swagger/config/SwaggerConfig.java diff --git a/.idea/modules.xml b/.idea/modules.xml index e21ecee..7e7eefc 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,7 +3,6 @@ - \ No newline at end of file diff --git a/JWT/build.gradle b/JWT/build.gradle index b84a5c4..c4128cc 100644 --- a/JWT/build.gradle +++ b/JWT/build.gradle @@ -42,9 +42,6 @@ dependencies { implementation 'io.jsonwebtoken:jjwt-jackson:0.11.2' // Swagger - implementation 'io.springfox:springfox-boot-starter:3.0.0' - implementation 'io.springfox:springfox-swagger-ui:3.0.0' -// implementation 'io.springfox:springfox-swagger2:2.9.2' implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' diff --git a/JWT/src/main/java/JWTLogIn/JWT/Swagger/config/SwaggerConfig.java b/JWT/src/main/java/JWTLogIn/JWT/Swagger/config/SwaggerConfig.java new file mode 100644 index 0000000..07188a5 --- /dev/null +++ b/JWT/src/main/java/JWTLogIn/JWT/Swagger/config/SwaggerConfig.java @@ -0,0 +1,34 @@ +package JWTLogIn.JWT.Swagger.config; + + +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 org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Arrays; + +@OpenAPIDefinition( + info = @Info(title = "tg-wing 홈페이지", + description = "다들 아자아자 화이팅^^", + version = "v1")) +@Configuration +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(Arrays.asList(securityRequirement)); + } + +} \ No newline at end of file