diff --git a/flask_restx/namespace.py b/flask_restx/namespace.py index 6d55fabe..39d9ae18 100644 --- a/flask_restx/namespace.py +++ b/flask_restx/namespace.py @@ -230,9 +230,9 @@ def expect(self, *inputs, **kwargs): expect.append(param) return self.doc(**params) - def parser(self): + def parser(self, **kwargs): """Instanciate a :class:`~RequestParser`""" - return RequestParser() + return RequestParser(**kwargs) def as_list(self, field): """Allow to specify nested lists for documentation""" diff --git a/tests/test_namespace.py b/tests/test_namespace.py index dfc51067..8c4505dc 100644 --- a/tests/test_namespace.py +++ b/tests/test_namespace.py @@ -175,6 +175,6 @@ def post(self): resp = client.post_json("/apples/validation/", data, status=400) assert re.match( - "Additional properties are not allowed \(u*'agge' was unexpected\)", + r"Additional properties are not allowed \(u*'agge' was unexpected\)", resp["errors"][""], ) diff --git a/tests/test_reqparse.py b/tests/test_reqparse.py index 2b319ed9..278278d5 100644 --- a/tests/test_reqparse.py +++ b/tests/test_reqparse.py @@ -18,6 +18,11 @@ def test_api_shortcut(self, app): parser = api.parser() assert isinstance(parser, RequestParser) + def test_api_shortcut_kwargs(self, app): + api = Api(app) + parser = api.parser(trim=True) + assert parser.trim == True + def test_parse_model(self, app): model = Model("Todo", {"task": fields.String(required=True)})