2021-12-11 11:53:10 +07:00
|
|
|
package com.cubetiqs.web.config
|
|
|
|
|
2021-12-11 12:19:23 +07:00
|
|
|
import com.cubetiqs.web.property.AppProperties
|
2021-12-11 12:06:10 +07:00
|
|
|
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType
|
|
|
|
import io.swagger.v3.oas.annotations.security.SecurityScheme
|
2021-12-11 11:53:10 +07:00
|
|
|
import io.swagger.v3.oas.models.OpenAPI
|
|
|
|
import io.swagger.v3.oas.models.info.Info
|
|
|
|
import io.swagger.v3.oas.models.info.License
|
|
|
|
import org.springdoc.core.GroupedOpenApi
|
2021-12-11 12:19:23 +07:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired
|
2021-12-11 11:53:10 +07:00
|
|
|
import org.springframework.context.annotation.Bean
|
|
|
|
import org.springframework.context.annotation.Configuration
|
2021-12-24 10:43:28 +07:00
|
|
|
import io.swagger.v3.oas.annotations.OpenAPIDefinition
|
|
|
|
import io.swagger.v3.oas.annotations.servers.Server
|
2022-04-11 09:03:04 +07:00
|
|
|
//import org.springdoc.core.SpringDocUtils
|
|
|
|
//import org.springdoc.core.converters.models.Pageable
|
|
|
|
//import javax.servlet.http.HttpServletRequest
|
2021-12-11 11:53:10 +07:00
|
|
|
|
|
|
|
@Configuration
|
2021-12-11 12:06:10 +07:00
|
|
|
@SecurityScheme(
|
|
|
|
name = "bearerAuth",
|
|
|
|
type = SecuritySchemeType.HTTP,
|
|
|
|
scheme = "bearer",
|
|
|
|
bearerFormat = "JWT",
|
|
|
|
)
|
2021-12-24 10:43:28 +07:00
|
|
|
@OpenAPIDefinition(
|
|
|
|
servers = [
|
|
|
|
Server(url = "/")
|
|
|
|
],
|
|
|
|
)
|
2021-12-11 12:19:23 +07:00
|
|
|
class OpenApiDocConfig @Autowired constructor(
|
|
|
|
val appProperties: AppProperties,
|
|
|
|
) {
|
2021-12-11 11:53:10 +07:00
|
|
|
companion object {
|
|
|
|
private val ADMIN_API_PATH get() = "/admin/**"
|
|
|
|
private val DEFAULT_API_PATH get() = "/**"
|
|
|
|
}
|
|
|
|
|
2022-04-11 09:03:04 +07:00
|
|
|
// init {
|
|
|
|
// SpringDocUtils.getConfig()
|
|
|
|
// .replaceParameterObjectWithClass(org.springframework.data.domain.Pageable::class.java, Pageable::class.java)
|
|
|
|
// .replaceParameterObjectWithClass(
|
|
|
|
// org.springframework.data.domain.PageRequest::class.java,
|
|
|
|
// Pageable::class.java
|
|
|
|
// )
|
|
|
|
// .removeRequestWrapperToIgnore(
|
|
|
|
// HttpServletRequest::class.java,
|
|
|
|
// org.springframework.data.domain.Pageable::class.java,
|
|
|
|
// org.springframework.data.domain.PageRequest::class.java,
|
|
|
|
// )
|
|
|
|
// }
|
|
|
|
|
2021-12-11 11:53:10 +07:00
|
|
|
@Bean
|
|
|
|
fun defaultApi(): GroupedOpenApi {
|
|
|
|
return GroupedOpenApi.builder()
|
2021-12-11 12:06:10 +07:00
|
|
|
.group("default")
|
2021-12-11 11:53:10 +07:00
|
|
|
.pathsToMatch(DEFAULT_API_PATH)
|
2021-12-11 12:06:10 +07:00
|
|
|
.pathsToExclude("/error", ADMIN_API_PATH)
|
2021-12-11 11:53:10 +07:00
|
|
|
.packagesToScan("com.cubetiqs.web")
|
|
|
|
.build()
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
fun adminApi(): GroupedOpenApi {
|
|
|
|
return GroupedOpenApi.builder()
|
2021-12-11 12:06:10 +07:00
|
|
|
.group("admin")
|
2021-12-11 11:53:10 +07:00
|
|
|
.pathsToMatch(ADMIN_API_PATH)
|
|
|
|
.build()
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
fun cubetiqOpenAPI(): OpenAPI {
|
|
|
|
return OpenAPI()
|
|
|
|
.info(
|
2021-12-11 12:19:23 +07:00
|
|
|
Info().title(appProperties.appName)
|
|
|
|
.description(appProperties.appDescription)
|
|
|
|
.version(appProperties.appVersion)
|
|
|
|
.license(License().name("Apache 2.0").url(appProperties.appLicenseUrl))
|
2021-12-11 11:53:10 +07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|