flask-restx icon indicating copy to clipboard operation
flask-restx copied to clipboard

Update reqparse.py so that pattern is properly set on list objects wh…

Open alexissavin opened this issue 2 years ago • 1 comments

…en using option "append"

Using the reqparse option "append" in combination with a "pattern" leads to the wrong validation schema. Example, using the following code:

obj.add_argument('tag', location='args', type=inputs.regex('^[-_a-zA-Z0-9]+$') , action='append', default='', help='Filters obj tagged with the provided tags')

Currently result with the following schema:

{
  name: "tag",
  in: "query",
  type: "array",
  description: "Filters domains tagged with the provided tags",
  pattern: "^[-_a-zA-Z0-9]+$"
  default: "",
  items:
  {
    type: "string",
  },
  collectionFormat: "multi"
}

Which should be:

{
  name: "tag",
  in: "query",
  type: "array",
  description: "Filters domains tagged with the provided tags",
  default: "",
  items:
  {
    type: "string",
    pattern: "^[-_a-zA-Z0-9]+$"
  },
  collectionFormat: "multi"
}

Kind regards

alexissavin avatar Jul 11 '22 09:07 alexissavin

I include this in patch for reqparser here in my restx-monkey in 0.2.1+ version.

Ryu-CZ avatar Aug 31 '22 16:08 Ryu-CZ

I have fixed your patch and applied it on the main branch. Thanks again for your contribution.

ziirish avatar Oct 16 '22 19:10 ziirish

Thanks for fixing it and accepting the change.

alexissavin avatar Oct 17 '22 06:10 alexissavin