File tree Expand file tree Collapse file tree
src/main/java/com/qindesign/json/schema Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -160,6 +160,19 @@ private static boolean is(List<String> path, String name) {
160160 return path .get (path .size () - 1 ).equals (name );
161161 }
162162
163+ /**
164+ * Checks if the path ends with an unknown keyword.
165+ *
166+ * @param path the path
167+ * @return whether the last element is unknown.
168+ */
169+ private static boolean isUnknown (List <String > path ) {
170+ if (path .isEmpty ()) {
171+ return false ;
172+ }
173+ return !KNOWN_KEYWORDS .contains (path .get (path .size () - 1 ));
174+ }
175+
163176 /**
164177 * Checks the given schema and returns lists of any issues found for each
165178 * element in the tree. This returns a map of JSON element locations to a
@@ -290,8 +303,11 @@ public static Map<List<String>, List<String>> check(JsonElement schema) {
290303 is (path , Definitions .NAME );
291304 }
292305
293- // Allow anything directly below defs
294- if (inDefs ) {
306+ // Allow anything directly below defs or unknown keywords
307+ // Note that arrays will have a path that ends in a number, and so is
308+ // technically an unknown keyword; this is why we must also test for the
309+ // parent being an array
310+ if (inDefs || (isUnknown (path ) && parent != null && !parent .isJsonArray ())) {
295311 return ;
296312 }
297313
You can’t perform that action at this time.
0 commit comments