File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
main/java/org/everit/json/schema
test/java/org/everit/json/schema Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -276,11 +276,9 @@ public boolean requiresObject() {
276
276
private List <ValidationException > testAdditionalProperties (final JSONObject subject ) {
277
277
if (!additionalProperties ) {
278
278
return getAdditionalProperties (subject )
279
- .findFirst ()
280
279
.map (unneeded -> String .format ("extraneous key [%s] is not permitted" , unneeded ))
281
280
.map (msg -> new ValidationException (this , msg ))
282
- .map (exc -> Arrays .asList (exc ))
283
- .orElse (Collections .emptyList ());
281
+ .collect (Collectors .toList ());
284
282
} else if (schemaOfAdditionalProperties != null ) {
285
283
List <String > additionalPropNames = getAdditionalProperties (subject )
286
284
.collect (Collectors .toList ());
Original file line number Diff line number Diff line change @@ -53,6 +53,18 @@ public void minPropertiesFailure() {
53
53
TestSupport .expectFailure (subject , "#" , OBJECTS .get ("minPropertiesFailure" ));
54
54
}
55
55
56
+ @ Test
57
+ public void multipleAdditionalProperties () {
58
+ ObjectSchema subject = ObjectSchema .builder ().additionalProperties (false ).build ();
59
+ try {
60
+ subject .validate (new JSONObject ("{\" a\" :true,\" b\" :true}" ));
61
+ Assert .fail ("did not throw exception for multiple additional properties" );
62
+ } catch (ValidationException e ) {
63
+ Assert .assertEquals ("#: 2 schema violations found" , e .getMessage ());
64
+ Assert .assertEquals (2 , e .getCausingExceptions ().size ());
65
+ }
66
+ }
67
+
56
68
@ Test
57
69
public void multipleSchemaDepViolation () {
58
70
Schema billingAddressSchema = new StringSchema ();
You can’t perform that action at this time.
0 commit comments