I wondered if there is a way to pass a dict to the arguments of a RequestParser .add_argument() command
it normally works like this
my_parser = reqparse.RequestParser()
my_parser.add_argument('my_field', type=dict, help='my_field must be a dict', required=True)
For code re-usability purposes, I'd like to use it somewhat like this
my_arguments = {type=dict, help='my_field must be a dict', required=True}
and then pass these as arguments to the .add_argument function using:
my_parser.add_argument('my_field', my_arguments)
I got stuck trying to do this using list comprehension,
my_parser.add_arguments('my_field', list(key=value for (key, value) in parser_arguments.items()))
at which point I realized I probably can't use a dict, might need to do a getattr() and clearly investing too much time on this. It seems possible and elegant to me, but I can't find a solution anyway, thankful for any enlightening ideas on this.
Edit: I can't use the intuitive
my_parser.add_argument('my_field', my_arguments)
because the dict will be added to the "default" field of the parser argument, and the actual fields ("type", "help" and "required") are unaffected.