Method: Fdoc::EndpointPresenter#example_from_atom

Defined in:
lib/fdoc/presenters/endpoint_presenter.rb

#example_from_atom(schema) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/fdoc/presenters/endpoint_presenter.rb', line 112

def example_from_atom(schema)
  type = Array(schema["type"])
  hash = schema.hash

  if type.include?("boolean")
    [true, false][hash % 2]
  elsif type.include?("integer")
    hash % 1000
  elsif type.include?("number")
    Math.sqrt(hash % 1000).round 2
  elsif type.include?("string")
    ""
  else
    nil
  end
end