Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_load_operations_from_docstring_empty_docstring(docstring):
assert yaml_utils.load_operations_from_docstring(docstring) == {}
return operations
operations = {}
# views can be class based
if view.get("attr"):
global_meta = load_operations_from_docstring(view["callable"].__doc__)
if global_meta:
operations.update(global_meta)
f_view = getattr(view["callable"], view["attr"])
# or just function callables
else:
f_view = view.get("callable")
methods = view.get("request_methods")
view_operations = load_operations_from_docstring(f_view.__doc__)
if not view_operations:
view_operations = {}
if is_string(methods):
methods = [methods]
if not methods:
methods = ALL_METHODS[:]
operation = load_yaml_from_docstring(f_view.__doc__)
if operation:
for method in methods:
view_operations[method.lower()] = operation
elif autodoc:
for method in methods:
view_operations.setdefault(method.lower(), {"responses": {}})
operations.update(view_operations)
return operations