Updated annotation and add openapi, node, health for spring boot template
This commit is contained in:
parent
e1c4b424cd
commit
e0f3ab1889
@ -1,6 +1,6 @@
|
||||
package com.cubetiqs.web
|
||||
|
||||
import com.cubetiqs.web.stereotype.FunctionComponent
|
||||
import com.cubetiqs.web.annotation.FunctionComponent
|
||||
import org.springframework.context.annotation.Lazy
|
||||
|
||||
@FunctionComponent
|
||||
|
@ -0,0 +1,7 @@
|
||||
package com.cubetiqs.web.annotation
|
||||
|
||||
import org.springdoc.core.converters.models.PageableAsQueryParam
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
@PageableAsQueryParam
|
||||
annotation class ApiPageableAsQuery()
|
@ -0,0 +1,7 @@
|
||||
package com.cubetiqs.web.annotation
|
||||
|
||||
import io.swagger.v3.oas.annotations.Parameter
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
@Parameter(hidden = true)
|
||||
annotation class ApiParamHidden()
|
@ -1,4 +1,4 @@
|
||||
package com.cubetiqs.web.stereotype
|
||||
package com.cubetiqs.web.annotation
|
||||
|
||||
import org.springframework.context.annotation.Lazy
|
||||
import org.springframework.core.annotation.AliasFor
|
@ -12,6 +12,9 @@ import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import io.swagger.v3.oas.annotations.OpenAPIDefinition
|
||||
import io.swagger.v3.oas.annotations.servers.Server
|
||||
//import org.springdoc.core.SpringDocUtils
|
||||
//import org.springdoc.core.converters.models.Pageable
|
||||
//import javax.servlet.http.HttpServletRequest
|
||||
|
||||
@Configuration
|
||||
@SecurityScheme(
|
||||
@ -33,6 +36,20 @@ class OpenApiDocConfig @Autowired constructor(
|
||||
private val DEFAULT_API_PATH get() = "/**"
|
||||
}
|
||||
|
||||
// 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,
|
||||
// )
|
||||
// }
|
||||
|
||||
@Bean
|
||||
fun defaultApi(): GroupedOpenApi {
|
||||
return GroupedOpenApi.builder()
|
||||
|
@ -3,6 +3,7 @@ package com.cubetiqs.web.controller
|
||||
import com.cubetiqs.web.model.response.ApiInfoAuthorResponse
|
||||
import com.cubetiqs.web.model.response.ApiInfoResponse
|
||||
import com.cubetiqs.web.model.response.HealthResponse
|
||||
import com.cubetiqs.web.model.response.NodeInfoResponse
|
||||
import com.cubetiqs.web.util.RouteConstants
|
||||
import io.swagger.v3.oas.annotations.tags.Tag
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
@ -44,4 +45,11 @@ class IndexController @Autowired constructor(
|
||||
HealthResponse.UP
|
||||
)
|
||||
}
|
||||
|
||||
@GetMapping("/node")
|
||||
fun node(): ResponseEntity<NodeInfoResponse?> {
|
||||
return response(
|
||||
NodeInfoResponse.INFO
|
||||
)
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ package com.cubetiqs.web.model.response
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
|
||||
@Schema(name = "HealthResponse", description = "HealthResponse")
|
||||
@Schema(name = "HealthResponse", description = "Health Response")
|
||||
data class HealthResponse(
|
||||
@Schema(name = "status", description = "Status for the service")
|
||||
val status: String,
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.cubetiqs.web.model.response
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import org.apache.commons.lang3.SystemUtils
|
||||
import java.util.*
|
||||
|
||||
@Schema(name = "NodeInfoResponse", description = "Node Info Response")
|
||||
data class NodeInfoResponse(
|
||||
@Schema(name = "instance", description = "Instance ID of the node")
|
||||
val instance: String?,
|
||||
|
||||
@Schema(name = "serverTime", description = "Server Time of the node")
|
||||
val serverTime: Date,
|
||||
) : BaseRequestModel {
|
||||
companion object {
|
||||
val INFO get() = NodeInfoResponse(
|
||||
instance = SystemUtils.getHostName(),
|
||||
serverTime = Date(),
|
||||
)
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.cubetiqs.web.property
|
||||
|
||||
import com.cubetiqs.web.stereotype.FunctionComponent
|
||||
import com.cubetiqs.web.annotation.FunctionComponent
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
|
||||
@FunctionComponent
|
||||
|
Loading…
Reference in New Issue
Block a user