openapi: Standardize URL format to use {var_name} syntax.

The previous code for the validator test was fairly messy due to
checking for both formats of the openapi url, one with
<variable_name> and the other with {variable_name}. To eliminate
this, we have standardized the format and restricted it to
{variable_name} as per the official format at:
https://swagger.io/docs/specification/describing-parameters.
This commit is contained in:
Hemanth V. Alluri 2019-07-11 16:15:26 +05:30 committed by Tim Abbott
parent fe59c31e85
commit ffd2bccd4e
12 changed files with 47 additions and 47 deletions

View File

@ -2,7 +2,7 @@
Permanently delete a message.
`DELETE {{ api_url }}/v1/messages/<msg_id>`
`DELETE {{ api_url }}/v1/messages/{msg_id}`
This API corresponds to the
[delete a message completely][delete-completely] feature documented in

View File

@ -2,7 +2,7 @@
Fetch the message edit history of a previously edited message.
`GET {{ api_url }}/v1/messages/<message_id>/history`
`GET {{ api_url }}/v1/messages/{message_id}/history`
Note that edit history may be disabled in some organizations; see the
[Zulip Help Center documentation on editing messages][edit-settings].
@ -19,7 +19,7 @@ Note that edit history may be disabled in some organizations; see the
{tab|curl}
``` curl
curl -X GET {{ api_url }}/v1/messages/<message_id>/history \
curl -X GET {{ api_url }}/v1/messages/{message_id}/history \
-u BOT_EMAIL_ADDRESS:BOT_API_KEY
```

View File

@ -8,7 +8,7 @@ Zulip clients like mobile/desktop apps will want to use the main
presence endpoint, which returns data for all active users in the
organization, instead.
`GET {{ api_url }}/v1/users/<email>/presence`
`GET {{ api_url }}/v1/users/{email}/presence`
See
[Zulip's developer documentation](https://zulip.readthedocs.io/en/latest/subsystems/presence.html)
@ -24,7 +24,7 @@ for details on the data model for presence in Zulip.
{tab|curl}
``` curl
curl -X GET {{ api_url }}/v1/users/<email>/presence \
curl -X GET {{ api_url }}/v1/users/{email}/presence \
-u BOT_EMAIL_ADDRESS:BOT_API_KEY
```
@ -40,7 +40,7 @@ curl -X GET {{ api_url }}/v1/users/<email>/presence \
* `presence`: An object containing the presence details for every type
of client the user has ever logged into.
* `<client_name>` or `aggregated`: the keys for these objects are
* `{client_name}` or `aggregated`: the keys for these objects are
the names of the different clients where this user is logged in,
like `website`, `ZulipDesktop`, `ZulipTerminal`, or
`ZulipMobile`. There is also an `aggregated` key, which matches

View File

@ -2,7 +2,7 @@
Get the raw content of a message.
`GET {{ api_url }}/v1/messages/<msg_id>`
`GET {{ api_url }}/v1/messages/{msg_id}`
This is a rarely-used endpoint relevant for clients that primarily
work with HTML-rendered messages but might need to occasionally fetch
@ -19,7 +19,7 @@ UI).
{tab|curl}
``` curl
curl -X GET {{ api_url }}/v1/messages/<msg_id> \
curl -X GET {{ api_url }}/v1/messages/{msg_id} \
-u BOT_EMAIL_ADDRESS:BOT_API_KEY \
```

View File

