openapi-generator/bin/swift3-petstore-all.sh
ehyche 95ef1bf62e Swift3: properly percent-escape path parameters (#6705)
* Add addiitional files from upstream

* Remove mis-added files

* Swift3: Properly percent-escape path parameters

This change fixes the following issue:

https://github.com/swagger-api/swagger-codegen/issues/6400

The problem was that path parameters were not properly percent-escaped before being placed into the URL path. This leads to creation of an invalid URL, which then fails.

So therefore, in the API template where path parameters are handled, we propertly percent escape them, using the characters which are allowed in URL paths.

In addition to this template change, then this PR includes the following changes:

1. Resulting changes in all generated code due to the above template change.
2. I added the objcCompatible run to the swift3-petstore-all.sh so that I could re-generated all of the generated code with a single script.
3. I added a unit test in UserAPITests.swift which verifies that paths are properly escaped.
4. In order to make the unit test work, then I needed access to RequestBuilder<T>.URLString to verify that the path was properly escaped. However, RequestBuilder<T>.URLString had "internal" access control so it was inaccessible from the unit test. So therefore, I made four contants in RequestBuilder<T> to be public. This should not harm anything, since they are constants ("let's") and cannot be changed from the outside of the class after initialization.
5. There were also some stray changes which look like they were caused by having not run bin/swift3-petstore-all.sh in a while.
2017-10-30 15:40:00 +08:00

49 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
SCRIPT="$0"
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/swagger-codegen-cli/target/swagger-codegen-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 -t modules/swagger-codegen/src/main/resources/swift3 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift3 -c ./bin/swift3-petstore.json -o samples/client/petstore/swift3/default"
echo "#### Petstore Swift API client (default) ####"
java $JAVA_OPTS -jar $executable $ags
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift3 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift3 -c ./bin/swift3-petstore-promisekit.json -o samples/client/petstore/swift3/promisekit"
echo "#### Petstore Swift API client (promisekit) ####"
java $JAVA_OPTS -jar $executable $ags
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift3 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift3 -c ./bin/swift3-petstore-rxswift.json -o samples/client/petstore/swift3/rxswift"
echo "#### Petstore Swift API client (rxswift) ####"
java $JAVA_OPTS -jar $executable $ags
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift3 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift3 -c ./bin/swift3-petstore-unwraprequired.json -o samples/client/petstore/swift3/unwraprequired"
echo "#### Petstore Swift API client (unwraprequired) ####"
java $JAVA_OPTS -jar $executable $ags
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift3 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l swift3 -c ./bin/swift3-petstore-objcCompatible.json -o samples/client/petstore/swift3/objcCompatible"
echo "#### Petstore Swift API client (objcCompatible) ####"
java $JAVA_OPTS -jar $executable $ags