Skip to content

Commit

Permalink
[BUG-1865] Added serialization support for typescript on complex obje…
Browse files Browse the repository at this point in the history
…ct headers. (#1874)

* [BUG-1865] Added serialization support for typescript on complex object headers.

* Update api.mustache

integrate feedback from #1874 (comment)

* [BUG-1865] post merge fixes

* [BUG-1865] addded windows scripts

* Apply suggestions from code review

Co-Authored-By: Esteban Gehring <esteban.gehring@gmail.com>

* [BUG-1865] regenerated samples
  • Loading branch information
Sebastian Rühl authored and macjohnny committed Jul 29, 2019
1 parent b4f1581 commit 1bf8c15
Show file tree
Hide file tree
Showing 15 changed files with 2,973 additions and 1 deletion.
1 change: 1 addition & 0 deletions bin/typescript-axios-petstore-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
./bin/typescript-axios-petstore-target-es6.sh
./bin/typescript-axios-petstore-with-npm-version.sh
./bin/typescript-axios-petstore-with-npm-version-and-separate-models-and-api.sh
./bin/typescript-axios-petstore-with-complex-headers.sh
./bin/typescript-axios-petstore-interfaces.sh
./bin/typescript-axios-petstore.sh
32 changes: 32 additions & 0 deletions bin/typescript-axios-petstore-with-complex-headers.sh
Original file line number Diff line number Diff line change
@@ -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 -B 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-with-complex-headers.yaml -g typescript-axios -o samples/client/petstore/typescript-axios/builds/with-complex-headers $@"

java $JAVA_OPTS -jar $executable $ags
1 change: 1 addition & 0 deletions bin/windows/typescript-axios-petstore-all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

call bin\windows\typescript-axios-petstore.bat
call bin\windows\typescript-axios-petstore-target-es6.bat
call bin\windows\typescript-axios-petstore-with-complex-headers.bat
call bin\windows\typescript-axios-petstore-with-npm-version.bat
call bin\windows\typescript-axios-petstore-interfaces.bat
call bin\windows\typescript-axios-petstore-with-npm-version-and-separate-models-and-api.bat
12 changes: 12 additions & 0 deletions bin/windows/typescript-axios-petstore-with-complex-headers.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@ECHO OFF

set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar

If Not Exist %executable% (
mvn clean package
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore-with-complex-headers.yaml -g typescript-axios -o samples\client\petstore\typescript-axios\builds\with-complex-headers

java %JAVA_OPTS% -jar %executable% %ags%
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,18 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur
{{#headerParams}}
{{#isListContainer}}
if ({{paramName}}) {
localVarHeaderParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}});
let mapped = {{paramName}}.map(value => (<any>"{{{dataType}}}" !== "Array<string>") ? JSON.stringify(value) : (value || ""));
localVarHeaderParameter['{{baseName}}'] = mapped.join(COLLECTION_FORMATS["{{collectionFormat}}"]);
}
{{/isListContainer}}
{{^isListContainer}}
if ({{paramName}} !== undefined && {{paramName}} !== null) {
{{#isString}}
localVarHeaderParameter['{{baseName}}'] = String({{paramName}});
{{/isString}}
{{^isString}}
localVarHeaderParameter['{{baseName}}'] = String(JSON.stringify({{paramName}}));
{{/isString}}
}
{{/isListContainer}}
Expand Down
Loading

0 comments on commit 1bf8c15

Please # to comment.