Class: WeakSwaggerParameters::Definitions::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/weak_swagger_parameters/definitions/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(status_code, description, &block) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
11
12
# File 'lib/weak_swagger_parameters/definitions/response.rb', line 6

def initialize(status_code, description, &block)
  @status_code = status_code
  @description = description
  @content_schema = nil

  instance_eval(&block) if block.present?
end

Instance Method Details

#apply_docs(parent_node) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/weak_swagger_parameters/definitions/response.rb', line 26

def apply_docs(parent_node)
  status_code = @status_code
  response_options = { description: @description }
  content_schema = @content_schema

  parent_node.instance_eval do
    response status_code, response_options do
      response_node = self

      content_schema.apply_docs(response_node) if content_schema.present?
    end
  end
end

#collection(model_class) ⇒ Object



22
23
24
# File 'lib/weak_swagger_parameters/definitions/response.rb', line 22

def collection(model_class)
  @content_schema = WeakSwaggerParameters::Definitions::CollectionRef.new(model_class)
end

#hash(&block) ⇒ Object



14
15
16
# File 'lib/weak_swagger_parameters/definitions/response.rb', line 14

def hash(&block)
  @content_schema = WeakSwaggerParameters::Definitions::HashRef.new(&block)
end

#model(model_class) ⇒ Object



18
19
20
# File 'lib/weak_swagger_parameters/definitions/response.rb', line 18

def model(model_class)
  @content_schema = WeakSwaggerParameters::Definitions::ModelRef.new(model_class)
end