Search code examples
pythonflaskswaggerflasgger

Flasgger - Upload File


I am working on a project that requires to upload a file via flasgger UI. I modified my conf based on Swagger docs but doesn't seem to work. Below is my conf. Please, let know the mistake.

"""
This API let's you train word embeddings
Call this api passing your file and get the word embeddings.

---
tags:
  - Train (Word Embeddings)
consumes:
  - multipart/form-data  
parameters:
  - in: formData
    name: body
    required: true
    description: Upload your file.
responses:
  500:
    description: ERROR Failed!
  200:
    description: INFO Success!
    schema:
      $ref: '#/definitions/txt_embeddings'
"""

Solution

  • You are missing 'type: file', the following worked for me:

    ...
    parameters:
        - name: file
          required: false
          in: formData
          type: file
    ...