import pydantic
from typing import List


def _find_optionals(model: pydantic.BaseModel) -> List[str]:
    """Helper function to parse pydantic ModelField to find optional
    types

    Args:
        model (pydantic.BaseModel): A Pydantic Model

    Returns:
        List[str]: Optional parameters as a list of strings
    """
    optionals = []
    for k, v in model.__fields__.items():
        type_ = str(v).split(' ')[1].replace('type=', '')
        if 'Optional' in type_:
            optionals.append(k)
    return optionals