Notice
Recent Posts
Recent Comments
Link
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Archives
Today
Total
관리 메뉴

UpDown Dev Story

swagger 추가하기 본문

카테고리 없음

swagger 추가하기

updown 2018. 4. 26. 12:08

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

Api Documentation

Api Documentation


Comments