Swagger3
Application启动类添加注解
@EnableOpenApi
application.yml配置如下
swagger:
enabled: false
配置类
@Configuration
public class SwaggerConfig {
@Value("${swagger.enabled}")
Boolean swaggerEnabled =false;
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.OAS_30)
.enable(swaggerEnabled)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
/**
* 创建该API的基本信息(这些基本信息会展现在文档页面中)
* 访问地址:http://项目实际地址/swagger-ui.html
* @return
*/
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("构建RESTful APIs")
.description("更多请关注http://www.baidu.com")
.termsOfServiceUrl("http://www.baidu.com")
.version("1.0")
.build();
}
}
关闭后不显示接口信息

#######附加
如果想更换界面UI 改用knife4j的话 访问链接从/swagger-ui/index.html改为/doc.html
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
http://localhost:8080/doc.html

浙公网安备 33010602011771号