openapi: Suggest the -sS options to curl.

These options prevent curl from doing the downloading progress bar
(which is clutter).
This commit is contained in:
Tim Abbott
2019-08-07 14:25:41 +05:30
parent 2366490ffc
commit 26ac3ebd3e
3 changed files with 12 additions and 11 deletions

View File

@@ -105,16 +105,17 @@ def render_python_code_example(function: str, admin_config: Optional[bool]=False
def curl_method_arguments(endpoint: str, method: str,
api_url: str) -> List[str]:
# We also include the -sS verbosity arguments here.
method = method.upper()
url = "{}/v1{}".format(api_url, endpoint)
valid_methods = ["GET", "POST", "DELETE", "PUT", "PATCH", "OPTIONS"]
if method == valid_methods[0]:
if method == "GET":
# Then we need to make sure that each -d option translates to becoming
# a GET parameter (in the URL) and not a POST parameter (in the body).
# TODO: remove the -X part by updating the linting rule. It's redundant.
return ["-X", "GET", "-G", url]
return ["-sSX", "GET", "-G", url]
elif method in valid_methods:
return ["-X", method, url]
return ["-sSX", method, url]
else:
msg = "The request method {} is not one of {}".format(method,
valid_methods)