Skip to content

Commit 185ca2c

Browse files
authored
Merge pull request #747 from OptimumCode/draft202012
Update Kotlin kmp json schema validator
2 parents ed846f7 + 837eb3a commit 185ca2c

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
22
kotlin = "1.9.22"
3-
json-schema-validator = "0.0.4"
3+
json-schema-validator = "0.0.5"
44

55
[plugins]
66
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

src/main/kotlin/BowtieSampsonSchemaValidatorLauncher.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ fun main() {
3131
private val SUPPORTED_DIALECTS: Set<String> = hashSetOf(
3232
"http://json-schema.org/draft-07/schema#",
3333
"https://json-schema.org/draft/2019-09/schema",
34+
"https://json-schema.org/draft/2020-12/schema",
3435
)
3536

3637
enum class Result { CONTINUE, STOP }

src/main/kotlin/TestFilters.kt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fun getFilter(schemaType: SchemaType?): TestFilter =
1616
when (schemaType ?: SchemaType.entries.last()) {
1717
SchemaType.DRAFT_7 -> TestFilterDraft7
1818
SchemaType.DRAFT_2019_09 -> TestFilterDraft201909
19+
SchemaType.DRAFT_2020_12 -> TestFilterDraft202012
1920
}
2021

2122
object TestFilterDraft7 : TestFilter {
@@ -92,3 +93,42 @@ object TestFilterDraft201909 : TestFilter {
9293
}
9394
}
9495
}
96+
97+
object TestFilterDraft202012 : TestFilter {
98+
/**
99+
* All these cases are ignored because they contain remote refs or meta schema
100+
* Library does not support them yet.
101+
*/
102+
private val IGNORED_CASES_WITH_REMOTE_REF: Set<String> = hashSetOf(
103+
"invalid anchors",
104+
"Invalid use of fragments in location-independent \$id",
105+
"Valid use of empty fragments in location-independent \$id",
106+
"Unnormalized \$ids are allowed but discouraged",
107+
"URN base URI with f-component",
108+
"remote HTTP ref with different \$id",
109+
"remote HTTP ref with different URN \$id",
110+
"remote HTTP ref with nested absolute ref",
111+
"\$ref to \$ref finds detached \$anchor",
112+
"schema that uses custom metaschema with with no validation vocabulary",
113+
"ignore unrecognized optional vocabulary",
114+
"validate definition against metaschema",
115+
"retrieved nested refs resolve relative to their URI not \$id",
116+
"base URI change - change folder in subschema",
117+
"base URI change - change folder",
118+
"base URI change",
119+
"strict-tree schema, guards against misspelled properties",
120+
"tests for implementation dynamic anchor and reference link",
121+
"\$ref and \$dynamicAnchor are independent of order - \$defs first",
122+
"\$ref and \$dynamicAnchor are independent of order - \$ref first",
123+
"\$ref to \$dynamicRef finds detached \$dynamicAnchor",
124+
)
125+
126+
override fun shouldSkipCase(caseDescription: String): String? {
127+
return when {
128+
caseDescription.endsWith(" format") -> "the format keyword is not yet supported"
129+
caseDescription in IGNORED_CASES_WITH_REMOTE_REF || caseDescription.contains("remote ref") ->
130+
"remote schema loading and meta schemas are not yet supported"
131+
else -> null
132+
}
133+
}
134+
}

0 commit comments

Comments
 (0)