mirror of https://github.com/zulip/zulip.git
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:
parent
2366490ffc
commit
26ac3ebd3e
|
@ -105,16 +105,17 @@ def render_python_code_example(function: str, admin_config: Optional[bool]=False
|
||||||
|
|
||||||
def curl_method_arguments(endpoint: str, method: str,
|
def curl_method_arguments(endpoint: str, method: str,
|
||||||
api_url: str) -> List[str]:
|
api_url: str) -> List[str]:
|
||||||
|
# We also include the -sS verbosity arguments here.
|
||||||
method = method.upper()
|
method = method.upper()
|
||||||
url = "{}/v1{}".format(api_url, endpoint)
|
url = "{}/v1{}".format(api_url, endpoint)
|
||||||
valid_methods = ["GET", "POST", "DELETE", "PUT", "PATCH", "OPTIONS"]
|
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
|
# 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).
|
# 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.
|
# 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:
|
elif method in valid_methods:
|
||||||
return ["-X", method, url]
|
return ["-sSX", method, url]
|
||||||
else:
|
else:
|
||||||
msg = "The request method {} is not one of {}".format(method,
|
msg = "The request method {} is not one of {}".format(method,
|
||||||
valid_methods)
|
valid_methods)
|
||||||
|
|
|
@ -116,7 +116,7 @@ Missing required -X argument in curl command:
|
||||||
""".strip()
|
""".strip()
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
regex = r'curl [-]X "?(GET|DELETE|PATCH|POST)"?'
|
regex = r'curl [-](sS)?X "?(GET|DELETE|PATCH|POST)"?'
|
||||||
if line.startswith('curl'):
|
if line.startswith('curl'):
|
||||||
if re.search(regex, line) is None:
|
if re.search(regex, line) is None:
|
||||||
raise BugdownRenderingException(error_msg.format(command=line.strip()))
|
raise BugdownRenderingException(error_msg.format(command=line.strip()))
|
||||||
|
|
|
@ -703,7 +703,7 @@ class TestCurlExampleGeneration(ZulipTestCase):
|
||||||
generated_curl_example = self.curl_example("/get_stream_id", "GET")
|
generated_curl_example = self.curl_example("/get_stream_id", "GET")
|
||||||
expected_curl_example = [
|
expected_curl_example = [
|
||||||
"```curl",
|
"```curl",
|
||||||
"curl -X GET -G http://localhost:9991/api/v1/get_stream_id \\",
|
"curl -sSX GET -G http://localhost:9991/api/v1/get_stream_id \\",
|
||||||
" -u BOT_EMAIL_ADDRESS:BOT_API_KEY \\",
|
" -u BOT_EMAIL_ADDRESS:BOT_API_KEY \\",
|
||||||
" -d 'stream=Denmark'",
|
" -d 'stream=Denmark'",
|
||||||
"```"
|
"```"
|
||||||
|
@ -720,7 +720,7 @@ class TestCurlExampleGeneration(ZulipTestCase):
|
||||||
generated_curl_example = self.curl_example("/dev_fetch_api_key", "POST")
|
generated_curl_example = self.curl_example("/dev_fetch_api_key", "POST")
|
||||||
expected_curl_example = [
|
expected_curl_example = [
|
||||||
"```curl",
|
"```curl",
|
||||||
"curl -X POST http://localhost:9991/api/v1/dev_fetch_api_key \\",
|
"curl -sSX POST http://localhost:9991/api/v1/dev_fetch_api_key \\",
|
||||||
" -d 'username=iago@zulip.com'",
|
" -d 'username=iago@zulip.com'",
|
||||||
"```"
|
"```"
|
||||||
]
|
]
|
||||||
|
@ -732,7 +732,7 @@ class TestCurlExampleGeneration(ZulipTestCase):
|
||||||
generated_curl_example = self.curl_example("/mark_stream_as_read", "POST")
|
generated_curl_example = self.curl_example("/mark_stream_as_read", "POST")
|
||||||
expected_curl_example = [
|
expected_curl_example = [
|
||||||
"```curl",
|
"```curl",
|
||||||
"curl -X POST http://localhost:9991/api/v1/mark_stream_as_read \\",
|
"curl -sSX POST http://localhost:9991/api/v1/mark_stream_as_read \\",
|
||||||
" -d 'stream_id=1' \\",
|
" -d 'stream_id=1' \\",
|
||||||
" -d 'bool_param=false'",
|
" -d 'bool_param=false'",
|
||||||
"```"
|
"```"
|
||||||
|
@ -749,7 +749,7 @@ class TestCurlExampleGeneration(ZulipTestCase):
|
||||||
generated_curl_example = self.curl_example("/messages", "GET")
|
generated_curl_example = self.curl_example("/messages", "GET")
|
||||||
expected_curl_example = [
|
expected_curl_example = [
|
||||||
'```curl',
|
'```curl',
|
||||||
'curl -X GET -G http://localhost:9991/api/v1/messages \\',
|
'curl -sSX GET -G http://localhost:9991/api/v1/messages \\',
|
||||||
' -u BOT_EMAIL_ADDRESS:BOT_API_KEY \\',
|
' -u BOT_EMAIL_ADDRESS:BOT_API_KEY \\',
|
||||||
" -d 'anchor=42' \\",
|
" -d 'anchor=42' \\",
|
||||||
" -d 'use_first_unread_anchor=true' \\",
|
" -d 'use_first_unread_anchor=true' \\",
|
||||||
|
@ -768,7 +768,7 @@ class TestCurlExampleGeneration(ZulipTestCase):
|
||||||
generated_curl_example = self.curl_example("/endpoint", "GET")
|
generated_curl_example = self.curl_example("/endpoint", "GET")
|
||||||
expected_curl_example = [
|
expected_curl_example = [
|
||||||
'```curl',
|
'```curl',
|
||||||
'curl -X GET -G http://localhost:9991/api/v1/endpoint \\',
|
'curl -sSX GET -G http://localhost:9991/api/v1/endpoint \\',
|
||||||
' --data-urlencode param1=\'{"key": "value"}\'',
|
' --data-urlencode param1=\'{"key": "value"}\'',
|
||||||
'```'
|
'```'
|
||||||
]
|
]
|
||||||
|
@ -791,7 +791,7 @@ class TestCurlExampleGeneration(ZulipTestCase):
|
||||||
api_url="https://zulip.example.com/api")
|
api_url="https://zulip.example.com/api")
|
||||||
expected_curl_example = [
|
expected_curl_example = [
|
||||||
"```curl",
|
"```curl",
|
||||||
"curl -X GET -G https://zulip.example.com/api/v1/get_stream_id \\",
|
"curl -sSX GET -G https://zulip.example.com/api/v1/get_stream_id \\",
|
||||||
" -u email:key \\",
|
" -u email:key \\",
|
||||||
" -d 'stream=Denmark'",
|
" -d 'stream=Denmark'",
|
||||||
"```"
|
"```"
|
||||||
|
@ -803,7 +803,7 @@ class TestCurlExampleGeneration(ZulipTestCase):
|
||||||
exclude=["client_gravatar", "apply_markdown"])
|
exclude=["client_gravatar", "apply_markdown"])
|
||||||
expected_curl_example = [
|
expected_curl_example = [
|
||||||
'```curl',
|
'```curl',
|
||||||
'curl -X GET -G http://localhost:9991/api/v1/messages \\',
|
'curl -sSX GET -G http://localhost:9991/api/v1/messages \\',
|
||||||
' -u BOT_EMAIL_ADDRESS:BOT_API_KEY \\',
|
' -u BOT_EMAIL_ADDRESS:BOT_API_KEY \\',
|
||||||
" -d 'anchor=42' \\",
|
" -d 'anchor=42' \\",
|
||||||
" -d 'use_first_unread_anchor=true' \\",
|
" -d 'use_first_unread_anchor=true' \\",
|
||||||
|
|
Loading…
Reference in New Issue