Skip to content

Commit aa14c7e

Browse files
Vampirekrzema12
andauthored
test: use Core Schema in Json Schema Validator validation test (#280)
Co-authored-by: Piotr Krzemiński <[email protected]>
1 parent c4c1c12 commit aa14c7e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/jvmTest/kotlin/it/krzeminski/githubactionstyping/JsonSchemaValidatorSchemaValidationTest.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import io.kotest.matchers.should
77
import io.kotest.matchers.shouldNot
88
import io.kotest.mpp.sysprop
99
import it.krzeminski.snakeyaml.engine.kmp.api.Load
10+
import it.krzeminski.snakeyaml.engine.kmp.api.LoadSettings
11+
import it.krzeminski.snakeyaml.engine.kmp.schema.CoreSchema
1012
import kotlinx.serialization.json.JsonArray
1113
import kotlinx.serialization.json.JsonElement
1214
import kotlinx.serialization.json.JsonNull
@@ -46,7 +48,15 @@ private fun beValid(): Matcher<File> {
4648
var errorMessage: String? = null
4749
MatcherResult(
4850
runCatching {
49-
schema.validate(dataFile.inputStream().use { Load().loadOne(it) }.toJsonElement()) {
51+
schema.validate(dataFile.inputStream().use {
52+
Load(
53+
// work-around for https://github.com/krzema12/snakeyaml-engine-kmp/pull/390
54+
// Per https://yaml.org/spec/1.2.2/#recommended-schemas, the Core Schema is
55+
// the recommended default schema that YAML processor should use unless
56+
// instructed otherwise.
57+
LoadSettings.builder().setSchema(CoreSchema()).build()
58+
).loadOne(it)
59+
}.toJsonElement()) {
5060
errorMessage = buildString {
5161
if (errorMessage != null) {
5262
appendLine(errorMessage)

0 commit comments

Comments
 (0)