Class: OasRails::Spec::Responses

Inherits:
Object
  • Object
show all
Includes:
Specable
Defined in:
lib/oas_rails/spec/responses.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Specable

#as_json, #oas_fields

Constructor Details

#initialize(specification) ⇒ Responses

Returns a new instance of Responses.



7
8
9
10
# File 'lib/oas_rails/spec/responses.rb', line 7

def initialize(specification)
  @specification = specification
  @responses = {}
end

Instance Attribute Details

#responsesObject

Returns the value of attribute responses.



5
6
7
# File 'lib/oas_rails/spec/responses.rb', line 5

def responses
  @responses
end

Instance Method Details

#add_response(response) ⇒ Object



12
13
14
# File 'lib/oas_rails/spec/responses.rb', line 12

def add_response(response)
  @responses[response.code] = @specification.components.add_response(response)
end

#to_specObject



16
17
18
19
20
21
22
# File 'lib/oas_rails/spec/responses.rb', line 16

def to_spec
  spec = {}
  @responses.each do |key, value|
    spec[key] = value.to_spec
  end
  spec
end