Class: OasCore::Spec::Responses

Inherits:
Object
  • Object
show all
Includes:
Specable
Defined in:
lib/oas_core/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.



9
10
11
12
# File 'lib/oas_core/spec/responses.rb', line 9

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

Instance Attribute Details

#responsesObject

Returns the value of attribute responses.



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

def responses
  @responses
end

Instance Method Details

#add_reference_response(code, reference) ⇒ Object



18
19
20
# File 'lib/oas_core/spec/responses.rb', line 18

def add_reference_response(code, reference)
  @responses[code] = reference
end

#add_response(response) ⇒ Object



14
15
16
# File 'lib/oas_core/spec/responses.rb', line 14

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

#to_specObject



22
23
24
# File 'lib/oas_core/spec/responses.rb', line 22

def to_spec
  @responses.transform_values(&:to_spec)
end