[SpringBoot] 스프링부트 프로젝트 생성 후 Swagger 사용 및 테스트하기1 REST PULL테스트~Swagger 사용방법~(만들기 스프링부트3.25 )_IntelliJ IDEA 2024.1JDK17 spring-boot test api ajax json--++
* 초기 세팅 (개발환경) 및 설정
https://rockbottomdevbus.blogspot.com/2024/04/springboot-1-325-intellij-idea-20241.html
* Swagger
- RESTpull API를 테스트 할 수 있는 포스트맨과 비슷한 프레임워크
- 라이브러리 추가
1. build.gadle - dependencies에 라이브러리 한줄 추가
-- build.gradle
dependencies {
// Swagger UI (REST Pull [ajax] API 테스트용)
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0'
}
- SwaggerConfig 파일 생성
1. config 패키지 생성 >> 경로 : /main/java/{pakage name}/config
2. SwaggerConfig.java 클래스 생성 >> 1번 경로에 생성 Swagger 설정 파일 생성
-- SwaggerConfig.java
package org.zerock.b01.config;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI openAPI() {
return new OpenAPI()
.info(new Info().title("SpringDoc SwaggerUI Example")
.description("Test SwaggerUI application")
.version("v0.1.0"));
}
}
- 로컬 테스트
1. 아래화면이 나오면 성공
http://localhost:8090/swagger-ui/index.html
2. 1번화면의 sample-json-controller get부분 선택 >> Try it out 버튼 선택
3. 2번화면의 Excute 버튼 선택 >> 아래화면이 나오면 성공
* 다음 글
[SpringBoot] 스프링부트 프로젝트 생성 후 Swagger 사용 및 테스트하기2 REST PULL테스트~~(만들기 스프링부트3.25 )_IntelliJ IDEA 2024.1JDK17 spring-boot test api ajax json--++
https://rockbottomdevbus.blogspot.com/2024/04/springboot-jpa-2-rud-jpa-325-intellij.html
* 참고
댓글
댓글 쓰기