Generate a random plain schema, and a sample generation function.

    :param valid: Generate valid samples?
    :type valid: bool
    :returns: schema, sample-generator
    :rtype: *, generator

def generate_random_schema(valid):
    """ Generate a random plain schema, and a sample generation function.

    :param valid: Generate valid samples?
    :type valid: bool
    :returns: schema, sample-generator
    :rtype: *, generator
    """
    schema_type = choice(['literal', 'type'])

    if schema_type == 'literal':
        type, gen = generate_random_type(valid)
        value = next(gen)
        return value, (value if valid else None for i in itertools.count())
    elif schema_type == 'type':
        return generate_random_type(valid)
    else:
        raise AssertionError('!')