api docs: Expand checking for deprecated fields.

Added assertion to check that if a deprecated flag is in a field's
schema, then it should have deprecated mentioned in description
as well, and moved these checks to a separate function.
Fixes part of #15967.
This commit is contained in:
Suyash Vardhan Mathur
2021-02-16 17:31:36 +05:30
committed by Tim Abbott
parent 422fea8f20
commit 96bfeeb9e6
3 changed files with 12 additions and 8 deletions

View File

@@ -8,7 +8,7 @@ from django.utils.html import escape as escape_html
from markdown.extensions import Extension
from markdown.preprocessors import Preprocessor
from zerver.openapi.openapi import get_openapi_parameters, likely_deprecated_parameter
from zerver.openapi.openapi import check_deprecated_consistency, get_openapi_parameters
REGEXP = re.compile(r"\{generate_api_arguments_table\|\s*(.+?)\s*\|\s*(.+)\s*\}")
@@ -139,9 +139,7 @@ class APIArgumentsTablePreprocessor(Preprocessor):
else:
required_block = '<span class="api-argument-optional">optional</span>'
# Test to make sure deprecated parameters are marked so.
if likely_deprecated_parameter(description):
assert argument["deprecated"]
check_deprecated_consistency(argument, description)
if argument.get("deprecated", False):
deprecated_block = '<span class="api-argument-deprecated">Deprecated</span>'
else: