diff --git a/build.gradle b/build.gradle index ca14d4d..1c83357 100644 --- a/build.gradle +++ b/build.gradle @@ -33,8 +33,8 @@ dependencies { runtimeOnly 'com.mysql:mysql-connector-j' //Swagger, RestDocs - implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.1.0' - testImplementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-api', version: '2.1.0' + implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.3.0' + testImplementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-api', version: '2.3.0' //jwt implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.5' diff --git a/src/main/java/com/finfellows/global/config/OpenApiConfig.java b/src/main/java/com/finfellows/global/config/OpenApiConfig.java new file mode 100644 index 0000000..aa656b1 --- /dev/null +++ b/src/main/java/com/finfellows/global/config/OpenApiConfig.java @@ -0,0 +1,44 @@ +package com.finfellows.global.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Contact; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; + +@Configuration +public class OpenApiConfig { + + private final String securitySchemeName = "bearerAuth"; + + @Bean + public OpenAPI openAPI(@Value("OpenAPI") String appVersion) { + Info info = new Info().title("FinFellow API").version(appVersion) + .description("FinFellow 웹 애플리케이션 API입니다.") + .termsOfService("http://swagger.io/terms/") + .contact(new Contact().name("FinFellow").email("finfellow2023@gmail.com")) + .license(new License().name("Apache License Version 2.0") + .url("http://www.apache.org/licenses/LICENSE-2.0")); + + return new OpenAPI() + .addSecurityItem(new SecurityRequirement().addList(securitySchemeName)) + .components( + new Components() + .addSecuritySchemes(securitySchemeName, + new SecurityScheme() + .name(securitySchemeName) + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT") + ) + ) + .info(info); + } + +} \ No newline at end of file