From eaf5dc53f0d746764794edbbc204cd172fb1b344 Mon Sep 17 00:00:00 2001 From: EtiennePelletier Date: Thu, 22 Jan 2026 12:11:23 -0500 Subject: [PATCH 1/2] Enable using Namespace.parser(trim=True) --- flask_restx/namespace.py | 4 ++-- tests/test_reqparse.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) 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_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)}) From 7226fd39c3466926dc7e0f2c97083bba9308d60d Mon Sep 17 00:00:00 2001 From: EtiennePelletier Date: Thu, 22 Jan 2026 12:26:01 -0500 Subject: [PATCH 2/2] Fix invalid escape sequence test warning --- tests/test_namespace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"][""], )