Module: OpenApiAnnotator::ControllerAnnotatable

Defined in:
lib/open_api_annotator/controller_annotatable.rb

Instance Method Summary collapse

Instance Method Details

#endpoint(type) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/open_api_annotator/controller_annotatable.rb', line 12

def endpoint(type)
  validate_open_api_type!(type)
  @last_type = type

rescue ValidationError => e
  raise TypeError, "  \#{e.message}\n\n  Examples:\n    - `[Project]`: means collection of Project\n    - `Project`: means single resouce Project\n\n  In your controller:\n\n    endpoint [Project]\n    def index\n      # ... some code\n    end\n  EOL\nend\n"

#method_added(name) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/open_api_annotator/controller_annotatable.rb', line 33

def method_added(name)
  super
  return unless @last_type

  type = @last_type
  @last_type = nil

  return if private_method_defined?(name)

  type_hash[name] = type
end

#type_hashObject



3
4
5
# File 'lib/open_api_annotator/controller_annotatable.rb', line 3

def type_hash
  @type_hash ||= {}
end

#validate_open_api_type!(type) ⇒ Object



7
8
9
10
# File 'lib/open_api_annotator/controller_annotatable.rb', line 7

def validate_open_api_type!(type)
  @open_api_type_validator ||= TypeValidator.new
  @open_api_type_validator.validate!(type)
end