Skip to content

Commit 30acbac

Browse files
committed
fix(models): correctly handle missing model_rebuild in older pydantic versions
1 parent 68acc3d commit 30acbac

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/openapi_client/models.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ class OpenAPI(OpenAPIBase):
347347
for model in list(locals().values()):
348348
if isinstance(model, type) and issubclass(model, BaseModel) and model != BaseModel:
349349
if hasattr(model, "model_rebuild"):
350-
model.model_rebuild()
350+
try:
351+
model.model_rebuild()
352+
except AttributeError:
353+
if hasattr(model, "update_forward_refs"):
354+
model.update_forward_refs()
351355
elif hasattr(model, "update_forward_refs"):
352356
model.update_forward_refs()

0 commit comments

Comments
 (0)