You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Genrated method from_dict() of model is generated as follow:
@classmethoddeffrom_dict(cls, obj: Optional[Dict[str, Any]]) ->Optional[Self]:
"""Create an instance of IssueSchema from a dict"""ifobjisNone:
returnNoneifnotisinstance(obj, dict):
returncls.model_validate(obj)
_obj=cls.model_validate(
{
"property1": dict(
(_k, _v) for_k, _vinobj.get("property1").items() # This line is throwing an error.
),
"property2": obj.get("booleanPermissions"),
}
)
return_obj
When obj.get("property1") is None we can not call items() on it. Simple 'if' statement is fixing issue:
@classmethoddeffrom_dict(cls, obj: Optional[Dict[str, Any]]) ->Optional[Self]:
"""Create an instance of IssueSchema from a dict"""ifobjisNone:
returnNoneifnotisinstance(obj, dict):
returncls.model_validate(obj)
_obj=cls.model_validate(
{
"property1": dict(
(_k, _v) for_k, _vinobj.get("property1").items() # This line is throwing an error.
) ifobj.get("property1") isnotNoneelseNone, # This 'if' fix all problem."property2": obj.get("booleanPermissions"),
}
)
return_obj
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
When having schema where one of properties is optional enum, then generated model method from_dict() is throwing error:
Adding 'nullable: true' to property1 is not changing anything.
openapi-generator version
7.5.0
OpenAPI declaration file content or url
Generation Details
openapi-generator-cli generate -g python -c config.yaml
Config file:
Steps to reproduce
Try tu run method from_dict() of model genrated from provided schema when property1 is not present. For example:
Related issues/PRs
Suggest a fix
Genrated method from_dict() of model is generated as follow:
When obj.get("property1") is None we can not call items() on it. Simple 'if' statement is fixing issue:
The text was updated successfully, but these errors were encountered: