Class: GrapeOAS::ApiModel::Response
- Defined in:
- lib/grape_oas/api_model/response.rb
Overview
Represents an HTTP response in the DTO model for OpenAPI v2/v3. Used to describe possible responses for an operation, including status, content, and headers.
Constant Summary
Constants inherited from Node
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#examples ⇒ Object
Returns the value of attribute examples.
-
#extensions ⇒ Object
Returns the value of attribute extensions.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#http_status ⇒ Object
Returns the value of attribute http_status.
-
#media_types ⇒ Object
Returns the value of attribute media_types.
Attributes inherited from Node
Instance Method Summary collapse
- #add_media_type(media_type) ⇒ Object
-
#initialize(http_status:, description:, media_types: [], headers: [], extensions: nil, examples: nil) ⇒ Response
constructor
A new instance of Response.
Methods inherited from Node
Constructor Details
#initialize(http_status:, description:, media_types: [], headers: [], extensions: nil, examples: nil) ⇒ Response
Returns a new instance of Response.
13 14 15 16 17 18 19 20 21 |
# File 'lib/grape_oas/api_model/response.rb', line 13 def initialize(http_status:, description:, media_types: [], headers: [], extensions: nil, examples: nil) super() @http_status = http_status.to_s @description = description @media_types = Array(media_types) @headers = Array(headers) @extensions = extensions @examples = examples end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
11 12 13 |
# File 'lib/grape_oas/api_model/response.rb', line 11 def description @description end |
#examples ⇒ Object
Returns the value of attribute examples.
11 12 13 |
# File 'lib/grape_oas/api_model/response.rb', line 11 def examples @examples end |
#extensions ⇒ Object
Returns the value of attribute extensions.
11 12 13 |
# File 'lib/grape_oas/api_model/response.rb', line 11 def extensions @extensions end |
#headers ⇒ Object
Returns the value of attribute headers.
11 12 13 |
# File 'lib/grape_oas/api_model/response.rb', line 11 def headers @headers end |
#http_status ⇒ Object
Returns the value of attribute http_status.
11 12 13 |
# File 'lib/grape_oas/api_model/response.rb', line 11 def http_status @http_status end |
#media_types ⇒ Object
Returns the value of attribute media_types.
11 12 13 |
# File 'lib/grape_oas/api_model/response.rb', line 11 def media_types @media_types end |
Instance Method Details
#add_media_type(media_type) ⇒ Object
23 24 25 |
# File 'lib/grape_oas/api_model/response.rb', line 23 def add_media_type(media_type) @media_types << media_type end |