mirror of
https://github.com/Dannecron/spring-boot-demo.git
synced 2025-12-25 16:22:35 +03:00
add entrypoint to dockerfile and doc
fix resource usage
This commit is contained in:
@@ -5,19 +5,21 @@ import com.github.dannecron.demo.edgecontracts.validation.SchemaValidatorImp
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.util.ResourceUtils
|
||||
import org.springframework.core.io.ResourceLoader
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(ValidationProperties::class)
|
||||
class SchemaValidationConfig(
|
||||
private val validationProperties: ValidationProperties,
|
||||
private val resourceLoader: ResourceLoader,
|
||||
) {
|
||||
|
||||
@Bean
|
||||
fun schemaValidator(): SchemaValidator = SchemaValidatorImp(
|
||||
schemaMap = validationProperties.schema.mapValues {
|
||||
schema -> ResourceUtils.getFile("classpath:json-schemas/${schema.value}")
|
||||
.readText(Charsets.UTF_8)
|
||||
schema -> resourceLoader.getResource("classpath:json-schemas/${schema.value}")
|
||||
.takeIf { it.exists() }!!
|
||||
.getContentAsString(Charsets.UTF_8)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user