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

add changes so I can use reqparse and parameters at the same time

Open Menda0 opened this issue 7 years ago • 0 comments

I was having a problem generating parameters using reqparse parser. Sometimes I had a path parameters in my resources and I still want to use the request parser functionality. For that I used the parameters and rerparser properties in @swagger.doc like this:

"reqparser": {
    "name": "User signup info",
    "parser": postreqparse
},
"parameters": [
    {
        "description": "User email",
        "in": "path",
        "name": "email",
        "type": "string",
        "required": True
    }
]

that provoke the following exception 'parameters and reqparser can't be in same spec'.

if 'parameters' in operation:
  raise ValidationError('parameters and reqparser can\'t be in same spec')

For that to work for me I wanted both the method to work together, like a concatenation of parameters and reqparser so the output should be like this

"parameters": [
    {
        "description": "User email",
        "in": "path",
        "name": "email",
        "required": true,
        "type": "string"
    },
    {
        "description": "Request body",
        "in": "body",
        "name": "body",
        "required": true,
        "schema": {
            "$ref": "#/definitions/User signup info"
        }
    }
]

I fix this problem on this commit concatenating the result of reqparse parser and parameters and it worked as expected. I think that could be useful for someone like that was for me. So thats the reason of this pull request.

Hope I helped, Thanks for this awesome worked,

Cheers, Marco Mendão

Menda0 avatar Jul 24 '18 16:07 Menda0