Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 # 执行(测试)案例存储
c.meta = view_func.meta
break
if not c.meta:
return 'Http method [%s] not support' % c.method
context = {'api_config': {}, 'api_json_p': None}
c.url = request.path
c.path = 'http://+ request.environ[HTTP_HOST] + view.uri'
c.params = get_api_params(c.meta.param_list, context.get('api_config'))
c.title = text_to_html(c.meta.title)
c.params_config = {}
c.curr_api_config = {}
for plugin in c.meta.plugins:
if isinstance(plugin, jsonp.JsonP):
c.json_p = plugin.callback_field_name
# return context
# context = {'user': user,
# 'title': 'Test UI',
# 'web_ui_uri': app.config['web_ui']['uri'],
# 'exe_ui_uri': app.config['web_ui']['exe_ui']['uri'],
# 'post_type': request.args.get('type', 'j')}
# for name in app.view_functions.keys():
# view_class = getattr(app.view_functions[name], 'view_class', None)
# if view_class and issubclass(view_class, CView) and view_class != CView:
# for method_name in view_class.request_methods.keys():
# method = view_class.request_methods[method_name]
api_config_path = os.path.join(self.get_case_dir(view.uri, method.__name__.upper()), '__config__')
if os.path.exists(api_config_path):
with open(api_config_path, 'r') as config:
context['api_config'] = json.load(config)
# title, description = method.meta.title, method.meta.description
# context['api_uri'] = view.uri
# context['api_path'] = 'http://' + request.environ['HTTP_HOST'] + view.uri
# context['api_method'] = method.__name__.upper()
# context['api_params'] = get_api_params(method.meta.param_list, context.get('api_config'))
# context['api_description'] = text_to_html(title + (os.linesep*2 if description else '') + description)
# context['api_params_config'] = {}
context['api_codes'] = self.get_sorted_code(view, method)
for plugin in method.api.plugins:
if isinstance(plugin, JsonP):
context['api_json_p'] = plugin.callback_field_name
return context
def __init__(self, callback_field_name):
super(JsonP, self).__init__()
self.callback_field_name = callback_field_name