|
40 | 40 | import com.fasterxml.jackson.databind.JsonNode; |
41 | 41 | import com.fasterxml.jackson.databind.ObjectMapper; |
42 | 42 | 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; |
47 | 47 |
|
48 | 48 | /** |
49 | 49 | * Verifies an SPDX document and lists any verification errors |
@@ -172,17 +172,18 @@ public static List<String> verify(String filePath, SerFileType fileType) throws |
172 | 172 | } else { |
173 | 173 | jsonSchemaResource = JSON_SCHEMA_RESOURCE_V3; |
174 | 174 | } |
175 | | - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V202012); |
176 | | - JsonSchema schema; |
| 175 | + SchemaRegistry schemaRegistry = |
| 176 | + SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); |
| 177 | + Schema schema; |
177 | 178 | try (InputStream is = Verify.class.getResourceAsStream("/" + jsonSchemaResource)) { |
178 | | - schema = jsonSchemaFactory.getSchema(is); |
| 179 | + schema = schemaRegistry.getSchema(is); |
179 | 180 | } |
180 | 181 | JsonNode root; |
181 | 182 | try (InputStream is = new FileInputStream(file)) { |
182 | 183 | root = JSON_MAPPER.readTree(is); |
183 | 184 | } |
184 | | - Set<ValidationMessage> messages = schema.validate(root); |
185 | | - for (ValidationMessage msg:messages) { |
| 185 | + List<Error> messages = schema.validate(root); |
| 186 | + for (Error msg:messages) { |
186 | 187 | retval.add(msg.toString()); |
187 | 188 | } |
188 | 189 | } catch (IOException e) { |
|
0 commit comments