import re


def extract_path_arguments(path):
    """
    Extracts a swagger path arguments from the given flask path.
    This /path/<parameter> extracts [{name: 'parameter'}]
    And this /<string(length=2):lang_code>/<string:id>/<float:probability>
    extracts: [
    {name: 'lang_code', dataType: 'string'},
    {name: 'id', dataType: 'string'}
    {name: 'probability', dataType: 'float'}]
    """
    # Remove all parentheses
    path = re.sub('\([^\)]*\)', '', path)
    args = re.findall('<([^>]+)>', path)

    def split_arg(arg):
        spl = arg.split(':')
        if len(spl) == 1:
            return {
                'name': spl[0],
                'dataType': 'string',
                'paramType': 'path',
            }
        else:
            return {
                'name': spl[1],
                'dataType': spl[0],
                'paramType': 'path',
            }

    return list(map(split_arg, args))