api docs: Migrate POST /user_uploads to OpenAPI.

This commit is contained in:
Yago González 2018-06-21 03:04:05 +02:00 committed by Tim Abbott
parent 119b3c0bc4
commit 8d0cf3ebe5
5 changed files with 38 additions and 21 deletions

View File

@ -38,13 +38,5 @@
"required": false,
"example": "change_all"
}
],
"upload-file.md": [
{
"argument": "file",
"description": "File to be uploaded.",
"required": true,
"example": "See code examples above."
}
]
}

View File

@ -120,11 +120,6 @@
"msg": "You don't have permission to edit this message",
"result": "error"
},
"upload-file": {
"msg": "",
"result": "success",
"uri": "/user_uploads/1/4e/m2A3MSqFnWRLUf9SaPzQ0Up_/zulip.txt"
},
"user-not-authorized-error": {
"code": "BAD_REQUEST",
"msg": "User not authorized for this query",

View File

@ -2,7 +2,7 @@
Upload a single file and get the corresponding URI.
`POST {{ api_url}}/v1/user_uploads`
`POST {{ api_url }}/v1/user_uploads`
## Usage examples
<div class="code-section" markdown="1">
@ -13,7 +13,7 @@ Upload a single file and get the corresponding URI.
<div data-language="python" markdown="1">
{generate_code_example(python)|upload-file|example}
{generate_code_example(python)|/user_uploads:post|example}
</div>
@ -23,7 +23,8 @@ Upload a single file and get the corresponding URI.
## Arguments
{generate_api_arguments_table|arguments.json|upload-file.md}
The file to upload must be provided, and it should be placed in the request's
body as `multipart` media type.
## Maximum file size
@ -44,4 +45,4 @@ to 25MB.
A typical successful JSON response may look like:
{generate_code_example|upload-file|fixture}
{generate_code_example|/user_uploads:post|fixture(200)}

View File

@ -433,9 +433,7 @@ def upload_file(client):
)
# {code_example|end}
fixture = FIXTURES['upload-file']
test_against_fixture(result, fixture, check_if_equal=['msg', 'result'],
check_if_exists=['uri'])
validate_against_openapi_schema(result, '/user_uploads', 'post', '200')
def get_stream_topics(client, stream_id):
# type: (Client, int) -> None
@ -480,7 +478,7 @@ TEST_FUNCTIONS = {
'/users:get': get_members,
'/register:post': register_queue,
'/events:delete': deregister_queue,
'upload-file': upload_file,
'/user_uploads:post': upload_file,
'/users/me/{stream_id}/topics:get': get_stream_topics
}

View File

@ -402,6 +402,37 @@ paths:
"rendered": "<p><strong>foo</strong></p>",
"result": "success"
}
/user_uploads:
post:
description: Upload a single file and get the corresponding URI.
requestBody:
content:
multipart/form-data:
schema:
properties:
filename:
type: string
format: binary
security:
- basicAuth: []
responses:
'200':
description: Success.
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/JsonSuccess'
- properties:
uri:
type: string
description: The URI of the uploaded file.
- example:
{
"msg": "",
"result": "success",
"uri": "/user_uploads/1/4e/m2A3MSqFnWRLUf9SaPzQ0Up_/zulip.txt"
}
/users:
get:
description: Retrieve all users in a realm.