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
|
package com.cubetiqs.web
|
||||||
|
|
||||||
import com.cubetiqs.web.stereotype.FunctionComponent
|
import com.cubetiqs.web.annotation.FunctionComponent
|
||||||
import org.springframework.context.annotation.Lazy
|
import org.springframework.context.annotation.Lazy
|
||||||
|
|
||||||
@FunctionComponent
|
@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.context.annotation.Lazy
|
||||||
import org.springframework.core.annotation.AliasFor
|
import org.springframework.core.annotation.AliasFor
|
@ -12,6 +12,9 @@ import org.springframework.context.annotation.Bean
|
|||||||
import org.springframework.context.annotation.Configuration
|
import org.springframework.context.annotation.Configuration
|
||||||
import io.swagger.v3.oas.annotations.OpenAPIDefinition
|
import io.swagger.v3.oas.annotations.OpenAPIDefinition
|
||||||
import io.swagger.v3.oas.annotations.servers.Server
|
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
|
@Configuration
|
||||||
@SecurityScheme(
|
@SecurityScheme(
|
||||||
@ -33,6 +36,20 @@ class OpenApiDocConfig @Autowired constructor(
|
|||||||
private val DEFAULT_API_PATH get() = "/**"
|
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
|
@Bean
|
||||||
fun defaultApi(): GroupedOpenApi {
|
fun defaultApi(): GroupedOpenApi {
|
||||||
return GroupedOpenApi.builder()
|
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.ApiInfoAuthorResponse
|
||||||
import com.cubetiqs.web.model.response.ApiInfoResponse
|
import com.cubetiqs.web.model.response.ApiInfoResponse
|
||||||
import com.cubetiqs.web.model.response.HealthResponse
|
import com.cubetiqs.web.model.response.HealthResponse
|
||||||
|
import com.cubetiqs.web.model.response.NodeInfoResponse
|
||||||
import com.cubetiqs.web.util.RouteConstants
|
import com.cubetiqs.web.util.RouteConstants
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag
|
import io.swagger.v3.oas.annotations.tags.Tag
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
@ -44,4 +45,11 @@ class IndexController @Autowired constructor(
|
|||||||
HealthResponse.UP
|
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
|
import io.swagger.v3.oas.annotations.media.Schema
|
||||||
|
|
||||||
@Schema(name = "HealthResponse", description = "HealthResponse")
|
@Schema(name = "HealthResponse", description = "Health Response")
|
||||||
data class HealthResponse(
|
data class HealthResponse(
|
||||||
@Schema(name = "status", description = "Status for the service")
|
@Schema(name = "status", description = "Status for the service")
|
||||||
val status: String,
|
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
|
package com.cubetiqs.web.property
|
||||||
|
|
||||||
import com.cubetiqs.web.stereotype.FunctionComponent
|
import com.cubetiqs.web.annotation.FunctionComponent
|
||||||
import org.springframework.beans.factory.annotation.Value
|
import org.springframework.beans.factory.annotation.Value
|
||||||
|
|
||||||
@FunctionComponent
|
@FunctionComponent
|
||||||
|
Loading…
Reference in New Issue
Block a user