openapi: Make endpoint operationId dash-separated.

The operationId is directly used in URLs of API doc pages
to find the OpenAPI data to render. However, this is dash-
separated in the URLs, and having underscore_separated IDs
in OpenAPI data doesn't allow direct comparison of the two.

This commit changes all OperationIDs from underscore_separated
to dash-separated.
This commit is contained in:
Suyash Vardhan Mathur
2021-07-09 19:39:32 +05:30
committed by Tim Abbott
parent 644cd18dfd
commit 309f4ba145
4 changed files with 72 additions and 75 deletions

View File

@@ -92,9 +92,8 @@ class MarkdownDirectoryView(ApiURLView):
article_path = os.path.join(settings.DEPLOY_ROOT, "templates") + path
if (not os.path.exists(article_path)) and self.path_template == "/zerver/api/%s.md":
endpoint_path = article.replace("-", "_")
try:
endpoint_name, endpoint_method = get_endpoint_from_operationid(endpoint_path)
endpoint_name, endpoint_method = get_endpoint_from_operationid(article)
path = "/zerver/api/api-doc-template.md"
except AssertionError:
return DocumentationArticle(
@@ -159,7 +158,7 @@ class MarkdownDirectoryView(ApiURLView):
assert endpoint_method is not None
article_title = get_openapi_summary(endpoint_name, endpoint_method)
elif self.path_template == "/zerver/api/%s.md" and "{generate_api_title(" in first_line:
api_operation = context["OPEN_GRAPH_URL"].split("/api/")[1].replace("-", "_")
api_operation = context["OPEN_GRAPH_URL"].split("/api/")[1]
endpoint_name, endpoint_method = get_endpoint_from_operationid(api_operation)
article_title = get_openapi_summary(endpoint_name, endpoint_method)
else: