move schema validation to separate package

This commit is contained in:
Savosin Denis
2025-06-03 11:20:27 +07:00
parent 31e57678d4
commit fd73d94d70
10 changed files with 22 additions and 18 deletions

View File

@@ -1,3 +0,0 @@
package com.github.dannecron.demo.core.services.validation.exceptions
class SchemaNotFoundException: RuntimeException()

View File

@@ -0,0 +1,4 @@
dependencies {
implementation(rootProject.libs.spring.cloud.stream)
implementation(rootProject.libs.json.schema.validator)
}

View File

@@ -1,7 +1,7 @@
package com.github.dannecron.demo.core.services.validation package com.github.dannecron.demo.edgecontracts.validation
import com.github.dannecron.demo.core.services.validation.exceptions.ElementNotValidException import com.github.dannecron.demo.edgecontracts.validation.exceptions.ElementNotValidException
import com.github.dannecron.demo.core.services.validation.exceptions.SchemaNotFoundException import com.github.dannecron.demo.edgecontracts.validation.exceptions.SchemaNotFoundException
import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.JsonElement
interface SchemaValidator { interface SchemaValidator {

View File

@@ -1,7 +1,7 @@
package com.github.dannecron.demo.core.services.validation package com.github.dannecron.demo.edgecontracts.validation
import com.github.dannecron.demo.core.services.validation.exceptions.ElementNotValidException import com.github.dannecron.demo.edgecontracts.validation.exceptions.ElementNotValidException
import com.github.dannecron.demo.core.services.validation.exceptions.SchemaNotFoundException import com.github.dannecron.demo.edgecontracts.validation.exceptions.SchemaNotFoundException
import io.github.optimumcode.json.schema.JsonSchema import io.github.optimumcode.json.schema.JsonSchema
import io.github.optimumcode.json.schema.ValidationError import io.github.optimumcode.json.schema.ValidationError
import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.JsonElement

View File

@@ -1,8 +1,7 @@
package com.github.dannecron.demo.core.config package com.github.dannecron.demo.edgecontracts.validation.config
import com.github.dannecron.demo.core.config.properties.ValidationProperties import com.github.dannecron.demo.edgecontracts.validation.SchemaValidator
import com.github.dannecron.demo.core.services.validation.SchemaValidator import com.github.dannecron.demo.edgecontracts.validation.SchemaValidatorImp
import com.github.dannecron.demo.core.services.validation.SchemaValidatorImp
import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Configuration
import org.springframework.util.ResourceUtils import org.springframework.util.ResourceUtils

View File

@@ -1,4 +1,4 @@
package com.github.dannecron.demo.core.config.properties package com.github.dannecron.demo.edgecontracts.validation.config
import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.boot.context.properties.ConfigurationProperties

View File

@@ -1,4 +1,4 @@
package com.github.dannecron.demo.core.services.validation.exceptions package com.github.dannecron.demo.edgecontracts.validation.exceptions
import io.github.optimumcode.json.schema.ValidationError import io.github.optimumcode.json.schema.ValidationError

View File

@@ -0,0 +1,3 @@
package com.github.dannecron.demo.edgecontracts.validation.exceptions
class SchemaNotFoundException: RuntimeException()

View File

@@ -1,7 +1,7 @@
package com.github.dannecron.demo.core.services.validation package com.github.dannecron.demo.edgecontracts.validation
import com.github.dannecron.demo.core.services.validation.exceptions.ElementNotValidException import com.github.dannecron.demo.edgecontracts.validation.exceptions.ElementNotValidException
import com.github.dannecron.demo.core.services.validation.exceptions.SchemaNotFoundException import com.github.dannecron.demo.edgecontracts.validation.exceptions.SchemaNotFoundException
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.Arguments
@@ -91,6 +91,7 @@ class SchemaValidatorImpTest {
) )
} }
@Suppress("SameParameterValue")
private fun getJsonSchema(resourcePath: String) = javaClass.classLoader private fun getJsonSchema(resourcePath: String) = javaClass.classLoader
.getResourceAsStream(resourcePath)!! .getResourceAsStream(resourcePath)!!
.readAllBytes() .readAllBytes()