@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode
4
4
import com.fasterxml.jackson.databind.ObjectMapper
5
5
import com.networknt.schema.JsonSchemaFactory
6
6
import com.networknt.schema.OutputFormat
7
+ import com.networknt.schema.PathType
7
8
import com.networknt.schema.SchemaValidatorsConfig
8
9
import com.networknt.schema.SpecVersion.VersionFlag.V7
9
10
import com.networknt.schema.output.OutputFlag
@@ -65,7 +66,15 @@ abstract class AbstractComparisonBenchmark {
65
66
val factory = JsonSchemaFactory .getInstance(V7 )
66
67
networkntSchema =
67
68
Path .of(schemaPath).inputStream().use {
68
- factory.getSchema(it, SchemaValidatorsConfig ())
69
+ factory.getSchema(
70
+ it,
71
+ SchemaValidatorsConfig
72
+ .builder()
73
+ .pathType(PathType .JSON_POINTER )
74
+ .errorMessageKeyword(" message" )
75
+ .nullableKeywordEnabled(false )
76
+ .build(),
77
+ )
69
78
}
70
79
networkntDocument =
71
80
Path .of(objectPath).inputStream().use {
@@ -77,7 +86,8 @@ abstract class AbstractComparisonBenchmark {
77
86
private fun setupKmp () {
78
87
schema =
79
88
Path .of(schemaPath).inputStream().use {
80
- io.github.optimumcode.json.schema.JsonSchema .fromStream(it)
89
+ io.github.optimumcode.json.schema.JsonSchema
90
+ .fromStream(it)
81
91
}
82
92
document =
83
93
Path .of(objectPath).inputStream().use {
@@ -94,34 +104,30 @@ abstract class AbstractComparisonBenchmark {
94
104
openapiSchema = store.getSchema(uri)
95
105
openapiDocument =
96
106
JsonInstance (
97
- converter.convert(Path .of(objectPath).inputStream().use { it.readAllBytes() }.toString(Charsets .UTF_8 )),
107
+ converter.convert(
108
+ Path
109
+ .of(objectPath)
110
+ .inputStream()
111
+ .use { it.readAllBytes() }
112
+ .toString(Charsets .UTF_8 ),
113
+ ),
98
114
)
99
115
}
100
116
101
117
@Benchmark
102
- fun validateOpenApi (): ValidationStep {
103
- return openapiValidator.validate(openapiSchema, openapiDocument)
104
- }
118
+ fun validateOpenApi (): ValidationStep = openapiValidator.validate(openapiSchema, openapiDocument)
105
119
106
120
@Benchmark
107
- fun validateNetworkntFlag (): OutputFlag ? {
108
- return networkntSchema.validate(networkntDocument, OutputFormat .FLAG )
109
- }
121
+ fun validateNetworkntFlag (): OutputFlag ? = networkntSchema.validate(networkntDocument, OutputFormat .FLAG )
110
122
111
123
@Benchmark
112
- fun validateNetworkntDetailed (): OutputUnit {
113
- return networkntSchema.validate(networkntDocument, OutputFormat .LIST )
114
- }
124
+ fun validateNetworkntDetailed (): OutputUnit = networkntSchema.validate(networkntDocument, OutputFormat .LIST )
115
125
116
126
@Benchmark
117
- fun validateNetworkntVerbose (): OutputUnit {
118
- return networkntSchema.validate(networkntDocument, OutputFormat .HIERARCHICAL )
119
- }
127
+ fun validateNetworkntVerbose (): OutputUnit = networkntSchema.validate(networkntDocument, OutputFormat .HIERARCHICAL )
120
128
121
129
@Benchmark
122
- fun validateKmpEmptyCollector (): Boolean {
123
- return schema.validate(document, ErrorCollector .EMPTY )
124
- }
130
+ fun validateKmpEmptyCollector (): Boolean = schema.validate(document, ErrorCollector .EMPTY )
125
131
126
132
@Benchmark
127
133
fun validateKmpCollectErrors (): List <ValidationError > {
@@ -131,17 +137,11 @@ abstract class AbstractComparisonBenchmark {
131
137
}
132
138
133
139
@Benchmark
134
- fun validateKmpFlag (): ValidationOutput .Flag {
135
- return schema.validate(document, OutputCollector .flag())
136
- }
140
+ fun validateKmpFlag (): ValidationOutput .Flag = schema.validate(document, OutputCollector .flag())
137
141
138
142
@Benchmark
139
- fun validateKmpDetailed (): ValidationOutput .OutputUnit {
140
- return schema.validate(document, OutputCollector .detailed())
141
- }
143
+ fun validateKmpDetailed (): ValidationOutput .OutputUnit = schema.validate(document, OutputCollector .detailed())
142
144
143
145
@Benchmark
144
- fun validateKmpVerbose (): ValidationOutput .OutputUnit {
145
- return schema.validate(document, OutputCollector .verbose())
146
- }
146
+ fun validateKmpVerbose (): ValidationOutput .OutputUnit = schema.validate(document, OutputCollector .verbose())
147
147
}
0 commit comments