Class: Swagger::Data::Responses
- Inherits:
-
Object
- Object
- Object
- Swagger::Data::Responses
show all
- Defined in:
- lib/ruby-swagger/data/responses.rb
Overview
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Object
attr_swagger, #bulk_set, #swagger_attributes, #to_json, #to_swagger, #to_yaml
Constructor Details
Returns a new instance of Responses.
7
8
9
|
# File 'lib/ruby-swagger/data/responses.rb', line 7
def initialize
@responses = {}
end
|
Class Method Details
.parse(responses) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/ruby-swagger/data/responses.rb', line 11
def self.parse(responses)
return nil unless responses
r = Swagger::Data::Responses.new
responses.each do |response_key, response_value|
r.add_response(response_key, response_value)
end
r
end
|
Instance Method Details
34
35
36
|
# File 'lib/ruby-swagger/data/responses.rb', line 34
def [](key)
@responses[key]
end
|
#add_response(response_code, response) ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/ruby-swagger/data/responses.rb', line 23
def add_response(response_code, response)
raise ArgumentError.new('Swagger::Data::Responses#add_response - response is nil') unless response
if !response.is_a?(Swagger::Data::Reference) && !response.is_a?(Swagger::Data::Response)
response = response['$ref'] ? Swagger::Data::Reference.parse(response) : Swagger::Data::Response.parse(response)
end
@responses[response_code] = response
end
|
#as_swagger ⇒ Object
38
39
40
41
42
43
44
45
46
|
# File 'lib/ruby-swagger/data/responses.rb', line 38
def as_swagger
res = {}
@responses.each do |other_name, other_value|
res[other_name] = other_value.to_swagger
end
res
end
|