[Kotlin][SpringBoot3] Kopring 서버 기본 실습 03 - Swagger 적용하기 (using springdoc)
1. 이전 포스팅
https://growingsaja.tistory.com/954
[Kotlin][SpringBoot3] Kopring 서버 실습 02 - 간단한 api 구현 및 외부 api의 결과값을 가져와 return하는 api
1. 참고하면 좋은 이전 포스팅 https://growingsaja.tistory.com/953 [Kopring] Kotlin Spring Boot 서버 실습 01 - intelliJ 설치부터 간단한 프로젝트 실행까지 1. IntelliJ 다운로드 및 설치 https://www.jetbrains.com/ko-kr/idea/d
growingsaja.tistory.com
2. Spring Boot3 (kotlin) 에 swagger 적용하기
springdoc을 사용해 swagger를 적용합니다.
// vim build.gradle.kts
// ...
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
developmentOnly("org.springframework.boot:spring-boot-devtools")
runtimeOnly("com.h2database:h2")
testImplementation("org.springframework.boot:spring-boot-starter-test")
// swagger
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0")
}
// ...
4. swagger 설정 정보와 swagger api 문서 조회 기능 활성화 확인
http://localhost:8080/v3/api-docs
http://localhost:8080/swagger-ui/index.html
bybit-ticker : 클래스명에서 부분 가공해 노출되는 text입니다. 클래스명이 BybitTicker이기 때문에 bybit-ticker로 노출됩니다.
5. 참조
OpenAPI 3 Library for spring-boot
Library for OpenAPI 3 with spring boot projects. Is based on swagger-ui, to display the OpenAPI description.Generates automatically the OpenAPI file.
springdoc.org