module Apicraft::Mocker

def self.extract_type(schema)

def self.extract_type(schema)
  return schema.type if schema.type.present?
  return "one_of" if schema.one_of.present?
  return "any_of" if schema.any_of.present?
  "all_of" if schema.all_of.present?
end

def self.handler_for(schema)

def self.handler_for(schema)
  "Apicraft::Mocker::#{
    extract_type(schema).camelize
  }".constantize
end

def self.mock(schema)

def self.mock(schema)
  return if schema.blank?
  handler_for(schema).new(
    schema
  ).mock
end