From ce08b090dae4a48eaef3209d96229ea51f3d51d5 Mon Sep 17 00:00:00 2001 From: Gary O'Neall Date: Mon, 27 Oct 2025 12:13:13 -0700 Subject: [PATCH] Update com.networknt:json-schema-validator from 1.5.9 to 2.0.0 Includes updates for breaking changes to the API --- pom.xml | 2 +- src/main/java/org/spdx/tools/Verify.java | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index a47a2b1..7c55138 100644 --- a/pom.xml +++ b/pom.xml @@ -148,7 +148,7 @@ com.networknt json-schema-validator - 1.5.9 + 2.0.0 org.slf4j diff --git a/src/main/java/org/spdx/tools/Verify.java b/src/main/java/org/spdx/tools/Verify.java index d4d050d..9a8cf27 100644 --- a/src/main/java/org/spdx/tools/Verify.java +++ b/src/main/java/org/spdx/tools/Verify.java @@ -40,10 +40,10 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import com.networknt.schema.JsonSchema; -import com.networknt.schema.JsonSchemaFactory; -import com.networknt.schema.SpecVersion.VersionFlag; -import com.networknt.schema.ValidationMessage; +import com.networknt.schema.Schema; +import com.networknt.schema.SchemaRegistry; +import com.networknt.schema.SpecificationVersion; +import com.networknt.schema.Error; /** * Verifies an SPDX document and lists any verification errors @@ -172,17 +172,18 @@ public static List verify(String filePath, SerFileType fileType) throws } else { jsonSchemaResource = JSON_SCHEMA_RESOURCE_V3; } - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V202012); - JsonSchema schema; + SchemaRegistry schemaRegistry = + SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); + Schema schema; try (InputStream is = Verify.class.getResourceAsStream("/" + jsonSchemaResource)) { - schema = jsonSchemaFactory.getSchema(is); + schema = schemaRegistry.getSchema(is); } JsonNode root; try (InputStream is = new FileInputStream(file)) { root = JSON_MAPPER.readTree(is); } - Set messages = schema.validate(root); - for (ValidationMessage msg:messages) { + List messages = schema.validate(root); + for (Error msg:messages) { retval.add(msg.toString()); } } catch (IOException e) {