flask-restful-swagger icon indicating copy to clipboard operation
flask-restful-swagger copied to clipboard

allowMultiple=True not being parsed per spec

Open hamx0r opened this issue 11 years ago • 1 comments

According to the Swagger spec, setting allowMultiple = True will cause a CSV string (comma-separated values) to be converted to an array. The caveat is this field may be used only if paramType is "query", "header" or "path".

In contrast, flask-restful's reqparse can allow mutiple values too by setting action="append", but it's mechanism is to pass the same key several times. Per the documentation, this is how such multiple values would be passed with curl: curl http://api.example.com -d "Name=bob" -d "Name=sue" -d "Name=joe" . Digging into curl's documentation, the -d flag sends form data. This would match Swagger's paramType="form", which is incompatible with the allowMutliple=True setting.

It seems the Swagger spec and reqparse are incompatible in this way. However, as Swagger is only a documentation spec, and not an implementation spec, i'm not sure how to make the two libraries work together better.

hamx0r avatar Oct 14 '14 18:10 hamx0r

I'm in the same situation.

swagger-spec version 2.0 adds the parameter collectionFormat which can be "multi":

multi - corresponds to multiple parameter instances instead of multiple values for a single instance foo=bar&foo=baz. This is valid only for parameters in "query" or "formData". 

But so far it seems that this project supports only spec version 1.2.

See also: https://github.com/swagger-api/swagger-spec/issues/49

PabloCastellano avatar Dec 04 '14 14:12 PabloCastellano