File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ def message
1414 keys = details . fetch ( 'missing_keys' , [ ] ) . join ( ', ' )
1515 "object at #{ location } is missing required properties: #{ keys } "
1616 when 'dependentRequired'
17- keys = details . fetch ( 'missing_keys' ) . join ( ', ')
18- "object at #{ location } is missing required properties: #{ keys } "
17+ keys = details & .fetch ( 'missing_keys' )
18+ "object at #{ location } is missing required properties#{ keys && " #{ keys . join ( ', ' ) } " } "
1919 when 'string' , 'boolean' , 'number'
2020 "value at #{ location } is not a #{ type } "
2121 when 'array' , 'object' , 'integer'
Original file line number Diff line number Diff line change 1+ RSpec . describe OpenapiFirst ::Schema ::ValidationResult do
2+ def schema ( hash )
3+ JSONSchemer . schema ( hash )
4+ end
5+
6+ describe 'missing required field' do
7+ specify do
8+ validation = schema ( { required : [ 'id' ] } ) . validate ( { } )
9+ expect ( described_class . new ( validation ) . errors . first . message ) . to eq 'object at root is missing required properties: id'
10+ end
11+ end
12+
13+ describe 'missing dependentRequired field' do
14+ specify do
15+ validation = schema ( { 'dependentRequired' => { 'id' => [ 'type' ] } } ) . validate ( { 'id' => '2' } )
16+ expect ( described_class . new ( validation ) . errors . first . message ) . to eq 'object at `/id` is missing required properties'
17+ end
18+ end
19+ end
You can’t perform that action at this time.
0 commit comments