Skip to content

Commit a16c7bb

Browse files
committed
fix(models): conditionally rebuild pydantic models to support v1 and v2
1 parent 016f405 commit a16c7bb

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎src/openapi_client/models.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,4 +346,7 @@ class OpenAPI(OpenAPIBase):
346346
# Rebuild models due to forward references
347347
for model in list(locals().values()):
348348
if isinstance(model, type) and issubclass(model, BaseModel) and model != BaseModel:
349-
model.model_rebuild()
349+
if hasattr(model, "model_rebuild"):
350+
model.model_rebuild()
351+
elif hasattr(model, "update_forward_refs"): # pragma: no cover
352+
model.update_forward_refs() # pragma: no cover

0 commit comments

Comments
 (0)