You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
python-pydantic-v1: Keep trailing commas for enum validation tuples (OpenAPITools#19985)
* python-pydantic-v1: Keep trailing commas for tuples when enum has just single member
* Update samples
* Add test for single member enums
* Refactor test name
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/main/resources/python-fastapi/model_generic.mustache
+2-2
Original file line number
Diff line number
Diff line change
@@ -69,11 +69,11 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
69
69
{{/required}}
70
70
{{#isArray}}
71
71
for i in value:
72
-
if i not in ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}):
72
+
if i not in ({{#allowableValues}}{{#enumVars}}{{{value}}},{{^-last}} {{/-last}}{{/enumVars}}{{/allowableValues}}):
73
73
raise ValueError("each list item must be one of ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})")
74
74
{{/isArray}}
75
75
{{^isArray}}
76
-
if value not in ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}):
76
+
if value not in ({{#allowableValues}}{{#enumVars}}{{{value}}},{{^-last}} {{/-last}}{{/enumVars}}{{/allowableValues}}):
77
77
raise ValueError("must be one of enum values ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})")
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/main/resources/python-pydantic-v1/model_generic.mustache
+2-2
Original file line number
Diff line number
Diff line change
@@ -74,11 +74,11 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
74
74
{{/required}}
75
75
{{#isArray}}
76
76
for i in value:
77
-
if i not in ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}):
77
+
if i not in ({{#allowableValues}}{{#enumVars}}{{{value}}},{{^-last}} {{/-last}}{{/enumVars}}{{/allowableValues}}):
78
78
raise ValueError("each list item must be one of ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})")
79
79
{{/isArray}}
80
80
{{^isArray}}
81
-
if value not in ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}):
81
+
if value not in ({{#allowableValues}}{{#enumVars}}{{{value}}},{{^-last}} {{/-last}}{{/enumVars}}{{/allowableValues}}):
82
82
raise ValueError("must be one of enum values ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})")
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml
Copy file name to clipboardExpand all lines: samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_model_with_enum_default.py
0 commit comments