Skip to content

Commit

Permalink
Apply appropriate method for function wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
QuocDuong1306 committed Sep 17, 2024
1 parent ffdc03a commit a8b28e1
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/extendable_pydantic/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ def _create_response_field_wrapper(wrapped, instance, args, kwargs):
_resolve_model_fields_annotation([field])
return field

# fastapi < 0.112.3
wrapt.wrap_function_wrapper(
utils, "create_response_field", _create_response_field_wrapper
)

# fastapi >= 0.112.3
wrapt.wrap_function_wrapper(
utils, "create_model_field", _create_response_field_wrapper
)
if hasattr(utils, "create_response_field"):
# For fastapi < 0.112.3
wrapt.wrap_function_wrapper(
utils, "create_response_field", _create_response_field_wrapper
)
if hasattr(utils, "create_model_field"):
# For fastapi >= 0.112.3
wrapt.wrap_function_wrapper(
utils, "create_model_field", _create_response_field_wrapper
)

0 comments on commit a8b28e1

Please sign in to comment.