forked from loafle/openapi-generator-original
[Python Connexion Servers] BUGFIX: handle . in package names (#2508)
This fixes adding supporting files to packages that have a '.'. If the controllersPackage or modelsPackage has a '.' (eg to put the controllers and/or models in a subpackage of the invokerPackage), supporting controller and models were ending up in directories that included the period instead of converting the periods to file separators.
This commit is contained in:
parent
baf0e85216
commit
942a0dafb6
@ -201,10 +201,10 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
||||
}
|
||||
supportingFiles.add(new SupportingFile("__main__.mustache", packagePath(), "__main__.py"));
|
||||
supportingFiles.add(new SupportingFile("util.mustache", packagePath(), "util.py"));
|
||||
supportingFiles.add(new SupportingFile("__init__.mustache", packagePath() + File.separatorChar + controllerPackage, "__init__.py"));
|
||||
supportingFiles.add(new SupportingFile("security_controller_.mustache", packagePath() + File.separatorChar + controllerPackage, "security_controller_.py"));
|
||||
supportingFiles.add(new SupportingFile("__init__model.mustache", packagePath() + File.separatorChar + modelPackage, "__init__.py"));
|
||||
supportingFiles.add(new SupportingFile("base_model_.mustache", packagePath() + File.separatorChar + modelPackage, "base_model_.py"));
|
||||
supportingFiles.add(new SupportingFile("__init__.mustache", packagePath() + File.separatorChar + packageToPath(controllerPackage), "__init__.py"));
|
||||
supportingFiles.add(new SupportingFile("security_controller_.mustache", packagePath() + File.separatorChar + packageToPath(controllerPackage), "security_controller_.py"));
|
||||
supportingFiles.add(new SupportingFile("__init__model.mustache", packagePath() + File.separatorChar + packageToPath(modelPackage), "__init__.py"));
|
||||
supportingFiles.add(new SupportingFile("base_model_.mustache", packagePath() + File.separatorChar + packageToPath(modelPackage), "base_model_.py"));
|
||||
supportingFiles.add(new SupportingFile("openapi.mustache", packagePath() + File.separatorChar + "openapi", "openapi.yaml"));
|
||||
addSupportingFiles();
|
||||
|
||||
@ -212,6 +212,10 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
|
||||
controllerPackage = packageName + "." + controllerPackage;
|
||||
}
|
||||
|
||||
private static String packageToPath(String pkg) {
|
||||
return pkg.replace(".", File.separator);
|
||||
}
|
||||
|
||||
private static String dropDots(String str) {
|
||||
return str.replaceAll("\\.", "_");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user