From 70436794acbcfdc05fc29648018765eef88bd4b0 Mon Sep 17 00:00:00 2001 From: Jasmine Lea <106361522+jasminelea@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:09:46 -0800 Subject: [PATCH 1/3] Fix exclude logic --- sphinxcontrib/openapi/openapi31.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sphinxcontrib/openapi/openapi31.py b/sphinxcontrib/openapi/openapi31.py index 1c943fa..69846aa 100644 --- a/sphinxcontrib/openapi/openapi31.py +++ b/sphinxcontrib/openapi/openapi31.py @@ -473,11 +473,15 @@ def openapihttpdomain(spec, **options): # Remove paths matching regexp if "exclude" in options: _paths = [] - for e in options["exclude"]: - er = re.compile(e) - for path in paths: - if not er.match(path): - _paths.append(path) + compiled_options = [re.compile(e) for e in options["exclude"]] + for path in paths: + matched = False + for er in compiled_options: + if er.match(path): + matched = True + break + if not matched: + _paths.append(path) paths = _paths render_request = False From f095845910b0a313bace433c5e86a0f922666632 Mon Sep 17 00:00:00 2001 From: Jasmine Lea <106361522+jasminelea@users.noreply.github.com> Date: Mon, 12 Feb 2024 20:16:36 -0800 Subject: [PATCH 2/3] Fix PR feedback --- sphinxcontrib/openapi/openapi31.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/sphinxcontrib/openapi/openapi31.py b/sphinxcontrib/openapi/openapi31.py index 69846aa..3c3de0d 100644 --- a/sphinxcontrib/openapi/openapi31.py +++ b/sphinxcontrib/openapi/openapi31.py @@ -473,15 +473,8 @@ def openapihttpdomain(spec, **options): # Remove paths matching regexp if "exclude" in options: _paths = [] - compiled_options = [re.compile(e) for e in options["exclude"]] - for path in paths: - matched = False - for er in compiled_options: - if er.match(path): - matched = True - break - if not matched: - _paths.append(path) + if not any(re.match(pattern, path) for pattern in options["exclude"]): + _paths.append(path) paths = _paths render_request = False From 9054945ccbc8b3f1fbf129a49127e84e3e86de65 Mon Sep 17 00:00:00 2001 From: Jasmine Lea <106361522+jasminelea@users.noreply.github.com> Date: Mon, 12 Feb 2024 20:23:37 -0800 Subject: [PATCH 3/3] Fix typo --- sphinxcontrib/openapi/openapi31.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sphinxcontrib/openapi/openapi31.py b/sphinxcontrib/openapi/openapi31.py index 3c3de0d..eb3a7e0 100644 --- a/sphinxcontrib/openapi/openapi31.py +++ b/sphinxcontrib/openapi/openapi31.py @@ -473,8 +473,9 @@ def openapihttpdomain(spec, **options): # Remove paths matching regexp if "exclude" in options: _paths = [] - if not any(re.match(pattern, path) for pattern in options["exclude"]): - _paths.append(path) + for path in paths: + if not any(re.match(pattern, path) for pattern in options["exclude"]): + _paths.append(path) paths = _paths render_request = False