-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds dynamicPath sopport to enum, required, unevaluatedItem/Props sch…
…emas
- Loading branch information
Showing
6 changed files
with
74 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/test/kotlin/com/github/erosb/jsonsKema/UnevaluatedPropsItemsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.github.erosb.jsonsKema | ||
|
||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class UnevaluatedPropsItemsTest { | ||
|
||
@Test | ||
fun `dynamic path for unevaluatedProps`() { | ||
val schema = SchemaLoader(""" | ||
{ | ||
"unevaluatedProperties": { | ||
"type": "object", | ||
"required": ["reason"] | ||
}, | ||
"properties": { | ||
"a": {"type": "string"} | ||
} | ||
} | ||
""".trimIndent())() | ||
|
||
val actual = Validator.forSchema(schema).validate(""" | ||
{ | ||
"x": {} | ||
} | ||
""".trimIndent()) as UnevaluatedPropertiesValidationFailure | ||
|
||
assertEquals("#/unevaluatedProperties", actual.dynamicPath.toString()) | ||
|
||
val cause = actual.causes.single() as RequiredValidationFailure | ||
assertEquals("#/unevaluatedProperties/required", cause.dynamicPath.toString()) | ||
} | ||
|
||
@Test | ||
fun `dynamic path for unevaluatedItems`() { | ||
val schema = SchemaLoader(""" | ||
{ | ||
"unevaluatedItems": { | ||
"enum": [null] | ||
}, | ||
"prefixItems": [ | ||
{"type": "string"} | ||
] | ||
} | ||
""".trimIndent())() | ||
|
||
val actual = Validator.forSchema(schema).validate(""" | ||
["a", "b"] | ||
""".trimIndent()) as UnevaluatedItemsValidationFailure | ||
|
||
assertEquals("#/unevaluatedItems", actual.dynamicPath.toString()) | ||
|
||
val cause = actual.causes.single() as EnumValidationFailure | ||
assertEquals("#/unevaluatedItems/enum", cause.dynamicPath.toString()) | ||
} | ||
} |