@@ -67,6 +67,7 @@ public PythonClientCodegen() {
6767 languageSpecificPrimitives .add ("int" );
6868 languageSpecificPrimitives .add ("float" );
6969 languageSpecificPrimitives .add ("list" );
70+ languageSpecificPrimitives .add ("dict" );
7071 languageSpecificPrimitives .add ("bool" );
7172 languageSpecificPrimitives .add ("str" );
7273 languageSpecificPrimitives .add ("datetime" );
@@ -189,21 +190,16 @@ public void processOpts() {
189190 setPackageUrl ((String ) additionalProperties .get (PACKAGE_URL ));
190191 }
191192
192- String swaggerFolder = packageName ;
193-
194- modelPackage = swaggerFolder + File .separatorChar + "models" ;
195- apiPackage = swaggerFolder + File .separatorChar + "apis" ;
196-
197193 supportingFiles .add (new SupportingFile ("README.mustache" , "" , "README.md" ));
198194
199195 supportingFiles .add (new SupportingFile ("tox.mustache" , "" , "tox.ini" ));
200196 supportingFiles .add (new SupportingFile ("test-requirements.mustache" , "" , "test-requirements.txt" ));
201197 supportingFiles .add (new SupportingFile ("requirements.mustache" , "" , "requirements.txt" ));
202198
203- supportingFiles .add (new SupportingFile ("configuration.mustache" , swaggerFolder , "configuration.py" ));
204- supportingFiles .add (new SupportingFile ("__init__package.mustache" , swaggerFolder , "__init__.py" ));
205- supportingFiles .add (new SupportingFile ("__init__model.mustache" , modelPackage , "__init__.py" ));
206- supportingFiles .add (new SupportingFile ("__init__api.mustache" , apiPackage , "__init__.py" ));
199+ supportingFiles .add (new SupportingFile ("configuration.mustache" , packageName , "configuration.py" ));
200+ supportingFiles .add (new SupportingFile ("__init__package.mustache" , packageName , "__init__.py" ));
201+ supportingFiles .add (new SupportingFile ("__init__model.mustache" , packageName + File . separatorChar + modelPackage , "__init__.py" ));
202+ supportingFiles .add (new SupportingFile ("__init__api.mustache" , packageName + File . separatorChar + apiPackage , "__init__.py" ));
207203
208204 if (Boolean .FALSE .equals (excludeTests )) {
209205 supportingFiles .add (new SupportingFile ("__init__test.mustache" , testFolder , "__init__.py" ));
@@ -212,23 +208,42 @@ public void processOpts() {
212208 supportingFiles .add (new SupportingFile ("gitignore.mustache" , "" , ".gitignore" ));
213209 supportingFiles .add (new SupportingFile ("travis.mustache" , "" , ".travis.yml" ));
214210 supportingFiles .add (new SupportingFile ("setup.mustache" , "" , "setup.py" ));
215- supportingFiles .add (new SupportingFile ("api_client.mustache" , swaggerFolder , "api_client.py" ));
211+ supportingFiles .add (new SupportingFile ("api_client.mustache" , packageName , "api_client.py" ));
216212
217213 if ("asyncio" .equals (getLibrary ())) {
218- supportingFiles .add (new SupportingFile ("asyncio/rest.mustache" , swaggerFolder , "rest.py" ));
214+ supportingFiles .add (new SupportingFile ("asyncio/rest.mustache" , packageName , "rest.py" ));
219215 additionalProperties .put ("asyncio" , "true" );
220216 } else if ("tornado" .equals (getLibrary ())) {
221- supportingFiles .add (new SupportingFile ("tornado/rest.mustache" , swaggerFolder , "rest.py" ));
217+ supportingFiles .add (new SupportingFile ("tornado/rest.mustache" , packageName , "rest.py" ));
222218 additionalProperties .put ("tornado" , "true" );
223219 } else {
224- supportingFiles .add (new SupportingFile ("rest.mustache" , swaggerFolder , "rest.py" ));
220+ supportingFiles .add (new SupportingFile ("rest.mustache" , packageName , "rest.py" ));
225221 }
222+
223+ modelPackage = packageName + "." + modelPackage ;
224+ apiPackage = packageName + "." + apiPackage ;
225+
226226 }
227227
228228 private static String dropDots (String str ) {
229229 return str .replaceAll ("\\ ." , "_" );
230230 }
231231
232+ @ Override
233+ public String toModelImport (String name ) {
234+ String modelImport ;
235+ if (StringUtils .startsWithAny (name ,"import" , "from" )) {
236+ modelImport = name ;
237+ } else {
238+ modelImport = "from " ;
239+ if (!"" .equals (modelPackage ())) {
240+ modelImport += modelPackage () + "." ;
241+ }
242+ modelImport += toModelFilename (name )+ " import " + name ;
243+ }
244+ return modelImport ;
245+ }
246+
232247 @ Override
233248 public Map <String , Object > postProcessModels (Map <String , Object > objs ) {
234249 // process enum in models
0 commit comments