   generate {type: types[typeIndex]}, method, depth + 1
 
 
+# type = []
 generate.oneOf = (schema, method = 'all', depth = 0) ->
   return 0  unless schema.type.length # treat as 'any'
   randomOptions =

randexp = do () ->
  _randexp = require 'randexp'
  (pattern) -> new _randexp(pattern).gen()

module.exports = generate = (schema, method = 'all', depth = 0) ->
  return schema  unless type(schema) is 'object'

  random 'number', randomOptions


# type = string
generate.string = (schema, method = 'all', depth = 0) ->
  return randexp schema.pattern  if schema.pattern
  # FIXME format should not be ignored
  randomOptions =
    minLength: schema.minLength
    maxLength: schema.maxLength
  random 'string', randomOptions


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

  if schema.additionalItems
    if type(schema.minItems) isnt 'undefined'
      minimum = schema.minItems - o.length
    else
