Class: Brainstem::ApiDocs::Formatters::OpenApiSpecification::Version2::EndpointFormatter

Inherits:
AbstractFormatter
  • Object
show all
Extended by:
Forwardable
Includes:
Helper
Defined in:
lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#format_description, #format_http_method, #format_tag_name, #presenter_title, #type_and_format, #uncapitalize

Methods inherited from AbstractFormatter

call

Methods included from Concerns::Optional

#valid_options

Constructor Details

#initialize(endpoint, options = {}) ⇒ EndpointFormatter

Returns a new instance of EndpointFormatter.



26
27
28
29
30
31
32
33
34
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter.rb', line 26

def initialize(endpoint, options = {})
  self.endpoint     = endpoint
  self.presenter    = endpoint.presenter
  self.endpoint_key = formatted_url
  self.http_method  = format_http_method(endpoint)
  self.output       = { endpoint_key => { http_method => {} } }.with_indifferent_access

  super options
end

Instance Attribute Details

#endpointObject

Returns the value of attribute endpoint.



20
21
22
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter.rb', line 20

def endpoint
  @endpoint
end

#endpoint_keyObject

Returns the value of attribute endpoint_key.



20
21
22
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter.rb', line 20

def endpoint_key
  @endpoint_key
end

#http_methodObject

Returns the value of attribute http_method.



20
21
22
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter.rb', line 20

def http_method
  @http_method
end

#outputObject

Returns the value of attribute output.



20
21
22
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter.rb', line 20

def output
  @output
end

#presenterObject

Returns the value of attribute presenter.



20
21
22
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter.rb', line 20

def presenter
  @presenter
end

Instance Method Details

#callObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter.rb', line 36

def call
  return {} if endpoint.nodoc?

  format_summary!
  format_optional_info!
  format_security!
  format_tags!
  format_parameters!
  format_response!

  output
end