forked from loafle/openapi-generator-original
* [FIX] Replace File.seperator with slashes in PHP projects. * Replaced 'File.separator' with slashes in AbstractPhpCodegen.
This commit is contained in:
parent
f1fa0a80ad
commit
add63cb981
@ -49,8 +49,8 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
protected String apiDirName = "Api";
|
protected String apiDirName = "Api";
|
||||||
protected String modelDirName = "Model";
|
protected String modelDirName = "Model";
|
||||||
protected String variableNamingConvention = "snake_case";
|
protected String variableNamingConvention = "snake_case";
|
||||||
protected String apiDocPath = docsBasePath + File.separator + apiDirName;
|
protected String apiDocPath = docsBasePath + "/" + apiDirName;
|
||||||
protected String modelDocPath = docsBasePath + File.separator + modelDirName;
|
protected String modelDocPath = docsBasePath + "/" + modelDirName;
|
||||||
protected String interfaceNamePrefix = "", interfaceNameSuffix = "Interface";
|
protected String interfaceNamePrefix = "", interfaceNameSuffix = "Interface";
|
||||||
protected String abstractNamePrefix = "Abstract", abstractNameSuffix = "";
|
protected String abstractNamePrefix = "Abstract", abstractNameSuffix = "";
|
||||||
protected String traitNamePrefix = "", traitNameSuffix = "Trait";
|
protected String traitNamePrefix = "", traitNameSuffix = "Trait";
|
||||||
@ -242,27 +242,13 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
|||||||
basePath = basePath.replaceAll("[\\\\/]?$", "") + '/'; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
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
|
return (basePath
|
||||||
// Replace period, backslash, forward slash with file separator in package name
|
// Replace period, backslash, forward slash with file separator in package name
|
||||||
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement("/"))
|
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement("/"))
|
||||||
// Trim prefix file separators from package path
|
// Trim prefix file separators from package path
|
||||||
.replaceAll(regFirstPathSeparator, ""))
|
.replaceAll("^/", ""))
|
||||||
// Trim trailing file separators from the overall path
|
// Trim trailing file separators from the overall path
|
||||||
.replaceAll(regLastPathSeparator + "$", "");
|
.replaceAll("/$", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,9 +88,9 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
|
|||||||
setInvokerPackage("OpenAPI\\Server");
|
setInvokerPackage("OpenAPI\\Server");
|
||||||
setBundleName("OpenAPIServer");
|
setBundleName("OpenAPIServer");
|
||||||
modelDirName = "Model";
|
modelDirName = "Model";
|
||||||
docsBasePath = "Resources" + File.separator + "docs";
|
docsBasePath = "Resources" + "/" + "docs";
|
||||||
apiDocPath = docsBasePath + File.separator + apiDirName;
|
apiDocPath = docsBasePath + "/" + apiDirName;
|
||||||
modelDocPath = docsBasePath + File.separator + modelDirName;
|
modelDocPath = docsBasePath + "/" + modelDirName;
|
||||||
outputFolder = "generated-code" + File.separator + "php";
|
outputFolder = "generated-code" + File.separator + "php";
|
||||||
apiTemplateFiles.put("api_controller.mustache", ".php");
|
apiTemplateFiles.put("api_controller.mustache", ".php");
|
||||||
modelTestTemplateFiles.put("testing/model_test.mustache", ".php");
|
modelTestTemplateFiles.put("testing/model_test.mustache", ".php");
|
||||||
@ -275,13 +275,13 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
|
|||||||
additionalProperties.put("bundleAlias", bundleAlias);
|
additionalProperties.put("bundleAlias", bundleAlias);
|
||||||
|
|
||||||
// make api and model src path available in mustache template
|
// make api and model src path available in mustache template
|
||||||
additionalProperties.put("apiSrcPath", "." + File.separator + toSrcPath(apiPackage, srcBasePath));
|
additionalProperties.put("apiSrcPath", "." + "/" + toSrcPath(apiPackage, srcBasePath));
|
||||||
additionalProperties.put("modelSrcPath", "." + File.separator + toSrcPath(modelPackage, srcBasePath));
|
additionalProperties.put("modelSrcPath", "." + "/" + toSrcPath(modelPackage, srcBasePath));
|
||||||
additionalProperties.put("testsSrcPath", "." + File.separator + toSrcPath(testsPackage, srcBasePath));
|
additionalProperties.put("testsSrcPath", "." + "/" + toSrcPath(testsPackage, srcBasePath));
|
||||||
additionalProperties.put("apiTestsSrcPath", "." + File.separator + toSrcPath(apiTestsPackage, srcBasePath));
|
additionalProperties.put("apiTestsSrcPath", "." + "/" + toSrcPath(apiTestsPackage, srcBasePath));
|
||||||
additionalProperties.put("modelTestsSrcPath", "." + File.separator + toSrcPath(modelTestsPackage, srcBasePath));
|
additionalProperties.put("modelTestsSrcPath", "." + "/" + toSrcPath(modelTestsPackage, srcBasePath));
|
||||||
additionalProperties.put("apiTestPath", "." + File.separator + testsDirName + File.separator + apiDirName);
|
additionalProperties.put("apiTestPath", "." + "/" + testsDirName + "/" + apiDirName);
|
||||||
additionalProperties.put("modelTestPath", "." + File.separator + testsDirName + File.separator + modelDirName);
|
additionalProperties.put("modelTestPath", "." + "/" + testsDirName + "/" + modelDirName);
|
||||||
|
|
||||||
// make api and model doc path available in mustache template
|
// make api and model doc path available in mustache template
|
||||||
additionalProperties.put("apiDocPath", apiDocPath);
|
additionalProperties.put("apiDocPath", apiDocPath);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user