mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
api docs: Migrate GET /get_stream_id to OpenAPI.
This commit is contained in:
committed by
Tim Abbott
parent
679319a735
commit
57c2d8c72a
@@ -1,12 +1,4 @@
|
||||
{
|
||||
"get-stream-id.md": [
|
||||
{
|
||||
"argument": "stream",
|
||||
"description": "The name of the stream to retrieve the ID for.",
|
||||
"required": true,
|
||||
"example": "Denmark"
|
||||
}
|
||||
],
|
||||
"render-message.md": [
|
||||
{
|
||||
"argument": "content",
|
||||
|
||||
@@ -115,11 +115,6 @@
|
||||
"short_name": "iago",
|
||||
"user_id": 5
|
||||
},
|
||||
"get-stream-id": {
|
||||
"msg": "",
|
||||
"result": "success",
|
||||
"stream_id": 15
|
||||
},
|
||||
"get-subscribed-streams": {
|
||||
"msg": "",
|
||||
"result": "success",
|
||||
@@ -207,11 +202,6 @@
|
||||
"msg": "Invalid API key",
|
||||
"result": "error"
|
||||
},
|
||||
"invalid-stream-error": {
|
||||
"code": "BAD_REQUEST",
|
||||
"msg": "Invalid stream name 'nonexistent'",
|
||||
"result": "error"
|
||||
},
|
||||
"missing-request-argument-error": {
|
||||
"code": "REQUEST_VARIABLE_MISSING",
|
||||
"msg": "Missing 'content' argument",
|
||||
|
||||
@@ -24,7 +24,7 @@ curl {{ api_url }}/v1/get_stream_id?stream=Denmark \
|
||||
|
||||
<div data-language="python" markdown="1">
|
||||
|
||||
{generate_code_example(python)|get-stream-id|example}
|
||||
{generate_code_example(python)|/get_stream_id:get|example}
|
||||
|
||||
</div>
|
||||
|
||||
@@ -53,7 +53,7 @@ zulip(config).then((client) => {
|
||||
|
||||
**Note**: The following arguments are all URL query parameters.
|
||||
|
||||
{generate_api_arguments_table|arguments.json|get-stream-id.md}
|
||||
{generate_api_arguments_table|zulip.yaml|/get_stream_id:get}
|
||||
|
||||
## Response
|
||||
|
||||
@@ -65,8 +65,8 @@ zulip(config).then((client) => {
|
||||
|
||||
A typical successful JSON response may look like:
|
||||
|
||||
{generate_code_example|get-stream-id|fixture}
|
||||
{generate_code_example|/get_stream_id:get|fixture(200)}
|
||||
|
||||
An example JSON response for when the supplied stream does not exist:
|
||||
|
||||
{generate_code_example|invalid-stream-error|fixture}
|
||||
{generate_code_example|/get_stream_id:get|fixture(400)}
|
||||
|
||||
@@ -188,9 +188,7 @@ def get_stream_id(client):
|
||||
result = client.get_stream_id(stream_name)
|
||||
# {code_example|end}
|
||||
|
||||
fixture = FIXTURES['get-stream-id']
|
||||
test_against_fixture(result, fixture, check_if_equal=['msg', 'result'],
|
||||
check_if_exists=['stream_id'])
|
||||
validate_against_openapi_schema(result, '/get_stream_id', 'get', '200')
|
||||
|
||||
def get_streams(client):
|
||||
# type: (Client) -> None
|
||||
@@ -491,14 +489,13 @@ def test_invalid_stream_error(client):
|
||||
# type: (Client) -> None
|
||||
result = client.get_stream_id('nonexistent')
|
||||
|
||||
fixture = FIXTURES['invalid-stream-error']
|
||||
test_against_fixture(result, fixture)
|
||||
validate_against_openapi_schema(result, '/get_stream_id', 'get', '400')
|
||||
|
||||
TEST_FUNCTIONS = {
|
||||
'render-message': render_message,
|
||||
'/messages:post': send_message,
|
||||
'/messages/{message_id}:patch': update_message,
|
||||
'get-stream-id': get_stream_id,
|
||||
'/get_stream_id:get': get_stream_id,
|
||||
'get-subscribed-streams': list_subscriptions,
|
||||
'/streams:get': get_streams,
|
||||
'create-user': create_user,
|
||||
|
||||
@@ -24,6 +24,50 @@ servers:
|
||||
# Endpoint definitions
|
||||
#######################
|
||||
paths:
|
||||
/get_stream_id:
|
||||
get:
|
||||
description: Get the unique ID of a given stream.
|
||||
parameters:
|
||||
- name: stream
|
||||
in: query
|
||||
description: The name of the stream to retrieve the ID for.
|
||||
schema:
|
||||
type: string
|
||||
example: Denmark
|
||||
required: true
|
||||
security:
|
||||
- basicAuth: []
|
||||
responses:
|
||||
'200':
|
||||
description: Success
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/JsonSuccess'
|
||||
- properties:
|
||||
stream_id:
|
||||
type: integer
|
||||
description: The ID of the given stream.
|
||||
- example:
|
||||
{
|
||||
"msg": "",
|
||||
"result": "success",
|
||||
"stream_id": 15
|
||||
}
|
||||
'400':
|
||||
description: Bad request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/CodedError'
|
||||
- example:
|
||||
{
|
||||
"code": "BAD_REQUEST",
|
||||
"msg": "Invalid stream name 'nonexistent'",
|
||||
"result": "error"
|
||||
}
|
||||
/messages:
|
||||
post:
|
||||
description: Send a message.
|
||||
|
||||
Reference in New Issue
Block a user