Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ public void processOpts() {

if (generateSourceCodeOnly) {
// tests in <package>/test
testFolder = packageName + File.separatorChar + testFolder;
testFolder = packagePath() + File.separatorChar + testFolder;
// api/model docs in <package>/docs
apiDocPath = packageName + File.separatorChar + apiDocPath;
modelDocPath = packageName + File.separatorChar + modelDocPath;
apiDocPath = packagePath() + File.separatorChar + apiDocPath;
modelDocPath = packagePath() + File.separatorChar + modelDocPath;
}
// make api and model doc path available in mustache template
additionalProperties.put("apiDocPath", apiDocPath);
Expand All @@ -219,7 +219,7 @@ public void processOpts() {
String readmePath = "README.md";
String readmeTemplate = "README.mustache";
if (generateSourceCodeOnly) {
readmePath = packageName + "_" + readmePath;
readmePath = packagePath() + "_" + readmePath;
readmeTemplate = "README_onlypackage.mustache";
}
supportingFiles.add(new SupportingFile(readmeTemplate, "", readmePath));
Expand All @@ -234,25 +234,25 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
supportingFiles.add(new SupportingFile("setup.mustache", "", "setup.py"));
}
supportingFiles.add(new SupportingFile("configuration.mustache", packageName, "configuration.py"));
supportingFiles.add(new SupportingFile("__init__package.mustache", packageName, "__init__.py"));
supportingFiles.add(new SupportingFile("__init__model.mustache", packageName + File.separatorChar + modelPackage, "__init__.py"));
supportingFiles.add(new SupportingFile("__init__api.mustache", packageName + File.separatorChar + apiPackage, "__init__.py"));
supportingFiles.add(new SupportingFile("configuration.mustache", packagePath(), "configuration.py"));
supportingFiles.add(new SupportingFile("__init__package.mustache", packagePath(), "__init__.py"));
supportingFiles.add(new SupportingFile("__init__model.mustache", packagePath() + File.separatorChar + modelPackage, "__init__.py"));
supportingFiles.add(new SupportingFile("__init__api.mustache", packagePath() + File.separatorChar + apiPackage, "__init__.py"));

if (Boolean.FALSE.equals(excludeTests)) {
supportingFiles.add(new SupportingFile("__init__test.mustache", testFolder, "__init__.py"));
}

supportingFiles.add(new SupportingFile("api_client.mustache", packageName, "api_client.py"));
supportingFiles.add(new SupportingFile("api_client.mustache", packagePath(), "api_client.py"));

if ("asyncio".equals(getLibrary())) {
supportingFiles.add(new SupportingFile("asyncio/rest.mustache", packageName, "rest.py"));
supportingFiles.add(new SupportingFile("asyncio/rest.mustache", packagePath(), "rest.py"));
additionalProperties.put("asyncio", "true");
} else if ("tornado".equals(getLibrary())) {
supportingFiles.add(new SupportingFile("tornado/rest.mustache", packageName, "rest.py"));
supportingFiles.add(new SupportingFile("tornado/rest.mustache", packagePath(), "rest.py"));
additionalProperties.put("tornado", "true");
} else {
supportingFiles.add(new SupportingFile("rest.mustache", packageName, "rest.py"));
supportingFiles.add(new SupportingFile("rest.mustache", packagePath(), "rest.py"));
}

modelPackage = packageName + "." + modelPackage;
Expand Down Expand Up @@ -582,6 +582,10 @@ public void setPackageUrl(String packageUrl) {
this.packageUrl = packageUrl;
}

public String packagePath() {
return packageName.replace('.', File.separatorChar);
}

/**
* Generate Python package name from String `packageName`
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.openapitools.codegen.languages.PythonClientCodegen;
import org.openapitools.codegen.options.PythonClientOptionsProvider;

import java.io.File;

public class PythonClientOptionsTest extends AbstractOptionsTest {

@Tested
Expand All @@ -43,11 +45,20 @@ protected CodegenConfig getCodegenConfig() {
protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setPackageName(PythonClientOptionsProvider.PACKAGE_NAME_VALUE);
times = 1;

clientCodegen.setProjectName(PythonClientOptionsProvider.PROJECT_NAME_VALUE);
times = 1;

clientCodegen.setPackageVersion(PythonClientOptionsProvider.PACKAGE_VERSION_VALUE);
times = 1;

clientCodegen.setPackageUrl(PythonClientOptionsProvider.PACKAGE_URL_VALUE);
// clientCodegen.setLibrary(PythonClientCodegen.DEFAULT_LIBRARY);
times = 1;

clientCodegen.packagePath();
result = PythonClientOptionsProvider.PACKAGE_NAME_VALUE.replace('.', File.separatorChar);
minTimes = 1;
}};
}
}