-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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] New, separate and refreshed #7353
base: master
Are you sure you want to change the base?
Conversation
Technical committee: |
Some things to do (list may be expanded):
|
I added the cli options, so if someone wants to have a look, if they're correctly implemented |
modules/openapi-generator/src/main/resources/kotlin-multiplatform-client/api.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/kotlin-multiplatform-client/api.mustache
Outdated
Show resolved
Hide resolved
I did not forget this, but I'll need ~5-6 Weeks until I have time to work on this again |
modules/openapi-generator/src/main/resources/kotlin-multiplatform-client/data_class.mustache
Outdated
Show resolved
Hide resolved
.../openapi-generator/src/main/resources/kotlin-multiplatform-client/interface_opt_var.mustache
Show resolved
Hide resolved
Hi @cromefire . I came on a journey seeking OpenAPI / Multiplatform generation and, after looking at performing the changes myself, ended up here. This is clearly already great progress; is there any way I can help to complete it? |
I don't really think so I guess, there's not much left and I already have concrete ideas for it. I should be able to get it done in the next weeks though. |
Hey @cromefire I have been looking into your great work and tried to use it. What are your ideas for platform specific interop? |
Provide stuff like Futures for java or promises for JS, so you could also use the same client from a java/JS codebase instead of needing a kotlin shim or something like that. (For example if you publish a client for general use) |
I have a burning use case for this. @fullkomnun did you find the current |
…ate should be conditional (since it is optional)
@chris-hatton Sorry for the late response. I also have a use-case that requires this support for the latest I have been testing this PR, mainly focusing on JVM/NodeJS as targets and it works great except for a few issues i have fixed and submitted for review here. I performed one more significant change which I will soon submit as a PR which allows clients to provide a custom HttpClient to ApiClient. It is useful for using common Ktor features such as logging, timeouts and so on. |
It should be already possible to use a custom |
Another problem I'm facing while using the subproject generation:
Gradle errors with:
I found some slightly related youtrack issues with the workaround being to declare the plugins in the root project (with apply false), but I'm already doing it. Your generated subproject doesn't contain any version, so should be correct as far as I can tell, but maybe you have an Idea how to fix this? With jsEnabled and jsBrowser both on false the error disappears. EDIT: Nevermind, I had some noop build task defined in the root project. Removing this task seems to work... :) |
Another thing which would be awesome: Enable typescript definitions generation for the kotlin js IR compiler. The js target would need to be executable
and all files containing toplevel stuff would need the JsExport treatment (otherwise no definitions will be generated):
|
Yeah you can only set a version once in the whole project so this why I did it that way, schools probably document that. |
I think we need some gradle extension script or so but I didn't get it to work yet. |
Hi, nice job. I have a problem with enums. I tried to export the petstore sample and in models I have an unresolved reference for |
Are you sure it didn't cache anything or so while building? Because there isn't any reference to that in the code (anymore) |
Maven seems really bad at caching so I think you do something like |
Super thanks ! I will try again after a clean ! |
I got it to work, but a lot of generated code issn't exportable to JS, so this would need some major changes to the generated client (with
|
Well without enums and suspend functions you're probably not getting far, I've also tried some things there and settled that for a client to use from (directly) ts, you probably want to generate a "real" ja/ts client. |
…en/languages/KotlinMultiplatformClientCodegen.java Co-authored-by: Cromefire_ <[email protected]>
…fault_versions Update kotlin multiplatform default versions
It already does make use of it (but it sadly still has other problems I can't solve). |
What kind of problems? Need any help? |
Actually yes, the one I remember I couldn't figure out happens if you specify |
Any update on this? |
Nope, still those same problems and as I'm quite busy right now I haven't spent a lot of time on trying to find a solution for it. |
Some update on this @cromefire , as the Android Client is quite outdated and it would be interesting to have Multiplatform support with Kotlin. |
As always, there wasn't a lot of time to spare and too else much to do, there's not a lot of issues with the PR in it's current state except Also thought of maybe rewriting it without openapi-generator and Kotlin poet or so for more native code generation and less issues with templating... (as openapi-generator doesn't provide too much I think except the built-in templating) Maybe they'd even accept this generator not using tempating, but a code generator, but I don't think so and it would also add a dependency to the generator in the end (one that's not needed by most) and I don't think there's a plugin mechanism. If you have a good solution to the issue with Overall I really could use this myself and I'd love to have this but I just didn't have the time and motivation yet to finish it. Maybe now that multiplatform is more stable it'd be a fairly good time, especially with things like compose multiplatform. |
java, C# ,etc supports the additionalProperties. maybe we can these implementations as a starting point. I think we can cherry-pick some of the enhancements in #7353 (comment) to start with so that we can merge these enhancements separately. If anyone wants to help on this, please reply to let us know. most importantly thank you @cromefire for the awesome contributions 👍 |
AFAIK they usually do that by inheriting from a list, which isn't doable in kotlinx.serialization last time I checked (3 years ago). In general it can of course be done, but it's a bit of work, especially since I have to do it in templating. I might have some time next week, I just have to remember to look at this again. |
Hi there, I have been following this branch for a long time, because I am also planning to write an OpenAPI generator for Kotlin multiplatform (or rather: rewrite my existing one to KMM, instead of Retrofit+Moshi). My plan is to just use The value
|
PR checklist
./bin/generate-samples.sh
to update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH.master