Skip to content

Commit eefcd62

Browse files
authored
[Kotlin][Client] Added supporting Retrofit2(RxJava/RxJava2/Coroutines) (#5750)
* Added support Retrofit2(RxJava/RxJava2/Coroutines) to Kotlin client code generator * Added generated samples for Retrofit2(RxJava/RxJava2/Coroutines) on Kotlin * Fixed generating retrofit2 without Rx/Coroutines * Fixed MultipartBody template, remove redundant space after MultipartBody.Part annotation * Fix documentation diff. * Fix generating build.gradle file for samples. Add dependencies for rxJava/rxJava2 and rx retrofit's adapter. * Update generated sample with rx dependencies * Update generated sample with coroutines * Update generated sample with RxJava 2 dependencies * Update and refactoring scripts for sample generation * Update generated sample code * revert changes by mistake * revert changes by mistake #2 * Fix return type for first RxJava * Add RxJavaCallAdapterFactory to ApiClient scheme for RxJava 1/2 * Fix script loggin * Update generated code for RxJava 1/2 * Fix kotlin.md documentation by script export_docs_generators.sh * Update Kotlin samples project in pom.xml * Revert "Update Kotlin samples project in pom.xml" This reverts commit 9de4d0b * Fixed "" wrapping number types for annotation value Fixed generating polymorphic interfaces for Gson, interface fields can't be marked with @SerializedName annotation, it's enough to mark it in child model. Fixed instantiationTypes(array, list, map) for Kotlin generator * Update Kotlin samples project after last fixes * Update Kotlin samples project for kotlin-jvm-* * Update Kotlin readme.md documentations * Update Kotlin client sample changes * Fixed encoding braces for generics model * Update Kotlin client sample changes * Update Kotlin client sample after merge with master * Fixed adding empty braces for inherit from Map/Array * Update sample model after last fix with empty braces * Revert adding @SerializedName to Kotlin interface fields through @get:SerializedName as for Jackson * Update Kotlin client samples with adding @get:SerializedName
1 parent d1e8d63 commit eefcd62

File tree

529 files changed

+17809
-706
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

529 files changed

+17809
-706
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
4+
./bin/openapi3/kotlin-client-petstore.sh
5+
./bin/openapi3/kotlin-client-petstore-multiplatform.sh
6+
./bin/openapi3/kotlin-client-petstore-nullable-required.sh
7+
./bin/openapi3/kotlin-client-petstore-retrofit2-coroutines.sh
8+
./bin/openapi3/kotlin-client-petstore-retrofit2-rx.sh
9+
./bin/openapi3/kotlin-client-petstore-retrofit2-rx2.sh
10+

bin/openapi3/kotlin-client-petstore-multiplatform.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ then
2525
mvn clean package
2626
fi
2727

28+
samplePath="samples/openapi3/client/petstore/kotlin-multiplatform"
29+
2830
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
29-
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-client-petstore-multiplatform --library multiplatform -o samples/openapi3/client/petstore/kotlin-multiplatform $@"
31+
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-client-petstore-multiplatform --library multiplatform -o $samplePath $@"
3032

31-
echo "Cleaning previously generated files if any from samples/openapi3/client/petstore/kotlin-multiplatform"
32-
rm -rf samples/openapi3/client/petstore/kotlin-multiplatform
33+
echo "Cleaning previously generated files if any from $samplePath"
34+
rm -rf $samplePath
3335

3436
echo "Generating Kotling client..."
3537
java $JAVA_OPTS -jar $executable $ags

bin/openapi3/kotlin-client-petstore-nullable-required.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ then
2525
mvn clean package
2626
fi
2727

28+
samplePath="samples/openapi3/client/petstore/kotlin-nullable-required"
29+
2830
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
29-
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-nullable-required.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-petstore-nullable-required --additional-properties allowRequiredAsNullable=true -o samples/openapi3/client/petstore/kotlin-nullable-required $@"
31+
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-nullable-required.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-petstore-nullable-required --additional-properties allowRequiredAsNullable=true -o $samplePath $@"
3032

31-
echo "Cleaning previously generated files if any from samples/openapi3/client/petstore/kotlin-nullable-required"
32-
rm -rf samples/openapi3/client/petstore/kotlin-nullable-required
33+
echo "Cleaning previously generated files if any from $samplePath"
34+
rm -rf $samplePath
3335

3436
echo "Generating Kotling client..."
3537
java $JAVA_OPTS -jar $executable $ags
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
echo "# START SCRIPT: $SCRIPT"
5+
6+
while [ -h "$SCRIPT" ] ; do
7+
ls=$(ls -ld "$SCRIPT")
8+
link=$(expr "$ls" : '.*-> \(.*\)$')
9+
if expr "$link" : '/.*' > /dev/null; then
10+
SCRIPT="$link"
11+
else
12+
SCRIPT=$(dirname "$SCRIPT")/"$link"
13+
fi
14+
done
15+
16+
if [ ! -d "${APP_DIR}" ]; then
17+
APP_DIR=$(dirname "$SCRIPT")/..
18+
APP_DIR=$(cd "${APP_DIR}"; pwd)
19+
fi
20+
21+
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
22+
23+
if [ ! -f "$executable" ]
24+
then
25+
mvn clean package
26+
fi
27+
28+
samplePath="samples/openapi3/client/petstore/kotlin-jvm-retrofit2-coroutines"
29+
30+
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
31+
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-petstore-coroutines-client --library jvm-retrofit2 --additional-properties serializationLibrary=gson,dateLibrary=java8,serializableModel=true,useCoroutines=true -o $samplePath $@"
32+
33+
echo "Cleaning previously generated files if any from $samplePath"
34+
rm -rf $samplePath
35+
36+
echo "Generating Kotling client..."
37+
java $JAVA_OPTS -jar $executable $ags
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
echo "# START SCRIPT: $SCRIPT"
5+
6+
while [ -h "$SCRIPT" ] ; do
7+
ls=$(ls -ld "$SCRIPT")
8+
link=$(expr "$ls" : '.*-> \(.*\)$')
9+
if expr "$link" : '/.*' > /dev/null; then
10+
SCRIPT="$link"
11+
else
12+
SCRIPT=$(dirname "$SCRIPT")/"$link"
13+
fi
14+
done
15+
16+
if [ ! -d "${APP_DIR}" ]; then
17+
APP_DIR=$(dirname "$SCRIPT")/..
18+
APP_DIR=$(cd "${APP_DIR}"; pwd)
19+
fi
20+
21+
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
22+
23+
if [ ! -f "$executable" ]
24+
then
25+
mvn clean package
26+
fi
27+
28+
samplePath="samples/openapi3/client/petstore/kotlin-jvm-retrofit2-rx"
29+
30+
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
31+
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-petstore-rx-client --library jvm-retrofit2 --additional-properties serializationLibrary=gson,dateLibrary=java8,serializableModel=true,useRxJava=true -o $samplePath $@"
32+
33+
echo "Cleaning previously generated files if any from $samplePath"
34+
rm -rf $samplePath
35+
36+
echo "Generating Kotling client..."
37+
java $JAVA_OPTS -jar $executable $ags
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
echo "# START SCRIPT: $SCRIPT"
5+
6+
while [ -h "$SCRIPT" ] ; do
7+
ls=$(ls -ld "$SCRIPT")
8+
link=$(expr "$ls" : '.*-> \(.*\)$')
9+
if expr "$link" : '/.*' > /dev/null; then
10+
SCRIPT="$link"
11+
else
12+
SCRIPT=$(dirname "$SCRIPT")/"$link"
13+
fi
14+
done
15+
16+
if [ ! -d "${APP_DIR}" ]; then
17+
APP_DIR=$(dirname "$SCRIPT")/..
18+
APP_DIR=$(cd "${APP_DIR}"; pwd)
19+
fi
20+
21+
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
22+
23+
if [ ! -f "$executable" ]
24+
then
25+
mvn clean package
26+
fi
27+
28+
samplePath="samples/openapi3/client/petstore/kotlin-jvm-retrofit2-rx2"
29+
30+
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
31+
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-petstore-rx2-client --library jvm-retrofit2 --additional-properties serializationLibrary=gson,dateLibrary=java8,serializableModel=true,useRxJava2=true -o $samplePath $@"
32+
33+
echo "Cleaning previously generated files if any from $samplePath"
34+
rm -rf $samplePath
35+
36+
echo "Generating Kotling client..."
37+
java $JAVA_OPTS -jar $executable $ags

bin/openapi3/kotlin-client-petstore.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ then
2525
mvn clean package
2626
fi
2727

28+
samplePath="samples/openapi3/client/petstore/kotlin"
29+
2830
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
29-
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-petstore-client --additional-properties dateLibrary=java8,serializableModel=true -o samples/openapi3/client/petstore/kotlin $@"
31+
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-petstore-client --additional-properties dateLibrary=java8,serializableModel=true -o $samplePath $@"
3032

31-
echo "Cleaning previously generated files if any from samples/openapi3/client/petstore/kotlin"
32-
rm -rf samples/openapi3/client/petstore/kotlin
33+
echo "Cleaning previously generated files if any from $samplePath"
34+
rm -rf $samplePath
3335

3436
echo "Generating Kotling client..."
3537
java $JAVA_OPTS -jar $executable $ags

docs/generators/kotlin-server.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ sidebar_label: kotlin-server
4545

4646
| Type/Alias | Instantiated By |
4747
| ---------- | --------------- |
48-
|array|kotlin.arrayOf|
49-
|list|kotlin.arrayOf|
50-
|map|kotlin.mapOf|
48+
|array|kotlin.Array|
49+
|list|kotlin.collections.ArrayList|
50+
|map|kotlin.collections.HashMap|
5151

5252

5353
## LANGUAGE PRIMITIVES

docs/generators/kotlin-spring.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ sidebar_label: kotlin-spring
5454

5555
| Type/Alias | Instantiated By |
5656
| ---------- | --------------- |
57-
|array|kotlin.arrayOf|
58-
|list|kotlin.arrayOf|
59-
|map|kotlin.mapOf|
57+
|array|kotlin.Array|
58+
|list|kotlin.collections.ArrayList|
59+
|map|kotlin.collections.HashMap|
6060

6161

6262
## LANGUAGE PRIMITIVES

docs/generators/kotlin-vertx.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ sidebar_label: kotlin-vertx
3939

4040
| Type/Alias | Instantiated By |
4141
| ---------- | --------------- |
42-
|array|kotlin.arrayOf|
43-
|list|kotlin.arrayOf|
44-
|map|kotlin.mapOf|
42+
|array|kotlin.Array|
43+
|list|kotlin.collections.ArrayList|
44+
|map|kotlin.collections.HashMap|
4545

4646

4747
## LANGUAGE PRIMITIVES

0 commit comments

Comments
 (0)