OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA] Using microprofileRestClientVersion=3.0 generates a client which doesn't compile when used with Jakarta EE 9.1
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When generating a java client using microprofile REST client, I'm setting microprofileRestClientVersion=3.0. Microprofile REST client 3.0 is part of multiple versions of the microprofile spec. Here's a list of those microprofile spec versions, along with the version of the Jakarta EE spec they're compatible with:
Microprofile 5.0 (Jakarta EE 9.1)
Microprofile 6.0 (Jakarta EE 10)
The generated client makes use of Jakarta JSON binding to serialize and deserialize request and response objects. Jakarta EE 9.1 includes Jakarta JSON Binding 2.0. Jakarta EE 10 includes Jakarta JSON Binding 3.0.
The generated client makes use of the jakarta.json.bind.annotation.JsonbSubtype and jakarta.json.bind.annotation.JsonbTypeInfo annotations, which were introduced in Jakarta JSON Binding 3.0. This means that the generated client can not be used with Jakarta EE 9.1. This is a problem for me, as I need to generate a client that can be used with either Jakarta EE 9.1 or Jakarta EE 10. In this case, although there are API differences, they don't affect the compatibility of the generated client.
The generated code won't be able to compile at Jakarta EE 9.1 due to the use of classes above that aren't available at that spec level.
The sample project I've referenced doesn't actually require the jsonb polymorphism annotations, but they're still included as unused imports. This problem is equally relevant for generated code that does make use of the annotations. Simply removing the annotations where they're unused isn't going to fix this.
openapi-generator version
Problem exists from 7.11.0 up to and including 7.15.0-SNAPSHOT
OpenAPI declaration file content or url
Sample Maven project which reproduces the problem
Generation Details
Build the project with mvn clean install
Steps to reproduce
Build the referenced sample project with mvn clean install
Related issues/PRs
Suggest a fix
Introduced by this commit
From this PR
Is it possible to have an option which constrains the generated client to a particular microprofile specification version, rather than just the microprofileRestClient version, as other dependencies which are used can affect compatibility?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked sample Maven project and run mvn clean install to reproduce the Jakarta EE 9.1 compilation failure. Then inspect the referenced commit and PR that introduced the annotations and dependency behavior. Done means the generated client compiles with Jakarta EE 9.1 while remaining compatible with Jakarta EE 10, including cases that use JSON-B polymorphism.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100