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 @@ -54,8 +54,8 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
protected String apiDirName = "Api";
protected String modelDirName = "Model";
protected String variableNamingConvention = "snake_case";
protected String apiDocPath = docsBasePath + File.separator + apiDirName;
protected String modelDocPath = docsBasePath + File.separator + modelDirName;
protected String apiDocPath = docsBasePath + "/" + apiDirName;
protected String modelDocPath = docsBasePath + "/" + modelDirName;
protected String interfaceNamePrefix = "", interfaceNameSuffix = "Interface";
protected String abstractNamePrefix = "Abstract", abstractNameSuffix = "";
protected String traitNamePrefix = "", traitNameSuffix = "Trait";
Expand Down Expand Up @@ -261,27 +261,13 @@ public String toSrcPath(String packageName, String basePath) {
basePath = basePath.replaceAll("[\\\\/]?$", "") + '/'; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
}

String regFirstPathSeparator;
if ("/".equals(File.separator)) { // for mac, linux
regFirstPathSeparator = "^/";
} else { // for windows
regFirstPathSeparator = "^\\\\";
}

String regLastPathSeparator;
if ("/".equals(File.separator)) { // for mac, linux
regLastPathSeparator = "/$";
} else { // for windows
regLastPathSeparator = "\\\\$";
}

return (basePath
// Replace period, backslash, forward slash with file separator in package name
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement("/"))
// Trim prefix file separators from package path
.replaceAll(regFirstPathSeparator, ""))
.replaceAll("^/", ""))
// Trim trailing file separators from the overall path
.replaceAll(regLastPathSeparator + "$", "");
.replaceAll("/$", "");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ public PhpSymfonyServerCodegen() {
setInvokerPackage("OpenAPI\\Server");
setBundleName("OpenAPIServer");
modelDirName = "Model";
docsBasePath = "Resources" + File.separator + "docs";
apiDocPath = docsBasePath + File.separator + apiDirName;
modelDocPath = docsBasePath + File.separator + modelDirName;
docsBasePath = "Resources" + "/" + "docs";
apiDocPath = docsBasePath + "/" + apiDirName;
modelDocPath = docsBasePath + "/" + modelDirName;
outputFolder = "generated-code" + File.separator + "php";
apiTemplateFiles.put("api_controller.mustache", ".php");
modelTestTemplateFiles.put("testing/model_test.mustache", ".php");
Expand Down Expand Up @@ -275,13 +275,13 @@ public void processOpts() {
additionalProperties.put("bundleAlias", bundleAlias);

// make api and model src path available in mustache template
additionalProperties.put("apiSrcPath", "." + File.separator + toSrcPath(apiPackage, srcBasePath));
additionalProperties.put("modelSrcPath", "." + File.separator + toSrcPath(modelPackage, srcBasePath));
additionalProperties.put("testsSrcPath", "." + File.separator + toSrcPath(testsPackage, srcBasePath));
additionalProperties.put("apiTestsSrcPath", "." + File.separator + toSrcPath(apiTestsPackage, srcBasePath));
additionalProperties.put("modelTestsSrcPath", "." + File.separator + toSrcPath(modelTestsPackage, srcBasePath));
additionalProperties.put("apiTestPath", "." + File.separator + testsDirName + File.separator + apiDirName);
additionalProperties.put("modelTestPath", "." + File.separator + testsDirName + File.separator + modelDirName);
additionalProperties.put("apiSrcPath", "." + "/" + toSrcPath(apiPackage, srcBasePath));
additionalProperties.put("modelSrcPath", "." + "/" + toSrcPath(modelPackage, srcBasePath));
additionalProperties.put("testsSrcPath", "." + "/" + toSrcPath(testsPackage, srcBasePath));
additionalProperties.put("apiTestsSrcPath", "." + "/" + toSrcPath(apiTestsPackage, srcBasePath));
additionalProperties.put("modelTestsSrcPath", "." + "/" + toSrcPath(modelTestsPackage, srcBasePath));
additionalProperties.put("apiTestPath", "." + "/" + testsDirName + "/" + apiDirName);
additionalProperties.put("modelTestPath", "." + "/" + testsDirName + "/" + modelDirName);

// make api and model doc path available in mustache template
additionalProperties.put("apiDocPath", apiDocPath);
Expand Down