diff --git a/templates/zerver/api/arguments.json b/templates/zerver/api/arguments.json
index 286bac76b1..d0c3198d49 100644
--- a/templates/zerver/api/arguments.json
+++ b/templates/zerver/api/arguments.json
@@ -39,20 +39,6 @@
"example": "change_all"
}
],
- "remove-subscriptions.md": [
- {
- "argument": "subscriptions",
- "description": "A list of stream names to unsubscribe from. This argument is called `streams` in our Python API.",
- "required": true,
- "example": "['Verona', 'Denmark']"
- },
- {
- "argument": "principals",
- "description": "A list of email addresses of the users that will be unsubscribed from the streams specified in the `subscriptions` argument. Default is `None`. If not provided, then the requesting user/bot is unsubscribed.",
- "required": false,
- "example": "['ZOE@zulip.com']"
- }
- ],
"upload-file.md": [
{
"argument": "file",
diff --git a/templates/zerver/api/fixtures.json b/templates/zerver/api/fixtures.json
index f089755f39..d8381a59ce 100644
--- a/templates/zerver/api/fixtures.json
+++ b/templates/zerver/api/fixtures.json
@@ -111,20 +111,6 @@
"result": "error",
"var_name": "content"
},
- "nonexistent-stream-error": {
- "code": "STREAM_DOES_NOT_EXIST",
- "msg": "Stream 'nonexistent_stream' does not exist",
- "result": "error",
- "stream": "nonexistent_stream"
- },
- "remove-subscriptions": {
- "msg": "",
- "not_subscribed": [],
- "removed": [
- "new stream"
- ],
- "result": "success"
- },
"successful-response-empty": {
"msg": "",
"result": "success"
diff --git a/templates/zerver/api/remove-subscriptions.md b/templates/zerver/api/remove-subscriptions.md
index d532733717..c7f9197ed8 100644
--- a/templates/zerver/api/remove-subscriptions.md
+++ b/templates/zerver/api/remove-subscriptions.md
@@ -36,7 +36,7 @@ administrative privileges.
-{generate_code_example(python)|remove-subscriptions|example}
+{generate_code_example(python)|/users/me/subscriptions:delete|example}
@@ -73,7 +73,7 @@ zulip(config).then((client) => {
## Arguments
-{generate_api_arguments_table|arguments.json|remove-subscriptions.md}
+{generate_api_arguments_table|zulip.yaml|/users/me/subscriptions:delete}
#### Return values
@@ -87,8 +87,8 @@ zulip(config).then((client) => {
A typical successful JSON response may look like:
-{generate_code_example|remove-subscriptions|fixture}
+{generate_code_example|/users/me/subscriptions:delete|fixture(200)}
A typical failed JSON response for when the target stream does not exist:
-{generate_code_example|nonexistent-stream-error|fixture}
+{generate_code_example|/users/me/subscriptions:delete|fixture(400)}
diff --git a/zerver/lib/api_test_helpers.py b/zerver/lib/api_test_helpers.py
index 95c5d10a84..706476166d 100644
--- a/zerver/lib/api_test_helpers.py
+++ b/zerver/lib/api_test_helpers.py
@@ -235,8 +235,8 @@ def remove_subscriptions(client):
)
# {code_example|end}
- fixture = FIXTURES['remove-subscriptions']
- test_against_fixture(result, fixture)
+ validate_against_openapi_schema(result, '/users/me/subscriptions',
+ 'delete', '200')
# test it was actually removed
result = client.list_subscriptions()
@@ -252,7 +252,8 @@ def remove_subscriptions(client):
)
# {code_example|end}
- test_against_fixture(result, fixture)
+ validate_against_openapi_schema(result, '/users/me/subscriptions',
+ 'delete', '200')
def render_message(client):
# type: (Client) -> None
@@ -475,7 +476,7 @@ TEST_FUNCTIONS = {
'/users:post': create_user,
'get-profile': get_profile,
'add-subscriptions': add_subscriptions,
- 'remove-subscriptions': remove_subscriptions,
+ '/users/me/subscriptions:delete': remove_subscriptions,
'/users:get': get_members,
'/register:post': register_queue,
'/events:delete': deregister_queue,
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index ed06472c8a..0b572d3865 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -710,6 +710,84 @@ paths:
"private_stream"
]
}
+ delete:
+ description: Unsubscribe yourself or other users from one or more
+ streams.
+ parameters:
+ - name: subscriptions
+ in: query
+ description: A list of stream names to unsubscribe from. This argument
+ is called `streams` in our Python API.
+ schema:
+ type: array
+ items:
+ type: string
+ example: ['Verona', 'Denmark']
+ required: true
+ - name: principals
+ in: query
+ description: A list of email addresses of the users that will be
+ unsubscribed from the streams specified in the `subscriptions`
+ argument. If not provided, then the requesting user/bot is
+ unsubscribed.
+ schema:
+ type: array
+ items:
+ type: string
+ default:
+ example: ['ZOE@zulip.com']
+ security:
+ - basicAuth: []
+ responses:
+ '200':
+ description: Success.
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/JsonSuccess'
+ - properties:
+ not_subscribed:
+ type: array
+ items:
+ type: string
+ description: A list of the names of streams that the
+ user is already unsubscribed from, and hence doesn't
+ need to be unsubscribed.
+ removed:
+ type: array
+ items:
+ type: string
+ description: A list of the names of streams which were
+ unsubscribed from as a result of the query.
+ - example:
+ {
+ "msg": "",
+ "not_subscribed": [],
+ "removed": [
+ "new stream"
+ ],
+ "result": "success"
+ }
+ '400':
+ description: Bad request.
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: '#/components/schemas/CodedError'
+ - properties:
+ stream:
+ type: string
+ description: The name of the stream that could not be
+ found.
+ - example:
+ {
+ "code": "STREAM_DOES_NOT_EXIST",
+ "msg": "Stream 'nonexistent_stream' does not exist",
+ "result": "error",
+ "stream": "nonexistent_stream"
+ }
/register:
post:
description: This powerful endpoint can be used to register a Zulip