docs: Make upload-custom-emoji use curl example system.

This commit is contained in:
Vishnu Ks 2019-10-16 11:06:31 +00:00 committed by Tim Abbott
parent 438c4b2935
commit 9ac77a8734
4 changed files with 9 additions and 5 deletions

View File

@ -16,11 +16,7 @@ organization. Access to this endpoint depends on the
{tab|curl} {tab|curl}
``` curl {generate_code_example(curl)|/realm/emoji/{emoji_name}:post|example}
curl -X POST {{ api_url }}/v1/realm/emoji/{emoji_name} \
-F "data=@/path/to/img.png" \
-u USER_EMAIL:API_KEY
```
{end_tabs} {end_tabs}

View File

@ -188,6 +188,11 @@ def generate_curl_example(endpoint: str, method: str,
curl_argument=True) curl_argument=True)
lines.append(example_value) lines.append(example_value)
if "requestBody" in openapi_entry:
properties = openapi_entry["requestBody"]["content"]["multipart/form-data"]["schema"]["properties"]
for key, property in properties.items():
lines.append(' -F "{}=@{}"'.format(key, property["example"]))
for i in range(1, len(lines)-1): for i in range(1, len(lines)-1):
lines[i] = lines[i] + " \\" lines[i] = lines[i] + " \\"

View File

@ -35,6 +35,8 @@ exclude_list = [
'remove-linkifiers.md', 'remove-linkifiers.md',
# Endpoint does not accept bot requests # Endpoint does not accept bot requests
'get-user-groups.md', 'get-user-groups.md',
# Example files do not exist
'upload-custom-emoji.md',
] ]
def test_generated_curl_examples_for_success(client: Client) -> None: def test_generated_curl_examples_for_success(client: Client) -> None:

View File

@ -1747,6 +1747,7 @@ paths:
filename: filename:
type: string type: string
format: binary format: binary
example: /path/to/img.png
security: security:
- basicAuth: [] - basicAuth: []
responses: responses: