-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[kotlin-client] Add support okhttp3 and Android 4.x #4008
[kotlin-client] Add support okhttp3 and Android 4.x #4008
Conversation
@4brunu thanks for the PR. What about naming the option as "library" instead to make it more consistent with other generators (e.g. Java, Ruby) when it comes to supporting more than 1 HTTP library? |
@wing328 it's done, I also rerun the tests and the pet projects 🙂 |
@4brunu sorry I was not clear. I mean something like https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java#L146-L154 |
Hi, I was trying to do the changes but now the generator with the pet projects it's not working. Here is the commit and the logs. Log# START SCRIPT: bin/kotlin-client-okhttp3.sh [main] INFO o.o.codegen.DefaultGenerator - OpenAPI Generator: kotlin (client) [main] INFO o.o.codegen.DefaultGenerator - Generator 'kotlin' is considered stable. [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] INFO o.o.c.l.AbstractKotlinCodegen - Environment variable KOTLIN_POST_PROCESS_FILE not defined so the Kotlin code may not be properly formatted. To define it, try 'export KOTLIN_POST_PROCESS_FILE="/usr/local/bin/ktlint -F"' (Linux/Mac) [main] INFO o.o.c.l.AbstractKotlinCodegen - NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI). [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/models/ApiResponse.kt [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/docs/ApiResponse.md [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/models/Category.kt [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/docs/Category.md [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/models/Order.kt [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/docs/Order.md [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/models/Pet.kt [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/docs/Pet.md [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/models/Tag.kt [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/docs/Tag.md [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/models/User.kt [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/docs/User.md [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.DefaultCodegen - Multiple MediaTypes found, using only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.DefaultCodegen - Multiple MediaTypes found, using only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/PetApi.kt [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/docs/PetApi.md [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/docs/StoreApi.md [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/apis/UserApi.kt [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/docs/UserApi.md [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/README.md [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/build.gradle [main] INFO o.o.codegen.AbstractGenerator - writing file /Users/bruno.coelho/Developer/openapi-generator/samples/client/petstore/kotlin-okhttp3/settings.gradle [main] ERROR o.o.codegen.AbstractGenerator - kotlin-client/infrastructure/ApiClient.kt.mustache (No such file or directory) [main] ERROR o.o.codegen.AbstractGenerator - kotlin-client/infrastructure/ApiClient.kt.mustache (No such file or directory) [main] ERROR o.o.codegen.AbstractGenerator - can't load template kotlin-client/infrastructure/ApiClient.kt.mustache [main] ERROR o.o.codegen.AbstractGenerator - can't load template kotlin-client/infrastructure/ApiClient.kt.mustache Exception in thread "main" java.lang.RuntimeException: Could not generate supporting file 'SupportingFile: templateFile: infrastructure/ApiClient.kt.mustache folder: src/main/kotlin/org/openapitools/client/infrastructure destinationFilename: ApiClient.kt ' at org.openapitools.codegen.DefaultGenerator.generateSupportingFiles(DefaultGenerator.java:751) at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:930) at org.openapitools.codegen.cmd.Generate.run(Generate.java:408) at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:60) Caused by: java.lang.RuntimeException: can't load template kotlin-client/infrastructure/ApiClient.kt.mustache at org.openapitools.codegen.AbstractGenerator.readTemplate(AbstractGenerator.java:122) at org.openapitools.codegen.DefaultGenerator.getFullTemplateContents(DefaultGenerator.java:941) at org.openapitools.codegen.templating.MustacheEngineAdapter.compileTemplate(MustacheEngineAdapter.java:51) at org.openapitools.codegen.DefaultGenerator.generateSupportingFiles(DefaultGenerator.java:723) ... 3 more cp: CI/samples.ci/client/petstore/kotlin-okhttp3/pom.xml: No such file or directoryCan you please check the commit to see if this is was you had in mind? Since kotlin has the concept of jvm and multiplatform library, I'm not sure if it works nice to have a jvm-okhttp4 and jvm-okhttp3. |
Sounds good to me |
I'll try to find some time to review later today. |
Can you please push 4brunu@7190a80 to this branch/PR when you've time? Easy for me to try to it and figure out what's wrong. |
…-support-okhttp3 # Conflicts: # modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache
@wing328 done. thanks for helping 👍 |
@4brunu I've figured out the reason and got a "workaround' to make it work with all 3 different library settings. Please PM tomorrow (Thur) via Slack when you've time. |
Thanks for the help, now it's working 🙂 |
Don't merge this branch! After doing some more tests, It's not working. |
@wing328 the Serialisation and Parcelable/Parcelize features stop working. When migrating to library it stoped working... Here is a screenshot that shows what's wrong in the models. The generator is not generating the imports and Do you have any idea why? |
@wing328 sorry for the spam... |
CI failure not related to this PR. |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.master
,4.1.x
,5.0.x
. Default:master
.Description of the PR
@jimschubert (2017/09) ❤️, @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04)
This PR adds support for Add support okhttp3 and Android 4.x and fixes #4007