diff --git a/CI/bitrise.yml b/CI/bitrise.yml
index 8a572ab864ad..cfdb8601ecf3 100644
--- a/CI/bitrise.yml
+++ b/CI/bitrise.yml
@@ -49,6 +49,25 @@ workflows:
./samples/client/petstore/swift4/swift4_test_all.sh
./samples/client/test/swift4/swift4_test_all.sh
+ - script@1.1.5:
+ title: Update Swift5 samples
+ inputs:
+ - content: |
+ #!/usr/bin/env bash
+
+ set -e
+
+ sh bin/swift5-all.sh
+ - script@1.1.5:
+ title: Run Swift5 tests
+ inputs:
+ - content: |
+ #!/usr/bin/env bash
+
+ set -e
+
+ ./samples/client/petstore/swift5/swift5_test_all.sh
+ ./samples/client/test/swift5/swift5_test_all.sh
- script@1.1.5:
title: Run all bin scripts
inputs:
diff --git a/bin/swift5-all.sh b/bin/swift5-all.sh
new file mode 100755
index 000000000000..0fabcabab42d
--- /dev/null
+++ b/bin/swift5-all.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+./bin/swift5-petstore-all.sh
+./bin/swift5-test.sh
diff --git a/bin/swift5-petstore-alamofire.json b/bin/swift5-petstore-alamofire.json
new file mode 100644
index 000000000000..f6cc7270be64
--- /dev/null
+++ b/bin/swift5-petstore-alamofire.json
@@ -0,0 +1,7 @@
+{
+ "podSummary": "PetstoreClient",
+ "podHomepage": "https://github.com/openapitools/openapi-generator",
+ "podAuthors": "",
+ "projectName": "PetstoreClient",
+ "library": "alamofire"
+}
diff --git a/bin/swift5-petstore-alamofire.sh b/bin/swift5-petstore-alamofire.sh
new file mode 100755
index 000000000000..6c8ef2c5f803
--- /dev/null
+++ b/bin/swift5-petstore-alamofire.sh
@@ -0,0 +1,42 @@
+#!/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} -Xmx1024M -DloggerPath=conf/log4j.properties"
+ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore-alamofire.json -o samples/client/petstore/swift5/alamofireLibrary --generate-alias-as-model $@"
+
+java $JAVA_OPTS -jar $executable $ags
+
+if type "xcodegen" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/alamofireLibrary
+ xcodegen generate
+fi
+
+if type "swiftlint" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/alamofireLibrary
+ swiftlint autocorrect
+fi
\ No newline at end of file
diff --git a/bin/swift5-petstore-all.sh b/bin/swift5-petstore-all.sh
new file mode 100755
index 000000000000..bce216fcb420
--- /dev/null
+++ b/bin/swift5-petstore-all.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+./bin/swift5-petstore.sh
+./bin/swift5-petstore-promisekit.sh
+./bin/swift5-petstore-result.sh
+./bin/swift5-petstore-rxswift.sh
+./bin/swift5-petstore-objcCompatible.sh
+./bin/swift5-petstore-nonPublicApi.sh
+./bin/swift5-petstore-urlsession.sh
+./bin/swift5-petstore-alamofire.sh
+./bin/swift5-petstore-combine.sh
+
\ No newline at end of file
diff --git a/bin/swift5-petstore-combine.json b/bin/swift5-petstore-combine.json
new file mode 100644
index 000000000000..ef420f56e2e3
--- /dev/null
+++ b/bin/swift5-petstore-combine.json
@@ -0,0 +1,7 @@
+{
+ "podSummary": "PetstoreClient",
+ "podHomepage": "https://github.com/openapitools/openapi-generator",
+ "podAuthors": "",
+ "projectName": "PetstoreClient",
+ "responseAs": "Combine"
+}
diff --git a/bin/swift5-petstore-combine.sh b/bin/swift5-petstore-combine.sh
new file mode 100755
index 000000000000..71ca667a9adc
--- /dev/null
+++ b/bin/swift5-petstore-combine.sh
@@ -0,0 +1,42 @@
+#!/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} -Xmx1024M -DloggerPath=conf/log4j.properties"
+ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore-combine.json -o samples/client/petstore/swift5/combineLibrary --generate-alias-as-model $@"
+
+java $JAVA_OPTS -jar $executable $ags
+
+if type "xcodegen" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/combineLibrary
+ xcodegen generate
+fi
+
+if type "swiftlint" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/combineLibrary
+ swiftlint autocorrect
+fi
\ No newline at end of file
diff --git a/bin/swift5-petstore-nonPublicApi.json b/bin/swift5-petstore-nonPublicApi.json
new file mode 100644
index 000000000000..f20305dec059
--- /dev/null
+++ b/bin/swift5-petstore-nonPublicApi.json
@@ -0,0 +1,8 @@
+{
+ "podSummary": "PetstoreClient",
+ "podHomepage": "https://github.com/openapitools/openapi-generator",
+ "podAuthors": "",
+ "projectName": "PetstoreClient",
+ "nonPublicApi": true,
+ "sortParamsByRequiredFlag": false
+}
diff --git a/bin/swift5-petstore-nonPublicApi.sh b/bin/swift5-petstore-nonPublicApi.sh
new file mode 100755
index 000000000000..fc4035bfca6d
--- /dev/null
+++ b/bin/swift5-petstore-nonPublicApi.sh
@@ -0,0 +1,42 @@
+#!/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} -Xmx1024M -DloggerPath=conf/log4j.properties"
+ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore-nonPublicApi.json -o samples/client/petstore/swift5/nonPublicApi --generate-alias-as-model $@"
+
+java $JAVA_OPTS -jar $executable $ags
+
+if type "xcodegen" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/nonPublicApi
+ xcodegen generate
+fi
+
+if type "swiftlint" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/nonPublicApi
+ swiftlint autocorrect
+fi
\ No newline at end of file
diff --git a/bin/swift5-petstore-objcCompatible.json b/bin/swift5-petstore-objcCompatible.json
new file mode 100644
index 000000000000..c24c7abf69c4
--- /dev/null
+++ b/bin/swift5-petstore-objcCompatible.json
@@ -0,0 +1,7 @@
+{
+ "podSummary": "PetstoreClient",
+ "podHomepage": "https://github.com/openapitools/openapi-generator",
+ "podAuthors": "",
+ "projectName": "PetstoreClient",
+ "objcCompatible": true
+}
diff --git a/bin/swift5-petstore-objcCompatible.sh b/bin/swift5-petstore-objcCompatible.sh
new file mode 100755
index 000000000000..39d53ff8e653
--- /dev/null
+++ b/bin/swift5-petstore-objcCompatible.sh
@@ -0,0 +1,42 @@
+#!/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} -Xmx1024M -DloggerPath=conf/log4j.properties"
+ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore-objcCompatible.json -o samples/client/petstore/swift5/objcCompatible --generate-alias-as-model $@"
+
+java $JAVA_OPTS -jar $executable $ags
+
+if type "xcodegen" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/objcCompatible
+ xcodegen generate
+fi
+
+if type "swiftlint" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/objcCompatible
+ swiftlint autocorrect
+fi
\ No newline at end of file
diff --git a/bin/swift5-petstore-promisekit.json b/bin/swift5-petstore-promisekit.json
new file mode 100644
index 000000000000..48137f1f2800
--- /dev/null
+++ b/bin/swift5-petstore-promisekit.json
@@ -0,0 +1,7 @@
+{
+ "podSummary": "PetstoreClient",
+ "podHomepage": "https://github.com/openapitools/openapi-generator",
+ "podAuthors": "",
+ "projectName": "PetstoreClient",
+ "responseAs": "PromiseKit"
+}
diff --git a/bin/swift5-petstore-promisekit.sh b/bin/swift5-petstore-promisekit.sh
new file mode 100755
index 000000000000..f864088e9b2d
--- /dev/null
+++ b/bin/swift5-petstore-promisekit.sh
@@ -0,0 +1,42 @@
+#!/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} -Xmx1024M -DloggerPath=conf/log4j.properties"
+ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore-promisekit.json -o samples/client/petstore/swift5/promisekitLibrary --generate-alias-as-model $@"
+
+java $JAVA_OPTS -jar $executable $ags
+
+if type "xcodegen" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/promisekitLibrary
+ xcodegen generate
+fi
+
+if type "swiftlint" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/promisekitLibrary
+ swiftlint autocorrect
+fi
\ No newline at end of file
diff --git a/bin/swift5-petstore-result.json b/bin/swift5-petstore-result.json
new file mode 100644
index 000000000000..315433867862
--- /dev/null
+++ b/bin/swift5-petstore-result.json
@@ -0,0 +1,7 @@
+{
+ "podSummary": "PetstoreClient",
+ "podHomepage": "https://github.com/openapitools/openapi-generator",
+ "podAuthors": "",
+ "projectName": "PetstoreClient",
+ "responseAs": "Result"
+}
diff --git a/bin/swift5-petstore-result.sh b/bin/swift5-petstore-result.sh
new file mode 100755
index 000000000000..803c79a4f7c5
--- /dev/null
+++ b/bin/swift5-petstore-result.sh
@@ -0,0 +1,42 @@
+#!/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} -Xmx1024M -DloggerPath=conf/log4j.properties"
+ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore-result.json -o samples/client/petstore/swift5/resultLibrary --generate-alias-as-model $@"
+
+java $JAVA_OPTS -jar $executable $ags
+
+if type "xcodegen" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/resultLibrary
+ xcodegen generate
+fi
+
+if type "swiftlint" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/resultLibrary
+ swiftlint autocorrect
+fi
\ No newline at end of file
diff --git a/bin/swift5-petstore-rxswift.json b/bin/swift5-petstore-rxswift.json
new file mode 100644
index 000000000000..eb8b11dde559
--- /dev/null
+++ b/bin/swift5-petstore-rxswift.json
@@ -0,0 +1,7 @@
+{
+ "podSummary": "PetstoreClient",
+ "podHomepage": "https://github.com/openapitools/openapi-generator",
+ "podAuthors": "",
+ "projectName": "PetstoreClient",
+ "responseAs": "RxSwift"
+}
diff --git a/bin/swift5-petstore-rxswift.sh b/bin/swift5-petstore-rxswift.sh
new file mode 100755
index 000000000000..9c8398248ebd
--- /dev/null
+++ b/bin/swift5-petstore-rxswift.sh
@@ -0,0 +1,42 @@
+#!/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} -Xmx1024M -DloggerPath=conf/log4j.properties"
+ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore-rxswift.json -o samples/client/petstore/swift5/rxswiftLibrary --generate-alias-as-model $@"
+
+java $JAVA_OPTS -jar $executable $ags
+
+if type "xcodegen" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/rxswiftLibrary
+ xcodegen generate
+fi
+
+if type "swiftlint" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/rxswiftLibrary
+ swiftlint autocorrect
+fi
\ No newline at end of file
diff --git a/bin/swift5-petstore-urlsession.json b/bin/swift5-petstore-urlsession.json
new file mode 100644
index 000000000000..db0f6c9fbfb3
--- /dev/null
+++ b/bin/swift5-petstore-urlsession.json
@@ -0,0 +1,7 @@
+{
+ "podSummary": "PetstoreClient",
+ "podHomepage": "https://github.com/openapitools/openapi-generator",
+ "podAuthors": "",
+ "projectName": "PetstoreClient",
+ "library": "urlsession"
+}
diff --git a/bin/swift5-petstore-urlsession.sh b/bin/swift5-petstore-urlsession.sh
new file mode 100755
index 000000000000..76a674d4315c
--- /dev/null
+++ b/bin/swift5-petstore-urlsession.sh
@@ -0,0 +1,42 @@
+#!/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} -Xmx1024M -DloggerPath=conf/log4j.properties"
+ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore-urlsession.json -o samples/client/petstore/swift5/urlsessionLibrary --generate-alias-as-model $@"
+
+java $JAVA_OPTS -jar $executable $ags
+
+if type "xcodegen" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/urlsessionLibrary
+ xcodegen generate
+fi
+
+if type "swiftlint" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/urlsessionLibrary
+ swiftlint autocorrect
+fi
\ No newline at end of file
diff --git a/bin/swift5-petstore.json b/bin/swift5-petstore.json
new file mode 100644
index 000000000000..59bd94f43efb
--- /dev/null
+++ b/bin/swift5-petstore.json
@@ -0,0 +1,6 @@
+{
+ "podSummary": "PetstoreClient",
+ "podHomepage": "https://github.com/openapitools/openapi-generator",
+ "podAuthors": "",
+ "projectName": "PetstoreClient"
+}
diff --git a/bin/swift5-petstore.sh b/bin/swift5-petstore.sh
new file mode 100755
index 000000000000..f2752acc1a07
--- /dev/null
+++ b/bin/swift5-petstore.sh
@@ -0,0 +1,42 @@
+#!/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} -Xmx1024M -DloggerPath=conf/log4j.properties"
+ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c ./bin/swift5-petstore.json -o samples/client/petstore/swift5/default --generate-alias-as-model $@"
+
+java $JAVA_OPTS -jar $executable $ags
+
+if type "xcodegen" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/default
+ xcodegen generate
+fi
+
+if type "swiftlint" > /dev/null 2>&1; then
+ cd samples/client/petstore/swift5/default
+ swiftlint autocorrect
+fi
diff --git a/bin/swift5-test.json b/bin/swift5-test.json
new file mode 100644
index 000000000000..9341b740a2a6
--- /dev/null
+++ b/bin/swift5-test.json
@@ -0,0 +1,6 @@
+{
+ "podSummary": "TestClient",
+ "podHomepage": "https://github.com/openapitools/openapi-generator",
+ "podAuthors": "",
+ "projectName": "TestClient"
+}
diff --git a/bin/swift5-test.sh b/bin/swift5-test.sh
new file mode 100755
index 000000000000..1620ea6e270a
--- /dev/null
+++ b/bin/swift5-test.sh
@@ -0,0 +1,42 @@
+#!/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} -Xmx1024M -DloggerPath=conf/log4j.properties"
+ags="generate -t modules/openapi-generator/src/main/resources/swift5 -i modules/openapi-generator/src/test/resources/2_0/swift5Test.json -g swift5 -c ./bin/swift5-test.json -o samples/client/test/swift5/default --generate-alias-as-model $@"
+
+java $JAVA_OPTS -jar $executable $ags
+
+if type "xcodegen" > /dev/null 2>&1; then
+ cd samples/client/test/swift5/default
+ xcodegen generate
+fi
+
+if type "swiftlint" > /dev/null 2>&1; then
+ cd samples/client/test/swift5/default
+ swiftlint autocorrect
+fi
diff --git a/bin/windows/swift5-all.bat b/bin/windows/swift5-all.bat
new file mode 100755
index 000000000000..663df4e22de4
--- /dev/null
+++ b/bin/windows/swift5-all.bat
@@ -0,0 +1,2 @@
+call .\bin\windows\swift5-petstore-all.bat
+call .\bin\windows\swift5-test.bat
diff --git a/bin/windows/swift5-petstore-alamofire.bat b/bin/windows/swift5-petstore-alamofire.bat
new file mode 100755
index 000000000000..b982ea061e1d
--- /dev/null
+++ b/bin/windows/swift5-petstore-alamofire.bat
@@ -0,0 +1,10 @@
+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\2_0\swift\petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c bin\swift5-petstore-alamofire.json -o samples\client\petstore\swift5\alamofireLibrary
+
+java %JAVA_OPTS% -jar %executable% %ags%
diff --git a/bin/windows/swift5-petstore-all.bat b/bin/windows/swift5-petstore-all.bat
new file mode 100755
index 000000000000..1daaa1fee769
--- /dev/null
+++ b/bin/windows/swift5-petstore-all.bat
@@ -0,0 +1,9 @@
+call .\bin\windows\swift5-petstore.bat
+call .\bin\windows\swift5-petstore-promisekit.bat
+call .\bin\windows\swift5-petstore-result.bat
+call .\bin\windows\swift5-petstore-rxswift.bat
+call .\bin\windows\swift5-petstore-objcCompatible.bat
+call .\bin\windows\swift5-petstore-nonPublicApi.bat
+call .\bin\windows\swift5-petstore-urlsession.bat
+call .\bin\windows\swift5-petstore-alamofire.bat
+call .\bin\windows\swift5-petstore-combine.bat
diff --git a/bin/windows/swift5-petstore-combine.bat b/bin/windows/swift5-petstore-combine.bat
new file mode 100755
index 000000000000..5ea7cc88db94
--- /dev/null
+++ b/bin/windows/swift5-petstore-combine.bat
@@ -0,0 +1,10 @@
+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\2_0\swift\petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c bin\swift5-petstore-combine.json -o samples\client\petstore\swift5\combineLibrary
+
+java %JAVA_OPTS% -jar %executable% %ags%
diff --git a/bin/windows/swift5-petstore-nonPublicApi.bat b/bin/windows/swift5-petstore-nonPublicApi.bat
new file mode 100755
index 000000000000..685333690188
--- /dev/null
+++ b/bin/windows/swift5-petstore-nonPublicApi.bat
@@ -0,0 +1,10 @@
+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\2_0\swift\petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c bin\swift5-petstore-nonPublicApi.json -o samples\client\petstore\swift5\nonPublicApi
+
+java %JAVA_OPTS% -jar %executable% %ags%
diff --git a/bin/windows/swift5-petstore-objcCompatible.bat b/bin/windows/swift5-petstore-objcCompatible.bat
new file mode 100755
index 000000000000..7d9b7047b4f7
--- /dev/null
+++ b/bin/windows/swift5-petstore-objcCompatible.bat
@@ -0,0 +1,10 @@
+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\2_0\swift\petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c bin\swift5-petstore-objcCompatible.json -o samples\client\petstore\swift5\objcCompatible
+
+java %JAVA_OPTS% -jar %executable% %ags%
diff --git a/bin/windows/swift5-petstore-promisekit.bat b/bin/windows/swift5-petstore-promisekit.bat
new file mode 100755
index 000000000000..cfd9ff41effb
--- /dev/null
+++ b/bin/windows/swift5-petstore-promisekit.bat
@@ -0,0 +1,10 @@
+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\2_0\swift\petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c bin\swift5-petstore-promisekit.json -o samples\client\petstore\swift5\promisekitLibrary
+
+java %JAVA_OPTS% -jar %executable% %ags%
diff --git a/bin/windows/swift5-petstore-result.bat b/bin/windows/swift5-petstore-result.bat
new file mode 100755
index 000000000000..4aabf28d5049
--- /dev/null
+++ b/bin/windows/swift5-petstore-result.bat
@@ -0,0 +1,10 @@
+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\2_0\swift\petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c bin\swift5-petstore-result.json -o samples\client\petstore\swift5\resultLibrary
+
+java %JAVA_OPTS% -jar %executable% %ags%
diff --git a/bin/windows/swift5-petstore-rxswift.bat b/bin/windows/swift5-petstore-rxswift.bat
new file mode 100755
index 000000000000..862c18206762
--- /dev/null
+++ b/bin/windows/swift5-petstore-rxswift.bat
@@ -0,0 +1,10 @@
+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\2_0\swift\petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c bin\swift5-petstore-rxswift.json -o samples\client\petstore\swift5\rxswiftLibrary
+
+java %JAVA_OPTS% -jar %executable% %ags%
diff --git a/bin/windows/swift5-petstore-urlSession.bat b/bin/windows/swift5-petstore-urlSession.bat
new file mode 100755
index 000000000000..594317a3fa1d
--- /dev/null
+++ b/bin/windows/swift5-petstore-urlSession.bat
@@ -0,0 +1,10 @@
+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\2_0\swift\petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -c bin\swift5-petstore-urlsession.json -o samples\client\petstore\swift5\urlsessionLibrary
+
+java %JAVA_OPTS% -jar %executable% %ags%
diff --git a/bin/windows/swift5-petstore.bat b/bin/windows/swift5-petstore.bat
new file mode 100755
index 000000000000..26cee2940f4e
--- /dev/null
+++ b/bin/windows/swift5-petstore.bat
@@ -0,0 +1,10 @@
+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\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g swift5 -o samples\client\petstore\swift5\default
+
+java %JAVA_OPTS% -jar %executable% %ags%
diff --git a/bin/windows/swift5-test.bat b/bin/windows/swift5-test.bat
new file mode 100755
index 000000000000..60d74aabcf64
--- /dev/null
+++ b/bin/windows/swift5-test.bat
@@ -0,0 +1,10 @@
+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\2_0\swift5Test.json -g swift5 -c bin\swift5-test.json -o samples\client\test\swift5\default
+
+java %JAVA_OPTS% -jar %executable% %ags%
diff --git a/docs/generators.md b/docs/generators.md
index 59935cc3a645..eb4daced89e2 100644
--- a/docs/generators.md
+++ b/docs/generators.md
@@ -57,6 +57,7 @@ The following generators are available:
* [swift2-deprecated (deprecated)](generators/swift2-deprecated.md)
* [swift3-deprecated (deprecated)](generators/swift3-deprecated.md)
* [swift4](generators/swift4.md)
+* [swift5](generators/swift5.md)
* [typescript-angular](generators/typescript-angular.md)
* [typescript-angularjs](generators/typescript-angularjs.md)
* [typescript-aurelia](generators/typescript-aurelia.md)
diff --git a/docs/generators/swift5.md b/docs/generators/swift5.md
new file mode 100644
index 000000000000..2d3d9cff6ebe
--- /dev/null
+++ b/docs/generators/swift5.md
@@ -0,0 +1,31 @@
+---
+title: Config Options for swift5
+sidebar_label: swift5
+---
+
+| Option | Description | Values | Default |
+| ------ | ----------- | ------ | ------- |
+|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
+|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
+|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
+|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
+|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
+|projectName|Project name in Xcode| |null|
+|responseAs|Optionally use libraries to manage response. Currently PromiseKit, RxSwift, Result, Combine are available.| |null|
+|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.(default: false)| |null|
+|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |null|
+|objcCompatible|Add additional properties and methods for Objective-C compatibility (default: false)| |null|
+|podSource|Source information used for Podspec| |null|
+|podVersion|Version used for Podspec| |null|
+|podAuthors|Authors used for Podspec| |null|
+|podSocialMediaURL|Social Media URL used for Podspec| |null|
+|podLicense|License used for Podspec| |null|
+|podHomepage|Homepage used for Podspec| |null|
+|podSummary|Summary used for Podspec| |null|
+|podDescription|Description used for Podspec| |null|
+|podScreenshots|Screenshots used for Podspec| |null|
+|podDocumentationURL|Documentation URL used for Podspec| |null|
+|swiftUseApiNamespace|Flag to make all the API classes inner-class of {{projectName}}API| |null|
+|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
+|lenientTypeCast|Accept and cast values for simple types (string->bool, string->int, int->string)| |false|
+|library|Library template (sub-template) to use|
- **urlsession**
- [DEFAULT] HTTP client: URLSession
- **alamofire**
- HTTP client: Alamofire
|urlsession|
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5Codegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5Codegen.java
new file mode 100644
index 000000000000..1aa925356ffc
--- /dev/null
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift5Codegen.java
@@ -0,0 +1,1069 @@
+/*
+ * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ * Copyright 2018 SmartBear Software
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openapitools.codegen.languages;
+
+import io.swagger.v3.oas.models.media.ArraySchema;
+import io.swagger.v3.oas.models.media.Schema;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.text.WordUtils;
+import org.openapitools.codegen.*;
+import org.openapitools.codegen.utils.ModelUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static org.openapitools.codegen.utils.StringUtils.camelize;
+
+
+public class Swift5Codegen extends DefaultCodegen implements CodegenConfig {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Swift5Codegen.class);
+
+ public static final String PROJECT_NAME = "projectName";
+ public static final String RESPONSE_AS = "responseAs";
+ public static final String OBJC_COMPATIBLE = "objcCompatible";
+ public static final String POD_SOURCE = "podSource";
+ public static final String POD_AUTHORS = "podAuthors";
+ public static final String POD_SOCIAL_MEDIA_URL = "podSocialMediaURL";
+ public static final String POD_LICENSE = "podLicense";
+ public static final String POD_HOMEPAGE = "podHomepage";
+ public static final String POD_SUMMARY = "podSummary";
+ public static final String POD_DESCRIPTION = "podDescription";
+ public static final String POD_SCREENSHOTS = "podScreenshots";
+ public static final String POD_DOCUMENTATION_URL = "podDocumentationURL";
+ public static final String SWIFT_USE_API_NAMESPACE = "swiftUseApiNamespace";
+ public static final String DEFAULT_POD_AUTHORS = "OpenAPI Generator";
+ public static final String LENIENT_TYPE_CAST = "lenientTypeCast";
+ protected static final String LIBRARY_ALAMOFIRE = "alamofire";
+ protected static final String LIBRARY_URLSESSION = "urlsession";
+ protected static final String RESPONSE_LIBRARY_PROMISE_KIT = "PromiseKit";
+ protected static final String RESPONSE_LIBRARY_RX_SWIFT = "RxSwift";
+ protected static final String RESPONSE_LIBRARY_RESULT = "Result";
+ protected static final String RESPONSE_LIBRARY_COMBINE = "Combine";
+ protected static final String[] RESPONSE_LIBRARIES = {RESPONSE_LIBRARY_PROMISE_KIT, RESPONSE_LIBRARY_RX_SWIFT, RESPONSE_LIBRARY_RESULT, RESPONSE_LIBRARY_COMBINE};
+ protected String projectName = "OpenAPIClient";
+ protected boolean nonPublicApi = false;
+ protected boolean objcCompatible = false;
+ protected boolean lenientTypeCast = false;
+ protected boolean swiftUseApiNamespace;
+ protected String[] responseAs = new String[0];
+ protected String sourceFolder = "Classes" + File.separator + "OpenAPIs";
+ protected HashSet objcReservedWords;
+ protected String apiDocPath = "docs/";
+ protected String modelDocPath = "docs/";
+
+ /**
+ * Constructor for the swift5 language codegen module.
+ */
+ public Swift5Codegen() {
+ super();
+ outputFolder = "generated-code" + File.separator + "swift";
+ modelTemplateFiles.put("model.mustache", ".swift");
+ apiTemplateFiles.put("api.mustache", ".swift");
+ embeddedTemplateDir = templateDir = "swift5";
+ apiPackage = File.separator + "APIs";
+ modelPackage = File.separator + "Models";
+ modelDocTemplateFiles.put("model_doc.mustache", ".md");
+ apiDocTemplateFiles.put("api_doc.mustache", ".md");
+
+ languageSpecificPrimitives = new HashSet<>(
+ Arrays.asList(
+ "Int",
+ "Int32",
+ "Int64",
+ "Float",
+ "Double",
+ "Bool",
+ "Void",
+ "String",
+ "URL",
+ "Data",
+ "Date",
+ "Character",
+ "UUID",
+ "URL",
+ "AnyObject",
+ "Any",
+ "Decimal")
+ );
+ defaultIncludes = new HashSet<>(
+ Arrays.asList(
+ "Data",
+ "Date",
+ "URL", // for file
+ "UUID",
+ "Array",
+ "Dictionary",
+ "Set",
+ "Any",
+ "Empty",
+ "AnyObject",
+ "Any",
+ "Decimal")
+ );
+
+ objcReservedWords = new HashSet<>(
+ Arrays.asList(
+ // Added for Objective-C compatibility
+ "id", "description", "NSArray", "NSURL", "CGFloat", "NSSet", "NSString", "NSInteger", "NSUInteger",
+ "NSError", "NSDictionary"
+ )
+ );
+
+ reservedWords = new HashSet<>(
+ Arrays.asList(
+ // name used by swift client
+ "ErrorResponse", "Response",
+
+ // Swift keywords. This list is taken from here:
+ // https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html#//apple_ref/doc/uid/TP40014097-CH30-ID410
+ //
+ // Keywords used in declarations
+ "associatedtype", "class", "deinit", "enum", "extension", "fileprivate", "func", "import", "init",
+ "inout", "internal", "let", "open", "operator", "private", "protocol", "public", "static", "struct",
+ "subscript", "typealias", "var",
+ // Keywords uses in statements
+ "break", "case", "continue", "default", "defer", "do", "else", "fallthrough", "for", "guard", "if",
+ "in", "repeat", "return", "switch", "where", "while",
+ // Keywords used in expressions and types
+ "as", "Any", "catch", "false", "is", "nil", "rethrows", "super", "self", "Self", "throw", "throws", "true", "try",
+ // Keywords used in patterns
+ "_",
+ // Keywords that begin with a number sign
+ "#available", "#colorLiteral", "#column", "#else", "#elseif", "#endif", "#file", "#fileLiteral", "#function", "#if",
+ "#imageLiteral", "#line", "#selector", "#sourceLocation",
+ // Keywords reserved in particular contexts
+ "associativity", "convenience", "dynamic", "didSet", "final", "get", "infix", "indirect", "lazy", "left",
+ "mutating", "none", "nonmutating", "optional", "override", "postfix", "precedence", "prefix", "Protocol",
+ "required", "right", "set", "Type", "unowned", "weak", "willSet",
+
+ //
+ // Swift Standard Library types
+ // https://developer.apple.com/documentation/swift
+ //
+ // Numbers and Basic Values
+ "Bool", "Int", "Double", "Float", "Range", "ClosedRange", "Error", "Optional",
+ // Special-Use Numeric Types
+ "UInt", "UInt8", "UInt16", "UInt32", "UInt64", "Int8", "Int16", "Int32", "Int64", "Float80", "Float32", "Float64",
+ // Strings and Text
+ "String", "Character", "Unicode", "StaticString",
+ // Collections
+ "Array", "Dictionary", "Set", "OptionSet", "CountableRange", "CountableClosedRange",
+
+ // The following are commonly-used Foundation types
+ "URL", "Data", "Codable", "Encodable", "Decodable",
+
+ // The following are other words we want to reserve
+ "Void", "AnyObject", "Class", "dynamicType", "COLUMN", "FILE", "FUNCTION", "LINE"
+ )
+ );
+
+ typeMapping = new HashMap<>();
+ typeMapping.put("array", "Array");
+ typeMapping.put("List", "Array");
+ typeMapping.put("map", "Dictionary");
+ typeMapping.put("date", "Date");
+ typeMapping.put("Date", "Date");
+ typeMapping.put("DateTime", "Date");
+ typeMapping.put("boolean", "Bool");
+ typeMapping.put("string", "String");
+ typeMapping.put("char", "Character");
+ typeMapping.put("short", "Int");
+ typeMapping.put("int", "Int");
+ typeMapping.put("long", "Int64");
+ typeMapping.put("integer", "Int");
+ typeMapping.put("Integer", "Int");
+ typeMapping.put("float", "Float");
+ typeMapping.put("number", "Double");
+ typeMapping.put("double", "Double");
+ typeMapping.put("object", "Any");
+ typeMapping.put("file", "URL");
+ typeMapping.put("binary", "URL");
+ typeMapping.put("ByteArray", "Data");
+ typeMapping.put("UUID", "UUID");
+ typeMapping.put("URI", "String");
+ typeMapping.put("BigDecimal", "Decimal");
+
+ importMapping = new HashMap<>();
+
+ cliOptions.add(new CliOption(PROJECT_NAME, "Project name in Xcode"));
+ cliOptions.add(new CliOption(RESPONSE_AS,
+ "Optionally use libraries to manage response. Currently "
+ + StringUtils.join(RESPONSE_LIBRARIES, ", ")
+ + " are available."));
+ cliOptions.add(new CliOption(CodegenConstants.NON_PUBLIC_API,
+ CodegenConstants.NON_PUBLIC_API_DESC
+ + "(default: false)"));
+ cliOptions.add(new CliOption(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
+ CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC));
+ cliOptions.add(new CliOption(OBJC_COMPATIBLE,
+ "Add additional properties and methods for Objective-C "
+ + "compatibility (default: false)"));
+ cliOptions.add(new CliOption(POD_SOURCE, "Source information used for Podspec"));
+ cliOptions.add(new CliOption(CodegenConstants.POD_VERSION, "Version used for Podspec"));
+ cliOptions.add(new CliOption(POD_AUTHORS, "Authors used for Podspec"));
+ cliOptions.add(new CliOption(POD_SOCIAL_MEDIA_URL, "Social Media URL used for Podspec"));
+ cliOptions.add(new CliOption(POD_LICENSE, "License used for Podspec"));
+ cliOptions.add(new CliOption(POD_HOMEPAGE, "Homepage used for Podspec"));
+ cliOptions.add(new CliOption(POD_SUMMARY, "Summary used for Podspec"));
+ cliOptions.add(new CliOption(POD_DESCRIPTION, "Description used for Podspec"));
+ cliOptions.add(new CliOption(POD_SCREENSHOTS, "Screenshots used for Podspec"));
+ cliOptions.add(new CliOption(POD_DOCUMENTATION_URL,
+ "Documentation URL used for Podspec"));
+ cliOptions.add(new CliOption(SWIFT_USE_API_NAMESPACE,
+ "Flag to make all the API classes inner-class "
+ + "of {{projectName}}API"));
+ cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
+ CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
+ .defaultValue(Boolean.TRUE.toString()));
+ cliOptions.add(new CliOption(LENIENT_TYPE_CAST,
+ "Accept and cast values for simple types (string->bool, "
+ + "string->int, int->string)")
+ .defaultValue(Boolean.FALSE.toString()));
+
+ supportedLibraries.put(LIBRARY_URLSESSION, "[DEFAULT] HTTP client: URLSession");
+ supportedLibraries.put(LIBRARY_ALAMOFIRE, "HTTP client: Alamofire");
+
+ CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "Library template (sub-template) to use");
+ libraryOption.setEnum(supportedLibraries);
+ libraryOption.setDefault(LIBRARY_URLSESSION);
+ cliOptions.add(libraryOption);
+ setLibrary(LIBRARY_URLSESSION);
+ }
+
+ private static CodegenModel reconcileProperties(CodegenModel codegenModel,
+ CodegenModel parentCodegenModel) {
+ // To support inheritance in this generator, we will analyze
+ // the parent and child models, look for properties that match, and remove
+ // them from the child models and leave them in the parent.
+ // Because the child models extend the parents, the properties
+ // will be available via the parent.
+
+ // Get the properties for the parent and child models
+ final List parentModelCodegenProperties = parentCodegenModel.vars;
+ List codegenProperties = codegenModel.vars;
+ codegenModel.allVars = new ArrayList(codegenProperties);
+ codegenModel.parentVars = parentCodegenModel.allVars;
+
+ // Iterate over all of the parent model properties
+ boolean removedChildProperty = false;
+
+ for (CodegenProperty parentModelCodegenProperty : parentModelCodegenProperties) {
+ // Now that we have found a prop in the parent class,
+ // and search the child class for the same prop.
+ Iterator iterator = codegenProperties.iterator();
+ while (iterator.hasNext()) {
+ CodegenProperty codegenProperty = iterator.next();
+ if (codegenProperty.baseName.equals(parentModelCodegenProperty.baseName)) {
+ // We found a property in the child class that is
+ // a duplicate of the one in the parent, so remove it.
+ iterator.remove();
+ removedChildProperty = true;
+ }
+ }
+ }
+
+ if (removedChildProperty) {
+ // If we removed an entry from this model's vars, we need to ensure hasMore is updated
+ int count = 0;
+ int numVars = codegenProperties.size();
+ for (CodegenProperty codegenProperty : codegenProperties) {
+ count += 1;
+ codegenProperty.hasMore = count < numVars;
+ }
+ codegenModel.vars = codegenProperties;
+ }
+
+
+ return codegenModel;
+ }
+
+ @Override
+ public CodegenType getTag() {
+ return CodegenType.CLIENT;
+ }
+
+ @Override
+ public String getName() {
+ return "swift5";
+ }
+
+ @Override
+ public String getHelp() {
+ return "Generates a Swift 5.x client library.";
+ }
+
+ @Override
+ protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel,
+ Schema schema) {
+
+ final Schema additionalProperties = ModelUtils.getAdditionalProperties(schema);
+
+ if (additionalProperties != null) {
+ codegenModel.additionalPropertiesType = getSchemaType(additionalProperties);
+ }
+ }
+
+ @Override
+ public void processOpts() {
+ super.processOpts();
+
+ if (StringUtils.isEmpty(System.getenv("SWIFT_POST_PROCESS_FILE"))) {
+ LOGGER.info("Environment variable SWIFT_POST_PROCESS_FILE not defined so the Swift code may not be properly formatted. To define it, try 'export SWIFT_POST_PROCESS_FILE=/usr/local/bin/swiftformat' (Linux/Mac)");
+ LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
+ }
+
+ // Setup project name
+ if (additionalProperties.containsKey(PROJECT_NAME)) {
+ setProjectName((String) additionalProperties.get(PROJECT_NAME));
+ } else {
+ additionalProperties.put(PROJECT_NAME, projectName);
+ }
+ sourceFolder = projectName + File.separator + sourceFolder;
+
+ // Setup nonPublicApi option, which generates code with reduced access
+ // modifiers; allows embedding elsewhere without exposing non-public API calls
+ // to consumers
+ if (additionalProperties.containsKey(CodegenConstants.NON_PUBLIC_API)) {
+ setNonPublicApi(convertPropertyToBooleanAndWriteBack(CodegenConstants.NON_PUBLIC_API));
+ }
+ additionalProperties.put(CodegenConstants.NON_PUBLIC_API, nonPublicApi);
+
+ // Setup objcCompatible option, which adds additional properties
+ // and methods for Objective-C compatibility
+ if (additionalProperties.containsKey(OBJC_COMPATIBLE)) {
+ setObjcCompatible(convertPropertyToBooleanAndWriteBack(OBJC_COMPATIBLE));
+ }
+ additionalProperties.put(OBJC_COMPATIBLE, objcCompatible);
+
+ // add objc reserved words
+ if (Boolean.TRUE.equals(objcCompatible)) {
+ reservedWords.addAll(objcReservedWords);
+ }
+
+ if (additionalProperties.containsKey(RESPONSE_AS)) {
+ Object responseAsObject = additionalProperties.get(RESPONSE_AS);
+ if (responseAsObject instanceof String) {
+ setResponseAs(((String) responseAsObject).split(","));
+ } else {
+ setResponseAs((String[]) responseAsObject);
+ }
+ }
+ additionalProperties.put(RESPONSE_AS, responseAs);
+ if (ArrayUtils.contains(responseAs, RESPONSE_LIBRARY_PROMISE_KIT)) {
+ additionalProperties.put("usePromiseKit", true);
+ }
+ if (ArrayUtils.contains(responseAs, RESPONSE_LIBRARY_RX_SWIFT)) {
+ additionalProperties.put("useRxSwift", true);
+ }
+ if (ArrayUtils.contains(responseAs, RESPONSE_LIBRARY_RESULT)) {
+ additionalProperties.put("useResult", true);
+ }
+ if (ArrayUtils.contains(responseAs, RESPONSE_LIBRARY_COMBINE)) {
+ additionalProperties.put("useCombine", true);
+ }
+
+ // Setup swiftUseApiNamespace option, which makes all the API
+ // classes inner-class of {{projectName}}API
+ if (additionalProperties.containsKey(SWIFT_USE_API_NAMESPACE)) {
+ setSwiftUseApiNamespace(convertPropertyToBooleanAndWriteBack(SWIFT_USE_API_NAMESPACE));
+ }
+
+ if (!additionalProperties.containsKey(POD_AUTHORS)) {
+ additionalProperties.put(POD_AUTHORS, DEFAULT_POD_AUTHORS);
+ }
+
+ setLenientTypeCast(convertPropertyToBooleanAndWriteBack(LENIENT_TYPE_CAST));
+
+ // make api and model doc path available in mustache template
+ additionalProperties.put("apiDocPath", apiDocPath);
+ additionalProperties.put("modelDocPath", modelDocPath);
+
+ supportingFiles.add(new SupportingFile("Podspec.mustache",
+ "",
+ projectName + ".podspec"));
+ supportingFiles.add(new SupportingFile("Cartfile.mustache",
+ "",
+ "Cartfile"));
+ supportingFiles.add(new SupportingFile("Package.swift.mustache",
+ "",
+ "Package.swift"));
+ supportingFiles.add(new SupportingFile("APIHelper.mustache",
+ sourceFolder,
+ "APIHelper.swift"));
+ supportingFiles.add(new SupportingFile("Configuration.mustache",
+ sourceFolder,
+ "Configuration.swift"));
+ supportingFiles.add(new SupportingFile("Extensions.mustache",
+ sourceFolder,
+ "Extensions.swift"));
+ supportingFiles.add(new SupportingFile("Models.mustache",
+ sourceFolder,
+ "Models.swift"));
+ supportingFiles.add(new SupportingFile("APIs.mustache",
+ sourceFolder,
+ "APIs.swift"));
+ supportingFiles.add(new SupportingFile("CodableHelper.mustache",
+ sourceFolder,
+ "CodableHelper.swift"));
+ supportingFiles.add(new SupportingFile("OpenISO8601DateFormatter.mustache",
+ sourceFolder,
+ "OpenISO8601DateFormatter.swift"));
+ supportingFiles.add(new SupportingFile("JSONDataEncoding.mustache",
+ sourceFolder,
+ "JSONDataEncoding.swift"));
+ supportingFiles.add(new SupportingFile("JSONEncodingHelper.mustache",
+ sourceFolder,
+ "JSONEncodingHelper.swift"));
+ supportingFiles.add(new SupportingFile("git_push.sh.mustache",
+ "",
+ "git_push.sh"));
+ supportingFiles.add(new SupportingFile("SynchronizedDictionary.mustache",
+ sourceFolder,
+ "SynchronizedDictionary.swift"));
+ supportingFiles.add(new SupportingFile("gitignore.mustache",
+ "",
+ ".gitignore"));
+ supportingFiles.add(new SupportingFile("README.mustache",
+ "",
+ "README.md"));
+ supportingFiles.add(new SupportingFile("XcodeGen.mustache",
+ "",
+ "project.yml"));
+
+ switch (getLibrary()) {
+ case LIBRARY_ALAMOFIRE:
+ additionalProperties.put("useAlamofire", true);
+ supportingFiles.add(new SupportingFile("AlamofireImplementations.mustache",
+ sourceFolder,
+ "AlamofireImplementations.swift"));
+ break;
+ case LIBRARY_URLSESSION:
+ additionalProperties.put("useURLSession", true);
+ supportingFiles.add(new SupportingFile("URLSessionImplementations.mustache",
+ sourceFolder,
+ "URLSessionImplementations.swift"));
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ @Override
+ protected boolean isReservedWord(String word) {
+ return word != null && reservedWords.contains(word); //don't lowercase as super does
+ }
+
+ @Override
+ public String escapeReservedWord(String name) {
+ if (this.reservedWordsMappings().containsKey(name)) {
+ return this.reservedWordsMappings().get(name);
+ }
+ return "_" + name; // add an underscore to the name
+ }
+
+ @Override
+ public String modelFileFolder() {
+ return outputFolder + File.separator + sourceFolder
+ + modelPackage().replace('.', File.separatorChar);
+ }
+
+ @Override
+ public String apiFileFolder() {
+ return outputFolder + File.separator + sourceFolder
+ + apiPackage().replace('.', File.separatorChar);
+ }
+
+ @Override
+ public String getTypeDeclaration(Schema p) {
+ if (ModelUtils.isArraySchema(p)) {
+ ArraySchema ap = (ArraySchema) p;
+ Schema inner = ap.getItems();
+ return "[" + getTypeDeclaration(inner) + "]";
+ } else if (ModelUtils.isMapSchema(p)) {
+ Schema inner = ModelUtils.getAdditionalProperties(p);
+ return "[String:" + getTypeDeclaration(inner) + "]";
+ }
+ return super.getTypeDeclaration(p);
+ }
+
+ @Override
+ public String getSchemaType(Schema p) {
+ String openAPIType = super.getSchemaType(p);
+ String type;
+ if (typeMapping.containsKey(openAPIType)) {
+ type = typeMapping.get(openAPIType);
+ if (languageSpecificPrimitives.contains(type) || defaultIncludes.contains(type)) {
+ return type;
+ }
+ } else {
+ type = openAPIType;
+ }
+ return toModelName(type);
+ }
+
+ @Override
+ public boolean isDataTypeFile(String dataType) {
+ return dataType != null && dataType.equals("URL");
+ }
+
+ @Override
+ public boolean isDataTypeBinary(final String dataType) {
+ return dataType != null && dataType.equals("Data");
+ }
+
+ /**
+ * Output the proper model name (capitalized).
+ *
+ * @param name the name of the model
+ * @return capitalized model name
+ */
+ @Override
+ public String toModelName(String name) {
+ // FIXME parameter should not be assigned. Also declare it as "final"
+ name = sanitizeName(name);
+
+ if (!StringUtils.isEmpty(modelNameSuffix)) { // set model suffix
+ name = name + "_" + modelNameSuffix;
+ }
+
+ if (!StringUtils.isEmpty(modelNamePrefix)) { // set model prefix
+ name = modelNamePrefix + "_" + name;
+ }
+
+ // camelize the model name
+ // phone_number => PhoneNumber
+ name = camelize(name);
+
+ // model name cannot use reserved keyword, e.g. return
+ if (isReservedWord(name)) {
+ String modelName = "Model" + name;
+ LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to "
+ + modelName);
+ return modelName;
+ }
+
+ // model name starts with number
+ if (name.matches("^\\d.*")) {
+ // e.g. 200Response => Model200Response (after camelize)
+ String modelName = "Model" + name;
+ LOGGER.warn(name
+ + " (model name starts with number) cannot be used as model name."
+ + " Renamed to " + modelName);
+ return modelName;
+ }
+
+ return name;
+ }
+
+ /**
+ * Return the capitalized file name of the model.
+ *
+ * @param name the model name
+ * @return the file name of the model
+ */
+ @Override
+ public String toModelFilename(String name) {
+ // should be the same as the model name
+ return toModelName(name);
+ }
+
+ @Override
+ public String toDefaultValue(Schema p) {
+ if (p.getEnum() != null && !p.getEnum().isEmpty()) {
+ if (p.getDefault() != null) {
+ if (ModelUtils.isStringSchema(p)) {
+ return "." + toEnumVarName(escapeText((String) p.getDefault()), p.getType());
+ } else {
+ return "." + toEnumVarName(escapeText(p.getDefault().toString()), p.getType());
+ }
+ }
+ }
+ if (ModelUtils.isIntegerSchema(p) || ModelUtils.isNumberSchema(p) || ModelUtils.isBooleanSchema(p)) {
+ if (p.getDefault() != null) {
+ return p.getDefault().toString();
+ }
+ } else if (ModelUtils.isStringSchema(p)) {
+ if (p.getDefault() != null) {
+ return "\"" + escapeText((String) p.getDefault()) + "\"";
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String toInstantiationType(Schema p) {
+ if (ModelUtils.isMapSchema(p)) {
+ return getSchemaType(ModelUtils.getAdditionalProperties(p));
+ } else if (ModelUtils.isArraySchema(p)) {
+ ArraySchema ap = (ArraySchema) p;
+ String inner = getSchemaType(ap.getItems());
+ return "[" + inner + "]";
+ }
+ return null;
+ }
+
+ @Override
+ public String toApiName(String name) {
+ if (name.length() == 0) {
+ return "DefaultAPI";
+ }
+ return camelize(name) + "API";
+ }
+
+ @Override
+ public String apiDocFileFolder() {
+ return (outputFolder + "/" + apiDocPath).replace("/", File.separator);
+ }
+
+ @Override
+ public String modelDocFileFolder() {
+ return (outputFolder + "/" + modelDocPath).replace("/", File.separator);
+ }
+
+ @Override
+ public String toModelDocFilename(String name) {
+ return toModelName(name);
+ }
+
+ @Override
+ public String toApiDocFilename(String name) {
+ return toApiName(name);
+ }
+
+ @Override
+ public String toOperationId(String operationId) {
+ operationId = camelize(sanitizeName(operationId), true);
+
+ // Throw exception if method name is empty.
+ // This should not happen but keep the check just in case
+ if (StringUtils.isEmpty(operationId)) {
+ throw new RuntimeException("Empty method name (operationId) not allowed");
+ }
+
+ // method name cannot use reserved keyword, e.g. return
+ if (isReservedWord(operationId)) {
+ String newOperationId = camelize(("call_" + operationId), true);
+ LOGGER.warn(operationId + " (reserved word) cannot be used as method name."
+ + " Renamed to " + newOperationId);
+ return newOperationId;
+ }
+
+ // operationId starts with a number
+ if (operationId.matches("^\\d.*")) {
+ LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
+ operationId = camelize(sanitizeName("call_" + operationId), true);
+ }
+
+
+ return operationId;
+ }
+
+ @Override
+ public String toVarName(String name) {
+ // sanitize name
+ name = sanitizeName(name);
+
+ // if it's all uppper case, do nothing
+ if (name.matches("^[A-Z_]*$")) {
+ return name;
+ }
+
+ // camelize the variable name
+ // pet_id => petId
+ name = camelize(name, true);
+
+ // for reserved word or word starting with number, append _
+ if (isReservedWord(name) || name.matches("^\\d.*")) {
+ name = escapeReservedWord(name);
+ }
+
+ return name;
+ }
+
+ @Override
+ public String toParamName(String name) {
+ // sanitize name
+ name = sanitizeName(name);
+
+ // replace - with _ e.g. created-at => created_at
+ name = name.replaceAll("-", "_");
+
+ // if it's all uppper case, do nothing
+ if (name.matches("^[A-Z_]*$")) {
+ return name;
+ }
+
+ // camelize(lower) the variable name
+ // pet_id => petId
+ name = camelize(name, true);
+
+ // for reserved word or word starting with number, append _
+ if (isReservedWord(name) || name.matches("^\\d.*")) {
+ name = escapeReservedWord(name);
+ }
+
+ return name;
+ }
+
+ @Override
+ public CodegenModel fromModel(String name, Schema model) {
+ Map allDefinitions = ModelUtils.getSchemas(this.openAPI);
+ CodegenModel codegenModel = super.fromModel(name, model);
+ if (codegenModel.description != null) {
+ codegenModel.imports.add("ApiModel");
+ }
+ if (allDefinitions != null) {
+ String parentSchema = codegenModel.parentSchema;
+
+ // multilevel inheritance: reconcile properties of all the parents
+ while (parentSchema != null) {
+ final Schema parentModel = allDefinitions.get(parentSchema);
+ final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent,
+ parentModel);
+ codegenModel = Swift5Codegen.reconcileProperties(codegenModel, parentCodegenModel);
+
+ // get the next parent
+ parentSchema = parentCodegenModel.parentSchema;
+ }
+ }
+
+ return codegenModel;
+ }
+
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+ public void setNonPublicApi(boolean nonPublicApi) {
+ this.nonPublicApi = nonPublicApi;
+ }
+
+ public void setObjcCompatible(boolean objcCompatible) {
+ this.objcCompatible = objcCompatible;
+ }
+
+ public void setLenientTypeCast(boolean lenientTypeCast) {
+ this.lenientTypeCast = lenientTypeCast;
+ }
+
+ public void setResponseAs(String[] responseAs) {
+ this.responseAs = responseAs;
+ }
+
+ public void setSwiftUseApiNamespace(boolean swiftUseApiNamespace) {
+ this.swiftUseApiNamespace = swiftUseApiNamespace;
+ }
+
+ @Override
+ public String toEnumValue(String value, String datatype) {
+ // for string, array of string
+ if ("String".equals(datatype) || "[String]".equals(datatype) || "[String:String]".equals(datatype)) {
+ return "\"" + String.valueOf(value) + "\"";
+ } else {
+ return String.valueOf(value);
+ }
+ }
+
+ @Override
+ public String toEnumDefaultValue(String value, String datatype) {
+ return datatype + "_" + value;
+ }
+
+ @Override
+ public String toEnumVarName(String name, String datatype) {
+ if (name.length() == 0) {
+ return "empty";
+ }
+
+ Pattern startWithNumberPattern = Pattern.compile("^\\d+");
+ Matcher startWithNumberMatcher = startWithNumberPattern.matcher(name);
+ if (startWithNumberMatcher.find()) {
+ String startingNumbers = startWithNumberMatcher.group(0);
+ String nameWithoutStartingNumbers = name.substring(startingNumbers.length());
+
+ return "_" + startingNumbers + camelize(nameWithoutStartingNumbers, true);
+ }
+
+ // for symbol, e.g. $, #
+ if (getSymbolName(name) != null) {
+ return camelize(WordUtils.capitalizeFully(getSymbolName(name).toUpperCase(Locale.ROOT)), true);
+ }
+
+ // Camelize only when we have a structure defined below
+ Boolean camelized = false;
+ if (name.matches("[A-Z][a-z0-9]+[a-zA-Z0-9]*")) {
+ name = camelize(name, true);
+ camelized = true;
+ }
+
+ // Reserved Name
+ String nameLowercase = StringUtils.lowerCase(name);
+ if (isReservedWord(nameLowercase)) {
+ return escapeReservedWord(nameLowercase);
+ }
+
+ // Check for numerical conversions
+ if ("Int".equals(datatype) || "Int32".equals(datatype) || "Int64".equals(datatype)
+ || "Float".equals(datatype) || "Double".equals(datatype)) {
+ String varName = "number" + camelize(name);
+ varName = varName.replaceAll("-", "minus");
+ varName = varName.replaceAll("\\+", "plus");
+ varName = varName.replaceAll("\\.", "dot");
+ return varName;
+ }
+
+ // If we have already camelized the word, don't progress
+ // any further
+ if (camelized) {
+ return name;
+ }
+
+ char[] separators = {'-', '_', ' ', ':', '(', ')'};
+ return camelize(WordUtils.capitalizeFully(StringUtils.lowerCase(name), separators)
+ .replaceAll("[-_ :\\(\\)]", ""),
+ true);
+ }
+
+ @Override
+ public String toEnumName(CodegenProperty property) {
+ String enumName = toModelName(property.name);
+
+ // Ensure that the enum type doesn't match a reserved word or
+ // the variable name doesn't match the generated enum type or the
+ // Swift compiler will generate an error
+ if (isReservedWord(property.datatypeWithEnum)
+ || toVarName(property.name).equals(property.datatypeWithEnum)) {
+ enumName = property.datatypeWithEnum + "Enum";
+ }
+
+ // TODO: toModelName already does something for names starting with number,
+ // so this code is probably never called
+ if (enumName.matches("\\d.*")) { // starts with number
+ return "_" + enumName;
+ } else {
+ return enumName;
+ }
+ }
+
+ @Override
+ public Map postProcessModels(Map objs) {
+ Map postProcessedModelsEnum = postProcessModelsEnum(objs);
+
+ // We iterate through the list of models, and also iterate through each of the
+ // properties for each model. For each property, if:
+ //
+ // CodegenProperty.name != CodegenProperty.baseName
+ //
+ // then we set
+ //
+ // CodegenProperty.vendorExtensions["x-codegen-escaped-property-name"] = true
+ //
+ // Also, if any property in the model has x-codegen-escaped-property-name=true, then we mark:
+ //
+ // CodegenModel.vendorExtensions["x-codegen-has-escaped-property-names"] = true
+ //
+ List