From 3499cf154a2f3cfa80264296ac6c6893aa60978f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Er=C5=91s?= Date: Mon, 2 Sep 2024 19:03:31 +0200 Subject: [PATCH] adding reproducer for #109 --- .../erosb/jsonsKema/Issue109ReproTest.kt | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/test/kotlin/com/github/erosb/jsonsKema/Issue109ReproTest.kt diff --git a/src/test/kotlin/com/github/erosb/jsonsKema/Issue109ReproTest.kt b/src/test/kotlin/com/github/erosb/jsonsKema/Issue109ReproTest.kt new file mode 100644 index 0000000..fdeda70 --- /dev/null +++ b/src/test/kotlin/com/github/erosb/jsonsKema/Issue109ReproTest.kt @@ -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) + } +}