api_docs: Update get-file-temporary-url endpoint and add to sidebar.

Co-authored-by: Lauryn Menard <lauryn@zulip.com>
This commit is contained in:
Karl Stolley
2025-08-25 16:35:10 -04:00
committed by Tim Abbott
parent 6e17b05156
commit 41e8d79e00
4 changed files with 27 additions and 7 deletions

View File

@@ -5,6 +5,7 @@
# based on Zulip's OpenAPI definitions, as well as test setup and
# fetching of appropriate parameter values to use when running the
# cURL examples as part of the tools/test-api test suite.
import re
from collections.abc import Callable
from functools import wraps
from typing import Any
@@ -413,3 +414,16 @@ def add_channel_folders() -> dict[str, object]:
channel_folders = ChannelFolder.objects.filter(realm=realm)
return {"order": [folder.id for folder in channel_folders]}
@openapi_param_value_generator(["/user_uploads/{realm_id_str}/{filename}:get"])
def get_temporary_url_for_uploaded_file() -> dict[str, object]:
realm_id = ""
filename = ""
user_profile = helpers.example_user("iago")
url = upload_message_attachment("dummy.txt", "text/plain", b"zulip!", user_profile)[0]
upload_path_parts = re.match(r"/user_uploads/(\d+)/(.*)", url)
if upload_path_parts:
realm_id = upload_path_parts[1]
filename = upload_path_parts[2]
return {"realm_id_str": realm_id, "filename": filename}