openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

UPDATE ktor-client to 3.0.0 and fix HttpBasicAuth.kt to support it

Open ninovanhooff opened this issue 1 year ago • 7 comments

For ktor 3.0.0 compatibility, an import must be updated in HttpBasicAuth.kt

I basically did a project wide find-and-replace for the offending import

Fixes issue #19447

PR checklist

  • [x] Read the contribution guidelines.
  • [x] Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • [x] Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH) Commit all changed files. 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*. IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • [x] File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • [x] If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

ninovanhooff avatar Oct 16 '24 09:10 ninovanhooff

Force push reason: changing commit message

@e5l please advise: with this change ktor client is updated to 3.0.0. And it also fixes the samples. Client Users of openapi-generators might need to update ktor to 3.0.0

  • The migration guide only mentions steps for server, not client. https://ktor.io/docs/migrating-3.html Is this considered a breaking change and should I target branch 8.x.0? Note that I did not update the server version in modules/openapi-generator/src/main/resources/kotlin-server/libraries/ktor/build.gradle.kts.mustache
  • ~When running ./bin/generate-samples.sh ./bin/configs/*.yaml my ktor version change is being reverted to 2.3.6. But I don't see relevant occurrences of 2.3.6 anymore in the project. Can you explain why?~ edit: found it in the .mustanche file. fixed.

ninovanhooff avatar Oct 16 '24 10:10 ninovanhooff

thanks for the PR

cc @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) @e5l (2024/10)

wing328 avatar Oct 16 '24 11:10 wing328

The migration guide only mentions steps for server, not client. https://ktor.io/docs/migrating-3.html Is this considered a breaking change and should I target branch 8.x.0?

My take is to go ahead with this change and if users need to use ktor 2.x for whatever reasons, we may create an option for fallback if needed (or they can use customize templates with a different set of versions for dependencies).

wing328 avatar Oct 16 '24 11:10 wing328

@wing328, the client has no broken changes in this release (except the shared ktor-io module)

e5l avatar Oct 16 '24 11:10 e5l

@ninovanhooff can you please review the CI failures when you've time?

wing328 avatar Oct 16 '24 12:10 wing328

I can't seem to find the last ones. Whatever other version number I find that is left, I assume is related to ktor-server rather than client. Help appreciated, @wing328 @e5l

ninovanhooff avatar Oct 16 '24 14:10 ninovanhooff

Your current Kotlin version is 1.9.20, while kotlinx.serialization core runtime 1.7.3 requires at least Kotlin 2.0.0-RC1. Please update your Kotlin compiler and IDE plugin.

To use 1.7.3 kotlinx.serialization you need to bump Kotlin to 2.0.0

e5l avatar Oct 16 '24 14:10 e5l

I'd love to help get Ktor v3 into the Kotlin clients. Regarding Kotlin 2.0.0, do you prefer to do this in a separate PR?

eirikvaa avatar Oct 22 '24 07:10 eirikvaa

@eirikvaa thanks for reaching out and offering support.

Tbh, my team decided to not use this project due to lack of oneof (aka sealed class in kotlin) support. So my motivation to finish this up has dropped significantly. In addition, kotlin 2 migration is a bit more work (not necessarily a lot) than just replacing some version numbers.

If you would like to, please branch / fork from my work and open a new PR, then I will close this.

ninovanhooff avatar Oct 22 '24 08:10 ninovanhooff

@eirikvaa thanks for reaching out and offering support.

Tbh, my team decided to not use this project due to lack of oneof (aka sealed class in kotlin) support. So my motivation to finish this up has dropped significantly. In addition, kotlin 2 migration is a bit more work (not necessarily a lot) than just replacing some version numbers.

If you would like to, please branch / fork from my work and open a new PR, then I will close this.

You can keep it open for now 👍

eirikvaa avatar Oct 22 '24 08:10 eirikvaa

Tbh, my team decided to not use this project due to lack of oneof (aka sealed class in kotlin) support. So my motivation to finish this up has dropped significantly.

Did you try the option generateOneOfAnyOfWrappers ?

https://openapi-generator.tech/docs/generators/kotlin/

wing328 avatar Oct 22 '24 08:10 wing328

Tbh, my team decided to not use this project due to lack of oneof (aka sealed class in kotlin) support. So my motivation to finish this up has dropped significantly.

Did you try the option generateOneOfAnyOfWrappers ?

https://openapi-generator.tech/docs/generators/kotlin/

Yes, that did not produce compilable code. I think it was designed to produce Gson models and even then it did not compile or clash with the kotlin-serialization models generated by the remainder of the kotlin + jvm-ktor and kotlin + Multiplatform config. Very disappointing

ninovanhooff avatar Oct 22 '24 13:10 ninovanhooff

  library: jvm-retrofit2
  serializationLibrary: gson

that's what we've tested so far

ref: https://github.com/OpenAPITools/openapi-generator/blob/master/bin/configs/kotlin-model-prefix-type-mapping.yaml

you can give it a try to see if the output meets your requirements

and we will see how we can plot the implementation to other serialization libraries

wing328 avatar Oct 22 '24 17:10 wing328

@eirikvaa thanks for reaching out and offering support.

Tbh, my team decided to not use this project due to lack of oneof (aka sealed class in kotlin) support. So my motivation to finish this up has dropped significantly. In addition, kotlin 2 migration is a bit more work (not necessarily a lot) than just replacing some version numbers.

If you would like to, please branch / fork from my work and open a new PR, then I will close this.

Not oneOf but polymorphic serialization was fixed here 3 years ago but never merged: https://github.com/OpenAPITools/openapi-generator/pull/14301

tjerkw avatar Jul 28 '25 08:07 tjerkw

@wing328 This one can be closed. ktor has been upgraded to 3.x in https://github.com/OpenAPITools/openapi-generator/pull/20053

grEvenX avatar Sep 11 '25 06:09 grEvenX