How to use the fair.parameter.List function in fair

To help you get started, we’ve selected a few fair examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github remyzane / fair-api / fair / api_meta.py View on Github external
if request_method not in ('HEAD', 'OPTIONS'):
                    if request_method not in param_type.support:
                        error = 'parameter %s not support http %s method in %s'
                        raise Exception(error % (param_type.__name__, request_method, self.rule))

            param = {'name': items[-1], 'type': param_type, 'requisite': False, 'description': content}
            if len(items) > 2 and items[1] == '*':
                param['requisite'] = True
                self.param_not_null.append(items[-1])
            else:
                self.param_allow_null.append(items[-1])
            self.param_list.append(param)
            self.param_dict[items[-1]] = param
            self.param_default[items[-1]] = None
            self.param_types[items[-1]] = param_type
            if isinstance(param['type'], List):
                self.__code_set(param_type.type.error_code, param_type.type.description, 'type')
                self.__code_set(param_type.error_code,
                                        param_type.description % param_type.type.__name__, 'type')
            elif param['type'] != Param:
                self.__code_set(param_type.error_code, param_type.description, 'type')
        else:
            setattr(self, name, content)
github remyzane / fair-api / fair / meta_old.py View on Github external
if not param_type:
                raise Exception('%s.%s use undefined parameter type %s' % (self.__name__, method.__name__, items[0]))
            if method.__name__.upper() not in param_type.support:
                raise Exception('%s.%s use parameter %s type that not support %s method.' %
                                (self.__name__, method.__name__, param_type.__name__, method.__name__.upper()))
            param = {'name': items[-1], 'type': param_type, 'requisite': False, 'description': content}
            if len(items) > 2 and items[1] == '*':
                param['requisite'] = True
                self.param_not_null.append(items[-1])
            else:
                self.param_allow_null.append(items[-1])
            self.param_list.append(param)
            self.param_dict[items[-1]] = param
            self.param_default[items[-1]] = None
            self.param_types[items[-1]] = param_type
            if isinstance(param['type'], List):
                self.__meta_code_set(param_type.type.error_code, param_type.type.description, 'type')
                self.__meta_code_set(param_type.error_code, param_type.description % param_type.type.__name__, 'type')
            elif param['type'] != Param:
                self.__meta_code_set(param_type.error_code, param_type.description, 'type')
        else:
            setattr(self, name, content)
github remyzane / fair-api / fair / parameter.py View on Github external
def __init__(self, _type=None):
        self.type = _type
        # self.__name__ = 'List[%s]' % _type.__name__
        self.__name__ = List.__name__