Changeset View
Changeset View
Standalone View
Standalone View
swh/web/api/apiresponse.py
Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | ) -> HttpResponse: | ||||
# get request status code | # get request status code | ||||
doc_data["status_code"] = options.get("status", 200) | doc_data["status_code"] = options.get("status", 200) | ||||
# when requesting HTML, typically when browsing the API through its | # when requesting HTML, typically when browsing the API through its | ||||
# documented views, we need to enrich the input data with documentation | # documented views, we need to enrich the input data with documentation | ||||
# and render the apidoc HTML template | # and render the apidoc HTML template | ||||
if request.accepted_media_type == "text/html": | if request.accepted_media_type == "text/html": | ||||
doc_data["response_data"] = data | doc_data["response_data"] = data | ||||
if data: | if data is not None: | ||||
doc_data["response_data"] = json.dumps( | doc_data["response_data"] = json.dumps( | ||||
data, cls=JSONEncoder, sort_keys=True, indent=4, separators=(",", ": ") | data, cls=JSONEncoder, sort_keys=True, indent=4, separators=(",", ": ") | ||||
) | ) | ||||
doc_data["heading"] = shorten_path(str(request.path)) | doc_data["heading"] = shorten_path(str(request.path)) | ||||
# generate breadcrumbs data | # generate breadcrumbs data | ||||
if "route" in doc_data: | if "route" in doc_data: | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |