-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Kotlin multiplatform client #3900
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 multiplatform client #3900
Conversation
Kotlin multiplatform allows Kotlin code to be shared across various target platforms. This implementation generates Swagger clients for JVM and iOS platforms.
eb95cd0
to
44fec6f
Compare
) | ||
|
||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties | ||
set ags=generate --artifact-id "kotlin-client-petstore-multiplatform" -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -g kotlin --library multiplatform -o samples\client\petstore\kotlin-multiplatform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For -i
, please use modules\openapi-generator\src\test\resources\2_0\petstore.yaml
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Updated.
Please run the following to update the documentation so as to address the CircleCI failure:
|
@Override | ||
public Map<String, Object> postProcessModels(Map<String, Object> objs) { | ||
|
||
// workaround for: https://github.com/swagger-api/swagger-codegen/issues/4258 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this workaround?
I think the issue has been fixed in OpenAPI Generator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. I couldn't find a reference to the issue in OpenAPI Generator (and I couldn't remember in what scenario it was necessary). I'll run through some tests and get back to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please. If it's still an issue, we need to track it and get it fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed fixed. Unnecessary code removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate pull request created:
#3928
I got the following errors when testing the multiplatform client locally:
Is it supposed to work on Mac as well? |
Try it with the wrapper:
Yes. I've tested on Mac and Windows. |
Thanks for the tips. It works for me in my machine:
|
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many empty lines. I'll see what I can do to fix these in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Tested locally and the result is good.
Thanks. Looking forward to community feedback and improvements. |
Support for the generation of Kotlin Multiplatform clients.
Background
The
kotlin
language defined in the Swagger Codegen project currently generates a Kotlin client that can run on the JVM. Somewhat recently, JetBrains introduced Kotlin Multiplatform, a platform that provides the ability to share code between various platforms: JVM, JS, iOS, Windows, etc. This pull request adds the ability to generate a Kotlin Multiplatform client.Library
The pull request includes Kotlin Multiplatform generation under the
kotlin
language and introduces two library options:jvm
: (default) to target the existing Kotlin JVM generation.multiplatform
: to target Kotlin Multiplatform generation.Limitations
The current pull request only currently adds support for JVM and iOS platforms but support for other platforms should be trivial to add.
At present,
date
anddate-time
objects are rendered as strings. No attempt is made to integrate any third-party date/time libraries.Tests
The current implementation doesn't include any tests beyond those already included as part of the
kotlin
language implementation. A test project can be found here that generates thepetstore
sample and includes tests to verify the correctness of the implementation.Comments welcome.
References
#3899
https://github.com/andrewemery/openapi-generator-kotlin-multiplatform-petstore