mirror of https://github.com/zulip/zulip.git
api docs: Display the default value of parameters when present.
Whenever a parameter for an endpoint in our REST API has a default value, it is displayed under the "Description" section of the arguments table in the docs. This way, we don't need to explicitly indicate the default values in the description, thus avoiding duplicate information in the OpenAPI source.
This commit is contained in:
parent
038f50b05e
commit
95ce311686
|
@ -115,11 +115,17 @@ class APIArgumentsTablePreprocessor(Preprocessor):
|
|||
md_engine = markdown.Markdown(extensions=[])
|
||||
|
||||
for argument in arguments:
|
||||
description = argument['description']
|
||||
|
||||
oneof = ['`' + item + '`'
|
||||
for item in argument.get('schema', {}).get('enum', [])]
|
||||
description = argument['description']
|
||||
if oneof:
|
||||
description += '\nMust be one of: {}.'.format(', '.join(oneof))
|
||||
|
||||
default = argument.get('schema', {}).get('default')
|
||||
if default is not None:
|
||||
description += '\nDefaults to `{}`.'.format(ujson.dumps(default))
|
||||
|
||||
# TODO: Swagger allows indicating where the argument goes
|
||||
# (path, querystring, form data...). A column in the table should
|
||||
# be added for this.
|
||||
|
|
Loading…
Reference in New Issue