OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.79k stars 6.57k forks source link

[REQ] Java client code that works with Java 8 and little else #17169

Open alexec opened 11 months ago

alexec commented 11 months ago

I need to generate client for many (100s to 1000s of API specifications) to be used by many (100s to 1000s) of consumers.

Describe the solution you'd like

A lowest common denominator client.

Describe alternatives you've considered

I'd use native, but that is Java 11+.

What's the most widely compatible option? Should I write my own using HTTPUrlConnection?

wing328 commented 11 months ago

I'd use native, but that is Java 11+.

what about the default which is okhttp-gson? it should work with JDK8

Eric-Telavox commented 11 months ago

Same thing forme, i am sitting with an older code base using Java and i cant i my life get the maven plugin or the cli generator to make me a client that works. Either there is miss matching in file names, packeges or imports.

Maven pluggin 7.0.0 is not able to run under Java 8 så i need to go back to an older version, but still just issues. Spent to much time on this and do someone know if there is a known version and setup for generating a Java client using an OpenApi 3.0.1 spec, using Java 1.8 and Maven.

alexec commented 11 months ago

My conclusion is: Unless you have a need to integrate with a specific framework, use native for Java 11+ and apache-httpclient for Java 8+.

I spend several hours testing out the different Java generator libraries and evaluating them. Here is that tabulated:

image

I may have made mistakes, please correct and I'll update.

Commentary:

Here are the runtime dependencies of native:

image

Here are the runtime dependencies of apache-httpclient:

image

In this list, I've struck out dependencies that Maven identified as unused. You could probably remove them.

Eric-Telavox commented 11 months ago

@alexec

Awesome writing, thank you. And yes the Java generator feels awful i agree. I am not a fun of Java in the first hand but this have been such a mess to get going. What i ended upp doing is made my self a script that first clean out old generated god, then generate new one with a .openapi-ignore file so it just generates the client code that i want, and some supporting files. And since the Java8 generator is so buggy and not able to place the package and the folder structure in a good way i just used some terminal move command and then som folder cleaning with the script.....

I can see why anyone could use this in a production environment.