8000 rework conditional loading of the OAS plugins (#11585) · localstack/localstack@b11d2ba · GitHub
[go: up one dir, main page]

Skip to content

Commit b11d2ba

Browse files
authored
rework conditional loading of the OAS plugins (#11585)
1 parent 6f16877 commit b11d2ba

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

localstack-core/localstack/aws/handlers/validation.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ class OpenAPIValidator(Handler):
7373
open_apis: list["OpenAPI"]
7474

7575
def __init__(self) -> None:
76-
# avoid to load the specs if we don't have to perform any validation
76+
self._load_specs()
77+
78+
def _load_specs(self) -> None:
79+
"""Load the openapi spec plugins iff at least one between request and response validation is set."""
7780
if not (config.OPENAPI_VALIDATE_REQUEST or config.OPENAPI_VALIDATE_RESPONSE):
7881
return
7982
specs = PluginManager("localstack.openapi.spec").load_all()
@@ -92,6 +95,7 @@ def __call__(self, chain: HandlerChain, context: RequestContext, response: Respo
9295
if not config.OPENAPI_VALIDATE_REQUEST:
9396
return
9497

98+
hasattr(self, "open_apis") or self._load_specs()
9599
path = context.request.path
96100

97101
if path.startswith(f"{INTERNAL_RESOURCE_PATH}/") or path.startswith("/_aws/"):
@@ -119,6 +123,7 @@ def __call__(self, chain: HandlerChain, context: RequestContext, response: Respo
119123
if not config.OPENAPI_VALIDATE_RESPONSE:
120124
return
121125

126+
hasattr(self, "open_apis") or self._load_specs()
122127
path = context.request.path
123128

124129
if path.startswith(f"{INTERNAL_RESOURCE_PATH}/") or path.startswith("/_aws/"):

0 commit comments

Comments
 (0)
0