Class: Eazypi::Responses
- Inherits:
-
Object
- Object
- Eazypi::Responses
- Defined in:
- lib/eazypi/responses.rb
Overview
OpenAPI spec ResponsesObject
Instance Method Summary collapse
- #add_response(status_code, &block) ⇒ Object
- #collect_components(**kwargs) ⇒ Object
-
#initialize ⇒ Responses
constructor
A new instance of Responses.
- #response_for_response_code(response_code) ⇒ Object
- #to_openapi_spec ⇒ Object
Constructor Details
#initialize ⇒ Responses
Returns a new instance of Responses.
6 7 8 |
# File 'lib/eazypi/responses.rb', line 6 def initialize @responses = {} end |
Instance Method Details
#add_response(status_code, &block) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/eazypi/responses.rb', line 10 def add_response(status_code, &block) response = Response.new response.load(&block) @responses[status_code.to_s] = response end |
#collect_components(**kwargs) ⇒ Object
22 23 24 25 26 |
# File 'lib/eazypi/responses.rb', line 22 def collect_components(**kwargs) @responses.each_value do |response| response.collect_components(**kwargs) end end |
#response_for_response_code(response_code) ⇒ Object
17 18 19 20 |
# File 'lib/eazypi/responses.rb', line 17 def response_for_response_code(response_code) # Future improvement could be partial match @responses[response_code.to_s] end |
#to_openapi_spec ⇒ Object
28 29 30 |
# File 'lib/eazypi/responses.rb', line 28 def to_openapi_spec @responses.transform_values(&:to_openapi_spec) end |