Commit 94ef0d856feb1802a9a672ee079308497578ae6b
1 parent
96bc081e
修复关闭接口文档失效
Showing
4 changed files
with
43 additions
and
20 deletions
pom.xml
| @@ -253,6 +253,9 @@ | @@ -253,6 +253,9 @@ | ||
| 253 | <plugin> | 253 | <plugin> |
| 254 | <groupId>org.apache.maven.plugins</groupId> | 254 | <groupId>org.apache.maven.plugins</groupId> |
| 255 | <artifactId>maven-surefire-plugin</artifactId> | 255 | <artifactId>maven-surefire-plugin</artifactId> |
| 256 | + <configuration> | ||
| 257 | + <skipTests>true</skipTests> | ||
| 258 | + </configuration> | ||
| 256 | </plugin> | 259 | </plugin> |
| 257 | 260 | ||
| 258 | </plugins> | 261 | </plugins> |
src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java
| 1 | package com.genersoft.iot.vmp.conf; | 1 | package com.genersoft.iot.vmp.conf; |
| 2 | 2 | ||
| 3 | +import org.springframework.beans.factory.annotation.Value; | ||
| 3 | import org.springframework.context.annotation.Bean; | 4 | import org.springframework.context.annotation.Bean; |
| 4 | import org.springframework.context.annotation.Configuration; | 5 | import org.springframework.context.annotation.Configuration; |
| 5 | import springfox.documentation.builders.ApiInfoBuilder; | 6 | import springfox.documentation.builders.ApiInfoBuilder; |
| @@ -13,49 +14,70 @@ import springfox.documentation.spring.web.plugins.Docket; | @@ -13,49 +14,70 @@ import springfox.documentation.spring.web.plugins.Docket; | ||
| 13 | @Configuration | 14 | @Configuration |
| 14 | public class Swagger3Config { | 15 | public class Swagger3Config { |
| 15 | 16 | ||
| 17 | + @Value("${swagger-ui.enabled}") | ||
| 18 | + private boolean enable; | ||
| 19 | + | ||
| 16 | @Bean | 20 | @Bean |
| 17 | public Docket createRestApi() { | 21 | public Docket createRestApi() { |
| 18 | return new Docket(DocumentationType.OAS_30) | 22 | return new Docket(DocumentationType.OAS_30) |
| 19 | .apiInfo(apiInfo()) | 23 | .apiInfo(apiInfo()) |
| 20 | - .groupName("全部") | 24 | + .groupName("1. 全部") |
| 21 | .select() | 25 | .select() |
| 22 | .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager")) | 26 | .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager")) |
| 23 | .paths(PathSelectors.any()) | 27 | .paths(PathSelectors.any()) |
| 24 | .build() | 28 | .build() |
| 25 | - .pathMapping("/"); | 29 | + .pathMapping("/") |
| 30 | + .enable(enable); | ||
| 26 | } | 31 | } |
| 27 | @Bean | 32 | @Bean |
| 28 | public Docket createRestGBApi() { | 33 | public Docket createRestGBApi() { |
| 29 | return new Docket(DocumentationType.OAS_30) | 34 | return new Docket(DocumentationType.OAS_30) |
| 30 | .apiInfo(apiInfo()) | 35 | .apiInfo(apiInfo()) |
| 31 | - .groupName("国标") | 36 | + .groupName("2. 国标28181") |
| 32 | .select() | 37 | .select() |
| 33 | .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.gb28181")) | 38 | .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.gb28181")) |
| 34 | .paths(PathSelectors.any()) | 39 | .paths(PathSelectors.any()) |
| 35 | .build() | 40 | .build() |
| 36 | - .pathMapping("/"); | 41 | + .pathMapping("/") |
| 42 | + .enable(enable); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Bean | ||
| 46 | + public Docket createRestONVIFApi() { | ||
| 47 | + return new Docket(DocumentationType.OAS_30) | ||
| 48 | + .apiInfo(apiInfo()) | ||
| 49 | + .groupName("3. ONVIF") | ||
| 50 | + .select() | ||
| 51 | + .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.onvif")) | ||
| 52 | + .paths(PathSelectors.any()) | ||
| 53 | + .build() | ||
| 54 | + .pathMapping("/") | ||
| 55 | + .enable(enable); | ||
| 37 | } | 56 | } |
| 57 | + | ||
| 38 | @Bean | 58 | @Bean |
| 39 | public Docket createRestStreamProxyApi() { | 59 | public Docket createRestStreamProxyApi() { |
| 40 | return new Docket(DocumentationType.OAS_30) | 60 | return new Docket(DocumentationType.OAS_30) |
| 41 | .apiInfo(apiInfo()) | 61 | .apiInfo(apiInfo()) |
| 42 | - .groupName("拉流转发") | 62 | + .groupName("4. 拉流转发") |
| 43 | .select() | 63 | .select() |
| 44 | .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.streamProxy")) | 64 | .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.streamProxy")) |
| 45 | .paths(PathSelectors.any()) | 65 | .paths(PathSelectors.any()) |
| 46 | .build() | 66 | .build() |
| 47 | - .pathMapping("/"); | 67 | + .pathMapping("/") |
| 68 | + .enable(enable); | ||
| 48 | } | 69 | } |
| 49 | @Bean | 70 | @Bean |
| 50 | public Docket createRestStreamPushApi() { | 71 | public Docket createRestStreamPushApi() { |
| 51 | return new Docket(DocumentationType.OAS_30) | 72 | return new Docket(DocumentationType.OAS_30) |
| 52 | .apiInfo(apiInfo()) | 73 | .apiInfo(apiInfo()) |
| 53 | - .groupName("推流管理") | 74 | + .groupName("5. 推流管理") |
| 54 | .select() | 75 | .select() |
| 55 | .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.streamPush")) | 76 | .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.streamPush")) |
| 56 | .paths(PathSelectors.any()) | 77 | .paths(PathSelectors.any()) |
| 57 | .build() | 78 | .build() |
| 58 | - .pathMapping("/"); | 79 | + .pathMapping("/") |
| 80 | + .enable(enable); | ||
| 59 | } | 81 | } |
| 60 | 82 | ||
| 61 | 83 | ||
| @@ -63,23 +85,25 @@ public class Swagger3Config { | @@ -63,23 +85,25 @@ public class Swagger3Config { | ||
| 63 | public Docket createServerApi() { | 85 | public Docket createServerApi() { |
| 64 | return new Docket(DocumentationType.OAS_30) | 86 | return new Docket(DocumentationType.OAS_30) |
| 65 | .apiInfo(apiInfo()) | 87 | .apiInfo(apiInfo()) |
| 66 | - .groupName("服务管理") | 88 | + .groupName("6. 服务管理") |
| 67 | .select() | 89 | .select() |
| 68 | .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.server")) | 90 | .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.server")) |
| 69 | .paths(PathSelectors.any()) | 91 | .paths(PathSelectors.any()) |
| 70 | .build() | 92 | .build() |
| 71 | - .pathMapping("/"); | 93 | + .pathMapping("/") |
| 94 | + .enable(enable); | ||
| 72 | } | 95 | } |
| 73 | @Bean | 96 | @Bean |
| 74 | public Docket createUserApi() { | 97 | public Docket createUserApi() { |
| 75 | return new Docket(DocumentationType.OAS_30) | 98 | return new Docket(DocumentationType.OAS_30) |
| 76 | .apiInfo(apiInfo()) | 99 | .apiInfo(apiInfo()) |
| 77 | - .groupName("用户管理") | 100 | + .groupName("7. 用户管理") |
| 78 | .select() | 101 | .select() |
| 79 | .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.user")) | 102 | .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.user")) |
| 80 | .paths(PathSelectors.any()) | 103 | .paths(PathSelectors.any()) |
| 81 | .build() | 104 | .build() |
| 82 | - .pathMapping("/"); | 105 | + .pathMapping("/") |
| 106 | + .enable(enable); | ||
| 83 | } | 107 | } |
| 84 | 108 | ||
| 85 | private ApiInfo apiInfo() { | 109 | private ApiInfo apiInfo() { |
src/main/resources/all-application.yml
| @@ -152,7 +152,5 @@ user-settings: | @@ -152,7 +152,5 @@ user-settings: | ||
| 152 | record-push-live: true | 152 | record-push-live: true |
| 153 | 153 | ||
| 154 | # 在线文档: swagger-ui(生产环境建议关闭) | 154 | # 在线文档: swagger-ui(生产环境建议关闭) |
| 155 | -springfox: | ||
| 156 | - documentation: | ||
| 157 | - swagger-ui: | ||
| 158 | - enabled: true | ||
| 159 | \ No newline at end of file | 155 | \ No newline at end of file |
| 156 | +swagger-ui: | ||
| 157 | + enabled: true | ||
| 160 | \ No newline at end of file | 158 | \ No newline at end of file |
src/main/resources/application-dev.yml
| @@ -84,7 +84,5 @@ user-settings: | @@ -84,7 +84,5 @@ user-settings: | ||
| 84 | record-push-live: true | 84 | record-push-live: true |
| 85 | 85 | ||
| 86 | # 在线文档: swagger-ui(生产环境建议关闭) | 86 | # 在线文档: swagger-ui(生产环境建议关闭) |
| 87 | -springfox: | ||
| 88 | - documentation: | ||
| 89 | - swagger-ui: | ||
| 90 | - enabled: true | ||
| 91 | \ No newline at end of file | 87 | \ No newline at end of file |
| 88 | +swagger-ui: | ||
| 89 | + enabled: true | ||
| 92 | \ No newline at end of file | 90 | \ No newline at end of file |