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:
Yago González
2018-07-13 10:29:48 +05:30
committed by Tim Abbott
parent c2f3c4282b
commit 1cdd6862b7

View File

@@ -123,7 +123,9 @@ class APIArgumentsTablePreprocessor(Preprocessor):
# be added for this.
table.append(tr.format(
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',
description=md_engine.convert(description),
))