Skip to content

Commit

Permalink
improve message withotu pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
mkon committed Jul 19, 2023
1 parent 5df74a2 commit 096dfd4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/openapi_contracts/validators/schema_validation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ def validate_schema(schema, data)
end

def error_to_message(error)
pointer = " at #{error['data_pointer']}" if error['data_pointer'].present?
if error.key?('details')
error['details'].to_a.map { |(key, val)|
"#{key.humanize}: #{val} at #{error['data_pointer']}"
"#{key.humanize}: #{val}#{pointer}"
}.to_sentence
else
"#{error['data'].inspect} at #{error['data_pointer']} does not match the schema"
"#{error['data'].inspect}#{pointer} does not match the schema"
end
end
end
Expand Down

0 comments on commit 096dfd4

Please sign in to comment.