mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
api docs: Migrate DELETE /users/me/subscriptions to OpenAPI.
This commit is contained in:
committed by
Tim Abbott
parent
14c9277095
commit
119b3c0bc4
@@ -39,20 +39,6 @@
|
|||||||
"example": "change_all"
|
"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": [
|
"upload-file.md": [
|
||||||
{
|
{
|
||||||
"argument": "file",
|
"argument": "file",
|
||||||
|
|||||||
@@ -111,20 +111,6 @@
|
|||||||
"result": "error",
|
"result": "error",
|
||||||
"var_name": "content"
|
"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": {
|
"successful-response-empty": {
|
||||||
"msg": "",
|
"msg": "",
|
||||||
"result": "success"
|
"result": "success"
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ administrative privileges.
|
|||||||
|
|
||||||
<div data-language="python" markdown="1">
|
<div data-language="python" markdown="1">
|
||||||
|
|
||||||
{generate_code_example(python)|remove-subscriptions|example}
|
{generate_code_example(python)|/users/me/subscriptions:delete|example}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ zulip(config).then((client) => {
|
|||||||
|
|
||||||
## Arguments
|
## Arguments
|
||||||
|
|
||||||
{generate_api_arguments_table|arguments.json|remove-subscriptions.md}
|
{generate_api_arguments_table|zulip.yaml|/users/me/subscriptions:delete}
|
||||||
|
|
||||||
#### Return values
|
#### Return values
|
||||||
|
|
||||||
@@ -87,8 +87,8 @@ zulip(config).then((client) => {
|
|||||||
|
|
||||||
A typical successful JSON response may look like:
|
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:
|
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)}
|
||||||
|
|||||||
@@ -235,8 +235,8 @@ def remove_subscriptions(client):
|
|||||||
)
|
)
|
||||||
# {code_example|end}
|
# {code_example|end}
|
||||||
|
|
||||||
fixture = FIXTURES['remove-subscriptions']
|
validate_against_openapi_schema(result, '/users/me/subscriptions',
|
||||||
test_against_fixture(result, fixture)
|
'delete', '200')
|
||||||
|
|
||||||
# test it was actually removed
|
# test it was actually removed
|
||||||
result = client.list_subscriptions()
|
result = client.list_subscriptions()
|
||||||
@@ -252,7 +252,8 @@ def remove_subscriptions(client):
|
|||||||
)
|
)
|
||||||
# {code_example|end}
|
# {code_example|end}
|
||||||
|
|
||||||
test_against_fixture(result, fixture)
|
validate_against_openapi_schema(result, '/users/me/subscriptions',
|
||||||
|
'delete', '200')
|
||||||
|
|
||||||
def render_message(client):
|
def render_message(client):
|
||||||
# type: (Client) -> None
|
# type: (Client) -> None
|
||||||
@@ -475,7 +476,7 @@ TEST_FUNCTIONS = {
|
|||||||
'/users:post': create_user,
|
'/users:post': create_user,
|
||||||
'get-profile': get_profile,
|
'get-profile': get_profile,
|
||||||
'add-subscriptions': add_subscriptions,
|
'add-subscriptions': add_subscriptions,
|
||||||
'remove-subscriptions': remove_subscriptions,
|
'/users/me/subscriptions:delete': remove_subscriptions,
|
||||||
'/users:get': get_members,
|
'/users:get': get_members,
|
||||||
'/register:post': register_queue,
|
'/register:post': register_queue,
|
||||||
'/events:delete': deregister_queue,
|
'/events:delete': deregister_queue,
|
||||||
|
|||||||
@@ -710,6 +710,84 @@ paths:
|
|||||||
"private_stream"
|
"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:
|
/register:
|
||||||
post:
|
post:
|
||||||
description: This powerful endpoint can be used to register a Zulip
|
description: This powerful endpoint can be used to register a Zulip
|
||||||
|
|||||||
Reference in New Issue
Block a user