Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
view_class = getattr(endpoint, 'view_class', None)
if view_class and issubclass(view_class, SwaggerView):
apispec_swag = {}
apispec_attrs = optional_fields + [
'parameters', 'definitions', 'responses',
'summary', 'description'
]
for attr in apispec_attrs:
value = getattr(view_class, attr)
if value:
apispec_swag[attr] = value
apispec_definitions = apispec_swag.get('definitions', {})
swag.update(
convert_schemas(apispec_swag, apispec_definitions)
)
swag['definitions'] = apispec_definitions
swagged = True
if doc_dir:
if view_class:
file_path = os.path.join(
doc_dir, endpoint.__name__, method.__name__ + '.yml')
else:
file_path = os.path.join(
doc_dir, endpoint.__name__ + '.yml')
if os.path.isfile(file_path):
func = method.__func__ \
if hasattr(method, '__func__') else method
setattr(func, 'swag_type', 'yml')
if method is None:
if is_mv: # #76 Empty MethodViews
continue
raise RuntimeError(
'Cannot detect view_func for rule {0}'.format(rule)
)
swag = {}
swagged = False
if getattr(method, 'specs_dict', None):
definition = {}
merge_specs(
swag,
convert_schemas(deepcopy(method.specs_dict), definition)
)
swag['definitions'] = definition
swagged = True
view_class = getattr(endpoint, 'view_class', None)
if view_class and issubclass(view_class, SwaggerView):
apispec_swag = {}
apispec_attrs = optional_fields + [
'parameters', 'definitions', 'responses',
'summary', 'description'
]
for attr in apispec_attrs:
value = getattr(view_class, attr)
if value:
apispec_swag[attr] = value