正在显示
2 个修改的文件
包含
17 行增加
和
10 行删除
| @@ -33,9 +33,13 @@ public class SwaggerConfig | @@ -33,9 +33,13 @@ public class SwaggerConfig | ||
| 33 | @Autowired | 33 | @Autowired |
| 34 | private RuoYiConfig ruoyiConfig; | 34 | private RuoYiConfig ruoyiConfig; |
| 35 | 35 | ||
| 36 | - /** Swagger开关配置 */ | ||
| 37 | - @Value("${swagger.enable}") | ||
| 38 | - private boolean swaggerEnable; | 36 | + /** 是否开启swagger */ |
| 37 | + @Value("${swagger.enabled}") | ||
| 38 | + private boolean enabled; | ||
| 39 | + | ||
| 40 | + /** 设置请求的统一前缀 */ | ||
| 41 | + @Value("${swagger.pathMapping}") | ||
| 42 | + private String pathMapping; | ||
| 39 | 43 | ||
| 40 | /** | 44 | /** |
| 41 | * 创建API | 45 | * 创建API |
| @@ -45,8 +49,7 @@ public class SwaggerConfig | @@ -45,8 +49,7 @@ public class SwaggerConfig | ||
| 45 | { | 49 | { |
| 46 | return new Docket(DocumentationType.SWAGGER_2) | 50 | return new Docket(DocumentationType.SWAGGER_2) |
| 47 | // 是否启用Swagger | 51 | // 是否启用Swagger |
| 48 | - .enable(swaggerEnable) | ||
| 49 | - .pathMapping("/dev-api") | 52 | + .enable(enabled) |
| 50 | // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) | 53 | // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) |
| 51 | .apiInfo(apiInfo()) | 54 | .apiInfo(apiInfo()) |
| 52 | // 设置哪些接口暴露给Swagger展示 | 55 | // 设置哪些接口暴露给Swagger展示 |
| @@ -54,13 +57,14 @@ public class SwaggerConfig | @@ -54,13 +57,14 @@ public class SwaggerConfig | ||
| 54 | // 扫描所有有注解的api,用这种方式更灵活 | 57 | // 扫描所有有注解的api,用这种方式更灵活 |
| 55 | .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) | 58 | .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
| 56 | // 扫描指定包中的swagger注解 | 59 | // 扫描指定包中的swagger注解 |
| 57 | - //.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger")) | 60 | + // .apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger")) |
| 58 | // 扫描所有 .apis(RequestHandlerSelectors.any()) | 61 | // 扫描所有 .apis(RequestHandlerSelectors.any()) |
| 59 | .paths(PathSelectors.any()) | 62 | .paths(PathSelectors.any()) |
| 60 | .build() | 63 | .build() |
| 61 | /* 设置安全模式,swagger可以设置访问token */ | 64 | /* 设置安全模式,swagger可以设置访问token */ |
| 62 | .securitySchemes(securitySchemes()) | 65 | .securitySchemes(securitySchemes()) |
| 63 | - .securityContexts(securityContexts()); | 66 | + .securityContexts(securityContexts()) |
| 67 | + .pathMapping(pathMapping); | ||
| 64 | } | 68 | } |
| 65 | 69 | ||
| 66 | /** | 70 | /** |
| @@ -72,7 +76,7 @@ public class SwaggerConfig | @@ -72,7 +76,7 @@ public class SwaggerConfig | ||
| 72 | apiKeyList.add(new ApiKey("Authorization", "Authorization", "header")); | 76 | apiKeyList.add(new ApiKey("Authorization", "Authorization", "header")); |
| 73 | return apiKeyList; | 77 | return apiKeyList; |
| 74 | } | 78 | } |
| 75 | - | 79 | + |
| 76 | /** | 80 | /** |
| 77 | * 安全上下文 | 81 | * 安全上下文 |
| 78 | */ | 82 | */ |
| @@ -86,7 +90,7 @@ public class SwaggerConfig | @@ -86,7 +90,7 @@ public class SwaggerConfig | ||
| 86 | .build()); | 90 | .build()); |
| 87 | return securityContexts; | 91 | return securityContexts; |
| 88 | } | 92 | } |
| 89 | - | 93 | + |
| 90 | /** | 94 | /** |
| 91 | * 默认的安全上引用 | 95 | * 默认的安全上引用 |
| 92 | */ | 96 | */ |
-
请 注册 或 登录 后发表评论