mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-20 03:17:14 +00:00
[Python] Correct sanitize_for_serialization in python generator for list in oneOf schema elements, fixes #18106 (#19405)
* correct sanitize_for_serialization in python generator, fixes #18106 The method did not consider the objects created for oneOf schemata. If one of the cases was a list, to_dict would return it instead of something that has an items() method. * generate new samples
This commit is contained in:
@@ -383,6 +383,10 @@ class ApiClient:
|
||||
else:
|
||||
obj_dict = obj.__dict__
|
||||
|
||||
if isinstance(obj_dict, list):
|
||||
# here we handle instances that can either be a list or something else, and only became a real list by calling to_dict()
|
||||
return self.sanitize_for_serialization(obj_dict)
|
||||
|
||||
return {
|
||||
key: self.sanitize_for_serialization(val)
|
||||
for key, val in obj_dict.items()
|
||||
|
||||
Reference in New Issue
Block a user