Riku
2025-06-11 d3b43d50df28c4fe27c104dcd146d35b2bad4d20
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
package com.flightfeather.uav.config
 
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.spi.DocumentationType
import springfox.documentation.spring.web.plugins.Docket
import springfox.documentation.swagger2.annotations.EnableSwagger2
 
/**
 * @author riku
 * Date: 2020/8/28
 */
@Configuration
@EnableSwagger2
class Swagger2Configuration(
    @Value("\${springfox.documentation.swagger.v2.enabled}") var swagger2Enable: Boolean,
) {
 
    companion object {
        const val SWAGGER_SCAN_BASE_PACKAGE = "com.flightfeather.uav"
 
        const val VERSION = "1.0.0"
    }
 
//    @Value("\${springfox.documentation.swagger.v2.enabled}")
//    private val swagger2Enable: Boolean = true
 
    @Bean
    fun createRestApi(): Docket =
            Docket(DocumentationType.OAS_30)
                    .enable(swagger2Enable)
                    .apiInfo(apiInfo())
                    .select()
                    .apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE))
                    .paths(PathSelectors.any())
                    .build()
 
 
    private fun apiInfo() =
            ApiInfoBuilder()
                    .title("飞羽走航监测服务")
                    .description("飞羽走航监测服务 API 接口文档")
                    .version(VERSION)
                    .build()
}