diff options
| author | Jan Friedli | 2020-07-13 08:34:18 +0200 |
|---|---|---|
| committer | Jan Friedli | 2020-07-13 08:34:18 +0200 |
| commit | b148e03cb57b9b6eeb98354f23a2eadf9b6fa05b (patch) | |
| tree | 9632a2e81b1773ea22074daf2953bcbef11c79ad /matweb | |
| parent | 77269a82e62025b915e939b93b59ae1be03497cc (diff) | |
documented bulk creator
Diffstat (limited to 'matweb')
| -rw-r--r-- | matweb/oas/bulk.yml | 48 | ||||
| -rw-r--r-- | matweb/oas/upload.yml | 2 | ||||
| -rw-r--r-- | matweb/rest_api.py | 3 |
3 files changed, 51 insertions, 2 deletions
diff --git a/matweb/oas/bulk.yml b/matweb/oas/bulk.yml new file mode 100644 index 0000000..f91573f --- /dev/null +++ b/matweb/oas/bulk.yml | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | --- | ||
| 2 | tags: | ||
| 3 | - "File Bulk Download" | ||
| 4 | summary: 'Group multiple files to download as one zip archive' | ||
| 5 | consumes: | ||
| 6 | - "application/json" | ||
| 7 | produces: | ||
| 8 | - "application/json" | ||
| 9 | parameters: | ||
| 10 | - in: "body" | ||
| 11 | name: "body" | ||
| 12 | description: "The files that will be combined for one single download" | ||
| 13 | required: true | ||
| 14 | schema: | ||
| 15 | $ref: '#/definitions/BulkBody' | ||
| 16 | |||
| 17 | responses: | ||
| 18 | 201: | ||
| 19 | description: "A new resource to download all files as one archive" | ||
| 20 | schema: | ||
| 21 | $ref: '#/definitions/UploadResponse' | ||
| 22 | 400: | ||
| 23 | description: "Invalid input" | ||
| 24 | schema: | ||
| 25 | $ref: '#/definitions/ErrorResponse' | ||
| 26 | 500: | ||
| 27 | description: "Unable to clean the file" | ||
| 28 | schema: | ||
| 29 | $ref: '#/definitions/ErrorResponse' | ||
| 30 | |||
| 31 | definitions: | ||
| 32 | BulkBody: | ||
| 33 | type: "object" | ||
| 34 | properties: | ||
| 35 | download_list: | ||
| 36 | type: "array" | ||
| 37 | description: "An object containing the files you want to create a bulk download for" | ||
| 38 | items: | ||
| 39 | $ref: '#/definitions/BulkFile' | ||
| 40 | BulkFile: | ||
| 41 | type: "object" | ||
| 42 | properties: | ||
| 43 | file_name: | ||
| 44 | type: "string" | ||
| 45 | key: | ||
| 46 | type: "string" | ||
| 47 | secret: | ||
| 48 | type: "string" \ No newline at end of file | ||
diff --git a/matweb/oas/upload.yml b/matweb/oas/upload.yml index c7a9bd7..71cb87b 100644 --- a/matweb/oas/upload.yml +++ b/matweb/oas/upload.yml | |||
| @@ -22,7 +22,7 @@ parameters: | |||
| 22 | example: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==' | 22 | example: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==' |
| 23 | 23 | ||
| 24 | responses: | 24 | responses: |
| 25 | 200: | 25 | 201: |
| 26 | description: "An object containing all info about the cleaned file" | 26 | description: "An object containing all info about the cleaned file" |
| 27 | schema: | 27 | schema: |
| 28 | $ref: '#/definitions/UploadResponse' | 28 | $ref: '#/definitions/UploadResponse' |
diff --git a/matweb/rest_api.py b/matweb/rest_api.py index 0e47a5d..2bf44f0 100644 --- a/matweb/rest_api.py +++ b/matweb/rest_api.py | |||
| @@ -64,7 +64,7 @@ class APIUpload(Resource): | |||
| 64 | filename=output_filename, | 64 | filename=output_filename, |
| 65 | _external=True | 65 | _external=True |
| 66 | ) | 66 | ) |
| 67 | ) | 67 | ), 201 |
| 68 | 68 | ||
| 69 | 69 | ||
| 70 | class APIDownload(Resource): | 70 | class APIDownload(Resource): |
| @@ -110,6 +110,7 @@ class APIBulkDownloadCreator(Resource): | |||
| 110 | } | 110 | } |
| 111 | v = Validator(schema) | 111 | v = Validator(schema) |
| 112 | 112 | ||
| 113 | @swag_from('./oas/bulk.yml') | ||
| 113 | def post(self): | 114 | def post(self): |
| 114 | utils.check_upload_folder(self.upload_folder) | 115 | utils.check_upload_folder(self.upload_folder) |
| 115 | data = request.json | 116 | data = request.json |
