 
 
   # type = boolean
-  boolean: (schema, method = 'all', depth = 0) ->
+  boolean: (schema, depth = 0) ->
     random 'boolean'
 
 
   # type = number / integer
-  number: (schema, method = 'all', depth = 0) ->
-    @integer schema, method, depth
+  number: (schema, depth = 0) ->
+    @integer schema, depth
 
-  integer: (schema, method = 'all', depth = 0) ->
+  integer: (schema, depth = 0) ->
     minimum = schema.exclusiveMinimum + 1  if schema.exclusiveMinimum
     minimum ?= schema.minimum
     maximum = schema.exclusiveMaximum - 1  if schema.exclusiveMaximum


module.exports = exports = (schema, method = 'all') ->
  generator = new exports.Generator
  return generator.generate schema, method

class exports.Generator

  generate: (schema, method = 'all', depth = 0) ->

    return schema  unless type(schema) is 'object'

    return @enum schema, method, depth  if schema.enum

    switch schema.type
      when 'string', 'number', 'integer', 'boolean', 'array', 'object', 'null'
        return @[schema.type] schema, method, depth
      else
        if type(schema.type) is 'array'
          return @oneOf schema, method, depth
        # FIXME what if type(schema.type) = 'object' and _.size(schema.type) > 0 ?
        if schema.type is 'any' or type(schema.type) is 'undefined' or (type(schema.type) is 'object' and _.size(schema.type) is 0)
          return @any schema, method, depth
        # FIXME what type is this?
        console.log schema.type
        throw "what type is this ?"


  # enum
  'enum': (schema, method = 'all', depth = 0) ->
    randomOptions =
      minimum: 0
      maximum: schema.enum.length - 1
    randomIndex = random 'integer', randomOptions
    enumValue = schema.enum[randomIndex]
    @generate enumValue, method, depth + 1


  # type = null



  # type = array
  array: (schema, depth = 0) ->
    o = []
    if type(schema.items) is 'array' and schema.items.length
      for itemSchema in schema.items
        o.push @generate itemSchema, depth + 1

    if schema.additionalItems
      if type(schema.minItems) isnt 'undefined'
