I am trying to upload a file and well as take an input from the user in json format using Swagger UI. I have written the below code for the same.
upload_parser = api.parser()
upload_parser.add_argument('file', location='files',
type=FileStorage, required=True)
type = api.model("tax", {
"tax_form": fields.String()})
@api.route('/extraction')
@api.expect(upload_parser)
class extraction(Resource):
@api.expect(type)
def post(self):
tax_form= api.payload # json input string
print(tax_form['tax_form'])
args = upload_parser.parse_args() # upload a file
uploaded_file = args['file']
output = func_extract(uploaded_file,tax_form['tax_form'])
return output, 201
When i run the above individually for eg, if i only upload a file or only take an input from user, the code works but if i do them together. tax_from returns None value, it does not take what I am inputting as json value via Swagger UI.