def to_schema(self):
        """
        Convert the current schema to a `dict`.
        """
        types = set()
        generated_schemas = []
        for schema_generator in self._schema_generators:
            generated_schema = schema_generator.to_schema()
            if len(generated_schema) == 1 and 'type' in generated_schema:
                types.add(generated_schema['type'])
            else:
                generated_schemas.append(generated_schema)

        if types:
            if len(types) == 1:
                (types,) = types
            else:
                types = sorted(types)
            generated_schemas = [{'type': types}] + generated_schemas
        if len(generated_schemas) == 1:
            (result_schema,) = generated_schemas
        elif generated_schemas:
            result_schema = {'anyOf': generated_schemas}
        else:
            result_schema = {}

        return result_schema
def to_schema ( self ) : types = set ( ) generated_schemas = [ ] for schema_generator in self . _schema_generators : generated_schema = schema_generator . to_schema ( ) if len ( generated_schema ) == 1 and 'type' in generated_schema : types . add ( generated_schema [ 'type' ] ) else : generated_schemas . append ( generated_schema ) if types : if len ( types ) == 1 : ( types , ) = types else : types = sorted ( types ) generated_schemas = [ { 'type' : types } ] + generated_schemas if len ( generated_schemas ) == 1 : ( result_schema , ) = generated_schemas elif generated_schemas : result_schema = { 'anyOf' : generated_schemas } else : result_schema = { } return result_schema
Convert the current schema to a `dict`.