Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

api-docs: Handle readOnly properties in request param objects.

Sachin Kumar49c9f9db85c8
diff --git a/zerver/lib/markdown/api_arguments_table_generator.py b/zerver/lib/markdown/api_arguments_table_generator.py
index b1f7e5e5177..b1e4d25f369 100644
--- a/zerver/lib/markdown/api_arguments_table_generator.py
+++ b/zerver/lib/markdown/api_arguments_table_generator.py
@@ -221,6 +221,11 @@ class APIArgumentsTablePreprocessor(Preprocessor):
object_values = schema.get("properties", {})
for value in object_values:
+ if object_values[value].get("readOnly", False):
+ # readOnly object properties are included in responses
+ # but not in requests.
+ continue
+
description = ""
if "description" in object_values[value]:
description = object_values[value]["description"]
@@ -268,6 +273,8 @@ class APIArgumentsTablePreprocessor(Preprocessor):
details = ""
if "object" in data_type and "properties" in object_values[value]:
details += self.render_object_details(object_values[value], str(value))
+ elif "items" in object_values[value] and "properties" in object_values[value]["items"]:
+ details += self.render_object_details(object_values[value]["items"], str(value))
elif "oneOf" in object_values[value]:
details += self.render_oneof_block(object_values[value], str(value))
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index b4ac074b21a..10a49754793 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -28584,10 +28584,9 @@ components:
properties:
id:
type: integer
+ readOnly: true
description: |
- The unique ID of the draft. It will only used whenever the drafts are
- fetched. This field should not be specified when the draft is being
- created or edited.
+ The unique ID of the draft.
type:
type: string
description: |