Class: Brainstem::ApiDocs::Formatters::OpenApiSpecification::Version2::Endpoint::ResponseDefinitionsFormatter

Inherits:
AbstractFormatter
  • Object
show all
Includes:
Helper
Defined in:
lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_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) ⇒ ResponseDefinitionsFormatter

Returns a new instance of ResponseDefinitionsFormatter.



21
22
23
24
25
26
27
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter.rb', line 21

def initialize(endpoint)
  @endpoint    = endpoint
  @http_method = format_http_method(endpoint)
  @presenter   = endpoint.presenter
  @model_name  = presenter ? presenter_title(presenter) : "object"
  @output      = ActiveSupport::HashWithIndifferentAccess.new
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



19
20
21
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter.rb', line 19

def output
  @output
end

Instance Method Details

#callObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter.rb', line 29

def call
  if endpoint.custom_response_configuration_tree.present?
    format_custom_response!
  elsif http_method == 'delete'
    format_delete_response!
  else
    format_schema_response!
  end
  format_error_responses!

  output
end