I see why <https://github.com/Foso/Ktorfit/issues/...
# ktor
s
I see why https://github.com/Foso/Ktorfit/issues/200 was requested. πŸ˜„ All Kotlin OpenAPI Generators are really old and date back to 2019 πŸ‘€ Isn’t swagger such a popular tech?
s
I was working on OpenAPI-kt, and it was working for OpenAI spec a couple months ago. I want to pick it back up soon. You could try the latest version.
πŸ‘ 1
πŸ‘€ 1
h
It’s not. But I also did just write my own code generator for Kotlin classes, Ktor client and Ktor server, will try to open source it.
❀️ 1
s
Ktor server comes with something official, but Ktor client seems to be the issue.
βž• 1
@hfhbd Please ping me if that worked out. πŸ™‚ The generated code I got from the old generators is really ugly.
@simon.vergauwen Unfortunately your project didn't work for me and I'm not sure what to do with the error message.
h
Keep in mind, APIs are mostly always broken 🫠
And you should validate them before with eg redocly cli
s
Ok, will check. I got an api.yml that a colleague send me. ^^
s
Oof, looks like a bad error message in my Gradle plugin.. Is this in your Gradle setup?
Copy code
plugin {
  id("io.github.nomisrev.openapi-kt-plugin") version "0.0.6"
}

openApiConfig {
  spec("OpenAI", file("openai.yaml")) {
    // packageName = "my.company.openai.generated"
  }
}
OpenAPI's in the wild are indeed more often incorrect than correct πŸ˜…
yes black 1
s
If IntelliJ IDEA Ultimate can generate this doc from the file I got, can I assume it's correct? Or is there an extra validator?
id("org.openapi.generator") version "6.3.0"
works with my file and generates a stub.
My issue with the super old code it generates is that there is not a separate interface I could use to implement a dummy for unit testing. A ktorfit client generation would be awesome.
s
100% in addition to that it only supports super simple types. My generator generates an interface with what you would otherwise write manually in Ktor as the implementation. I did so because I wanted the implementation to look and read as idiomatic Kotlin code. Besides that I allow customising the Ktor client with lambdas at the construction side of your interfaces, and with an optional lambda in every method you call. This is similar to how you would customise the HttpClient in your own codebase. I also have a set of templates that achieves this on top of the "old" generator. If you like I can share them with you @Stefan Oltmann but they're quite cumbersome to maintain if something changes.
s
I'm looking for a hassle free solution πŸ˜…
βž• 1
h
docker run --rm -v $PWD:/spec <http://ghcr.io/redocly/cli|ghcr.io/redocly/cli> lint --config=config/redocly.yaml myOpenapi.json
and I use this config for the redocly:
Copy code
telemetry: off

extends:
  - recommended-strict

rules:
  info-license: off # because the openapi is for internal use only
πŸ‘€ 1
This is (an older) output of my generator for the maven central api, but because the openapi is broken, I needed to overwrite some classes... https://github.com/hfhbd/mavencentral/tree/main/central-api
😍 1
s
πŸ‘€
h
You need to store the config file at the specific path
s
I'm too stupid. ^^ I guess I need to find an easy to use online-tool πŸ˜„
I assume the spec is valid since the other generators don't fail.
h
-v $PWD passes the local (Downloads) folder to the container so the paths must relative
s
🫣
h
You need to use -v $PWD:/spec
βœ… 1
s
Oh, okay, the linter is not happy. I will return the file πŸ˜„
h
Keep in mind, this config uses
strict
πŸ‘ 1
s
People need to stop inventing new logging & DI frameworks and should make a up-to-date Open API generator 😬
πŸ˜‚ 1