module Brainstem::ApiDocs::Formatters::OpenApiSpecification::Helper
Constants
- TYPE_INFO
Public Instance Methods
format_http_method(endpoint)
click to toggle source
# File lib/brainstem/api_docs/formatters/open_api_specification/helper.rb, line 11 def format_http_method(endpoint) endpoint.http_methods.first.downcase end
format_sentence(description)
click to toggle source
# File lib/brainstem/api_docs/formatters/open_api_specification/helper.rb, line 21 def format_sentence(description) return '' if description.blank? desc = description.to_s.strip.tap { |desc| desc[0] = desc[0].upcase } desc += "." unless desc =~ /\.\s*\z/ desc end
format_tag_name(name)
click to toggle source
# File lib/brainstem/api_docs/formatters/open_api_specification/helper.rb, line 15 def format_tag_name(name) return name if name.blank? name.underscore.titleize.strip end
presenter_title(presenter)
click to toggle source
# File lib/brainstem/api_docs/formatters/open_api_specification/helper.rb, line 6 def presenter_title(presenter) presenter.contextual_documentation(:title).presence || presenter.target_class.underscore.singularize.titleize.strip end
type_and_format(type, item_type = nil)
click to toggle source
# File lib/brainstem/api_docs/formatters/open_api_specification/helper.rb, line 35 def type_and_format(type, item_type = nil) result = case type.to_s.downcase when 'array' { 'type' => 'array', 'items' => type_and_format(item_type.presence || 'string') } else TYPE_INFO[type.to_s] end result ? result.with_indifferent_access : nil end
uncapitalize(description)
click to toggle source
# File lib/brainstem/api_docs/formatters/open_api_specification/helper.rb, line 29 def uncapitalize(description) return '' if description.blank? description.strip.tap { |desc| desc[0] = desc[0].downcase } end