-
子模块 common 下面创建子子模块 service_base,创建 swagger 的配置类
- 文档头部信息
- 路径匹配
@Configuration//配置类
@EnableSwagger2//swagger注解
public class SwaggerConfig {
@Bean
public Docket weApiConfig(){
return new Docket(DocumentationType.SWAGGER_2)
.groupName("webApi")
.apiInfo(webApiInfo())
.select()
.paths(Predicates.not(PathSelectors.regex("/admin/.*")))
.paths(Predicates.not(PathSelectors.regex("/error.*")))
.build();
}
private ApiInfo webApiInfo(){
return new ApiInfoBuilder()
.title("网站-课程中心API文档")
.description("本文档描述类课程中心微服务接口定义")
.version("1.0")
.contact(new Contact("你的名字","https://你的网站","你的邮箱@qq.com"))
.build();
}
}
2.访问地址 :
http://localhost:模块端口/swagger-ui.html
3.注解
定义在类上:@Api
定义在方法上:@ApiOperation
定义在参数上:@ApiParam
实体类成员变量:
@ApiModelProperty(value = “创建时间”, example = “2019-01-01 8:00:00”)