documented bulk creator

This commit is contained in:
Jan Friedli 2020-07-13 08:34:18 +02:00
parent 77269a82e6
commit b148e03cb5
No known key found for this signature in database
GPG key ID: F945FA2FCA30549D
3 changed files with 51 additions and 2 deletions

48
matweb/oas/bulk.yml Normal file
View file

@ -0,0 +1,48 @@
---
tags:
- "File Bulk Download"
summary: 'Group multiple files to download as one zip archive'
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- in: "body"
name: "body"
description: "The files that will be combined for one single download"
required: true
schema:
$ref: '#/definitions/BulkBody'
responses:
201:
description: "A new resource to download all files as one archive"
schema:
$ref: '#/definitions/UploadResponse'
400:
description: "Invalid input"
schema:
$ref: '#/definitions/ErrorResponse'
500:
description: "Unable to clean the file"
schema:
$ref: '#/definitions/ErrorResponse'
definitions:
BulkBody:
type: "object"
properties:
download_list:
type: "array"
description: "An object containing the files you want to create a bulk download for"
items:
$ref: '#/definitions/BulkFile'
BulkFile:
type: "object"
properties:
file_name:
type: "string"
key:
type: "string"
secret:
type: "string"

View file

@ -22,7 +22,7 @@ parameters:
example: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==' example: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=='
responses: responses:
200: 201:
description: "An object containing all info about the cleaned file" description: "An object containing all info about the cleaned file"
schema: schema:
$ref: '#/definitions/UploadResponse' $ref: '#/definitions/UploadResponse'

View file

@ -64,7 +64,7 @@ class APIUpload(Resource):
filename=output_filename, filename=output_filename,
_external=True _external=True
) )
) ), 201
class APIDownload(Resource): class APIDownload(Resource):
@ -110,6 +110,7 @@ class APIBulkDownloadCreator(Resource):
} }
v = Validator(schema) v = Validator(schema)
@swag_from('./oas/bulk.yml')
def post(self): def post(self):
utils.check_upload_folder(self.upload_folder) utils.check_upload_folder(self.upload_folder)
data = request.json data = request.json