无关风月
2025-02-14 11ec1c23a9f47ed70b124e413e33e3696897390f
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
package com.jilongda.common.swagger;
 
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.stereotype.Component;
 
import java.util.List;
 
/**
 * @author ck
 * @version 1.0
 * @date 2021-12-03 12:21
 * swagger2的配置参数
 * 并设定默认开关,@ConfigurationProperties
 */
@Data
@Component
@ConfigurationProperties(prefix = "web.swagger")
public class SwaggerProperties {
 
    /**
     * 是否启动Swagger2,默认开启
     */
    private boolean enabled = true;
    /**
     * Swagger2扫描的包,默认为:com
     */
    private String basePackage = "com";
    /**
     * 基础映射路径,默认当前项目根路径
     */
    private String pathMapping = "/";
    /**
     * 标题
     */
    private String title="未定义标题";
 
    /**
     * 描述
     */
    private String description;
    /**
     * 服务地址
     */
    private String serviceUrl;
    /**
     * 证书 eg: The Apache License, Version 2.0
     */
    private String license;
    /**
     * 证书地址 eg: http://www.apache.org/licenses/LICENSE-2.0.html
     */
    private String licenseUrl;
    /**
     * 联系:默认
     */
    @NestedConfigurationProperty
    private Contact contact = new Contact();
    /**
     * 版本,默认为:1.0.0
     */
    private String version = "1.0.0";
    /**
     * 文档需要填充的固定参数,例如token之类的
     * 填充示例
     * web.swagger.reqFixedParameters[0].paramKey=token
     * web.swagger.reqFixedParameters[0].description=description
     * web.swagger.reqFixedParameters[0].required=fasle
     * web.swagger.reqFixedParameters[1].paramKey=token
     * web.swagger.reqFixedParameters[1].description=description
     * web.swagger.reqFixedParameters[1].required=true
     * ---------------------
     */
    private List<ReqFixedParameter> reqFixedParameters;
    /**
     * 联系内部类===作者信息
     */
    @Data
    static class Contact {
 
        /**
         * 联系名
         */
        private String name;
        /**
         * 网址
         */
        private String url;
        /**
         * Email地址
         */
        private String email;
    }
 
    /**
     * 联系内部类===请求头部固定参数类
     */
    @Data
    static class ReqFixedParameter {
 
        /**
         * 参数名
         */
        private String paramKey;
        /**
         * 描述
         */
        private String description;
        /**
         * 是否必填,默认非必填
         */
        private boolean required = false;
    }
 
}