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 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";
|
||||
@ -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'.
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -88,9 +88,9 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
|
||||
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");
|
||||
@ -275,13 +275,13 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user