File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed
core/src/main/java/org/everit/json/schema
tests/src/test/java/org/everit/json/schema Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -255,10 +255,15 @@ private void testAdditionalProperties(final JSONObject subject) {
255
255
}
256
256
257
257
private Stream <String > getAdditionalProperties (final JSONObject subject ) {
258
- return Arrays
259
- .stream (JSONObject .getNames (subject ))
260
- .filter (key -> !propertySchemas .containsKey (key ))
261
- .filter (key -> !matchesAnyPattern (key ));
258
+ String [] names = JSONObject .getNames (subject );
259
+ if (names == null ) {
260
+ return Stream .empty ();
261
+ } else {
262
+ return Arrays
263
+ .stream (names )
264
+ .filter (key -> !propertySchemas .containsKey (key ))
265
+ .filter (key -> !matchesAnyPattern (key ));
266
+ }
262
267
}
263
268
264
269
private void testProperties (final JSONObject subject ) {
Original file line number Diff line number Diff line change
1
+ package org .everit .json .schema ;
2
+
3
+ import org .everit .json .schema .loader .SchemaLoader ;
4
+ import org .json .JSONObject ;
5
+ import org .json .JSONTokener ;
6
+ import org .junit .Test ;
7
+
8
+ public class EmptyObjectTest {
9
+ @ Test
10
+ public void validateEmptyObject () {
11
+
12
+ JSONObject jsonSchema = new JSONObject (new JSONTokener (
13
+ MetaSchemaTest .class
14
+ .getResourceAsStream ("/org/everit/json/schema/json-schema-draft-04.json" )));
15
+
16
+ JSONObject jsonSubject = new JSONObject ("{\n " +
17
+ " \" type\" : \" object\" ,\n " +
18
+ " \" properties\" : {}\n " +
19
+ "}" );
20
+
21
+ Schema schema = SchemaLoader .load (jsonSchema );
22
+ schema .validate (jsonSubject );
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments