From 7f05c911762f93a1522d9fd10696184e53cb300d Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 19 Aug 2022 17:12:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=9D=E8=B5=96=E5=8C=85=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/conf/SpringDocConfig.java | 89 +++++++++++++ .../iot/vmp/conf/Swagger3Config.java | 117 ------------------ 2 files changed, 89 insertions(+), 117 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java delete mode 100644 src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java new file mode 100644 index 00000000..2cc74959 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java @@ -0,0 +1,89 @@ +package com.genersoft.iot.vmp.conf; + +import io.swagger.v3.oas.models.ExternalDocumentation; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Contact; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.parameters.HeaderParameter; +import org.springdoc.core.GroupedOpenApi; +import org.springdoc.core.SpringDocConfigProperties; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author lin + */ +@Configuration +public class SpringDocConfig { + + @Value("${doc.enabled: true}") + private boolean enable; + + @Bean + public OpenAPI springShopOpenApi() { + Contact contact = new Contact(); + contact.setName("pan"); + contact.setEmail("648540858@qq.com"); + return new OpenAPI() + .info(new Info().title("WVP-PRO 接口文档") + .contact(contact) + .description("开箱即用的28181协议视频平台") + .version("v2.0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + + /** + * 添加分组 + * @return + */ + @Bean + public GroupedOpenApi publicApi() { + return GroupedOpenApi.builder() + .group("1. 全部") + .packagesToScan("com.genersoft.iot.vmp.vmanager") + .build(); + } + + @Bean + public GroupedOpenApi publicApi2() { + return GroupedOpenApi.builder() + .group("2. 国标28181") + .packagesToScan("com.genersoft.iot.vmp.vmanager.gb28181") + .build(); + } + + @Bean + public GroupedOpenApi publicApi3() { + return GroupedOpenApi.builder() + .group("3. 拉流转发") + .packagesToScan("com.genersoft.iot.vmp.vmanager.streamProxy") + .build(); + } + + @Bean + public GroupedOpenApi publicApi4() { + return GroupedOpenApi.builder() + .group("4. 推流管理") + .packagesToScan("com.genersoft.iot.vmp.vmanager.streamPush") + .build(); + } + + @Bean + public GroupedOpenApi publicApi5() { + return GroupedOpenApi.builder() + .group("4. 服务管理") + .packagesToScan("com.genersoft.iot.vmp.vmanager.server") + .build(); + } + + @Bean + public GroupedOpenApi publicApi6() { + return GroupedOpenApi.builder() + .group("5. 用户管理") + .packagesToScan("com.genersoft.iot.vmp.vmanager.user") + .build(); + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java b/src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java deleted file mode 100644 index 7ee13f84..00000000 --- a/src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.genersoft.iot.vmp.conf; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; - -@Configuration -public class Swagger3Config { - - @Value("${swagger-ui.enabled: true}") - private boolean enable; - - @Bean - public Docket createRestApi() { - return new Docket(DocumentationType.OAS_30) - .apiInfo(apiInfo()) - .groupName("1. 全部") - .select() - .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager")) - .paths(PathSelectors.any()) - .build() - .pathMapping("/") - .enable(enable); - } - @Bean - public Docket createRestGBApi() { - return new Docket(DocumentationType.OAS_30) - .apiInfo(apiInfo()) - .groupName("2. 国标28181") - .select() - .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.gb28181")) - .paths(PathSelectors.any()) - .build() - .pathMapping("/") - .enable(enable); - } - - @Bean - public Docket createRestONVIFApi() { - return new Docket(DocumentationType.OAS_30) - .apiInfo(apiInfo()) - .groupName("3. ONVIF") - .select() - .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.onvif")) - .paths(PathSelectors.any()) - .build() - .pathMapping("/") - .enable(enable); - } - - @Bean - public Docket createRestStreamProxyApi() { - return new Docket(DocumentationType.OAS_30) - .apiInfo(apiInfo()) - .groupName("4. 拉流转发") - .select() - .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.streamProxy")) - .paths(PathSelectors.any()) - .build() - .pathMapping("/") - .enable(enable); - } - @Bean - public Docket createRestStreamPushApi() { - return new Docket(DocumentationType.OAS_30) - .apiInfo(apiInfo()) - .groupName("5. 推流管理") - .select() - .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.streamPush")) - .paths(PathSelectors.any()) - .build() - .pathMapping("/") - .enable(enable); - } - - - @Bean - public Docket createServerApi() { - return new Docket(DocumentationType.OAS_30) - .apiInfo(apiInfo()) - .groupName("6. 服务管理") - .select() - .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.server")) - .paths(PathSelectors.any()) - .build() - .pathMapping("/") - .enable(enable); - } - @Bean - public Docket createUserApi() { - return new Docket(DocumentationType.OAS_30) - .apiInfo(apiInfo()) - .groupName("7. 用户管理") - .select() - .apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp.vmanager.user")) - .paths(PathSelectors.any()) - .build() - .pathMapping("/") - .enable(enable); - } - - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("WVP-PRO 接口文档") - .description("更多请咨询服务开发者(https://github.com/648540858/wvp-GB28181-pro)。") - .contact(new Contact("648540858", "648540858", "648540858@qq.com")) - .version("2.0") - .build(); - } -}