Skip to content

Commit 3c253e9

Browse files
Update aws_lambda_powertools/event_handler/api_gateway.py
Co-authored-by: Leandro Damascena <[email protected]> Signed-off-by: Ruben Fonseca <[email protected]>
1 parent 8c2818d commit 3c253e9

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

aws_lambda_powertools/event_handler/api_gateway.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,17 +1572,17 @@ def _get_openapi_security(
15721572
security: Optional[List[Dict[str, List[str]]]],
15731573
security_schemes: Optional[Dict[str, "SecurityScheme"]],
15741574
) -> Optional[List[Dict[str, List[str]]]]:
1575-
if security:
1576-
if not security_schemes:
1577-
raise ValueError("security_schemes must be provided if security is provided")
1575+
if not security:
1576+
return None
15781577

1579-
# Check if all keys in security are present in the security_schemes
1580-
if not all(key in security_schemes for sec in security for key in sec):
1581-
raise ValueError("Some security schemes not found in security_schemes")
1578+
if not security_schemes:
1579+
raise ValueError("security_schemes must be provided if security is provided")
15821580

1583-
return security
1584-
else:
1585-
return None
1581+
# Check if all keys in security are present in the security_schemes
1582+
if any(key not in security_schemes for sec in security for key in sec):
1583+
raise ValueError("Some security schemes not found in security_schemes")
1584+
1585+
return security
15861586

15871587
@staticmethod
15881588
def _determine_openapi_version(openapi_version):

0 commit comments

Comments
 (0)