diff --git a/templates/zerver/api/update-stream.md b/templates/zerver/api/update-stream.md index 7af2b0355c..2b334233de 100644 --- a/templates/zerver/api/update-stream.md +++ b/templates/zerver/api/update-stream.md @@ -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} diff --git a/zerver/lib/bugdown/api_code_examples.py b/zerver/lib/bugdown/api_code_examples.py index df99315cd0..9dfabb8cae 100644 --- a/zerver/lib/bugdown/api_code_examples.py +++ b/zerver/lib/bugdown/api_code_examples.py @@ -140,6 +140,8 @@ cURL example.""".format(endpoint, method, param_name) 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 diff --git a/zerver/openapi/test_curl_examples.py b/zerver/openapi/test_curl_examples.py index f72658ac7b..9c881f9d6d 100644 --- a/zerver/openapi/test_curl_examples.py +++ b/zerver/openapi/test_curl_examples.py @@ -30,6 +30,7 @@ exclude_list = [ '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', diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 0901b817a6..9553a934cc 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -2502,6 +2502,7 @@ 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 @@ -2509,6 +2510,7 @@ paths: description: The new name for the stream. schema: type: string + format: json example: "Italy" required: false - name: is_private