Skip to content

Commit

Permalink
docs: Make update-stream use curl example system.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hackerkid authored and timabbott committed Oct 18, 2019
1 parent e96d96b commit 0af7aa8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
8 changes: 1 addition & 7 deletions templates/zerver/api/update-stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ including:

{tab|curl}

``` curl
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'
```
{generate_code_example(curl, include=["new_name", "description", "is_private"])|/streams/{stream_id}:patch|example}

{end_tabs}

Expand Down
2 changes: 2 additions & 0 deletions zerver/lib/bugdown/api_code_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ def get_openapi_param_example_value_as_string(endpoint: str, method: str, param:
example_value = param.get("example", DEFAULT_EXAMPLE[param["schema"]["type"]])
if type(example_value) == bool:
example_value = str(example_value).lower()
if param["schema"].get("format", "") == "json":
example_value = json.dumps(example_value)
if curl_argument:
return " -d '{}={}'".format(param_name, example_value)
return example_value
Expand Down
1 change: 1 addition & 0 deletions zerver/openapi/test_curl_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'add-linkifiers.md',
'get-events-from-queue.md',
'delete-queue.md',
'update-stream.md',
# Endpoint can be called only by administrators.
'create-user.md',
'remove-linkifiers.md',
Expand Down
2 changes: 2 additions & 0 deletions zerver/openapi/zulip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2502,13 +2502,15 @@ paths:
description: The new description for the stream.
schema:
type: string
format: json
example: "This stream is related to football dicsussions."
required: false
- name: new_name
in: query
description: The new name for the stream.
schema:
type: string
format: json
example: "Italy"
required: false
- name: is_private
Expand Down

0 comments on commit 0af7aa8

Please sign in to comment.