|
2 | 2 | * SPDX-FileCopyrightText: Copyright (c) 2015 Source Auditor Inc. |
3 | 3 | * SPDX-FileType: SOURCE |
4 | 4 | * SPDX-License-Identifier: Apache-2.0 |
5 | | - * |
| 5 | + * <br/> |
6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | 7 | * you may not use this file except in compliance with the License. |
8 | 8 | * You may obtain a copy of the License at |
9 | | - * |
| 9 | + * <br/> |
10 | 10 | * https://www.apache.org/licenses/LICENSE-2.0 |
11 | | - * |
| 11 | + * <br/> |
12 | 12 | * Unless required by applicable law or agreed to in writing, software |
13 | 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
26 | 26 | import java.util.ArrayList; |
27 | 27 | import java.util.List; |
28 | 28 | import java.util.Objects; |
| 29 | +import java.util.Set; |
29 | 30 |
|
30 | 31 | import com.fasterxml.jackson.core.JsonParseException; |
31 | 32 |
|
|
39 | 40 | import com.fasterxml.jackson.databind.JsonNode; |
40 | 41 | import com.fasterxml.jackson.databind.ObjectMapper; |
41 | 42 | import com.fasterxml.jackson.databind.SerializationFeature; |
42 | | -import com.networknt.schema.Schema; |
43 | | -import com.networknt.schema.SchemaRegistry; |
44 | | -import com.networknt.schema.SpecificationVersion; |
45 | | -import com.networknt.schema.Error; |
| 43 | + |
| 44 | +import com.networknt.schema.JsonSchema; |
| 45 | +import com.networknt.schema.JsonSchemaFactory; |
| 46 | +import com.networknt.schema.SpecVersion.VersionFlag; |
| 47 | +import com.networknt.schema.ValidationMessage; |
46 | 48 |
|
47 | 49 | /** |
48 | 50 | * Verifies an SPDX document and lists any verification errors |
@@ -171,18 +173,17 @@ public static List<String> verify(String filePath, SerFileType fileType) throws |
171 | 173 | } else { |
172 | 174 | jsonSchemaResource = JSON_SCHEMA_RESOURCE_V3; |
173 | 175 | } |
174 | | - SchemaRegistry schemaRegistry = |
175 | | - SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12); |
176 | | - Schema schema; |
| 176 | + JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.getInstance(VersionFlag.V202012); |
| 177 | + JsonSchema schema; |
177 | 178 | try (InputStream is = Verify.class.getResourceAsStream("/" + jsonSchemaResource)) { |
178 | | - schema = schemaRegistry.getSchema(is); |
| 179 | + schema = jsonSchemaFactory.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 | | - List<Error> messages = schema.validate(root); |
185 | | - for (Error msg:messages) { |
| 185 | + Set<ValidationMessage> messages = schema.validate(root); |
| 186 | + for (ValidationMessage msg:messages) { |
186 | 187 | retval.add(msg.toString()); |
187 | 188 | } |
188 | 189 | } catch (IOException e) { |
|
0 commit comments