diff --git a/examples/org/spdx/examples/ExpandedLicenseExampleV3.java b/examples/org/spdx/examples/ExpandedLicenseExampleV3.java
index 030b1b2..5b07d11 100644
--- a/examples/org/spdx/examples/ExpandedLicenseExampleV3.java
+++ b/examples/org/spdx/examples/ExpandedLicenseExampleV3.java
@@ -3,7 +3,7 @@
* SPDX-FileCopyrightText: Copyright (c) 2025 Source Auditor Inc.
* SPDX-FileType: SOURCE
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Example of serializing a single expanded license
*/
@@ -12,10 +12,10 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
-import com.networknt.schema.Error;
-import com.networknt.schema.Schema;
-import com.networknt.schema.SchemaRegistry;
-import com.networknt.schema.SpecificationVersion;
+import com.networknt.schema.JsonSchema;
+import com.networknt.schema.JsonSchemaFactory;
+import com.networknt.schema.SpecVersion.VersionFlag;
+import com.networknt.schema.ValidationMessage;
import org.spdx.core.DefaultModelStore;
import org.spdx.core.IModelCopyManager;
import org.spdx.library.LicenseInfoFactory;
@@ -37,6 +37,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Set;
import static org.spdx.tools.Verify.JSON_SCHEMA_RESOURCE_V3;
@@ -158,18 +159,17 @@ public static void main(String[] args) throws Exception {
try (OutputStream outStream = new FileOutputStream(outFile)) {
modelStore.serialize(outStream, doc);
}
- SchemaRegistry schemaRegistry =
- SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12);
- Schema schema;
+ JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V202012);
+ JsonSchema schema;
try (InputStream is = Verify.class.getResourceAsStream("/" + JSON_SCHEMA_RESOURCE_V3)) {
- schema = schemaRegistry.getSchema(is);
+ schema = jsonSchemaFactory.getSchema(is);
}
JsonNode root;
try (InputStream is = new FileInputStream(outFile)) {
root = JSON_MAPPER.readTree(is);
}
- List messages = schema.validate(root);
- for (Error msg:messages) {
+ Set messages = schema.validate(root);
+ for (ValidationMessage msg:messages) {
warnings.add(msg.toString());
}
if (!warnings.isEmpty()) {
diff --git a/examples/org/spdx/examples/FullSpdxV3Example.java b/examples/org/spdx/examples/FullSpdxV3Example.java
index fd1b269..132b3a6 100644
--- a/examples/org/spdx/examples/FullSpdxV3Example.java
+++ b/examples/org/spdx/examples/FullSpdxV3Example.java
@@ -3,7 +3,7 @@
* SPDX-FileCopyrightText: Copyright (c) 2025 Source Auditor Inc.
* SPDX-FileType: SOURCE
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Full example of an SPDX document using all classes
*/
@@ -12,10 +12,10 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
-import com.networknt.schema.Error;
-import com.networknt.schema.Schema;
-import com.networknt.schema.SchemaRegistry;
-import com.networknt.schema.SpecificationVersion;
+import com.networknt.schema.JsonSchema;
+import com.networknt.schema.JsonSchemaFactory;
+import com.networknt.schema.SpecVersion.VersionFlag;
+import com.networknt.schema.ValidationMessage;
import org.spdx.core.DefaultModelStore;
import org.spdx.core.IModelCopyManager;
import org.spdx.core.InvalidSPDXAnalysisException;
@@ -838,18 +838,17 @@ public static void main(String[] args) throws Exception {
}
// Validate using the schema
- SchemaRegistry schemaRegistry =
- SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12);
- Schema schema;
+ JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V202012);
+ JsonSchema schema;
try (InputStream is = Verify.class.getResourceAsStream("/" + JSON_SCHEMA_RESOURCE_V3)) {
- schema = schemaRegistry.getSchema(is);
+ schema = jsonSchemaFactory.getSchema(is);
}
JsonNode root;
try (InputStream is = new FileInputStream(outFile)) {
root = JSON_MAPPER.readTree(is);
}
- List messages = schema.validate(root);
- for (Error msg:messages) {
+ Set messages = schema.validate(root);
+ for (ValidationMessage msg:messages) {
warnings.add(msg.toString());
}
if (!warnings.isEmpty()) {
diff --git a/pom.xml b/pom.xml
index a1309e7..2034dbe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -148,7 +148,7 @@
com.networknt
json-schema-validator
- 2.0.0
+ 1.5.9
org.slf4j
diff --git a/src/main/java/org/spdx/tools/Verify.java b/src/main/java/org/spdx/tools/Verify.java
index 80b4f75..00ff30e 100644
--- a/src/main/java/org/spdx/tools/Verify.java
+++ b/src/main/java/org/spdx/tools/Verify.java
@@ -2,13 +2,13 @@
* SPDX-FileCopyrightText: Copyright (c) 2015 Source Auditor Inc.
* SPDX-FileType: SOURCE
* SPDX-License-Identifier: Apache-2.0
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* https://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+import java.util.Set;
import com.fasterxml.jackson.core.JsonParseException;
@@ -39,10 +40,11 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
-import com.networknt.schema.Schema;
-import com.networknt.schema.SchemaRegistry;
-import com.networknt.schema.SpecificationVersion;
-import com.networknt.schema.Error;
+
+import com.networknt.schema.JsonSchema;
+import com.networknt.schema.JsonSchemaFactory;
+import com.networknt.schema.SpecVersion.VersionFlag;
+import com.networknt.schema.ValidationMessage;
/**
* Verifies an SPDX document and lists any verification errors
@@ -171,18 +173,17 @@ public static List verify(String filePath, SerFileType fileType) throws
} else {
jsonSchemaResource = JSON_SCHEMA_RESOURCE_V3;
}
- SchemaRegistry schemaRegistry =
- SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12);
- Schema schema;
+ JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V202012);
+ JsonSchema schema;
try (InputStream is = Verify.class.getResourceAsStream("/" + jsonSchemaResource)) {
- schema = schemaRegistry.getSchema(is);
+ schema = jsonSchemaFactory.getSchema(is);
}
JsonNode root;
try (InputStream is = new FileInputStream(file)) {
root = JSON_MAPPER.readTree(is);
}
- List messages = schema.validate(root);
- for (Error msg:messages) {
+ Set messages = schema.validate(root);
+ for (ValidationMessage msg:messages) {
retval.add(msg.toString());
}
} catch (IOException e) {