mirror of https://github.com/zulip/zulip.git
api_docs: Fix enum strings in parameters to have quotes.
Fixes the rendering of enums to show strings with quotation marks, while integers will continue to be rendered without quotation marks. This allows for an empty string to be passed as an enum value and be rendered as such in the documentation. Null will be rendered without quotation marks, like integer values.
This commit is contained in:
parent
5e506a833f
commit
a832a8a3af
|
@ -140,9 +140,12 @@ class APIArgumentsTablePreprocessor(Preprocessor):
|
|||
for argument in arguments:
|
||||
name = argument.get("argument") or argument.get("name")
|
||||
description = argument["description"]
|
||||
oneof = ["`" + str(item) + "`" for item in argument.get("schema", {}).get("enum", [])]
|
||||
if oneof:
|
||||
description += "\nMust be one of: {}.".format(", ".join(oneof))
|
||||
enums = argument.get("schema", {}).get("enum")
|
||||
if enums is not None:
|
||||
formatted_enums = [
|
||||
OBJECT_CODE_TEMPLATE.format(value=json.dumps(enum)) for enum in enums
|
||||
]
|
||||
description += "\nMust be one of: {}. ".format(", ".join(formatted_enums))
|
||||
|
||||
default = argument.get("schema", {}).get("default")
|
||||
if default is not None:
|
||||
|
|
Loading…
Reference in New Issue