Skip to content

Commit 5d1ce1f

Browse files
committed
Update com.networknt:json-schema-validator from 1.5.9 to 2.0.0
Includes updates for breaking changes to the API
1 parent 6919563 commit 5d1ce1f

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
<dependency>
149149
<groupId>com.networknt</groupId>
150150
<artifactId>json-schema-validator</artifactId>
151-
<version>1.5.9</version>
151+
<version>2.0.0</version>
152152
</dependency>
153153
<dependency>
154154
<groupId>org.slf4j</groupId>

src/main/java/org/spdx/tools/Verify.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
import com.fasterxml.jackson.databind.JsonNode;
4141
import com.fasterxml.jackson.databind.ObjectMapper;
4242
import com.fasterxml.jackson.databind.SerializationFeature;
43-
import com.networknt.schema.JsonSchema;
44-
import com.networknt.schema.JsonSchemaFactory;
45-
import com.networknt.schema.SpecVersion.VersionFlag;
46-
import com.networknt.schema.ValidationMessage;
43+
import com.networknt.schema.Schema;
44+
import com.networknt.schema.SchemaRegistry;
45+
import com.networknt.schema.SpecificationVersion;
46+
import com.networknt.schema.Error;
4747

4848
/**
4949
* Verifies an SPDX document and lists any verification errors
@@ -172,17 +172,18 @@ public static List<String> verify(String filePath, SerFileType fileType) throws
172172
} else {
173173
jsonSchemaResource = JSON_SCHEMA_RESOURCE_V3;
174174
}
175-
JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V202012);
176-
JsonSchema schema;
175+
SchemaRegistry schemaRegistry =
176+
SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12);
177+
Schema schema;
177178
try (InputStream is = Verify.class.getResourceAsStream("/" + jsonSchemaResource)) {
178-
schema = jsonSchemaFactory.getSchema(is);
179+
schema = schemaRegistry.getSchema(is);
179180
}
180181
JsonNode root;
181182
try (InputStream is = new FileInputStream(file)) {
182183
root = JSON_MAPPER.readTree(is);
183184
}
184-
Set<ValidationMessage> messages = schema.validate(root);
185-
for (ValidationMessage msg:messages) {
185+
List<Error> messages = schema.validate(root);
186+
for (Error msg:messages) {
186187
retval.add(msg.toString());
187188
}
188189
} catch (IOException e) {

0 commit comments

Comments
 (0)