from typing import Dict
from typing import Any
from typing import List


def process_properties(schema: Dict[str, Any]) -> Dict[str, Any]:
    """Processes a Pydantic generated schema to a confluent compliant schema

    :param schema: a valid pydantic schema
    :type schema: Dict[str, Any]
    :return: schema with `fields` and `names` keys
    :rtype: Dict[str, Any]
    """
    fields: List[Dict[str, Any]] = []

    json2avro_types = {
        'number': 'double',
        'integer': 'int'
    }

    python2avro_defaults = {
        False: 'false',
        True: 'true'
    }

    for name, value in schema['properties'].items():
        try:
            value.pop('title')
            value['name'] = name

            json_type = value['type']
            value['type'] = json2avro_types.get(json_type, json_type)

            if value.get('default') is not None:
                default = value['default']
                value['default'] = python2avro_defaults.get(default, default)

        finally:
            fields.append(value)
    schema['fields'] = fields
    return schema