Swagger2配置

/**
 *
 */
@Configuration
@EnableSwagger2
@Profile({"dev"}) // 指定只能在开发环境中使用
public class Swagger2Config {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.web.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * @return
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().build();
    }
}

 

posted @ 2020-04-23 10:40  jamess  阅读(579)  评论(0编辑  收藏  举报