docs: Make update-stream use curl example system.

new_name and description params should be valid JSON
strings. The format of these params are marked as
json so that the curl example genenrator can convert
them into json strings.
This commit is contained in:
Vishnu KS
2019-10-18 12:17:27 +05:30
committed by Tim Abbott
parent e96d96b6e4
commit 0af7aa8db3
4 changed files with 6 additions and 7 deletions

View File

@@ -20,13 +20,7 @@ including:
{tab|curl} {tab|curl}
``` curl {generate_code_example(curl, include=["new_name", "description", "is_private"])|/streams/{stream_id}:patch|example}
curl -X PATCH {{ api_url }}/v1/streams/{stream_id} \
-u BOT_EMAIL_ADDRESS:BOT_API_KEY \
-d 'new_name="Manchester United"' \
-d 'description="Biggest club in the world"' \
-d 'is_private=false'
```
{end_tabs} {end_tabs}

View File

@@ -140,6 +140,8 @@ cURL example.""".format(endpoint, method, param_name)
example_value = param.get("example", DEFAULT_EXAMPLE[param["schema"]["type"]]) example_value = param.get("example", DEFAULT_EXAMPLE[param["schema"]["type"]])
if type(example_value) == bool: if type(example_value) == bool:
example_value = str(example_value).lower() example_value = str(example_value).lower()
if param["schema"].get("format", "") == "json":
example_value = json.dumps(example_value)
if curl_argument: if curl_argument:
return " -d '{}={}'".format(param_name, example_value) return " -d '{}={}'".format(param_name, example_value)
return example_value return example_value

View File

@@ -30,6 +30,7 @@ exclude_list = [
'add-linkifiers.md', 'add-linkifiers.md',
'get-events-from-queue.md', 'get-events-from-queue.md',
'delete-queue.md', 'delete-queue.md',
'update-stream.md',
# Endpoint can be called only by administrators. # Endpoint can be called only by administrators.
'create-user.md', 'create-user.md',
'remove-linkifiers.md', 'remove-linkifiers.md',

View File

@@ -2502,6 +2502,7 @@ paths:
description: The new description for the stream. description: The new description for the stream.
schema: schema:
type: string type: string
format: json
example: "This stream is related to football dicsussions." example: "This stream is related to football dicsussions."
required: false required: false
- name: new_name - name: new_name
@@ -2509,6 +2510,7 @@ paths:
description: The new name for the stream. description: The new name for the stream.
schema: schema:
type: string type: string
format: json
example: "Italy" example: "Italy"
required: false required: false
- name: is_private - name: is_private