class Fictium::OpenApi::V3Exporter::ContentFormatter

Public Instance Methods

format(http_object, default = nil) click to toggle source
# File lib/fictium/exporters/open_api/v3_exporter/content_formatter.rb, line 5
def format(http_object, default = nil)
  type = (http_object.presence && http_object[:content_type].presence) || default
  return if type.blank?

  {}.tap do |content|
    media_type = {
      example: http_object[:body]
    }
    media_type[:schema] = http_object[:schema] if http_object[:schema].present?
    content[type.to_sym] = media_type
  end
end