How to use the fair.response.JsonRaise 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 / examples / hello.py View on Github external
def get(uid):
    """ Hello Fair-API

    :plugin: json_p
    :param Int * uid: you id ...
    """
    return JsonRaise('success', {'uid': uid})
github remyzane / fair-api / fair / register.py View on Github external
def setup(app, cache_path,
               responses=None,
               plugins=None,
               parameter_types=None):



    app.config['responses'] = {'default': JsonRaise}

    # set parameter types
    set_parameter_types(app, parameter_types)

    # configure web ui
    web_ui_config = {
        'uri': 'api',
        'test_ui': {
            'uri': 'tests'
        }
    }
    app.config['web_ui'] = web_ui_config
    setup_web_ui(app, web_ui_config, cache_path, TestsLocalStorage)
github remyzane / fair-api / examples / hello.py View on Github external
def echo(name):
    """ Hello Fair-API

    :param Str * name: you name ...
    """
    return JsonRaise('success', {'name': name})
github remyzane / fair-api / fair / api_setts.py View on Github external
def __init__(self, app, case_storage=None):
        from .plugin import jsonp
        self.app = app

        self.url_map = dict()

        self.plugins = {'json_p': jsonp.JsonP('callback')}

        self.responses = {'default': JsonRaise}

        self.parameter_types = get_parameter_types()

        self.case_storage = case_storage                    # 执行(测试)案例存储
github remyzane / fair-api / fair / configure_old.py View on Github external
def fair_setup(app, cache_path,
               view_packages=None,
               responses=None,
               plugins=None,
               parameter_types=None):

    app.config['fair_plugins'] = plugins or {}

    app.config['responses'] = {'default': JsonRaise}

    # set parameter types
    set_parameter_types(app, parameter_types)

    # configure view
    setup_view(app, view_packages)

    # configure web ui
    web_ui_config = {
        'uri': 'api',
        'exe_ui': {
            'uri': 'tests'
        }
    }
    app.config['web_ui'] = web_ui_config
    setup_web_ui(app, web_ui_config, cache_path, CaseLocalStorage)
github remyzane / fair-api / examples / hello.py View on Github external
def post(name, msg):
    """ Hello Fair-API

    :param Str * name: you name ...
    :param Str msg: you message ...
    """
    return JsonRaise('success', {'name': name, 'msg': msg})