Skip to content

Commit c116c8f

Browse files
authored
[PHP] Decommission "packagePath", add new option "packageName" (#681)
* remove packagePath from php file location, use -o instead * fix php symfony top folder * restore pacakgePath * update php laraavel samples * remove packagePath from PHP generator * add new silex files * update window batch - php silex * fix openapi3 silex script
1 parent 1ab4fe4 commit c116c8f

34 files changed

Lines changed: 197 additions & 135 deletions

bin/openapi3/php-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ fi
3333

3434
# if you've executed sbt assembly previously it will use that instead.
3535
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
36-
ags="generate -t modules/openapi-generator/src/main/resources/php -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g php -o samples/openapi3/client/petstore/php $@"
36+
ags="generate -t modules/openapi-generator/src/main/resources/php -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g php -o samples/openapi3/client/petstore/php/OpenAPIClient-php $@"
3737

3838
java $JAVA_OPTS -jar $executable $ags

bin/openapi3/php-silex-petstore-server.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
ags="generate -t modules/openapi-generator/src/main/resources/php-silex -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g php-silex -o samples/server/petstore/php-silex $@"
30+
ags="generate -t modules/openapi-generator/src/main/resources/php-silex -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g php-silex -o samples/server/petstore/php-silex/OpenAPIServer $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags

bin/openapi3/php-symfony-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if [ ! -d "${APP_DIR}" ]; then
2323
fi
2424

2525
# Make sure that we are regenerating the sample by removing any existing target directory
26-
TARGET_DIR="$SCRIPT_DIR/../../samples/server/petstore/php-symfony"
26+
TARGET_DIR="$SCRIPT_DIR/../../samples/server/petstore/php-symfony/SymfonyBundle-php"
2727
if [ -d "$TARGET_DIR" ]; then
2828
rm -rf $TARGET_DIR
2929
fi

bin/php-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ fi
3333

3434
# if you've executed sbt assembly previously it will use that instead.
3535
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
36-
ags="generate -t modules/openapi-generator/src/main/resources/php -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g php -o samples/client/petstore/php $@"
36+
ags="generate -t modules/openapi-generator/src/main/resources/php -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g php -o samples/client/petstore/php/OpenAPIClient-php $@"
3737

3838
java $JAVA_OPTS -jar $executable $ags

bin/php-silex-petstore-server.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
ags="generate -t modules/openapi-generator/src/main/resources/php-silex -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g php-silex -o samples/server/petstore/php-silex $@"
30+
ags="generate -t modules/openapi-generator/src/main/resources/php-silex -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g php-silex -o samples/server/petstore/php-silex/OpenAPIServer $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags

bin/php-symfony-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if [ ! -d "${APP_DIR}" ]; then
2323
fi
2424

2525
# Make sure that we are regenerating the sample by removing any existing target directory
26-
TARGET_DIR="$SCRIPT_DIR/../samples/server/petstore/php-symfony"
26+
TARGET_DIR="$SCRIPT_DIR/../samples/server/petstore/php-symfony/SymfonyBundle-php"
2727
if [ -d "$TARGET_DIR" ]; then
2828
rm -rf $TARGET_DIR
2929
fi

bin/windows/php-petstore.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ If Not Exist %executable% (
55
)
66

77
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
8-
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g php -o samples\client\petstore\php
8+
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g php -o samples\client\petstore\php\OpenAPIClient-php
99

1010
java %JAVA_OPTS% -jar %executable% %ags%

bin/windows/php-silex-petstore-server.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ If Not Exist %executable% (
55
)
66

77
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
8-
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g php-silex -o samples\server\petstore\php-silex
8+
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g php-silex -o samples\server\petstore\php-silex\OpenAPIServer
99

1010
java %JAVA_OPTS% -jar %executable% %ags%

bin/windows/php-symfony-petstore-server.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ If Not Exist %executable% (
55
)
66

77
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
8-
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g php-symfony -o samples\server\petstore\php-symfony
8+
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g php-symfony -o samples\server\petstore\php-symfony\SymfonyBundle-php
99

1010
java %JAVA_OPTS% -jar %executable% %ags%

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

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
4646
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractPhpCodegen.class);
4747

