python-pydantic-v1: Return the primitive type in to_dict for anyOf models (#19488)

* python: Return the primitive type in to_dict for anyOf models

* Regenerate samples

* Update test
This commit is contained in:
Chirag Jain
2024-09-13 16:20:55 +05:30
committed by GitHub
parent cd349dc5ea
commit 740b971074
7 changed files with 38 additions and 7 deletions

View File

@@ -146,7 +146,8 @@ class AnyOfColor(BaseModel):
if callable(to_json):
return self.actual_instance.to_dict()
else:
return json.dumps(self.actual_instance)
# primitive type
return self.actual_instance
def to_str(self) -> str:
"""Returns the string representation of the actual instance"""

View File

@@ -125,7 +125,8 @@ class AnyOfPig(BaseModel):
if callable(to_json):
return self.actual_instance.to_dict()
else:
return json.dumps(self.actual_instance)
# primitive type
return self.actual_instance
def to_str(self) -> str:
"""Returns the string representation of the actual instance"""