UpDown Dev Story
swagger 추가하기 본문
Swagger 로 API 자동 문서화 하기
maven dependency 추가하기
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
configration 추가하기
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api(){
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any()).build();
// 현재 RequestMapping으로 할당된 모든 URL 리스트를 추출
// .paths(PathSelectors.ant("/api/**")) // 그중 /api/** 인 URL들만 필터링
}
}
접속 확인하기 localhost:8080/swagger-ui.html
Comments