Class: OpenapiFirst::ErrorResponse
- Inherits:
-
Object
- Object
- OpenapiFirst::ErrorResponse
- Defined in:
- lib/openapi_first/error_response.rb
Overview
This is the base class for error responses
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#validation_output ⇒ Object
readonly
Returns the value of attribute validation_output.
Instance Method Summary collapse
- #body ⇒ Object
- #content_type ⇒ Object
-
#initialize(status:, location:, title:, validation_result:) ⇒ ErrorResponse
constructor
A new instance of ErrorResponse.
- #render ⇒ Object
Constructor Details
#initialize(status:, location:, title:, validation_result:) ⇒ ErrorResponse
Returns a new instance of ErrorResponse.
10 11 12 13 14 15 16 17 |
# File 'lib/openapi_first/error_response.rb', line 10 def initialize(status:, location:, title:, validation_result:) @status = status @title = title @location = location @validation_output = validation_result&.output @schema = validation_result&.schema @data = validation_result&.data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
19 20 21 |
# File 'lib/openapi_first/error_response.rb', line 19 def data @data end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
19 20 21 |
# File 'lib/openapi_first/error_response.rb', line 19 def location @location end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
19 20 21 |
# File 'lib/openapi_first/error_response.rb', line 19 def schema @schema end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
19 20 21 |
# File 'lib/openapi_first/error_response.rb', line 19 def status @status end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
19 20 21 |
# File 'lib/openapi_first/error_response.rb', line 19 def title @title end |
#validation_output ⇒ Object (readonly)
Returns the value of attribute validation_output.
19 20 21 |
# File 'lib/openapi_first/error_response.rb', line 19 def validation_output @validation_output end |
Instance Method Details
#body ⇒ Object
27 28 29 |
# File 'lib/openapi_first/error_response.rb', line 27 def body raise NotImplementedError end |
#content_type ⇒ Object
25 |
# File 'lib/openapi_first/error_response.rb', line 25 def content_type = 'application/json' |
#render ⇒ Object
21 22 23 |
# File 'lib/openapi_first/error_response.rb', line 21 def render Rack::Response.new(body, status, Rack::CONTENT_TYPE => content_type).finish end |