@@ -337,7 +337,7 @@ def define_requires_none
337
337
338
338
get '/required' , items : [ { key : 'hash in array' } ]
339
339
expect ( last_response . status ) . to eq ( 400 )
340
- expect ( last_response . body ) . to eq ( 'items is invalid, items[key] does not have a valid value' )
340
+ expect ( last_response . body ) . to eq ( 'items is invalid, items[0][ key] does not have a valid value' )
341
341
end
342
342
343
343
it 'works when all params match' do
@@ -492,7 +492,7 @@ def validate_param!(attr_name, params)
492
492
# NOTE: with body parameters in json or XML or similar this
493
493
# should actually fail with: children[parents][name] is missing.
494
494
expect ( last_response . status ) . to eq ( 400 )
495
- expect ( last_response . body ) . to eq ( 'children[parents] is missing' )
495
+ expect ( last_response . body ) . to eq ( 'children[0][ parents] is missing' )
496
496
end
497
497
498
498
it 'safely handles empty arrays and blank parameters' do
@@ -503,7 +503,7 @@ def validate_param!(attr_name, params)
503
503
expect ( last_response . body ) . to eq ( 'children is missing' )
504
504
get '/within_array' , children : [ name : 'Jay' ]
505
505
expect ( last_response . status ) . to eq ( 400 )
506
- expect ( last_response . body ) . to eq ( 'children[parents] is missing' )
506
+ expect ( last_response . body ) . to eq ( 'children[0][ parents] is missing' )
507
507
end
508
508
509
509
it 'errors when param is not an Array' do
@@ -518,7 +518,7 @@ def validate_param!(attr_name, params)
518
518
519
519
get '/within_array' , children : [ name : 'Jay' , parents : { name : 'Fred' } ]
520
520
expect ( last_response . status ) . to eq ( 400 )
521
- expect ( last_response . body ) . to eq ( 'children[parents] is invalid' )
521
+ expect ( last_response . body ) . to eq ( 'children[0][ parents] is invalid' )
522
522
end
523
523
end
524
524
@@ -644,15 +644,15 @@ def validate_param!(attr_name, params)
644
644
{ name : 'Job' , parents : [ { name : 'Joy' } ] }
645
645
]
646
646
expect ( last_response . status ) . to eq ( 400 )
647
- expect ( last_response . body ) . to eq ( 'children[parents][name] is missing' )
647
+ expect ( last_response . body ) . to eq ( 'children[0][ parents][0 ][name] is missing' )
648
648
end
649
649
650
650
it 'safely handles empty arrays and blank parameters' do
651
651
put_with_json '/within_array' , children : [ ]
652
652
expect ( last_response . status ) . to eq ( 200 )
653
653
put_with_json '/within_array' , children : [ name : 'Jay' ]
654
654
expect ( last_response . status ) . to eq ( 400 )
655
- expect ( last_response . body ) . to eq ( 'children[parents] is missing' )
655
+ expect ( last_response . body ) . to eq ( 'children[0][ parents] is missing' )
656
656
end
657
657
end
658
658
@@ -683,7 +683,7 @@ def validate_param!(attr_name, params)
683
683
it 'errors when group is present, but required param is not' do
684
684
get '/optional_group' , items : [ { not_key : 'foo' } ]
685
685
expect ( last_response . status ) . to eq ( 400 )
686
- expect ( last_response . body ) . to eq ( 'items[key] is missing' )
686
+ expect ( last_response . body ) . to eq ( 'items[0][ key] is missing' )
687
687
end
688
688
689
689
it "errors when param is present but isn't an Array" do
@@ -727,7 +727,7 @@ def validate_param!(attr_name, params)
727
727
it 'does internal validations if the outer group is present' do
728
728
get '/nested_optional_group' , items : [ { key : 'foo' } ]
729
729
expect ( last_response . status ) . to eq ( 400 )
730
- expect ( last_response . body ) . to eq ( 'items[required_subitems] is missing' )
730
+ expect ( last_response . body ) . to eq ( 'items[0][ required_subitems] is missing' )
731
731
732
732
get '/nested_optional_group' , items : [ { key : 'foo' , required_subitems : [ { value : 'bar' } ] } ]
733
733
expect ( last_response . status ) . to eq ( 200 )
@@ -737,7 +737,7 @@ def validate_param!(attr_name, params)
737
737
it 'handles deep nesting' do
738
738
get '/nested_optional_group' , items : [ { key : 'foo' , required_subitems : [ { value : 'bar' } ] , optional_subitems : [ { not_value : 'baz' } ] } ]
739
739
expect ( last_response . status ) . to eq ( 400 )
740
- expect ( last_response . body ) . to eq ( 'items[optional_subitems][value] is missing' )
740
+ expect ( last_response . body ) . to eq ( 'items[0][ optional_subitems][0 ][value] is missing' )
741
741
742
742
get '/nested_optional_group' , items : [ { key : 'foo' , required_subitems : [ { value : 'bar' } ] , optional_subitems : [ { value : 'baz' } ] } ]
743
743
expect ( last_response . status ) . to eq ( 200 )
@@ -747,15 +747,15 @@ def validate_param!(attr_name, params)
747
747
it 'handles validation within arrays' do
748
748
get '/nested_optional_group' , items : [ { key : 'foo' } ]
749
749
expect ( last_response . status ) . to eq ( 400 )
750
- expect ( last_response . body ) . to eq ( 'items[required_subitems] is missing' )
750
+ expect ( last_response . body ) . to eq ( 'items[0][ required_subitems] is missing' )
751
751
752
752
get '/nested_optional_group' , items : [ { key : 'foo' , required_subitems : [ { value : 'bar' } ] } ]
753
753
expect ( last_response . status ) . to eq ( 200 )
754
754
expect ( last_response . body ) . to eq ( 'nested optional group works' )
755
755
756
756
get '/nested_optional_group' , items : [ { key : 'foo' , required_subitems : [ { value : 'bar' } ] , optional_subitems : [ { not_value : 'baz' } ] } ]
757
757
expect ( last_response . status ) . to eq ( 400 )
758
- expect ( last_response . body ) . to eq ( 'items[optional_subitems][value] is missing' )
758
+ expect ( last_response . body ) . to eq ( 'items[0][ optional_subitems][0 ][value] is missing' )
759
759
end
760
760
761
761
it 'adds to declared parameters' do
0 commit comments