api: Document POST ../messages/{message_id}/reactions endpoint.

This refactors add_reaction in python_examples.py to use the
openapi_test_function decorator and validate result with
validate_against_openapi_schema. Minor changes have been made to the
OpenAPI format data for /messages/{message_id}/reactions endpoint.

This also adds add-emoji.md to templates/zerver/api and adds
add-emoji to rest-endpoints.md (templates/zerver/help/include).
This commit is contained in:
akashaviator
2020-02-29 19:32:34 +05:30
committed by Tim Abbott
parent 9c63976da5
commit 5dd1a1fc83
4 changed files with 73 additions and 20 deletions

View File

@@ -698,25 +698,26 @@ def send_message(client):
return message_id
@openapi_test_function("/messages/{message_id}/reactions:post")
def add_reaction(client, message_id):
# type: (Client, int) -> None
# {code_example|start}
# Add an emoji reaction
request = {
'message_id': str(message_id),
'emoji_name': 'joy',
'emoji_code': '1f602',
'emoji_type': 'unicode_emoji'
'emoji_name': 'octopus',
}
result = client.add_reaction(request)
assert result['result'] == 'success'
result = client.add_reaction(request)
# {code_example|end}
validate_against_openapi_schema(result, '/messages/{message_id}/reactions', 'post', '200')
@openapi_test_function("/messages/{message_id}/reactions:delete")
def remove_reaction(client, message_id):
# type: (Client, int) -> None
request = {
'message_id': str(message_id),
'emoji_name': 'joy',
'emoji_code': '1f602',
'emoji_name': 'octopus',
'reaction_type': 'unicode_emoji'
}