Skip to content

Commit af9d57e

Browse files
ackintoshjmini
authored andcommitted
[PHP] Remove platform dependency from file path (#610)
1 parent eeda132 commit af9d57e

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ public void processOpts() {
228228
additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\"));
229229

230230
// make api and model src path available in mustache template
231-
additionalProperties.put("apiSrcPath", "." + File.separator + toSrcPath(apiPackage, srcBasePath));
232-
additionalProperties.put("modelSrcPath", "." + File.separator + toSrcPath(modelPackage, srcBasePath));
233-
additionalProperties.put("apiTestPath", "." + File.separator + testBasePath + File.separator + apiDirName);
234-
additionalProperties.put("modelTestPath", "." + File.separator + testBasePath + File.separator + modelDirName);
231+
additionalProperties.put("apiSrcPath", "./" + toSrcPath(apiPackage, srcBasePath));
232+
additionalProperties.put("modelSrcPath", "./" + toSrcPath(modelPackage, srcBasePath));
233+
additionalProperties.put("apiTestPath", "./" + testBasePath + "/" + apiDirName);
234+
additionalProperties.put("modelTestPath", "./" + testBasePath + "/" + modelDirName);
235235

236236
// make api and model doc path available in mustache template
237237
additionalProperties.put("apiDocPath", apiDocPath);
@@ -255,7 +255,7 @@ public String toPackagePath(String packageName, String basePath) {
255255
public String toSrcPath(String packageName, String basePath) {
256256
packageName = packageName.replace(invokerPackage, ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
257257
if (basePath != null && basePath.length() > 0) {
258-
basePath = basePath.replaceAll("[\\\\/]?$", "") + File.separatorChar; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
258+
basePath = basePath.replaceAll("[\\\\/]?$", "") + '/'; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
259259
}
260260

261261
String regFirstPathSeparator;
@@ -274,7 +274,7 @@ public String toSrcPath(String packageName, String basePath) {
274274

275275
return (basePath
276276
// Replace period, backslash, forward slash with file separator in package name
277-
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement(File.separator))
277+
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement("/"))
278278
// Trim prefix file separators from package path
279279
.replaceAll(regFirstPathSeparator, ""))
280280
// Trim trailing file separators from the overall path

0 commit comments

Comments
 (0)