File tree 1 file changed +18
-2
lines changed
src/main/java/com/qindesign/json/schema
1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,19 @@ private static boolean is(List<String> path, String name) {
160
160
return path .get (path .size () - 1 ).equals (name );
161
161
}
162
162
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
+
163
176
/**
164
177
* Checks the given schema and returns lists of any issues found for each
165
178
* 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) {
290
303
is (path , Definitions .NAME );
291
304
}
292
305
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 ())) {
295
311
return ;
296
312
}
297
313
You can’t perform that action at this time.
0 commit comments