Skip to content

Commit

Permalink
refactor(general): drop pydantic v1 (#4305)
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrodamascena authored May 10, 2024
1 parent c2d088e commit e21b916
Show file tree
Hide file tree
Showing 49 changed files with 755 additions and 1,141 deletions.
12 changes: 3 additions & 9 deletions aws_lambda_powertools/event_handler/api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -1587,22 +1587,16 @@ def _get_openapi_security(
return security

@staticmethod
def _determine_openapi_version(openapi_version):
from aws_lambda_powertools.event_handler.openapi.pydantic_loader import PYDANTIC_V2
def _determine_openapi_version(openapi_version: str):

# Pydantic V2 has no support for OpenAPI schema 3.0
if PYDANTIC_V2 and not openapi_version.startswith("3.1"):
if not openapi_version.startswith("3.1"):
warnings.warn(
"You are using Pydantic v2, which is incompatible with OpenAPI schema 3.0. Forcing OpenAPI 3.1",
stacklevel=2,
)
openapi_version = "3.1.0"
elif not PYDANTIC_V2 and not openapi_version.startswith("3.0"):
warnings.warn(
"You are using Pydantic v1, which is incompatible with OpenAPI schema 3.1. Forcing OpenAPI 3.0",
stacklevel=2,
)
openapi_version = "3.0.3"

return openapi_version

def get_openapi_json_schema(
Expand Down
Loading

0 comments on commit e21b916

Please sign in to comment.