Commit 7f05c911762f93a1522d9fd10696184e53cb300d
1 parent
1a9e49d9
依赖包版本升级
Showing
2 changed files
with
89 additions
and
117 deletions
src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.conf; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.models.ExternalDocumentation; | ||
| 4 | +import io.swagger.v3.oas.models.OpenAPI; | ||
| 5 | +import io.swagger.v3.oas.models.info.Contact; | ||
| 6 | +import io.swagger.v3.oas.models.info.Info; | ||
| 7 | +import io.swagger.v3.oas.models.info.License; | ||
| 8 | +import io.swagger.v3.oas.models.media.StringSchema; | ||
| 9 | +import io.swagger.v3.oas.models.parameters.HeaderParameter; | ||
| 10 | +import org.springdoc.core.GroupedOpenApi; | ||
| 11 | +import org.springdoc.core.SpringDocConfigProperties; | ||
| 12 | +import org.springframework.beans.factory.annotation.Value; | ||
| 13 | +import org.springframework.context.annotation.Bean; | ||
| 14 | +import org.springframework.context.annotation.Configuration; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * @author lin | ||
| 18 | + */ | ||
| 19 | +@Configuration | ||
| 20 | +public class SpringDocConfig { | ||
| 21 | + | ||
| 22 | + @Value("${doc.enabled: true}") | ||
| 23 | + private boolean enable; | ||
| 24 | + | ||
| 25 | + @Bean | ||
| 26 | + public OpenAPI springShopOpenApi() { | ||
| 27 | + Contact contact = new Contact(); | ||
| 28 | + contact.setName("pan"); | ||
| 29 | + contact.setEmail("648540858@qq.com"); | ||
| 30 | + return new OpenAPI() | ||
| 31 | + .info(new Info().title("WVP-PRO 接口文档") | ||
| 32 | + .contact(contact) | ||
| 33 | + .description("开箱即用的28181协议视频平台") | ||
| 34 | + .version("v2.0") | ||
| 35 | + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 添加分组 | ||
| 40 | + * @return | ||
| 41 | + */ | ||
| 42 | + @Bean | ||
| 43 | + public GroupedOpenApi publicApi() { | ||
| 44 | + return GroupedOpenApi.builder() | ||
| 45 | + .group("1. 全部") | ||
| 46 | + .packagesToScan("com.genersoft.iot.vmp.vmanager") | ||
| 47 | + .build(); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @Bean | ||
| 51 | + public GroupedOpenApi publicApi2() { | ||
| 52 | + return GroupedOpenApi.builder() | ||
| 53 | + .group("2. 国标28181") | ||
| 54 | + .packagesToScan("com.genersoft.iot.vmp.vmanager.gb28181") | ||
| 55 | + .build(); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @Bean | ||
| 59 | + public GroupedOpenApi publicApi3() { | ||
| 60 | + return GroupedOpenApi.builder() | ||
| 61 | + .group("3. 拉流转发") | ||
| 62 | + .packagesToScan("com.genersoft.iot.vmp.vmanager.streamProxy") | ||
| 63 | + .build(); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @Bean | ||
| 67 | + public GroupedOpenApi publicApi4() { | ||
| 68 | + return GroupedOpenApi.builder() | ||
| 69 | + .group("4. 推流管理") | ||
| 70 | + .packagesToScan("com.genersoft.iot.vmp.vmanager.streamPush") | ||
| 71 | + .build(); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @Bean | ||
| 75 | + public GroupedOpenApi publicApi5() { | ||
| 76 | + return GroupedOpenApi.builder() | ||
| 77 | + .group("4. 服务管理") | ||
| 78 | + .packagesToScan("com.genersoft.iot.vmp.vmanager.server") | ||
| 79 | + .build(); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @Bean | ||
| 83 | + public GroupedOpenApi publicApi6() { | ||
| 84 | + return GroupedOpenApi.builder() | ||
| 85 | + .group("5. 用户管理") | ||
| 86 | + .packagesToScan("com.genersoft.iot.vmp.vmanager.user") | ||
| 87 | + .build(); | ||
| 88 | + } | ||
| 89 | +} |
src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java deleted
100644 → 0
| 1 | -package com.genersoft.iot.vmp.conf; | ||
| 2 | - | ||
| 3 | -import org.springframework.beans.factory.annotation.Value; | ||
| 4 | -import org.springframework.context.annotation.Bean; | ||
| 5 | -import org.springframework.context.annotation.Configuration; | ||
| 6 | -import springfox.documentation.builders.ApiInfoBuilder; | ||
| 7 | -import springfox.documentation.builders.PathSelectors; | ||
| 8 | -import springfox.documentation.builders.RequestHandlerSelectors; | ||
| 9 | -import springfox.documentation.service.ApiInfo; | ||
| 10 | -import springfox.documentation.service.Contact; | ||
| 11 | -import springfox.documentation.spi.DocumentationType; | ||
| 12 | -import springfox.documentation.spring.web.plugins.Docket; | ||
| 13 | - | ||
| 14 | -@Configuration | ||
| 15 | -public class Swagger3Config { | ||
| 16 | - | ||
| 17 | - @Value("${swagger-ui.enabled: true}") | ||
| 18 | - private boolean enable; | ||
| 19 | - | ||
| 20 | - @Bean | ||
| 21 | - public Docket createRestApi() { | ||
| 22 | - return new Docket(DocumentationType.OAS_30) | ||
| 23 | - .apiInfo(apiInfo()) | ||
| 24 | - .groupName("1. 全部") | ||
| 25 | - .select() | ||
| 26 | - .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager")) | ||
| 27 | - .paths(PathSelectors.any()) | ||
| 28 | - .build() | ||
| 29 | - .pathMapping("/") | ||
| 30 | - .enable(enable); | ||
| 31 | - } | ||
| 32 | - @Bean | ||
| 33 | - public Docket createRestGBApi() { | ||
| 34 | - return new Docket(DocumentationType.OAS_30) | ||
| 35 | - .apiInfo(apiInfo()) | ||
| 36 | - .groupName("2. 国标28181") | ||
| 37 | - .select() | ||
| 38 | - .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.gb28181")) | ||
| 39 | - .paths(PathSelectors.any()) | ||
| 40 | - .build() | ||
| 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); | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | - @Bean | ||
| 59 | - public Docket createRestStreamProxyApi() { | ||
| 60 | - return new Docket(DocumentationType.OAS_30) | ||
| 61 | - .apiInfo(apiInfo()) | ||
| 62 | - .groupName("4. 拉流转发") | ||
| 63 | - .select() | ||
| 64 | - .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.streamProxy")) | ||
| 65 | - .paths(PathSelectors.any()) | ||
| 66 | - .build() | ||
| 67 | - .pathMapping("/") | ||
| 68 | - .enable(enable); | ||
| 69 | - } | ||
| 70 | - @Bean | ||
| 71 | - public Docket createRestStreamPushApi() { | ||
| 72 | - return new Docket(DocumentationType.OAS_30) | ||
| 73 | - .apiInfo(apiInfo()) | ||
| 74 | - .groupName("5. 推流管理") | ||
| 75 | - .select() | ||
| 76 | - .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.streamPush")) | ||
| 77 | - .paths(PathSelectors.any()) | ||
| 78 | - .build() | ||
| 79 | - .pathMapping("/") | ||
| 80 | - .enable(enable); | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - | ||
| 84 | - @Bean | ||
| 85 | - public Docket createServerApi() { | ||
| 86 | - return new Docket(DocumentationType.OAS_30) | ||
| 87 | - .apiInfo(apiInfo()) | ||
| 88 | - .groupName("6. 服务管理") | ||
| 89 | - .select() | ||
| 90 | - .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.server")) | ||
| 91 | - .paths(PathSelectors.any()) | ||
| 92 | - .build() | ||
| 93 | - .pathMapping("/") | ||
| 94 | - .enable(enable); | ||
| 95 | - } | ||
| 96 | - @Bean | ||
| 97 | - public Docket createUserApi() { | ||
| 98 | - return new Docket(DocumentationType.OAS_30) | ||
| 99 | - .apiInfo(apiInfo()) | ||
| 100 | - .groupName("7. 用户管理") | ||
| 101 | - .select() | ||
| 102 | - .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.user")) | ||
| 103 | - .paths(PathSelectors.any()) | ||
| 104 | - .build() | ||
| 105 | - .pathMapping("/") | ||
| 106 | - .enable(enable); | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | - private ApiInfo apiInfo() { | ||
| 110 | - return new ApiInfoBuilder() | ||
| 111 | - .title("WVP-PRO 接口文档") | ||
| 112 | - .description("更多请咨询服务开发者(https://github.com/648540858/wvp-GB28181-pro)。") | ||
| 113 | - .contact(new Contact("648540858", "648540858", "648540858@qq.com")) | ||
| 114 | - .version("2.0") | ||
| 115 | - .build(); | ||
| 116 | - } | ||
| 117 | -} |