Skip to content

test: use Core Schema in Json Schema Validator validation test #280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 11, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import io.kotest.matchers.should
import io.kotest.matchers.shouldNot
import io.kotest.mpp.sysprop
import it.krzeminski.snakeyaml.engine.kmp.api.Load
import it.krzeminski.snakeyaml.engine.kmp.api.LoadSettings
import it.krzeminski.snakeyaml.engine.kmp.schema.CoreSchema
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonNull
Expand Down Expand Up @@ -46,7 +48,15 @@ private fun beValid(): Matcher<File> {
var errorMessage: String? = null
MatcherResult(
runCatching {
schema.validate(dataFile.inputStream().use { Load().loadOne(it) }.toJsonElement()) {
schema.validate(dataFile.inputStream().use {
Load(
// work-around for https://github.com/krzema12/snakeyaml-engine-kmp/pull/390
// Per https://yaml.org/spec/1.2.2/#recommended-schemas, the Core Schema is
// the recommended default schema that YAML processor should use unless
// instructed otherwise.
LoadSettings.builder().setSchema(CoreSchema()).build()
).loadOne(it)
}.toJsonElement()) {
errorMessage = buildString {
if (errorMessage != null) {
appendLine(errorMessage)
Expand Down
Loading