File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
modules/swagger-codegen/src/main
java/io/swagger/codegen/languages Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,9 @@ public PythonClientCodegen() {
77
77
languageSpecificPrimitives .add ("date" );
78
78
languageSpecificPrimitives .add ("object" );
79
79
80
+ instantiationTypes .put ("array" , "list" );
81
+ instantiationTypes .put ("map" , "dict" );
82
+
80
83
typeMapping .clear ();
81
84
typeMapping .put ("integer" , "int" );
82
85
typeMapping .put ("float" , "float" );
@@ -350,6 +353,14 @@ public String modelTestFileFolder() {
350
353
return outputFolder + File .separatorChar + testFolder ;
351
354
}
352
355
356
+ @ Override
357
+ public String toInstantiationType (Property p ) {
358
+ if (p instanceof MapProperty ) {
359
+ return instantiationTypes .get ("map" );
360
+ }
361
+ return super .toInstantiationType (p );
362
+ }
363
+
353
364
@ Override
354
365
public String getTypeDeclaration (Property p ) {
355
366
if (p instanceof ArrayProperty ) {
Original file line number Diff line number Diff line change @@ -620,6 +620,12 @@ class ApiClient(object):
620
620
621
621
instance = klass(**kwargs)
622
622
623
+ if (isinstance(instance, dict) and
624
+ klass.swagger_types is not None and
625
+ isinstance(data, dict)):
626
+ for key, value in data.items():
627
+ if key not in klass.swagger_types:
628
+ instance[key] = value
623
629
if hasattr(instance, 'get_real_child_model'):
624
630
klass_name = instance.get_real_child_model(data)
625
631
if klass_name:
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import six
14
14
15
15
{ {#models} }
16
16
{ {#model} }
17
- class { {classname} }(object):
17
+ class { {classname} }({ {#parent } } { {parent } } { {/parent } } { {^parent } } object{ {/parent } } ):
18
18
"""NOTE: This class is auto generated by the swagger code generator program.
19
19
20
20
Do not edit the class manually.
@@ -194,6 +194,9 @@ class {{classname}}(object):
194
194
))
195
195
else:
196
196
result[attr] = value
197
+ if issubclass({ {classname} }, dict):
198
+ for key, value in self.items():
199
+ result[key] = value
197
200
198
201
return result
199
202
You can’t perform that action at this time.
0 commit comments