Skip to content

Commit eb3d6d2

Browse files
[python][template] move _path_to_item of simple init to avoid name error (#8737)
* [python][template] move _path_to_item of simple init up so its avaliable for missing default errors * update generated examples
1 parent 19f43b5 commit eb3d6d2

File tree

14 files changed

+28
-14
lines changed

14 files changed

+28
-14
lines changed

modules/openapi-generator/src/main/resources/python/model_templates/method_init_simple.mustache

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
value ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501
2121
{{> model_templates/docstring_init_required_kwargs }}
2222
"""
23+
# required up here when default value is not given
24+
_path_to_item = kwargs.pop('_path_to_item', ())
2325

2426
if 'value' in kwargs:
2527
value = kwargs.pop('value')
@@ -41,7 +43,6 @@
4143

4244
_check_type = kwargs.pop('_check_type', True)
4345
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
44-
_path_to_item = kwargs.pop('_path_to_item', ())
4546
_configuration = kwargs.pop('_configuration', None)
4647
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
4748

samples/client/petstore/python/petstore_api/model/animal_farm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def __init__(self, *args, **kwargs):
136136
through its discriminator because we passed in
137137
_visited_composed_classes = (Animal,)
138138
"""
139+
# required up here when default value is not given
140+
_path_to_item = kwargs.pop('_path_to_item', ())
139141

140142
if 'value' in kwargs:
141143
value = kwargs.pop('value')
@@ -151,7 +153,6 @@ def __init__(self, *args, **kwargs):
151153

152154
_check_type = kwargs.pop('_check_type', True)
153155
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
154-
_path_to_item = kwargs.pop('_path_to_item', ())
155156
_configuration = kwargs.pop('_configuration', None)
156157
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
157158

samples/client/petstore/python/petstore_api/model/enum_class.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def __init__(self, *args, **kwargs):
136136
through its discriminator because we passed in
137137
_visited_composed_classes = (Animal,)
138138
"""
139+
# required up here when default value is not given
140+
_path_to_item = kwargs.pop('_path_to_item', ())
139141

140142
if 'value' in kwargs:
141143
value = kwargs.pop('value')
@@ -147,7 +149,6 @@ def __init__(self, *args, **kwargs):
147149

148150
_check_type = kwargs.pop('_check_type', True)
149151
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
150-
_path_to_item = kwargs.pop('_path_to_item', ())
151152
_configuration = kwargs.pop('_configuration', None)
152153
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
153154

samples/client/petstore/python/petstore_api/model/number_with_validations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ def __init__(self, *args, **kwargs):
135135
through its discriminator because we passed in
136136
_visited_composed_classes = (Animal,)
137137
"""
138+
# required up here when default value is not given
139+
_path_to_item = kwargs.pop('_path_to_item', ())
138140

139141
if 'value' in kwargs:
140142
value = kwargs.pop('value')
@@ -150,7 +152,6 @@ def __init__(self, *args, **kwargs):
150152

151153
_check_type = kwargs.pop('_check_type', True)
152154
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
153-
_path_to_item = kwargs.pop('_path_to_item', ())
154155
_configuration = kwargs.pop('_configuration', None)
155156
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
156157

samples/client/petstore/python/petstore_api/model/string_enum.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def __init__(self, *args, **kwargs):
136136
through its discriminator because we passed in
137137
_visited_composed_classes = (Animal,)
138138
"""
139+
# required up here when default value is not given
140+
_path_to_item = kwargs.pop('_path_to_item', ())
139141

140142
if 'value' in kwargs:
141143
value = kwargs.pop('value')
@@ -151,7 +153,6 @@ def __init__(self, *args, **kwargs):
151153

152154
_check_type = kwargs.pop('_check_type', True)
153155
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
154-
_path_to_item = kwargs.pop('_path_to_item', ())
155156
_configuration = kwargs.pop('_configuration', None)
156157
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
157158

samples/openapi3/client/petstore/python/petstore_api/model/animal_farm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def __init__(self, *args, **kwargs):
136136
through its discriminator because we passed in
137137
_visited_composed_classes = (Animal,)
138138
"""
139+
# required up here when default value is not given
140+
_path_to_item = kwargs.pop('_path_to_item', ())
139141

140142
if 'value' in kwargs:
141143
value = kwargs.pop('value')
@@ -151,7 +153,6 @@ def __init__(self, *args, **kwargs):
151153

152154
_check_type = kwargs.pop('_check_type', True)
153155
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
154-
_path_to_item = kwargs.pop('_path_to_item', ())
155156
_configuration = kwargs.pop('_configuration', None)
156157
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
157158

samples/openapi3/client/petstore/python/petstore_api/model/array_of_enums.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def __init__(self, *args, **kwargs):
136136
through its discriminator because we passed in
137137
_visited_composed_classes = (Animal,)
138138
"""
139+
# required up here when default value is not given
140+
_path_to_item = kwargs.pop('_path_to_item', ())
139141

140142
if 'value' in kwargs:
141143
value = kwargs.pop('value')
@@ -151,7 +153,6 @@ def __init__(self, *args, **kwargs):
151153

152154
_check_type = kwargs.pop('_check_type', True)
153155
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
154-
_path_to_item = kwargs.pop('_path_to_item', ())
155156
_configuration = kwargs.pop('_configuration', None)
156157
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
157158

samples/openapi3/client/petstore/python/petstore_api/model/enum_class.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def __init__(self, *args, **kwargs):
136136
through its discriminator because we passed in
137137
_visited_composed_classes = (Animal,)
138138
"""
139+
# required up here when default value is not given
140+
_path_to_item = kwargs.pop('_path_to_item', ())
139141

140142
if 'value' in kwargs:
141143
value = kwargs.pop('value')
@@ -147,7 +149,6 @@ def __init__(self, *args, **kwargs):
147149

148150
_check_type = kwargs.pop('_check_type', True)
149151
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
150-
_path_to_item = kwargs.pop('_path_to_item', ())
151152
_configuration = kwargs.pop('_configuration', None)
152153
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
153154

samples/openapi3/client/petstore/python/petstore_api/model/integer_enum.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def __init__(self, *args, **kwargs):
136136
through its discriminator because we passed in
137137
_visited_composed_classes = (Animal,)
138138
"""
139+
# required up here when default value is not given
140+
_path_to_item = kwargs.pop('_path_to_item', ())
139141

140142
if 'value' in kwargs:
141143
value = kwargs.pop('value')
@@ -151,7 +153,6 @@ def __init__(self, *args, **kwargs):
151153

152154
_check_type = kwargs.pop('_check_type', True)
153155
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
154-
_path_to_item = kwargs.pop('_path_to_item', ())
155156
_configuration = kwargs.pop('_configuration', None)
156157
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
157158

samples/openapi3/client/petstore/python/petstore_api/model/integer_enum_one_value.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ def __init__(self, *args, **kwargs):
134134
through its discriminator because we passed in
135135
_visited_composed_classes = (Animal,)
136136
"""
137+
# required up here when default value is not given
138+
_path_to_item = kwargs.pop('_path_to_item', ())
137139

138140
if 'value' in kwargs:
139141
value = kwargs.pop('value')
@@ -145,7 +147,6 @@ def __init__(self, *args, **kwargs):
145147

146148
_check_type = kwargs.pop('_check_type', True)
147149
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
148-
_path_to_item = kwargs.pop('_path_to_item', ())
149150
_configuration = kwargs.pop('_configuration', None)
150151
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
151152

0 commit comments

Comments
 (0)