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

View File

@ -4,10 +4,16 @@ import com.cubetiqs.web.stereotype.FunctionComponent
import org.springframework.beans.factory.annotation.Value import org.springframework.beans.factory.annotation.Value
@FunctionComponent @FunctionComponent
class AppProperties ( class AppProperties(
@Value("\${cubetiq.app.name:CUBETIQ API Service}") @Value("\${cubetiq.app.name:CUBETIQ Web API}")
val appName: String, val appName: String,
@Value("\${cubetiq.app.description:CUBETIQ APIs Documentation}") @Value("\${cubetiq.app.description:CUBETIQ Web APIs Documentation}")
val appDescription: String, 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: cubetiq:
app: app:
data-dir: ${APP_DATA_DIR:${user.home}/${spring.application.name}} data-dir: ${APP_DATA_DIR:${user.home}/${spring.application.name}}
name: CUBETIQ API Service name: CUBETIQ Web API
description: CUBETIQ API's Documentation description: CUBETIQ Spring Web API's Documentation
logging: logging:
file: file:
path: ${LOGGING_FILE_PATH:${cubetiq.app.data-dir}/logs/} path: ${LOGGING_FILE_PATH:${cubetiq.app.data-dir}/logs/}
name: ${logging.file.path}/app.log name: ${logging.file.path}/app.log
springdoc: springdoc:
api-docs: api-docs:
enabled: true enabled: true