Class: RailsAutodoc::DSL::ControllerExtensions::AnnotationBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_autodoc/dsl/controller_extensions.rb

Instance Method Summary collapse

Constructor Details

#initialize(annotation) ⇒ AnnotationBuilder

Returns a new instance of AnnotationBuilder.



15
16
17
# File 'lib/rails_autodoc/dsl/controller_extensions.rb', line 15

def initialize(annotation)
  @annotation = annotation
end

Instance Method Details

#body_param(name, type, options = {}) ⇒ Object



39
40
41
# File 'lib/rails_autodoc/dsl/controller_extensions.rb', line 39

def body_param(name, type, options = {})
  @annotation.body_params << { name: name.to_s, type: type.to_s }.merge(options)
end

#deprecated(value = true) ⇒ Object



31
32
33
# File 'lib/rails_autodoc/dsl/controller_extensions.rb', line 31

def deprecated(value = true)
  @annotation.deprecated = value
end

#description(text) ⇒ Object



23
24
25
# File 'lib/rails_autodoc/dsl/controller_extensions.rb', line 23

def description(text)
  @annotation.description = text
end

#exclude(value = true) ⇒ Object



35
36
37
# File 'lib/rails_autodoc/dsl/controller_extensions.rb', line 35

def exclude(value = true)
  @annotation.exclude = value
end

#query_param(name, type, options = {}) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/rails_autodoc/dsl/controller_extensions.rb', line 43

def query_param(name, type, options = {})
  @annotation.query_params << {
    name: name.to_s,
    type: type.to_s,
    required: options.fetch(:required, false)
  }.merge(options)
end

#request_body(schema) ⇒ Object



59
60
61
# File 'lib/rails_autodoc/dsl/controller_extensions.rb', line 59

def request_body(schema)
  @annotation.request_body_schema = schema
end

#response(status, options = {}) ⇒ Object



51
52
53
# File 'lib/rails_autodoc/dsl/controller_extensions.rb', line 51

def response(status, options = {})
  @annotation.responses[status.to_s] = options
end

#security(scheme) ⇒ Object



55
56
57
# File 'lib/rails_autodoc/dsl/controller_extensions.rb', line 55

def security(scheme)
  @annotation.security = scheme
end

#summary(text) ⇒ Object



19
20
21
# File 'lib/rails_autodoc/dsl/controller_extensions.rb', line 19

def summary(text)
  @annotation.summary = text
end

#tag(*tags) ⇒ Object



27
28
29
# File 'lib/rails_autodoc/dsl/controller_extensions.rb', line 27

def tag(*tags)
  @annotation.tags.concat(tags.map(&:to_s))
end