648540858
2022-03-02 1dcdbc3742835ccab28a8983ae002d2bbdba87eb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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();
    }
}