Skip to content

Commit

Permalink
Fix compatibility issue with fastapi >= 0.112.3
Browse files Browse the repository at this point in the history
    If fastapi is installed we path the method used to build the field definition from model to ensure that the registry is initialized. From version 0.112.3 the patched method 'create_response_field' has been renamed 'create_model_field'. This change ensure that this new method is also patched

    fixes #20
  • Loading branch information
lmignon committed Sep 19, 2024
1 parent ffdc03a commit d599672
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/extendable_pydantic/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ def _create_response_field_wrapper(wrapped, instance, args, kwargs):
return field

# fastapi < 0.112.3
wrapt.wrap_function_wrapper(
utils, "create_response_field", _create_response_field_wrapper
)
if hasattr(utils, "create_response_field"):
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_model_field"):
wrapt.wrap_function_wrapper(
utils, "create_model_field", _create_response_field_wrapper
)

0 comments on commit d599672

Please sign in to comment.