Skip to content

Commit 7589c1a

Browse files
authored
fix: generation of model_oneof for python (#102)
1 parent db32adf commit 7589c1a

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

templates/python/model_anyof.mustache

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
133133
error_messages.append(str(e))
134134
{{/isPrimitiveType}}
135135
{{^isPrimitiveType}}
136-
# {{vendorExtensions.x-py-name}}: {{{vendorExtensions.x-py-typing}}}
137136
try:
138137
instance.actual_instance = {{{dataType}}}.from_json(json_str)
139138
return instance

templates/python/model_oneof.mustache

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
8383
{{/isPrimitiveType}}
8484
{{/isContainer}}
8585
{{/composedSchemas.oneOf}}
86-
if match > 1:
87-
# more than 1 match
88-
raise ValueError("Multiple matches found when setting `actual_instance` in {{{classname}}} with oneOf schemas: {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. Details: " + ", ".join(error_messages))
89-
elif match == 0:
86+
if match == 0:
9087
# no match
9188
raise ValueError("No match found when setting `actual_instance` in {{{classname}}} with oneOf schemas: {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. Details: " + ", ".join(error_messages))
9289
else:

0 commit comments

Comments
 (0)