Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get(uid):
""" Hello Fair-API
:plugin: json_p
:param Int * uid: you id ...
"""
return JsonRaise('success', {'uid': uid})
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)
def echo(name):
""" Hello Fair-API
:param Str * name: you name ...
"""
return JsonRaise('success', {'name': name})
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 # 执行(测试)案例存储
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)
def post(name, msg):
""" Hello Fair-API
:param Str * name: you name ...
:param Str msg: you message ...
"""
return JsonRaise('success', {'name': name, 'msg': msg})