Skip to content

Commit d599672

Browse files
committed
Fix compatibility issue with fastapi >= 0.112.3
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
1 parent ffdc03a commit d599672

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/extendable_pydantic/_patch.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ def _create_response_field_wrapper(wrapped, instance, args, kwargs):
6767
return field
6868

6969
# fastapi < 0.112.3
70-
wrapt.wrap_function_wrapper(
71-
utils, "create_response_field", _create_response_field_wrapper
72-
)
70+
if hasattr(utils, "create_response_field"):
71+
wrapt.wrap_function_wrapper(
72+
utils, "create_response_field", _create_response_field_wrapper
73+
)
7374

7475
# fastapi >= 0.112.3
75-
wrapt.wrap_function_wrapper(
76-
utils, "create_model_field", _create_response_field_wrapper
77-
)
76+
if hasattr(utils, "create_model_field"):
77+
wrapt.wrap_function_wrapper(
78+
utils, "create_model_field", _create_response_field_wrapper
79+
)

0 commit comments

Comments
 (0)