class SwaggerPrinter

This class walks through the payload object and builds a prettified representation in rswag format.

Public Class Methods

end_wrap() click to toggle source
# File lib/printer.rb, line 28
def end_wrap
  line = ''
  while @indent > 2
    @indent -= 2
    line += ' ' * @indent + "}\n"
  end
  line + '}'
end
escape_key(key) click to toggle source
# File lib/printer.rb, line 90
def escape_key(key)
  return key unless key.to_s.include?('-')

  "'#{key}'"
end
prettify_value(type, key, val) click to toggle source
# File lib/printer.rb, line 96
def prettify_value(type, key, val)
  return ':' + val.to_s if key == :type
  return val if key != :example
  return 'nil' if val.nil?

  type[:type] == :string ? "'#{val}'" : val
end
print_array(key, val) click to toggle source
print_hash(key, val) click to toggle source
print_line(key, val) click to toggle source
print_swagger(object, test_title) click to toggle source
print_values(object) click to toggle source
wrap_array() click to toggle source
# File lib/printer.rb, line 21
def wrap_array
  line  = ' ' * @indent + "type: :array,\n"
  line += ' ' * @indent + "items: {\n"
  @indent += 2
  line
end
wrap_hash() click to toggle source
# File lib/printer.rb, line 14
def wrap_hash
  line  = ' ' * @indent + "type: :object,\n"
  line += ' ' * @indent + "properties: {\n"
  @indent += 2
  line
end