mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 12:33:40 +00:00
apidocs: Fix invalid API page bug.
The current logic to get API pages' title using OperationID should be used when the first line of the file explicitly mentions so. In cases where the files didn't begin with `#` but also didn't need to get title from OpenAPI summary, this logic fails and causes Server error. This particularly happens when the article is invalid, and the `missing.md` file doesn't need title to be generated, but doesn't start with `#` either. This commit fixes the logic of using the generated title and covers the bug.
This commit is contained in:
committed by
Tim Abbott
parent
5db53029a5
commit
d1ccf15cd3
@@ -106,7 +106,7 @@ class MarkdownDirectoryView(ApiURLView):
|
||||
with open(article_path) as article_file:
|
||||
first_line = article_file.readlines()[0]
|
||||
# Strip the header and then use the first line to get the article title
|
||||
if self.path_template == "/zerver/api/%s.md" and first_line[0] != "#":
|
||||
if self.path_template == "/zerver/api/%s.md" and "{generate_api_title(" in first_line:
|
||||
api_operation = context["OPEN_GRAPH_URL"].split("/api/")[1].replace("-", "_")
|
||||
endpoint_path, endpoint_method = get_endpoint_from_operationid(api_operation)
|
||||
article_title = get_openapi_summary(endpoint_path, endpoint_method)
|
||||
|
||||
Reference in New Issue
Block a user