Swagger 사용 설정
저는 본격적인 개발을 시작하기 전에, Swagger를 사용 설정을 해주었습니다.
1. 우선 필요한 해당 의존성을 추가해주었습니다.
//swagger 추가.
implementation("io.springfox:springfox-swagger2:2.9.2")
implementation("io.springfox:springfox-swagger-ui:2.9.2")
2. @Configuration을 추가해주었습니다.
@Configuration
@EnableSwagger2
class SwaggerConfig {
@Bean
fun api(): Docket {
return Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("hw.boardkotlin"))
.paths(PathSelectors.regex("/.*"))
.build()
.apiInfo(apiInfo())
}
private fun apiInfo(): ApiInfo {
return ApiInfoBuilder().apply {
title("BrotherOne Board API")
description("API Endpoint for serving file")
contact(Contact("Brotherone", "https://github.com/Hyeongwon-up", "leehwdatabase@gmail.com"))
}.build()
}
}
3. http://localhost:8080/swagger-ui.html 통해 확인할 수 있습니다.
'Spring > Kotlin' 카테고리의 다른 글
[Kotlin+Springboot+JPA] Exception Handling by Kotlin (0) | 2021.08.31 |
---|---|
[SpringBoot + Kotlin + JPA] 간단한 게시글 CRUD REST Api 구현. (0) | 2021.08.08 |
[Springboot + Kotlin] Slack 채널 메세지 전송 연동. (0) | 2021.08.06 |
[Kotlin + Springboot + Kotest] Kotest 알아보자. (0) | 2021.08.01 |
[Kotlin + Springboot + JPA] Entity 생성에 관하여. (0) | 2021.07.28 |