server2020. 5. 15. 17:39

[swagger2] 설정방법

 

api 를 내보내기 위해서.. 

 

pom.xml

 

<dependency>

    <groupId>io.springfox</groupId>

    <artifactId>springfox-swagger2</artifactId>

    <version>2.9.2</version>

</dependency>

    

   

<dependency>

    <groupId>io.springfox</groupId>

    <artifactId>springfox-swagger-ui</artifactId>

    <version>2.9.2</version>

</dependency> 

 

application

 

@EnableSwagger2

 

@Bean

    public Docket api() {

        return new Docket(DocumentationType.SWAGGER_2)

                .select()

                .apis(RequestHandlerSelectors.any()) // 현재 RequestMapping으로 할당된 모든 URL 리스트를 추출

                .paths(PathSelectors.ant("/api/**")) // 그중 /api/** 인 URL들만 필터링

                .build();

    }

 

 

 

 

 

Posted by thdeodls85