diff --git a/build.gradle.kts b/build.gradle.kts index 5176fc01..5ca77d57 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -40,6 +40,7 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-security") implementation("com.github.f4b6a3:ulid-creator:5.2.3") implementation("org.mariadb.jdbc:mariadb-java-client:2.7.3") + implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0") compileOnly("org.projectlombok:lombok") runtimeOnly("com.mysql:mysql-connector-j") runtimeOnly("com.h2database:h2") diff --git a/src/main/kotlin/com/dobby/backend/presentation/api/config/SwaggerConfig.kt b/src/main/kotlin/com/dobby/backend/presentation/api/config/SwaggerConfig.kt new file mode 100644 index 00000000..e2d20237 --- /dev/null +++ b/src/main/kotlin/com/dobby/backend/presentation/api/config/SwaggerConfig.kt @@ -0,0 +1,34 @@ +package com.dobby.backend.presentation.api.config + +import io.swagger.v3.oas.annotations.OpenAPIDefinition +import io.swagger.v3.oas.annotations.info.Contact +import io.swagger.v3.oas.annotations.info.Info +import io.swagger.v3.oas.annotations.servers.Server +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 + +@OpenAPIDefinition( + servers = [Server( + url = "/", + description = "Default Server URL" + )], + info = Info( + title = "그라밋 백엔드 API 명세", + description = "그라밋 Swagger 문서입니다.", + version = "1.0", + contact = Contact(name = "깃허브 주소", url = "https://github.com/YAPP-Github/25th-Web-Team-2-BE/") + ) +) +@Configuration +class SwaggerConfig { + @Bean + fun openAPI(): OpenAPI = OpenAPI() + .addSecurityItem(SecurityRequirement().addList("JWT 토큰")) + .components( + Components().addSecuritySchemes("JWT 토큰", + SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("Bearer").bearerFormat("JWT"))) +}