Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ commonsText = "1.15.0"
exposed = "1.2.0"
flyway = "12.6.1"
hikari = "7.0.2"
jsonSchemaValidator = "2.0.1"
jsonSchemaValidator = "3.0.2"
kaml = "0.104.0"
keycloakTestcontainerVersion = "4.2.1"
koin = "4.2.1"
Expand Down
13 changes: 3 additions & 10 deletions workers/common/src/test/kotlin/JsonSchemaTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

package org.eclipse.apoapsis.ortserver.workers.common

import com.networknt.schema.InputFormat
import com.networknt.schema.SchemaRegistry
import com.networknt.schema.SpecificationVersion
import com.networknt.schema.serialization.NodeReader

import io.kotest.core.spec.style.WordSpec
import io.kotest.inspectors.forAll
Expand All @@ -31,8 +31,6 @@ import io.kotest.matchers.shouldNot

import java.io.File

import org.ossreviewtoolkit.model.yamlMapper

class JsonSchemaTest : WordSpec({
val validConfigs = File("src/test/resources")
.walk().maxDepth(1)
Expand All @@ -46,7 +44,7 @@ class JsonSchemaTest : WordSpec({
"successfully validate all valid .ort.env.yml files" {
@Suppress("IgnoredReturnValue")
validConfigs.forAll { file ->
val errors = schema.validate(file.toJsonNode())
val errors = schema.validate(file.readText(), InputFormat.YAML)

errors should beEmpty()
}
Expand All @@ -57,21 +55,16 @@ class JsonSchemaTest : WordSpec({
// treated as invalid by the JSON schema validator.
@Suppress("IgnoredReturnValue")
invalidConfigs.forAll { file ->
val errors = schema.validate(file.toJsonNode())
val errors = schema.validate(file.readText(), InputFormat.YAML)

errors shouldNot beEmpty()
}
}
}
})

private fun File.toJsonNode() = yamlMapper.readTree(inputStream())

private val nodeReader = NodeReader.builder().yamlMapper(yamlMapper).build()

private val schemaV7 = SchemaRegistry
.builder(SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_7))
.nodeReader(nodeReader)
.build()

private val schema = schemaV7.getSchema(
Expand Down
Loading