You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.7 KiB
45 lines
1.7 KiB
package com.yipin.liuwanr.config; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
import org.springframework.context.annotation.Bean; |
|
import org.springframework.context.annotation.Configuration; |
|
import springfox.documentation.builders.ApiInfoBuilder; |
|
import springfox.documentation.builders.PathSelectors; |
|
import springfox.documentation.builders.RequestHandlerSelectors; |
|
import springfox.documentation.service.ApiInfo; |
|
import springfox.documentation.service.Contact; |
|
import springfox.documentation.spi.DocumentationType; |
|
import springfox.documentation.spring.web.plugins.Docket; |
|
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|
|
|
@Configuration |
|
@EnableSwagger2 |
|
public class SwaggerConfig { |
|
|
|
@Bean |
|
public Docket productApi() { |
|
return new Docket(DocumentationType.SWAGGER_2) |
|
.apiInfo(apiInfo()) |
|
.select()//添加ApiOperiation注解的被扫描 |
|
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
|
.paths(PathSelectors.any()) |
|
.build(); |
|
} |
|
|
|
private ApiInfo apiInfo() { |
|
return new ApiInfoBuilder().title("项目管理").description("项目管理模块") |
|
.version("1.0").build(); |
|
} |
|
|
|
/*public ApiInfo createApi(){ |
|
return new ApiInfoBuilder().title("项目管理"). |
|
description("项目管理"). |
|
contact(new Contact("龚世杰","http://projestmgs.com","projestmgs@qq.com")).build(); |
|
} |
|
@Bean //等价于 <bean>标签 |
|
public Docket createDoc(){ |
|
return new Docket(DocumentationType.SWAGGER_2).apiInfo(createApi()).select(). |
|
apis(RequestHandlerSelectors.basePackage("com.yipin.liuwanr.controller")).build(); |
|
}*/ |
|
|
|
} |