Skip to content

Commit

Permalink
add reproducer
Browse files Browse the repository at this point in the history
  • Loading branch information
erosb committed Dec 11, 2024
1 parent cf3cee8 commit 0e3ad58
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions src/test/kotlin/com/github/erosb/jsonsKema/Issue32Test.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.github.erosb.jsonsKema

import org.junit.jupiter.api.Test

class Issue32Test {

@Test
fun test() {
val schema = SchemaLoader("""
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"if": {
"properties": {
"type": {
"const": "business"
}
},
"required": [
"type"
],
"type": "object"
},
"properties": {
"city": {
"type": "string"
},
"state": {
"type": "string"
},
"street_address": {
"type": "string"
},
"type": {
"enum": [
"residential",
"business"
]
}
},
"required": [
"street_address",
"city",
"state",
"type"
],
"then": {
"properties": {
"department": {
"type": "string"
}
}
},
"title": "MyTestSchema",
"type": "object",
"unevaluatedProperties": false
}
""".trimIndent())()

val actual= Validator.forSchema(schema).validate("""
{
"street_address": "1600 Pennsylvania Avenue NW",
"city": "Washington",
"state": "DC",
"type": "residential",
"department": "HR"
}
""".trimIndent()) as UnevaluatedPropertiesValidationFailure
println(actual)
}
}

0 comments on commit 0e3ad58

Please sign in to comment.