openapi: Document various properties in `EXCLUDED_PROPERTIES`.

The `EXCLUDE_PROPERTIES` is a dictionary in `zerver/openapi/openapi.py`
which holds the undocumented properties of our API. Document all
properties other than:

*`delivery_email` which is in another PR.
*'events' and 'register'.
*'/setting/notification' since its response is about to undergo heavy
  changes.
This commit is contained in:
orientor 2020-06-23 22:59:17 +05:30 committed by Tim Abbott
parent 8acd2c3fb0
commit 358d9fc35f
2 changed files with 332 additions and 282 deletions

View File

@ -12,12 +12,6 @@ OPENAPI_SPEC_PATH = os.path.abspath(os.path.join(
# The validator will ignore these keys when they appear in the "content" # The validator will ignore these keys when they appear in the "content"
# passed. # passed.
EXCLUDE_PROPERTIES = { EXCLUDE_PROPERTIES = {
'/attachments': {
'get': {
# messages is a small opaque object; should be easy to document
'200': ['messages'],
}
},
'/events': { '/events': {
'get': { 'get': {
# Array with opaque object # Array with opaque object
@ -38,17 +32,6 @@ EXCLUDE_PROPERTIES = {
'realm_name_in_notifications', 'presence_enabled'], 'realm_name_in_notifications', 'presence_enabled'],
}, },
}, },
'/streams': {
'get': {
# Some responses contain undocumented keys
'200': ['is_default'],
}
},
'/zulip-outgoing-webhook': {
'post': {
'200': ['result', 'msg', 'message'],
},
},
'/users': { '/users': {
'get': { 'get': {
'200': ['delivery_email'], '200': ['delivery_email'],
@ -65,33 +48,6 @@ EXCLUDE_PROPERTIES = {
# Some responses contain undocumented keys # Some responses contain undocumented keys
'200': ['delivery_email'], '200': ['delivery_email'],
}, },
'delete': {
# Some responses contain undocumented keys
'200': ['delivery_email'],
}
},
'/fetch_api_key': {
'post': {
# Required key not present in response
'200': ['email'],
}
},
'/messages': {
'get': {
# Some responses contain undocumented keys and
# 'user' is opaque
'200': ['last_edit_timestamp', 'display_recipient',
'match_content', 'match_subject', 'user'],
},
'post': {
# Extraneous
'200': ['deliver_at'],
}
},
'/calls/bigbluebutton/create': {
'get': {
'200': ['url']
}
}, },
} }

View File

@ -66,7 +66,7 @@ paths:
required: true required: true
responses: responses:
'200': '200':
description: Success. description: The credentials needed to use the Zulip API.
content: content:
application/json: application/json:
schema: schema:
@ -401,6 +401,19 @@ paths:
uploaded file. uploaded file.
items: items:
type: object type: object
properties:
name:
type: number
description: |
Time when the message was sent as a UNIX timestamp
multiplied by 1000 (matching the format of getTime() in JavaScript).
**Deprecated**: We plan to rename this field.
id:
type: integer
description: |
The unique message ID. Messages should always be
displayed sorted by ID.
upload_space_used: upload_space_used:
type: integer type: integer
description: | description: |
@ -420,11 +433,11 @@ paths:
"messages": [ "messages": [
{ {
"id": 102, "id": 102,
"name": 1588145424000 "name": 1588145424000.0
}, },
{ {
"id": 103, "id": 103,
"name": 1588145448000 "name": 1588145448000.0
} }
] ]
} }
@ -591,172 +604,7 @@ paths:
an array of `message` objects, each containing the following an array of `message` objects, each containing the following
fields: fields:
items: items:
type: object $ref: '#/components/schemas/Messages'
properties:
avatar_url:
type: string
nullable: true
description: |
The URL of the user's avatar. Can be null only if client_gravatar was passed,
which means that the user has not uploaded an avatar in Zulip, and the
client should compute the gravatar URL by hashing the
user's email address itself for this user.
client:
type: string
description: |
A Zulip "client" string, describing what Zulip client
sent the message.
content:
type: string
description: |
The content/body of the message.
content_type:
type: string
description: |
The HTTP `content_type` for the message content. This
will be `text/html` or `text/x-markdown`, depending on
whether `apply_markdown` was set.
display_recepient:
oneOf:
- type: string
- type: array
items:
type: object
description: |
Data on the recipient of the message;
either the name of a stream or a dictionary containing basic data on
the users who received the message.
flags:
type: array
description: |
The user's [message flags][message-flags] for the message.
items:
type: string
id:
type: integer
description: |
The unique message ID. Messages should always be
displayed sorted by ID.
is_me_message:
type: boolean
description: |
Whether the message is a [/me status message][status-messages]
reactions:
type: array
description: |
Data on any reactions to the message.
items:
type: object
properties:
emoji_code:
type: string
description: |
A unique identifier, defining the specific emoji codepoint requested,
within the namespace of the `reaction_type`.
For example, for `unicode_emoji`, this will be an encoding of the
unicode codepoint.
emoji_name:
type: string
description: |
Name of the emoji.
reaction_type:
type: string
description: |
One of the following values:
* `unicode_emoji`: Unicode emoji (`emoji_code` will be its unicode
codepoint).
* `realm_emoji`: [Custom emoji](/help/add-custom-emoji).
(`emoji_code` will be its ID).
* `zulip_extra_emoji`: Special emoji included with Zulip. Exists to
namespace the `zulip` emoji.
user_id:
type: integer
description: |
The ID of the user who added the reaction.
**Changes**: New in Zulip 2.2 (feature level 2). The `user`
object is deprecated and will be removed in the future.
user:
type: object
description: |
Dictionary with data on the user who added the reaction, including
the user ID as the `id` field. **Note**: In the [events
API](/api/get-events), this `user` dictionary
confusing had the user ID in a field called `user_id`
instead. We recommend ignoring fields other than the user
ID. **Deprecated** and to be removed in a future release
once core clients have migrated to use the `user_id` field.
recipient_id:
type: integer
description: |
A unique ID for the set of users receiving the
message (either a stream or group of users). Useful primarily
for hashing.
sender_email:
type: string
description: |
The Zulip display email address of the message's sender.
sender_full_name:
type: string
description: |
The full name of the message's sender.
sender_id:
type: integer
description: |
The user ID of the message's sender.
sender_realm_str:
type: string
description: |
A string identifier for the realm the sender is in. Unique only within
the context of a given Zulip server.
E.g. on `example.zulip.com`, this will be `example`.
sender_short_name:
type: string
description: |
Reserved for future use.
stream_id:
type: integer
description: |
Only present for stream messages; the ID of the stream.
subject:
type: string
description: |
The `topic` of the message (only present for stream
messages). The field name is a legacy holdover from when topics were
called "subjects" and will eventually change.
topic_links:
type: array
items:
type: string
description: |
Data on any links to be included in the `topic`
line (these are generated by [custom linkification
filters][linkification-filters] that match content in the
message's topic.)
**Changes**: New in Zulip 2.2 (feature level 1).
Previously, this field was called `subject_links`;
clients are recommended to rename `subject_links`
to `topic_links` if present for compatibility with
older Zulip servers.
submessages:
type: array
items:
type: string
description: |
Data used for certain experimental Zulip integrations.
timestamp:
type: integer
description: |
The UNIX timestamp for when the message was sent,
in UTC seconds.
type:
type: string
description: |
The type of the message: `stream` or `private`.
- example: - example:
{ {
"anchor": 21, "anchor": 21,
@ -889,6 +737,13 @@ paths:
type: integer type: integer
description: | description: |
The unique ID assigned to the sent message. The unique ID assigned to the sent message.
deliver_at:
type: string
description: |
Present for scheduled messages, encodes the time when the message will
be sent. Note that scheduled messages ("Send later") is a beta API and
may change before it's a finished feature.
example: "2020-06-24 11:19:54.337533+00:00"
- example: - example:
{ {
"msg": "", "msg": "",
@ -3952,6 +3807,12 @@ paths:
**Changes**: Deprecated in Zulip 2.2 (feature level 1), use **Changes**: Deprecated in Zulip 2.2 (feature level 1), use
`stream_post_policy` instead. `stream_post_policy` instead.
is_default:
type: boolean
description: |
Whether the given stream is a
[default stream](/help/set-default-streams-for-new-users). Only
returned if the `include_default` parameter is `true`.
- example: - example:
{ {
"msg": "", "msg": "",
@ -4434,66 +4295,61 @@ paths:
content: content:
application/json: application/json:
schema: schema:
allOf: properties:
- $ref: '#/components/schemas/JsonSuccess' data:
- properties: type: string
data: description: |
type: string The message content, in raw markdown format (not rendered to HTML).
description: | trigger:
It contains the content of the message (in Markdown). type: string
trigger: description: |
type: string What aspect of the message triggered the outgoing webhook notification.
description: | Possible values include `private_message` and `mention`.
It contains the trigger method. token:
token: type: string
type: string description: |
description: | A string of alphanumeric characters that can be use to authenticate the
A string of alphanumeric characters that can be use to authenticate the webhook request. You can get the token used by a given outgoing webhook bot
webhook request (each bot user uses a fixed token). in the `zuliprc` file downloaded when creating the bot.
message: message:
type: object allOf:
description: | - description: |
A dict containing details on the message which triggered the outgoing A dict containing details on the message that triggered the
webhook outgoing webhook, in the format used by [`GET /messages`](/api/get-messages).
bot_email: - $ref: '#/components/schemas/Messages'
type: string bot_email:
description: | type: string
Email of the bot user description: |
- example: Email of the bot user.
{ example:
"data": "@**Outgoing Webhook Test** Zulip is the world\u2019s most productive group chat!", {
"trigger": "mention", "data": "@**Outgoing Webhook Test** Zulip is the world\u2019s most productive group chat!",
"token": "xvOzfurIutdRRVLzpXrIIHXJvNfaJLJ0", "trigger": "mention",
"message": { "token": "xvOzfurIutdRRVLzpXrIIHXJvNfaJLJ0",
"subject": "Verona2", "message": {
"sender_email": "iago@zulip.com", "subject": "Verona2",
"timestamp": 1527876931, "sender_email": "iago@zulip.com",
"client": "website", "timestamp": 1527876931,
"submessages": [ "client": "website",
"submessages": [],
], "recipient_id": 20,
"recipient_id": 20, "topic_links": [],
"topic_links": [ "sender_full_name": "Iago",
"avatar_url": "https://secure.gravatar.com/avatar/1f4f1575bf002ae562fea8fc4b861b09?d=identicon&version=1",
], "rendered_content": "<p><span class=\"user-mention\" data-user-id=\"25\">@Outgoing Webhook Test</span> Zulip is the world\u2019s most productive group chat!</p>",
"sender_full_name": "Iago", "sender_id": 5,
"avatar_url": "https://secure.gravatar.com/avatar/1f4f1575bf002ae562fea8fc4b861b09?d=identicon&version=1", "stream_id": 5,
"rendered_content": "<p><span class=\"user-mention\" data-user-id=\"25\">@Outgoing Webhook Test</span> Zulip is the world\u2019s most productive group chat!</p>", "content": "@**Outgoing Webhook Test** Zulip is the world\u2019s most productive group chat!",
"sender_id": 5, "display_recipient": "Verona",
"stream_id": 5, "type": "stream",
"content": "@**Outgoing Webhook Test** Zulip is the world\u2019s most productive group chat!", "id": 112,
"display_recipient": "Verona", "is_me_message": false,
"type": "stream", "reactions": [],
"id": 112, "sender_realm_str": "zulip",
"is_me_message": false, "sender_short_name": "iago"
"reactions": [ },
"bot_email": "outgoing-bot@localhost"
], }
"sender_realm_str": "zulip",
"sender_short_name": "iago"
},
"bot_email": "outgoing-bot@localhost"
}
/calls/bigbluebutton/create: /calls/bigbluebutton/create:
get: get:
@ -4508,13 +4364,20 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/JsonSuccess' allOf:
example: - $ref: '#/components/schemas/JsonSuccess'
{ - properties:
"msg": "", url:
"result": "success", description: |
"url": "/calls/bbb/join?meeting_id=%22zulip-something%22&password=%22something%22&checksum=%22somechecksum%22" The url for the Big Blue Button video call.
} type: string
example: "/calls/bbb/join?meeting_id=%22zulip-something%22&password=%22something%22&checksum=%22somechecksum%22"
- example:
{
"msg": "",
"result": "success",
"url": "/calls/bbb/join?meeting_id=%22zulip-something%22&password=%22something%22&checksum=%22somechecksum%22"
}
components: components:
####################### #######################
@ -4530,6 +4393,238 @@ components:
`/fetch_api_key` or `/dev_fetch_api_key` endpoints. `/fetch_api_key` or `/dev_fetch_api_key` endpoints.
schemas: schemas:
Messages:
type: object
properties:
avatar_url:
type: string
nullable: true
description: |
The URL of the user's avatar. Can be null only if client_gravatar was passed,
which means that the user has not uploaded an avatar in Zulip, and the
client should compute the gravatar URL by hashing the
user's email address itself for this user.
client:
type: string
description: |
A Zulip "client" string, describing what Zulip client
sent the message.
content:
type: string
description: |
The content/body of the message.
rendered_content:
type: string
description: |
The content/body of the message rendered in HTML.
content_type:
type: string
description: |
The HTTP `content_type` for the message content. This
will be `text/html` or `text/x-markdown`, depending on
whether `apply_markdown` was set.
display_recipient:
oneOf:
- type: string
- type: array
items:
type: object
properties:
id:
type: integer
description: |
ID of the user.
email:
type: string
description: |
Email of the user.
full_name:
type: string
description: |
Full name of the user.
short_name:
type: string
description: |
Short name of the user.
is_mirror_dummy:
type: boolean
description: |
Whether the user is a mirror dummy.
description: |
Data on the recipient of the message;
either the name of a stream or a dictionary containing basic data on
the users who received the message.
flags:
type: array
description: |
The user's [message flags][message-flags] for the message.
items:
type: string
id:
type: integer
description: |
The unique message ID. Messages should always be
displayed sorted by ID.
is_me_message:
type: boolean
description: |
Whether the message is a [/me status message][status-messages]
reactions:
type: array
description: |
Data on any reactions to the message.
items:
type: object
properties:
emoji_code:
type: string
description: |
A unique identifier, defining the specific emoji codepoint requested,
within the namespace of the `reaction_type`.
For example, for `unicode_emoji`, this will be an encoding of the
unicode codepoint.
emoji_name:
type: string
description: |
Name of the emoji.
reaction_type:
type: string
description: |
One of the following values:
* `unicode_emoji`: Unicode emoji (`emoji_code` will be its unicode
codepoint).
* `realm_emoji`: [Custom emoji](/help/add-custom-emoji).
(`emoji_code` will be its ID).
* `zulip_extra_emoji`: Special emoji included with Zulip. Exists to
namespace the `zulip` emoji.
user_id:
type: integer
description: |
The ID of the user who added the reaction.
**Changes**: New in Zulip 2.2 (feature level 2). The `user`
object is deprecated and will be removed in the future.
user:
type: object
description: |
Dictionary with data on the user who added the reaction, including
the user ID as the `id` field. **Note**: In the [events
API](/api/get-events), this `user` dictionary
confusing had the user ID in a field called `user_id`
instead. We recommend ignoring fields other than the user
ID. **Deprecated** and to be removed in a future release
once core clients have migrated to use the `user_id` field.
properties:
id:
type: integer
description: |
ID of the user.
email:
type: string
description: |
Email of the user.
full_name:
type: string
description: |
Full name of the user.
short_name:
type: string
description: |
Short name of the user.
is_mirror_dummy:
type: boolean
description: |
Whether the user is a mirror dummy.
recipient_id:
type: integer
description: |
A unique ID for the set of users receiving the
message (either a stream or group of users). Useful primarily
for hashing.
sender_email:
type: string
description: |
The Zulip display email address of the message's sender.
sender_full_name:
type: string
description: |
The full name of the message's sender.
sender_id:
type: integer
description: |
The user ID of the message's sender.
sender_realm_str:
type: string
description: |
A string identifier for the realm the sender is in. Unique only within
the context of a given Zulip server.
E.g. on `example.zulip.com`, this will be `example`.
sender_short_name:
type: string
description: |
Reserved for future use.
stream_id:
type: integer
description: |
Only present for stream messages; the ID of the stream.
subject:
type: string
description: |
The `topic` of the message (only present for stream
messages). The field name is a legacy holdover from when topics were
called "subjects" and will eventually change.
topic_links:
type: array
items:
type: string
description: |
Data on any links to be included in the `topic`
line (these are generated by [custom linkification
filters][linkification-filters] that match content in the
message's topic.)
**Changes**: New in Zulip 2.2 (feature level 1).
Previously, this field was called `subject_links`;
clients are recommended to rename `subject_links`
to `topic_links` if present for compatibility with
older Zulip servers.
submessages:
type: array
items:
type: string
description: |
Data used for certain experimental Zulip integrations.
timestamp:
type: integer
description: |
The UNIX timestamp for when the message was sent,
in UTC seconds.
last_edit_timestamp:
type: integer
description: |
The UNIX timestamp for when the message was last edited,
in UTC seconds.
type:
type: string
description: |
The type of the message: `stream` or `private`.
match_content:
type: string
description: |
Only present if keyword search was included among the narrow parameters.
HTML content of a queried message that matches the narrow, with
`<span class="highlight">` elements wrapping the matches for the
search keywords.
match_subject:
type: string
description: |
Only present if keyword search was included among the narrow parameters.
HTML-escaped topic of a queried message that matches the narrow, with
`<span class="highlight">` elements wrapping the matches for the
search keywords.
User: User:
type: object type: object
description: | description: |
@ -4685,7 +4780,6 @@ components:
- $ref: '#/components/schemas/JsonSuccess' - $ref: '#/components/schemas/JsonSuccess'
- required: - required:
- api_key - api_key
- email
- properties: - properties:
api_key: api_key:
type: string type: string
@ -4694,7 +4788,7 @@ components:
email: email:
type: string type: string
description: | description: |
The email address of the user who owns the API key. The email address of the user who owns the API key
- example: - example:
{ {
"api_key": "gjA04ZYcqXKalvYMA8OeXSfzUOLrtbZv", "api_key": "gjA04ZYcqXKalvYMA8OeXSfzUOLrtbZv",