「尝鲜」SpringBoot 快速整合 Swagger3.0( 二 )

<>(Arrays.asList(ts));}return null;}/*** 通用拦截器排除swagger设置 , 所有拦截器都会自动加swagger相关的资源排除信息*/@SuppressWarnings("unchecked")@Overridepublic void addInterceptors(InterceptorRegistry registry) {try {Field registrationsField = FieldUtils.getField(InterceptorRegistry.class, "registrations", true);List registrations = (List) ReflectionUtils.getField(registrationsField, registry);if (registrations != null) {for (InterceptorRegistration interceptorRegistration : registrations) {interceptorRegistration.excludePathPatterns("/swagger**/**").excludePathPatterns("/webjars/**").excludePathPatterns("/v3/**").excludePathPatterns("/doc.html");}}} catch (Exception e) {e.printStackTrace();}}}常用注解说明

  • @Api:用在controller类 , 描述API接口
  • @ApiOperation:描述接口方法
  • @ApiModel:描述对象
  • @ApiModelProperty:描述对象属性
  • @ApiImplicitParams:描述接口参数
  • @ApiResponses:描述接口响应
  • @ApiIgnore:忽略接口方法


推荐阅读