Search code examples
flaskswaggerswagger-uiflask-restful

Form type parameter not accessible by swagger


I am using flasgger to provide a swagger spec for my flask app. For a particular endpoint I need form type parameters.

Update user address
---   
 parameters:
     - name: user_id
       in: path
       type: integer
       required: true
     - name: address
       in: form
       type: string
       required: true
       description: Address.

The method related to this endpoint is :

def update_address(user_id):
    approved_by = request.form.get('address')
    result = user.approve_sample(user_id, address):
    return json.dumps("OK"), 200, {'Content-Type': 'application/json; charset=utf-8'}

However, the address which is a form type parameter does not get updated in the database. Any suggestion why is it not registering address?


Solution

  • Try using formData in the in field, as specified in the OpenAPI Specification:

     - name: address
       in: formData
    

    Note that possible values are query, header, path, formData or body.