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 10, 2024
1 parent 74e5cf7 commit 018a741
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/20.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes compatibility issue with fastapi version >= 0.112.3
6 changes: 6 additions & 0 deletions src/extendable_pydantic/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ 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
)

0 comments on commit 018a741

Please sign in to comment.