Class: EasyTalk::ErrorFormatter::Rfc7807
- Defined in:
- lib/easy_talk/error_formatter/rfc7807.rb
Overview
Formats validation errors according to RFC 7807 (Problem Details for HTTP APIs).
RFC 7807 defines a standard format for describing errors in HTTP APIs. This formatter produces a Problem Details object with validation errors in an extended "errors" array.
Constant Summary collapse
- DEFAULT_TITLE =
Default values for RFC 7807 fields
'Validation Failed'- DEFAULT_STATUS =
422- DEFAULT_DETAIL =
'The request contains invalid parameters'
Instance Method Summary collapse
-
#format ⇒ Hash
Format the errors as an RFC 7807 Problem Details object.
Constructor Details
This class inherits a constructor from EasyTalk::ErrorFormatter::Base
Instance Method Details
#format ⇒ Hash
Format the errors as an RFC 7807 Problem Details object.
33 34 35 36 37 38 39 40 41 |
# File 'lib/easy_talk/error_formatter/rfc7807.rb', line 33 def format { 'type' => error_type_uri, 'title' => .fetch(:title, DEFAULT_TITLE), 'status' => .fetch(:status, DEFAULT_STATUS), 'detail' => .fetch(:detail, DEFAULT_DETAIL), 'errors' => build_errors_array } end |