Updated openapi config and app properties

This commit is contained in:
Sambo Chea 2021-12-11 12:19:23 +07:00
parent 58087efdc1
commit 4561e68c28
Signed by: sombochea
GPG Key ID: 3C7CF22A05D95490
3 changed files with 21 additions and 17 deletions

View File

@ -1,12 +1,13 @@
package com.cubetiqs.web.config
import com.cubetiqs.web.property.AppProperties
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType
import io.swagger.v3.oas.annotations.security.SecurityScheme
import io.swagger.v3.oas.models.ExternalDocumentation
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
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@ -16,9 +17,10 @@ import org.springframework.context.annotation.Configuration
type = SecuritySchemeType.HTTP,
scheme = "bearer",
bearerFormat = "JWT",
)
class OpenApiDocConfig {
class OpenApiDocConfig @Autowired constructor(
val appProperties: AppProperties,
) {
companion object {
private val ADMIN_API_PATH get() = "/admin/**"
private val DEFAULT_API_PATH get() = "/**"
@ -46,15 +48,10 @@ class OpenApiDocConfig {
fun cubetiqOpenAPI(): OpenAPI {
return OpenAPI()
.info(
Info().title("CUBETIQ Web API")
.description("CUBETIQ Spring Web API Application")
.version("v0.0.1")
.license(License().name("Apache 2.0").url("https://cubetiqs.com"))
)
.externalDocs(
ExternalDocumentation()
.description("CUBETIQ Web Wiki Documentation")
.url("https://cubetiqs.com")
Info().title(appProperties.appName)
.description(appProperties.appDescription)
.version(appProperties.appVersion)
.license(License().name("Apache 2.0").url(appProperties.appLicenseUrl))
)
}
}

View File

@ -5,9 +5,15 @@ import org.springframework.beans.factory.annotation.Value
@FunctionComponent
class AppProperties(
@Value("\${cubetiq.app.name:CUBETIQ API Service}")
@Value("\${cubetiq.app.name:CUBETIQ Web API}")
val appName: String,
@Value("\${cubetiq.app.description:CUBETIQ APIs Documentation}")
@Value("\${cubetiq.app.description:CUBETIQ Web APIs Documentation}")
val appDescription: String,
@Value("\${cubetiq.app.version:v0.0.1}")
val appVersion: String,
@Value("\${cubetiq.app.license-url:https://cubetiqs.com}")
val appLicenseUrl: String,
)

View File

@ -7,13 +7,14 @@ spring:
cubetiq:
app:
data-dir: ${APP_DATA_DIR:${user.home}/${spring.application.name}}
name: CUBETIQ API Service
description: CUBETIQ API's Documentation
name: CUBETIQ Web API
description: CUBETIQ Spring Web API's Documentation
logging:
file:
path: ${LOGGING_FILE_PATH:${cubetiq.app.data-dir}/logs/}
name: ${logging.file.path}/app.log
springdoc:
api-docs:
enabled: true