diff --git a/templates/python/model_anyof.mustache b/templates/python/model_anyof.mustache index 3e2e6fc..ce454c4 100644 --- a/templates/python/model_anyof.mustache +++ b/templates/python/model_anyof.mustache @@ -133,7 +133,6 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} error_messages.append(str(e)) {{/isPrimitiveType}} {{^isPrimitiveType}} - # {{vendorExtensions.x-py-name}}: {{{vendorExtensions.x-py-typing}}} try: instance.actual_instance = {{{dataType}}}.from_json(json_str) return instance diff --git a/templates/python/model_oneof.mustache b/templates/python/model_oneof.mustache index 07a4d93..3e7c655 100644 --- a/templates/python/model_oneof.mustache +++ b/templates/python/model_oneof.mustache @@ -83,10 +83,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/isPrimitiveType}} {{/isContainer}} {{/composedSchemas.oneOf}} - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in {{{classname}}} with oneOf schemas: {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. Details: " + ", ".join(error_messages)) - elif match == 0: + if match == 0: # no match raise ValueError("No match found when setting `actual_instance` in {{{classname}}} with oneOf schemas: {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. Details: " + ", ".join(error_messages)) else: