mirror of https://github.com/zulip/zulip.git
openapi: Fix 'no parameters found' with x-parameter-description.
Currently, the message that no parameters are accepted by the endpoint is displayed if there are no parameters in OpenAPI data, but it is possible that information is encoded in x-parameter-description (example in upload-file endpoint), and we want to display that information rather than the message. Added an if condition to check the same.
This commit is contained in:
parent
ad9d1c0f80
commit
fab6a5192c
|
@ -8,7 +8,11 @@ from django.utils.html import escape as escape_html
|
|||
from markdown.extensions import Extension
|
||||
from markdown.preprocessors import Preprocessor
|
||||
|
||||
from zerver.openapi.openapi import check_deprecated_consistency, get_openapi_parameters
|
||||
from zerver.openapi.openapi import (
|
||||
check_deprecated_consistency,
|
||||
get_openapi_parameters,
|
||||
get_parameters_description,
|
||||
)
|
||||
|
||||
REGEXP = re.compile(r"\{generate_api_arguments_table\|\s*(.+?)\s*\|\s*(.+)\s*\}")
|
||||
|
||||
|
@ -74,8 +78,12 @@ class APIArgumentsTablePreprocessor(Preprocessor):
|
|||
|
||||
if arguments:
|
||||
text = self.render_table(arguments)
|
||||
else:
|
||||
# We want to show this message only if the parameters
|
||||
# description doesn't say anything else.
|
||||
elif is_openapi_format and get_parameters_description(endpoint, method) == "":
|
||||
text = ["This endpoint does not accept any parameters."]
|
||||
else:
|
||||
text = []
|
||||
# The line that contains the directive to include the macro
|
||||
# may be preceded or followed by text or tags, in that case
|
||||
# we need to make sure that any preceding or following text
|
||||
|
|
Loading…
Reference in New Issue