Changeset View
Changeset View
Standalone View
Standalone View
swh/web/api/apiresponse.py
Show First 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | if request.accepted_media_type == 'text/html': | ||||
if data: | if data: | ||||
data = json.dumps(data, sort_keys=True, | data = json.dumps(data, sort_keys=True, | ||||
indent=4, | indent=4, | ||||
separators=(',', ': ')) | separators=(',', ': ')) | ||||
doc_env['response_data'] = data | doc_env['response_data'] = data | ||||
doc_env['heading'] = shorten_path(str(request.path)) | doc_env['heading'] = shorten_path(str(request.path)) | ||||
# generate breadcrumbs data | |||||
if 'route' in doc_env: | if 'route' in doc_env: | ||||
doc_env['endpoint_path'] = gen_path_info(doc_env['route']) | doc_env['endpoint_path'] = gen_path_info(doc_env['route']) | ||||
for i in range(len(doc_env['endpoint_path']) - 1): | |||||
doc_env['endpoint_path'][i]['path'] += '/doc/' | |||||
if not doc_env['noargs']: | |||||
doc_env['endpoint_path'][-1]['path'] += '/doc/' | |||||
response_args['data'] = doc_env | response_args['data'] = doc_env | ||||
response_args['template_name'] = 'api/apidoc.html' | response_args['template_name'] = 'api/apidoc.html' | ||||
# otherwise simply return the raw data and let DRF picks | # otherwise simply return the raw data and let DRF picks | ||||
# the correct renderer (JSON or YAML) | # the correct renderer (JSON or YAML) | ||||
else: | else: | ||||
response_args['data'] = data | response_args['data'] = data | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |