概述

通过修改API信息配置,可以让前端开发人员更方便地知道API文档是谁编写的,以方便联系

配置类代码

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
package com.ledao.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
* Swagger配置
*
* @author LeDao
* @company
* @create 2021-10-05 22:04
*/
@Configuration
public class SwaggerConfig {

/**
* 配置swagger的Docket bean
*
* @return
*/
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.OAS_30)
.apiInfo(createApiInfo());
}

@Bean
public ApiInfo createApiInfo() {
return new ApiInfo(
"LeDao Swagger3",
"LeDao Api文档",
"3.0",
"https://blog.zoutl.cn",
new Contact("LeDao", "https://blog.zoutl.cn", "f110@gmail.com"),
"Apache 2.0",
"https://www.apache.org/licenses/LICENSE-2.0",
new ArrayList<>()
);
}
}

结果