Skip to content

forward_refs updates not running in all classes that need it #27

@agostof

Description

@agostof

When running a simple example client I get the following error:

pydantic.errors.ConfigError: field "status" not yet prepared so type is still a ForwardRef, 
  you might need to call Metadata.update_forward_refs().

It seems that the initialization code in client/__init__.py is not finding all the classes that need the fwd_refs to be updated.
My solution was to run update_forward_refs in all classes (openapi-python-templates/__init__package.mustache)

for model in inspect.getmembers(models, inspect.isclass):
    if model[1].__module__ == "client.models":
        model_class = model[1]
        if isinstance(model_class, BaseModel) or hasattr(model_class, "update_forward_refs"):
            model_class.update_forward_refs()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions