[JavaScript] fix JS shell scripts, add log to show template version (#5907)

* fix JS shell script, add log to show es version

* change CLI option default value for useES6

* fix shell script in JS ES6 promise

* fix windows batch files

* set useES6 to false
This commit is contained in:
wing328 2017-06-23 22:09:07 +08:00 committed by GitHub
parent 69ce921371
commit 5b4e8a8ed5
9 changed files with 17 additions and 8 deletions

View File

@ -29,6 +29,6 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/
ags="$@ generate -t modules/swagger-codegen/src/main/resources/Javascript/es6 \
-i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l javascript \
-o samples/client/petstore/javascript-es6 \
--additional-properties useEs6=true"
--additional-properties useES6=true"
java -DappName=PetstoreClient $JAVA_OPTS -jar $executable $ags

View File

@ -29,7 +29,6 @@ export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/
ags="$@ generate -t modules/swagger-codegen/src/main/resources/Javascript/es6 \
-i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l javascript \
-o samples/client/petstore/javascript-promise-es6 \
--additional-properties useEs6=true \
--additional-properties usePromises=true"
--additional-properties usePromises=true,useES6=true"
java -DappName=PetstoreClient $JAVA_OPTS -jar $executable $ags

View File

@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -l javascript -o samples\client\petstore\javascript-es6 --additional-properties useEs6=true
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -l javascript -o samples\client\petstore\javascript\es6 --additional-properties useES6=true
java -DappName=PetstoreClient %JAVA_OPTS% -jar %executable% %ags%

View File

@ -1,3 +1,4 @@
call .\bin\windows\javascript-petstore.bat
call .\bin\windows\javascript-promise-petstore.bat
call .\bin\windows\javascript-es6-petstore.bat
call .\bin\windows\javascript-promise-es6-petstore.bat

View File

@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -l javascript -o samples\client\petstore\javascript-promise-es6 --additional-properties useEs6=true --additional-properties usePromises=true
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -l javascript -o samples\client\petstore\javascript-promise-es6 --additional-properties useES6=true,usePromises=true
java -DappName=PetstoreClient %JAVA_OPTS% -jar %executable% %ags%

View File

@ -2511,7 +2511,6 @@ public class DefaultCodegen {
}
} else {
LOGGER.info("proessing body parameter ...");
if (!(param instanceof BodyParameter)) {
LOGGER.error("Cannot use Parameter " + param + " as Body Parameter");
}

View File

@ -96,7 +96,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
protected String modelDocPath = "docs/";
protected String apiTestPath = "api/";
protected String modelTestPath = "model/";
protected boolean useES6;
protected boolean useES6 = false; // default is ES5
public JavascriptClientCodegen() {
super();
@ -197,7 +197,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
.defaultValue(Boolean.TRUE.toString()));
cliOptions.add(new CliOption(USE_ES6,
"use JavaScript ES6 (ECMAScript 6)")
.defaultValue(Boolean.TRUE.toString()));
.defaultValue(Boolean.FALSE.toString()));
}
@Override
@ -268,6 +268,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
}
if (additionalProperties.containsKey(USE_ES6)) {
setUseES6(convertPropertyToBooleanAndWriteBack(USE_ES6));
} else {
setUseES6(false);
}
}
@ -432,8 +434,10 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
this.useES6 = useES6;
if (useES6) {
embeddedTemplateDir = templateDir = "Javascript/es6";
LOGGER.info("Using JS ES6 templates");
} else {
embeddedTemplateDir = templateDir = "Javascript";
LOGGER.info("Using JS ES5 templates");
}
}

View File

@ -0,0 +1,3 @@
{
"presets": ["es2015", "stage-0"]
}

View File

@ -0,0 +1,3 @@
{
"presets": ["es2015", "stage-0"]
}