Skip to content

Commit

Permalink
adding reproducer for #109
Browse files Browse the repository at this point in the history
  • Loading branch information
erosb committed Sep 2, 2024
1 parent 692bab4 commit 3499cf1
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions src/test/kotlin/com/github/erosb/jsonsKema/Issue109ReproTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.github.erosb.jsonsKema

import com.github.erosb.jsonsKema.Validator.Companion.forSchema
import org.junit.jupiter.api.Test

class Issue109ReproTest {

@Test
fun test() {
val schemaJson = JsonParser(
"""
{
"${'$'}schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"aaa": {
"type": "object",
"properties": {
"aaa1": {
"type": "object",
"properties": {
"code": {
"type": "string"
}
},
"additionalProperties": false
},
"aaa2": {
"type": "object",
"properties": {
"code": {
"type": "string"
}
},
"additionalProperties": false
}
},
"required": [
"aaa1",
"aaa2"
]
},
"bbb": {
"type": "object",
"properties": {
"code": {
"type": "string"
}
},
"additionalProperties": false
}
}
}
""".trimIndent()
).parse()
val schema = SchemaLoader(schemaJson).load()
val validator = forSchema(schema)
val instance = JsonParser(
"""
{
"aaa": {
"aaa1": {
"codeERROR": "AAA1"
},
"aaa2": {
"codeERROR": "AAA2"
}
},
"bbb": {
"codeERROR": "BBB"
}
}
""".trimIndent()
).parse()

val failure = validator.validate(instance)
println(failure)
}
}

0 comments on commit 3499cf1

Please sign in to comment.