mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 22:19:48 +00:00
api docs: Display example arguments as JSON.
Some of the arguments in our REST API have to be sent as JSON objects, which only accept double quotes for strings. If we display the examples as normal Python objects, the syntax would be quite similar but it would use simple quotes, which is invalid JSON (and isn't accepted by the server). That's why all the examples should be JSON-serialized in order to comply with the API's requirements.
This commit is contained in:
committed by
Tim Abbott
parent
c2f3c4282b
commit
1cdd6862b7
@@ -123,7 +123,9 @@ class APIArgumentsTablePreprocessor(Preprocessor):
|
|||||||
# be added for this.
|
# be added for this.
|
||||||
table.append(tr.format(
|
table.append(tr.format(
|
||||||
argument=argument.get('argument') or argument.get('name'),
|
argument=argument.get('argument') or argument.get('name'),
|
||||||
example=argument['example'],
|
# Show this as JSON to avoid changing the quoting style, which
|
||||||
|
# may cause problems with JSON encoding.
|
||||||
|
example=ujson.dumps(argument['example']),
|
||||||
required='Yes' if argument.get('required') else 'No',
|
required='Yes' if argument.get('required') else 'No',
|
||||||
description=md_engine.convert(description),
|
description=md_engine.convert(description),
|
||||||
))
|
))
|
||||||
|
|||||||
Reference in New Issue
Block a user