Swagger UI란?
Swagger UI allows anyone — be it your development team or your end consumers — to visualize and interact with the API’s resources without having any of the implementation logic in place. It’s automatically generated from your OpenAPI (formerly known as Swagger) Specification, with the visual documentation making it easy for back end implementation and client side consumption.
Swagger UI를 사용하면 개발 팀이든 엔드 유저든 누구나 구현 로직 없이도 API 리소스를 시각화하고 상호 작용할 수 있도록 도와준다.
Swagger는 OpenAPI (이전 Swagger) 사양으로 자동 생성되며 시각적 문서를 통해 백엔드 구현 및 클라이언트 측 사용을 쉽게 할 수 있게 한다.
Swagger UI를 적용하면 별도의 코드 추가 없이도 OpenAPI 규격에 맞게 API를 자동으로 시각화 시켜 줄 수 있다.
Swagger UI 사용방법
1.dependencies 추가
implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
2.application.properties 추가
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
3.자바 config 파일 추가
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api(){
return new Docket(DocumentationType.SWAGGER_2);
}
}
4.URL접속
http://localhost:8080/swagger-ui.html#/
'Spring & SpringBoot' 카테고리의 다른 글
| MockMVC (0) | 2023.01.13 |
|---|---|
| SpringBoot JPA 사용하기 (0) | 2022.12.30 |
| Spring AOP (0) | 2022.12.16 |
| SpringBoot 이전 페이지 URL가져오기 (0) | 2022.12.09 |
| Spring Boot에서 MariaDB 와 MyBatis를 적용해보기 (0) | 2022.11.30 |