Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
api: Document /default_streams API endpoint.
Kartik Srivastava887233a8eb94
diff --git a/templates/zerver/help/include/rest-endpoints.md b/templates/zerver/help/include/rest-endpoints.mdindex 62b6ce8c2d8..b00553bd851 100644--- a/templates/zerver/help/include/rest-endpoints.md+++ b/templates/zerver/help/include/rest-endpoints.md@@ -39,6 +39,8 @@* [Get topics in a stream](/api/get-stream-topics)* [Topic muting](/api/mute-topic)* [Delete a topic](/api/delete-topic)+* [Add a default stream](/api/add-default-stream)+* [Remove a default stream](/api/remove-default-stream)#### Usersdiff --git a/zerver/openapi/python_examples.py b/zerver/openapi/python_examples.pyindex 3778d123045..cfe22bd412d 100644--- a/zerver/openapi/python_examples.py+++ b/zerver/openapi/python_examples.py@@ -154,6 +154,36 @@ def get_presence(client: Client) -> None:validate_against_openapi_schema(result, "/realm/presence", "get", "200")+@openapi_test_function("/default_streams:post")+def add_default_stream(client: Client) -> None:++ # {code_example|start}+ # Add a stream to the set of default streams for new users.+ stream_id = 7++ result = client.add_default_stream(stream_id)+ # {code_example|end}++ validate_against_openapi_schema(result, "/default_streams", "post", "200")+++@openapi_test_function("/default_streams:delete")+def remove_default_stream(client: Client) -> None:++ # {code_example|start}+ # Remove a stream from the set of default streams for new users.+ request = {"stream_id": 7}++ result = client.call_endpoint(+ url="/default_streams",+ method="DELETE",+ request=request,+ )+ # {code_example|end}++ validate_against_openapi_schema(result, "/default_streams", "delete", "200")++@openapi_test_function("/users/{user_id_or_email}/presence:get")def get_user_presence(client: Client) -> None:@@ -1528,6 +1558,8 @@ def test_streams(client: Client, nonadmin_client: Client) -> None:get_stream_topics(client, 1)delete_topic(client, 1, "test")archive_stream(client, stream_id)+ add_default_stream(client)+ remove_default_stream(client)test_user_not_authorized_error(nonadmin_client)test_authorization_errors_fatal(client, nonadmin_client)diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex 9ce73b0e7ae..8cb56a890a2 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -4863,6 +4863,93 @@ paths:- description: |JSON response for when no draft exists with the provided ID.example: {"result": "error", "msg": "Draft does not exist"}+ /default_streams:+ post:+ operationId: add-default-stream+ tags: ["streams"]+ summary: Add a default stream+ x-requires-administrator: true+ description: |+ Add a stream to the set of [default streams][default-streams]+ for new users joining the organization.++ [default-streams]: /help/set-default-streams-for-new-users+ parameters:+ - name: stream_id+ in: query+ description: |+ The ID of the target stream.+ schema:+ type: integer+ example: 7+ required: true+ responses:+ "200":+ $ref: "#/components/responses/SimpleSuccess"+ "400":+ description: Bad request.+ content:+ application/json:+ schema:+ oneOf:+ - allOf:+ - $ref: "#/components/schemas/CodedError"+ - example:+ {+ "code": "BAD_REQUEST",+ "msg": "Invalid stream ID",+ "result": "error",+ }+ description: |+ A typical failed JSON response for when an invalid stream ID is passed:+ - allOf:+ - $ref: "#/components/schemas/CodedError"+ - example:+ {+ "code": "BAD_REQUEST",+ "msg": "Private streams cannot be made default.",+ "result": "error",+ }+ description: |+ A typical failed JSON response for when a user tries to add a private stream+ to the default streams set:+ delete:+ operationId: remove-default-stream+ summary: Remove a default stream+ tags: ["streams"]+ description: |+ Remove a stream from the set of [default streams][default-streams]+ for new users joining the organization.++ [default-streams]: /help/set-default-streams-for-new-users+ x-requires-administrator: true+ parameters:+ - name: stream_id+ in: query+ description: |+ The ID of the target stream.+ schema:+ type: integer+ example: 7+ required: true+ responses:+ "200":+ $ref: "#/components/responses/SimpleSuccess"+ "400":+ description: Bad request.+ content:+ application/json:+ schema:+ allOf:+ - $ref: "#/components/schemas/CodedError"+ - description: |+ A typical failed JSON response for when an invalid stream ID is passed:+ example:+ {+ "code": "BAD_REQUEST",+ "msg": "Invalid stream ID",+ "result": "error",+ }/messages:get:operationId: get-messagesdiff --git a/zerver/tests/test_openapi.py b/zerver/tests/test_openapi.pyindex 4afd0a6b5d2..5c5e643b5f6 100644--- a/zerver/tests/test_openapi.py+++ b/zerver/tests/test_openapi.py@@ -221,7 +221,6 @@ class OpenAPIArgumentsTest(ZulipTestCase):# Delete a data export."/export/realm/{export_id}",# Manage default streams and default stream groups- "/default_streams","/default_stream_groups/create","/default_stream_groups/{group_id}","/default_stream_groups/{group_id}/streams",