-
-
Notifications
You must be signed in to change notification settings - Fork 643
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
Support Java codegen for the OpenAPI backend #16862
Support Java codegen for the OpenAPI backend #16862
Conversation
Exciting! I was actually planning to do the same thing but for Python when I've got some spare time, but now I'll definitely hold that off and piggback off of the work here once it's merged. 🎉 |
@jyggen sounds like a plan, we can defo work together on adding support for more languages incrementally. Also, feel free to provide with any feedback/ideas where this implementation may differ from what you had in mind. |
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!
|
||
extra_jvm_options = [*subsystem.jvm_options, *request.extra_jvm_options] | ||
|
||
jvm_process = JvmProcess( |
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.
Since this code is specific to the JVM, it's probably not generic to all of openapi
the way its module namespace might suggest.
But also: since this is used in exactly one other @rule
, it feels like premature optimization to extract it?
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.
it is indeed a bit of a premature optimisation. The idea behind this is to make it easier to implement code generation for other languages as all of them use the same generation tool.
In other words: this is not specific to the Java code generator, the code generation tool is a JVM tool which can generate code for a wide variety of languages as it takes in its argument list the target language (aka generator) to be used: https://openapi-generator.tech/docs/generators
So with this rule, supporting new generators consist on adding a new enum value to OpenAPIGeneratorType
and then implementing the backend for that generator so that it uses this rule to build the final process the same way the java
generator does.
@jyggen mentioned he was interested in implementing the Python code generation, which would benefit from this. I guess the main inconvenience is that this will in fact still depend on the JVM rules.
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.
Ok: sounds good. Thanks!
_MAVEN_NAMESPACE = "http://maven.apache.org/POM/4.0.0" | ||
_MAVEN_NAMESPACE_MAP = {"mvn": _MAVEN_NAMESPACE} | ||
|
||
|
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.
Hah, neat. Potentially related to #13684
Initial implementation for a codegen feature in the OpenAPI backend. This is based on the OpenAPI Generator tool, which supports many different languages.
At this point, only the Java sources are generated with no support to detect the runtime dependencies, which will be added as this PR progresses.Because the OpenAPI Java generator doesn't have a single JVM dependency, the inference of the runtime dependencies is based on parsing the generated Maven POM file. We use a simple sample OpenAPI spec file to do that as the runtime dependencies will always be the same regardless of what is the input given to the OpenAPI Java generator.