@ -2,7 +2,7 @@
Get all the topics in a specific stream
`GET {{ api_url }}/v1/users/me/<stream_id>/topics`
`GET {{ api_url }}/v1/users/me/{stream_id}/topics`
## Usage examples
@ -32,7 +32,7 @@ zulip(config).then((client) => {
{tab|curl}
``` curl
curl -X GET {{ api_url }}/v1/users/me/<stream_id>/topics \
curl -X GET {{ api_url }}/v1/users/me/{stream_id}/topics \
-u BOT_EMAIL_ADDRESS:BOT_API_KEY
```

View File

@ -4,19 +4,19 @@ Remove [linkifiers](/help/add-a-custom-linkification-filter), regular
expression patterns that are automatically linkified when they appear
in messages and topics.
`DELETE {{ api_url }}/v1/realm/filters/<filter_id>`
`DELETE {{ api_url }}/v1/realm/filters/{filter_id}`
## Usage examples
{start_tabs}
{tab|python}
{generate_code_example(python)|/realm/filters/<filter_id>:delete|example}
{generate_code_example(python)|/realm/filters/{filter_id}:delete|example}
{tab|curl}
``` curl
curl -X DELETE {{ api_url }}/v1/realm/filters/<filter_id> \
curl -X DELETE {{ api_url }}/v1/realm/filters/{filter_id} \
-u BOT_EMAIL_ADDRESS:BOT_API_KEY
```
@ -24,7 +24,7 @@ curl -X DELETE {{ api_url }}/v1/realm/filters/<filter_id> \
## Arguments
{generate_api_arguments_table|zulip.yaml|/realm/filters/<filter_id>:delete}
{generate_api_arguments_table|zulip.yaml|/realm/filters/{filter_id}:delete}
## Response
@ -32,4 +32,4 @@ curl -X DELETE {{ api_url }}/v1/realm/filters/<filter_id> \
A typical successful JSON response may look like:
{generate_code_example|/realm/filters/<filter_id>:delete|fixture(200)}
{generate_code_example|/realm/filters/{filter_id}:delete|fixture(200)}

View File

@ -2,9 +2,9 @@
Edit/update the content or topic of a message.
`PATCH {{ api_url }}/v1/messages/<msg_id>`
`PATCH {{ api_url }}/v1/messages/{msg_id}`
`<msg_id>` in the above URL should be replaced with the ID of the
`{msg_id}` in the above URL should be replaced with the ID of the
message you wish you update.
## Usage examples
@ -39,7 +39,7 @@ zulip(config).then((client) => {
{tab|curl}
``` curl
curl -X "PATCH" {{ api_url }}/v1/messages/<msg_id> \
curl -X "PATCH" {{ api_url }}/v1/messages/{msg_id} \
-u BOT_EMAIL_ADDRESS:BOT_API_KEY \
-d $"content=New content"
```

View File

@ -4,7 +4,7 @@ This endpoint is used to upload a custom emoji for use in the user's
organization. Access to this endpoint depends on the
[organization's configuration](https://zulipchat.com/help/only-allow-admins-to-add-emoji).
`POST {{ api_url }}/v1/realm/emoji/<emoji_name>`
`POST {{ api_url }}/v1/realm/emoji/{emoji_name}`
## Usage examples
@ -12,12 +12,12 @@ organization. Access to this endpoint depends on the
{tab|python}
{generate_code_example(python)|/realm/emoji/<emoji_name>:post|example}
{generate_code_example(python)|/realm/emoji/{emoji_name}:post|example}
{tab|curl}
``` curl
curl -X POST {{ api_url }}/v1/realm/emoji/<emoji_name> \
curl -X POST {{ api_url }}/v1/realm/emoji/{emoji_name} \
-F "data=@/path/to/img.png" \
-u USER_EMAIL:API_KEY
```
@ -51,4 +51,4 @@ to 5MB.
A typical successful JSON response may look like:
{generate_code_example|/realm/emoji/<emoji_name>:post|fixture(200)}
{generate_code_example|/realm/emoji/{emoji_name}:post|fixture(200)}

View File

@ -460,7 +460,7 @@ following helper method:
# self.assert_bot_response(...)
`mock_http_conversation(fixture_name)` patches `requests.get` and returns the data specified
in the file `fixtures/<fixture_name>.json`. Use the following JSON code as a skeleton for new
in the file `fixtures/{fixture_name}.json`. Use the following JSON code as a skeleton for new
fixtures:
```
{

View File

@ -195,7 +195,7 @@ def remove_realm_filter(client):
result = client.remove_realm_filter(42)
# {code_example|end}
validate_against_openapi_schema(result, '/realm/filters/<filter_id>', 'delete', '200')
validate_against_openapi_schema(result, '/realm/filters/{filter_id}', 'delete', '200')
def get_profile(client):
# type: (Client) -> None
@ -861,7 +861,7 @@ def upload_custom_emoji(client):
# {code_example|end}
fp.close()
validate_against_openapi_schema(result,
'/realm/emoji/<emoji_name>',
'/realm/emoji/{emoji_name}',
'post', '200')
def get_alert_words(client):
@ -981,10 +981,10 @@ TEST_FUNCTIONS = {
'/users/me/subscriptions/properties:post': update_subscription_settings,
'/users:get': get_members,
'/realm/emoji:get': get_realm_emoji,
'/realm/emoji/<emoji_name>:post': upload_custom_emoji,
'/realm/emoji/{emoji_name}:post': upload_custom_emoji,
'/realm/filters:get': get_realm_filters,
'/realm/filters:post': add_realm_filter,
'/realm/filters/<filter_id>:delete': remove_realm_filter,
'/realm/filters/{filter_id}:delete': remove_realm_filter,
'/register:post': register_queue,
'/events:delete': deregister_queue,
'/server_settings:get': get_server_settings,

View File

@ -1369,7 +1369,7 @@ paths:
"msg": "Topic is not muted",
"result": "error"
}
/realm/emoji/<emoji_name>:
/realm/emoji/{emoji_name}:
post:
description: Upload a single emoji file.
parameters:
@ -1568,7 +1568,7 @@ paths:
"result": "success",
"msg": ""
}
/realm/filters/<filter_id>:
/realm/filters/{filter_id}:
delete:
description: Remove an organization filter.
parameters:

View File

@ -191,29 +191,29 @@ class OpenAPIArgumentsTest(ZulipTestCase):
'/users/me/android_gcm_reg_id',
'/users/me/apns_device_token',
# Regex based urls
'/realm/domains/<domain>',
'/realm/filters/<filter_id>',
'/realm/profile_fields/<field_id>',
'/users/<user_id>/reactivate',
'/users/<user_id>',
'/bots/<bot_id>/api_key/regenerate',
'/bots/<bot_id>',
'/invites/<prereg_id>',
'/invites/<prereg_id>/resend',
'/invites/multiuse/<invite_id>',
'/realm/domains/{domain}',
'/realm/filters/{filter_id}',
'/realm/profile_fields/{field_id}',
'/users/{user_id}/reactivate',
'/users/{user_id}',
'/bots/{bot_id}/api_key/regenerate',
'/bots/{bot_id}',
'/invites/{prereg_id}',
'/invites/{prereg_id}/resend',
'/invites/multiuse/{invite_id}',
'/messages/{message_id}',
'/messages/{message_id}/history',
'/users/me/subscriptions/{stream_id}',
'/messages/<message_id>/reactions',
'/messages/<message_id>/emoji_reactions/<emoji_name>',
'/attachments/<attachment_id>',
'/user_groups/<user_group_id>/members',
'/messages/{message_id}/reactions',
'/messages/{message_id}/emoji_reactions/{emoji_name}',
'/attachments/{attachment_id}',
'/user_groups/{user_group_id}/members',
'/users/me/{stream_id}/topics',
'/streams/<stream_id>/members',
'/streams/{stream_id}/members',
'/streams/{stream_id}',
'/streams/<stream_id>/delete_topic',
'/default_stream_groups/<group_id>',
'/default_stream_groups/<group_id>/streams',
'/streams/{stream_id}/delete_topic',
'/default_stream_groups/{group_id}',
'/default_stream_groups/{group_id}/streams',
# Regex with an unnamed capturing group.
'/users/(?!me/)(?P<email>[^/]*)/presence',
# Actually '/user_groups/<user_group_id>' in urls.py but fails the reverse mapping