I want to create a rest endpoint that allows multiple params of the same name, i.e. /api?param=a¶m=b
I am using flask for the implementation and swagger-ui to create a nice ui where you can test the rest call. Here is what I have:
from flask.ext.restful.reqparse import RequestParser
parser = RequestParser()
parser.add_argument('param', type=str, location='args', action='append')
class Foo(Resource):
@swagger.operation(
parameters=[
{
"allowMultiple": True,
"dataType": "string",
"description": "Params(s)",
"name": "param",
"paramType": "query",
"required": False
}
]
)
def get(self):
args = parser.parse_args()
print args['param']
Problem 1: in the swagger-ui there is only one text field for the parameter that is supposed to allow multiple values.
Problem 2: RequestParser
turns the parameter into a List
. So if I specify a comma separated list for instance in the swagger-ui, it will print ['value1,value2,value3']
.
How can I specify a comma separated list in the ui or have multiple input fields? When the args are parsed it should be a List
argument with multiple entries.