Skip to content

Commit 333fc3a

Browse files
committed
update usage for networknt
1 parent 2a5a1ff commit 333fc3a

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

benchmark/src/jvmMain/kotlin/io/github/optimumcode/json/schema/benchmark/AbstractComparisonBenchmark.kt

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ package io.github.optimumcode.json.schema.benchmark
22

33
import com.fasterxml.jackson.databind.JsonNode
44
import com.fasterxml.jackson.databind.ObjectMapper
5-
import com.networknt.schema.JsonSchemaFactory
5+
import com.networknt.schema.InputFormat
66
import com.networknt.schema.OutputFormat
7-
import com.networknt.schema.PathType
8-
import com.networknt.schema.SchemaValidatorsConfig
9-
import com.networknt.schema.SpecVersion.VersionFlag.V7
7+
import com.networknt.schema.SchemaRegistry
8+
import com.networknt.schema.dialect.Dialects
109
import com.networknt.schema.output.OutputFlag
1110
import com.networknt.schema.output.OutputUnit
1211
import io.github.optimumcode.json.schema.ErrorCollector
@@ -48,7 +47,7 @@ abstract class AbstractComparisonBenchmark {
4847
private val openapiValidator: Validator = Validator(ValidatorSettings().setOutput(FLAG))
4948

5049
// networknt
51-
private lateinit var networkntSchema: com.networknt.schema.JsonSchema
50+
private lateinit var networkntSchema: com.networknt.schema.Schema
5251
private lateinit var networkntDocument: JsonNode
5352

5453
private lateinit var schema: io.github.optimumcode.json.schema.JsonSchema
@@ -63,18 +62,10 @@ abstract class AbstractComparisonBenchmark {
6362
}
6463

6564
private fun setupNetworknt() {
66-
val factory = JsonSchemaFactory.getInstance(V7)
65+
val factory = SchemaRegistry.withDialect(Dialects.getDraft7())
6766
networkntSchema =
6867
Path.of(schemaPath).inputStream().use {
69-
factory.getSchema(
70-
it,
71-
SchemaValidatorsConfig
72-
.builder()
73-
.pathType(PathType.JSON_POINTER)
74-
.errorMessageKeyword("message")
75-
.nullableKeywordEnabled(false)
76-
.build(),
77-
)
68+
factory.getSchema(it, InputFormat.JSON)
7869
}
7970
networkntDocument =
8071
Path.of(objectPath).inputStream().use {

0 commit comments

Comments
 (0)