From 5114cd96b0fea23ac93245687cb68fde06a2bedf Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sat, 28 Apr 2018 12:11:02 +0800 Subject: [PATCH] Update TypeScript Petstore samples with OAS3 (#253) * add scripts for ts oas3 petstore * remove json files * update ts jquery with oas3 petstore * update ts inversify, fix file mapping * update ts fetch wtih oas3 (no diff), fix script --- bin/openapi3/bash-petstore.sh | 2 +- bin/openapi3/erlang-petstore-server.sh | 2 +- .../typescript-angular-petstore-all.sh | 49 +++++++++++++++++++ ...pescript-angular-v2-petstore-interfaces.sh | 32 ++++++++++++ ...typescript-angular-v2-petstore-with-npm.sh | 32 ++++++++++++ .../typescript-angular-v2-petstore.sh | 32 ++++++++++++ ...typescript-angular-v4-petstore-with-npm.sh | 32 ++++++++++++ ...pescript-angular-v4.3-petstore-with-npm.sh | 32 ++++++++++++ bin/openapi3/typescript-angularjs-petstore.sh | 32 ++++++++++++ bin/openapi3/typescript-aurelia-petstore.sh | 32 ++++++++++++ bin/openapi3/typescript-fetch-petstore-all.sh | 6 +++ .../typescript-fetch-petstore-interfaces.sh | 32 ++++++++++++ .../typescript-fetch-petstore-target-es6.sh | 32 ++++++++++++ ...escript-fetch-petstore-with-npm-version.sh | 32 ++++++++++++ bin/openapi3/typescript-fetch-petstore.sh | 32 ++++++++++++ bin/openapi3/typescript-inversify-petstore.sh | 32 ++++++++++++ .../typescript-jquery-petstore-all.sh | 37 ++++++++++++++ .../typescript-jquery-petstore-with-npm.sh | 32 ++++++++++++ bin/openapi3/typescript-jquery-petstore.sh | 32 ++++++++++++ bin/openapi3/typescript-node-petstore-all.sh | 37 ++++++++++++++ .../typescript-node-petstore-with-npm.sh | 32 ++++++++++++ bin/openapi3/typescript-node-petstore.sh | 32 ++++++++++++ .../AbstractTypeScriptClientCodegen.java | 6 +-- .../TypeScriptInversifyClientCodegen.java | 2 +- .../typescript-jquery/npm/api/StoreApi.ts | 1 + .../typescript-jquery/npm/api/UserApi.ts | 4 ++ 26 files changed, 651 insertions(+), 7 deletions(-) create mode 100755 bin/openapi3/typescript-angular-petstore-all.sh create mode 100755 bin/openapi3/typescript-angular-v2-petstore-interfaces.sh create mode 100755 bin/openapi3/typescript-angular-v2-petstore-with-npm.sh create mode 100755 bin/openapi3/typescript-angular-v2-petstore.sh create mode 100755 bin/openapi3/typescript-angular-v4-petstore-with-npm.sh create mode 100755 bin/openapi3/typescript-angular-v4.3-petstore-with-npm.sh create mode 100755 bin/openapi3/typescript-angularjs-petstore.sh create mode 100755 bin/openapi3/typescript-aurelia-petstore.sh create mode 100755 bin/openapi3/typescript-fetch-petstore-all.sh create mode 100755 bin/openapi3/typescript-fetch-petstore-interfaces.sh create mode 100755 bin/openapi3/typescript-fetch-petstore-target-es6.sh create mode 100755 bin/openapi3/typescript-fetch-petstore-with-npm-version.sh create mode 100755 bin/openapi3/typescript-fetch-petstore.sh create mode 100755 bin/openapi3/typescript-inversify-petstore.sh create mode 100755 bin/openapi3/typescript-jquery-petstore-all.sh create mode 100755 bin/openapi3/typescript-jquery-petstore-with-npm.sh create mode 100755 bin/openapi3/typescript-jquery-petstore.sh create mode 100755 bin/openapi3/typescript-node-petstore-all.sh create mode 100755 bin/openapi3/typescript-node-petstore-with-npm.sh create mode 100755 bin/openapi3/typescript-node-petstore.sh diff --git a/bin/openapi3/bash-petstore.sh b/bin/openapi3/bash-petstore.sh index 1fe00ee6166..d163b6ebe9f 100755 --- a/bin/openapi3/bash-petstore.sh +++ b/bin/openapi3/bash-petstore.sh @@ -27,6 +27,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -args="$@ generate -t modules/openapi-generator/src/main/resources/bash -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -l bash -o samples/client/petstore/bash -c modules/openapi-generator/src/test/resources/2_0/bash-config.json --additional-properties hideGenerationTimestamp=true" +args="$@ generate -t modules/openapi-generator/src/main/resources/bash -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -l bash -o samples/client/petstore/bash -c modules/openapi-generator/src/test/resources/3_0/bash-config.json --additional-properties hideGenerationTimestamp=true" java $JAVA_OPTS -jar $executable $args diff --git a/bin/openapi3/erlang-petstore-server.sh b/bin/openapi3/erlang-petstore-server.sh index 4c464bbfb97..91433aad420 100755 --- a/bin/openapi3/erlang-petstore-server.sh +++ b/bin/openapi3/erlang-petstore-server.sh @@ -27,6 +27,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/erlang-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l erlang-server -o samples/server/petstore/erlang-server $@" +ags="generate -t modules/openapi-generator/src/main/resources/erlang-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l erlang-server -o samples/server/petstore/erlang-server $@" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-angular-petstore-all.sh b/bin/openapi3/typescript-angular-petstore-all.sh new file mode 100755 index 00000000000..29f0b3376b9 --- /dev/null +++ b/bin/openapi3/typescript-angular-petstore-all.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" + +echo "Typescript Petstore API client (default)" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-angular -o samples/client/petstore/typescript-angular-v2/default --additional-properties ngVersion=2" +java $JAVA_OPTS -jar $executable $ags + +echo "Typescript Petstore API client (npm setting)" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-angular -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular-v2/npm --additional-properties ngVersion=2" +java $JAVA_OPTS -jar $executable $ags + +echo "Typescript Petstore API client (with interfaces generated)" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-angular -o samples/client/petstore/typescript-angular-v2/with-interfaces -D withInterfaces=true --additional-properties ngVersion=2" +java $JAVA_OPTS -jar $executable $ags + +echo "Typescript Petstore API client (v4 { Adding InjectionToken Over OpaqueToken })" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-angular -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular-v4/npm --additional-properties ngVersion=4" +java $JAVA_OPTS -jar $executable $ags + +echo "Typescript Petstore API client (v4.3 { Adding HttpClientModule over HttpModule })" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-angular -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular-v4.3/npm --additional-properties ngVersion=4.3" +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-angular-v2-petstore-interfaces.sh b/bin/openapi3/typescript-angular-v2-petstore-interfaces.sh new file mode 100755 index 00000000000..854804b3365 --- /dev/null +++ b/bin/openapi3/typescript-angular-v2-petstore-interfaces.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-angular -o samples/client/petstore/typescript-angular-v2/with-interfaces -D withInterfaces=true --additional-properties ngVersion=2" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-angular-v2-petstore-with-npm.sh b/bin/openapi3/typescript-angular-v2-petstore-with-npm.sh new file mode 100755 index 00000000000..19ef5bddebb --- /dev/null +++ b/bin/openapi3/typescript-angular-v2-petstore-with-npm.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-angular -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular-v2/npm --additional-properties ngVersion=2" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-angular-v2-petstore.sh b/bin/openapi3/typescript-angular-v2-petstore.sh new file mode 100755 index 00000000000..fe6225bc940 --- /dev/null +++ b/bin/openapi3/typescript-angular-v2-petstore.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-angular -o samples/client/petstore/typescript-angular-v2/default --additional-properties ngVersion=2 $@" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-angular-v4-petstore-with-npm.sh b/bin/openapi3/typescript-angular-v4-petstore-with-npm.sh new file mode 100755 index 00000000000..53c2d87e6dc --- /dev/null +++ b/bin/openapi3/typescript-angular-v4-petstore-with-npm.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-angular -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular-v4/npm --additional-properties ngVersion=4" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-angular-v4.3-petstore-with-npm.sh b/bin/openapi3/typescript-angular-v4.3-petstore-with-npm.sh new file mode 100755 index 00000000000..4a50401fbb0 --- /dev/null +++ b/bin/openapi3/typescript-angular-v4.3-petstore-with-npm.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-angular -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular-v4.3/npm --additional-properties ngVersion=4.3" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-angularjs-petstore.sh b/bin/openapi3/typescript-angularjs-petstore.sh new file mode 100755 index 00000000000..0a96d1b2def --- /dev/null +++ b/bin/openapi3/typescript-angularjs-petstore.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-angularjs -o samples/client/petstore/typescript-angularjs" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-aurelia-petstore.sh b/bin/openapi3/typescript-aurelia-petstore.sh new file mode 100755 index 00000000000..5c04c71f3eb --- /dev/null +++ b/bin/openapi3/typescript-aurelia-petstore.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-aurelia -o samples/client/petstore/typescript-aurelia/default" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-fetch-petstore-all.sh b/bin/openapi3/typescript-fetch-petstore-all.sh new file mode 100755 index 00000000000..0c6dd48b503 --- /dev/null +++ b/bin/openapi3/typescript-fetch-petstore-all.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +./bin/openapi3/typescript-fetch-petstore-target-es6.sh +./bin/openapi3/typescript-fetch-petstore-with-npm-version.sh +./bin/openapi3/typescript-fetch-petstore-interfaces.sh +./bin/openapi3/typescript-fetch-petstore.sh diff --git a/bin/openapi3/typescript-fetch-petstore-interfaces.sh b/bin/openapi3/typescript-fetch-petstore-interfaces.sh new file mode 100755 index 00000000000..09acfd70e72 --- /dev/null +++ b/bin/openapi3/typescript-fetch-petstore-interfaces.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-fetch -o samples/client/petstore/typescript-fetch/builds/with-interfaces -D withInterfaces=true" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-fetch-petstore-target-es6.sh b/bin/openapi3/typescript-fetch-petstore-target-es6.sh new file mode 100755 index 00000000000..75030d85c95 --- /dev/null +++ b/bin/openapi3/typescript-fetch-petstore-target-es6.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-fetch -c bin/typescript-fetch-petstore-target-es6.json -o samples/client/petstore/typescript-fetch/builds/es6-target" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-fetch-petstore-with-npm-version.sh b/bin/openapi3/typescript-fetch-petstore-with-npm-version.sh new file mode 100755 index 00000000000..261c0876b82 --- /dev/null +++ b/bin/openapi3/typescript-fetch-petstore-with-npm-version.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-fetch -c bin/typescript-fetch-petstore-with-npm-version.json -o samples/client/petstore/typescript-fetch/builds/with-npm-version" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-fetch-petstore.sh b/bin/openapi3/typescript-fetch-petstore.sh new file mode 100755 index 00000000000..1e4169a23e7 --- /dev/null +++ b/bin/openapi3/typescript-fetch-petstore.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-fetch -o samples/client/petstore/typescript-fetch/builds/default" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-inversify-petstore.sh b/bin/openapi3/typescript-inversify-petstore.sh new file mode 100755 index 00000000000..db016243195 --- /dev/null +++ b/bin/openapi3/typescript-inversify-petstore.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-inversify -o samples/client/petstore/typescript-inversify" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-jquery-petstore-all.sh b/bin/openapi3/typescript-jquery-petstore-all.sh new file mode 100755 index 00000000000..1bcd90eb38a --- /dev/null +++ b/bin/openapi3/typescript-jquery-petstore-all.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" + +echo "Typescript Petstore API client (default)" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-jquery -o samples/client/petstore/typescript-jquery/default" +java $JAVA_OPTS -jar $executable $ags + +echo "Typescript Petstore API client (npm setting)" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-jquery -c bin/typescript-jquery-petstore-npm.json -o samples/client/petstore/typescript-jquery/npm" +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-jquery-petstore-with-npm.sh b/bin/openapi3/typescript-jquery-petstore-with-npm.sh new file mode 100755 index 00000000000..4c719fbb764 --- /dev/null +++ b/bin/openapi3/typescript-jquery-petstore-with-npm.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-jquery -c bin/typescript-jquery-petstore-npm.json -o samples/client/petstore/typescript-jquery/npm" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-jquery-petstore.sh b/bin/openapi3/typescript-jquery-petstore.sh new file mode 100755 index 00000000000..922a0083569 --- /dev/null +++ b/bin/openapi3/typescript-jquery-petstore.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-jquery -o samples/client/petstore/typescript-jquery/default" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-node-petstore-all.sh b/bin/openapi3/typescript-node-petstore-all.sh new file mode 100755 index 00000000000..5bdc7071c7c --- /dev/null +++ b/bin/openapi3/typescript-node-petstore-all.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" + +echo "Typescript node Petstore API client (default setting)" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-node -o samples/client/petstore/typescript-node/default" +java $JAVA_OPTS -jar $executable $ags + +echo "Typescript node Petstore API client with npm setting" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-node -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-node/npm" +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-node-petstore-with-npm.sh b/bin/openapi3/typescript-node-petstore-with-npm.sh new file mode 100755 index 00000000000..4de0bbac459 --- /dev/null +++ b/bin/openapi3/typescript-node-petstore-with-npm.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-node -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-node/npm" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/typescript-node-petstore.sh b/bin/openapi3/typescript-node-petstore.sh new file mode 100755 index 00000000000..1e7515af08e --- /dev/null +++ b/bin/openapi3/typescript-node-petstore.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +SCRIPT="$0" +echo "# START SCRIPT: $SCRIPT" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l typescript-node -o samples/client/petstore/typescript-node/default" + +java $JAVA_OPTS -jar $executable $ags diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java index 3477ca22e0e..80f8e0680d3 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java @@ -87,12 +87,10 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp typeMapping.put("Map", "any"); typeMapping.put("date", "string"); typeMapping.put("DateTime", "Date"); - //TODO binary should be mapped to byte array - // mapped to String as a workaround - typeMapping.put("binary", "string"); + typeMapping.put("binary", "any"); + typeMapping.put("File", "any"); typeMapping.put("ByteArray", "string"); typeMapping.put("UUID", "string"); - typeMapping.put("File", "any"); typeMapping.put("Error", "Error"); cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue("camelCase")); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java index eab76efc8e3..5e059f1eec6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java @@ -154,7 +154,7 @@ public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCo @Override public String getTypeDeclaration(Schema p) { - if (p instanceof FileSchema) { + if (p instanceof FileSchema || p instanceof BinarySchema) { return "Blob"; } else { return super.getTypeDeclaration(p); diff --git a/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts b/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts index 4621027ca39..2a9b90746e5 100644 --- a/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts +++ b/samples/client/petstore/typescript-jquery/npm/api/StoreApi.ts @@ -232,6 +232,7 @@ export class StoreApi { localVarPath = localVarPath + "?" + $.param(queryParameters); // to determine the Content-Type header let consumes: string[] = [ + 'application/json' ]; // to determine the Accept header diff --git a/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts b/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts index a98e7c5e3fc..dfb36427471 100644 --- a/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts +++ b/samples/client/petstore/typescript-jquery/npm/api/UserApi.ts @@ -65,6 +65,7 @@ export class UserApi { localVarPath = localVarPath + "?" + $.param(queryParameters); // to determine the Content-Type header let consumes: string[] = [ + 'application/json' ]; // to determine the Accept header @@ -123,6 +124,7 @@ export class UserApi { localVarPath = localVarPath + "?" + $.param(queryParameters); // to determine the Content-Type header let consumes: string[] = [ + 'application/json' ]; // to determine the Accept header @@ -181,6 +183,7 @@ export class UserApi { localVarPath = localVarPath + "?" + $.param(queryParameters); // to determine the Content-Type header let consumes: string[] = [ + 'application/json' ]; // to determine the Accept header @@ -475,6 +478,7 @@ export class UserApi { localVarPath = localVarPath + "?" + $.param(queryParameters); // to determine the Content-Type header let consumes: string[] = [ + 'application/json' ]; // to determine the Accept header