Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vcutrona fix map enums #19829

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,22 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}

{{/isNullable}}
{{/required}}
{{#isContainer}}
{{#isArray}}
for i in value:
if i not in set([{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]):
raise ValueError("each list item must be one of ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})")
{{/isArray}}
{{^isArray}}
{{#isMap}}
for i in value.values():
if i not in set([{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]):
raise ValueError("dict values must be one of enum values ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})")
{{/isMap}}
{{/isContainer}}
{{^isContainer}}
if value not in set([{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]):
raise ValueError("must be one of enum values ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})")
{{/isArray}}
{{/isContainer}}
return value
{{/isEnum}}
{{/vars}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ def map_of_enum_string_validate_enum(cls, value):
if value is None:
return value

if value not in set(['UPPER', 'lower']):
raise ValueError("must be one of enum values ('UPPER', 'lower')")
for i in value.values():
if i not in set(['UPPER', 'lower']):
raise ValueError("dict values must be one of enum values ('UPPER', 'lower')")
return value

model_config = ConfigDict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ def map_of_enum_string_validate_enum(cls, value):
if value is None:
return value

if value not in set(['UPPER', 'lower']):
raise ValueError("must be one of enum values ('UPPER', 'lower')")
for i in value.values():
if i not in set(['UPPER', 'lower']):
raise ValueError("dict values must be one of enum values ('UPPER', 'lower')")
return value

model_config = ConfigDict(
Expand Down
Loading