4848
public static final String VARIABLE_NAMING_CONVENTION = "variableNamingConvention";
49-
public static final String PACKAGE_PATH = "packagePath";
49+
public static final String PACKAGE_NAME = "packageName";
5050
public static final String SRC_BASE_PATH = "srcBasePath";
5151
// composerVendorName/composerProjectName has be replaced by gitUserId/gitRepoId. prepare to remove these.
5252
// public static final String COMPOSER_VENDOR_NAME = "composerVendorName";
5353
// public static final String COMPOSER_PROJECT_NAME = "composerProjectName";
5454
// protected String composerVendorName = null;
5555
// protected String composerProjectName = null;
5656
protected String invokerPackage = "php";
57-
protected String packagePath = "php-base";
57+
protected String packageName = "php-base";
5858
protected String artifactVersion = null;
5959
protected String srcBasePath = "lib";
6060
protected String testBasePath = "test";
@@ -140,8 +140,8 @@ public AbstractPhpCodegen() {
140140
cliOptions.add(new CliOption(VARIABLE_NAMING_CONVENTION, "naming convention of variable name, e.g. camelCase.")
141141
.defaultValue("snake_case"));
142142
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, "The main namespace to use for all classes. e.g. Yay\\Pets"));
143-
cliOptions.add(new CliOption(PACKAGE_PATH, "The main package name for classes. e.g. GeneratedPetstore"));
144-
cliOptions.add(new CliOption(SRC_BASE_PATH, "The directory under packagePath to serve as source root."));
143+
cliOptions.add(new CliOption(PACKAGE_NAME, "The main package name for classes. e.g. GeneratedPetstore"));
144+
cliOptions.add(new CliOption(SRC_BASE_PATH, "The directory to serve as source root."));
145145
// cliOptions.add(new CliOption(COMPOSER_VENDOR_NAME, "The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets. IMPORTANT NOTE (2016/03): composerVendorName will be deprecated and replaced by gitUserId in the next openapi-generator release"));
146146
cliOptions.add(new CliOption(CodegenConstants.GIT_USER_ID, CodegenConstants.GIT_USER_ID_DESC));
147147
// cliOptions.add(new CliOption(COMPOSER_PROJECT_NAME, "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client. IMPORTANT NOTE (2016/03): composerProjectName will be deprecated and replaced by gitRepoId in the next openapi-generator release"));
@@ -153,10 +153,10 @@ public AbstractPhpCodegen() {
153153
public void processOpts() {
154154
super.processOpts();
155155

156-
if (additionalProperties.containsKey(PACKAGE_PATH)) {
157-
this.setPackagePath((String) additionalProperties.get(PACKAGE_PATH));
156+
if (additionalProperties.containsKey(PACKAGE_NAME)) {
157+
this.setPackageName((String) additionalProperties.get(PACKAGE_NAME));
158158
} else {
159-
additionalProperties.put(PACKAGE_PATH, packagePath);
159+
additionalProperties.put(PACKAGE_NAME, packageName);
160160
}
161161

162162
if (additionalProperties.containsKey(SRC_BASE_PATH)) {
@@ -236,16 +236,12 @@ public void processOpts() {
236236
// make test path available in mustache template
237237
additionalProperties.put("testBasePath", testBasePath);
238238

239-
// // apache v2 license
240-
// supportingFiles.add(new SupportingFile("LICENSE", getPackagePath(), "LICENSE"));
239+
// apache v2 license
240+
// supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
241241
}
242242

243-
public String getPackagePath() {
244-
return packagePath;
245-
}
246-
247-
public String toPackagePath(String packageName, String basePath) {
248-
return (getPackagePath() + File.separatorChar + toSrcPath(packageName, basePath));
243+
public String getPackageName() {
244+
return packageName;
249245
}
250246

251247
public String toSrcPath(String packageName, String basePath) {
@@ -287,32 +283,32 @@ public String escapeReservedWord(String name) {
287283

288284
@Override
289285
public String apiFileFolder() {
290-
return (outputFolder + File.separator + toPackagePath(apiPackage, srcBasePath));
286+
return (outputFolder + File.separator + toSrcPath(apiPackage, srcBasePath));
291287
}
292288

293289
@Override
294290
public String modelFileFolder() {
295-
return (outputFolder + File.separator + toPackagePath(modelPackage, srcBasePath));
291+
return (outputFolder + File.separator + toSrcPath(modelPackage, srcBasePath));
296292
}
297293

298294
@Override
299295
public String apiTestFileFolder() {
300-
return (outputFolder + File.separator + getPackagePath() + File.separator + testBasePath + File.separator + apiDirName);
296+
return (outputFolder + File.separator + testBasePath + File.separator + apiDirName);
301297
}
302298

303299
@Override
304300
public String modelTestFileFolder() {
305-
return (outputFolder + File.separator + getPackagePath() + File.separator + testBasePath + File.separator + modelDirName);
301+
return (outputFolder + File.separator + testBasePath + File.separator + modelDirName);
306302
}
307303

308304
@Override
309305
public String apiDocFileFolder() {
310-
return (outputFolder + File.separator + getPackagePath() + File.separator + apiDocPath);
306+
return (outputFolder + File.separator + apiDocPath);
311307
}
312308

313309
@Override
314310
public String modelDocFileFolder() {
315-
return (outputFolder + File.separator + getPackagePath() + File.separator + modelDocPath);
311+
return (outputFolder + File.separator + modelDocPath);
316312
}
317313

318314
@Override
@@ -382,8 +378,8 @@ public void setArtifactVersion(String artifactVersion) {
382378
this.artifactVersion = artifactVersion;
383379
}
384380

385-
public void setPackagePath(String packagePath) {
386-
this.packagePath = packagePath;
381+
public void setPackageName(String packageName) {
382+
this.packageName = packageName;
387383
}
388384

389385
public void setSrcBasePath(String srcBasePath) {

0 commit comments

Comments
 (0)