[Java] Fix issue 22209 oneof pojo #23594
Open
Chhida wants to merge 3 commits intoOpenAPITools:masterfrom
Open
Conversation
… of abstract wrapper and ensure real POJO model is produced - Add useOneOfPojo option to generate real POJO classes for oneOf schemas instead of wrapper models - Override updateModelForComposedSchema() to restore original vars when option is enabled - Process the option in processOpts() method with default value false for backward compatibility fixes OpenAPITools#22209
0d98002 to
09ed65d
Compare
- Added bin/configs/java-jersey3-oneOf-pojo.yaml config with useOneOfPojo: true - Generated samples/client/petstore/java/jersey3-oneOf-pojo/ - Demonstrates how useOneOfPojo=true generates real POJO classes instead of wrapper models
Contributor
There was a problem hiding this comment.
7 issues found across 47 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="samples/client/petstore/java/jersey3-oneOf-pojo/src/main/java/org/openapitools/client/Configuration.java">
<violation number="1" location="samples/client/petstore/java/jersey3-oneOf-pojo/src/main/java/org/openapitools/client/Configuration.java:39">
P2: `AtomicReference.updateAndGet` callback invokes a potentially side-effectful supplier, which may run multiple times under contention.</violation>
</file>
<file name="samples/client/petstore/java/jersey3-oneOf-pojo/README.md">
<violation number="1" location="samples/client/petstore/java/jersey3-oneOf-pojo/README.md:18">
P2: README minimum Java version is incorrect for the Jersey 3.1 dependency baseline.</violation>
</file>
<file name="samples/client/petstore/java/jersey3-oneOf-pojo/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java">
<violation number="1" location="samples/client/petstore/java/jersey3-oneOf-pojo/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java:32">
P2: Custom deserializers are registered after `super.setupModule(context)`, so they may not be applied to the mapper during module registration.</violation>
</file>
<file name="samples/client/petstore/java/jersey3-oneOf-pojo/git_push.sh">
<violation number="1" location="samples/client/petstore/java/jersey3-oneOf-pojo/git_push.sh:42">
P2: The script checks for any remote instead of specifically checking for `origin`, which can cause pull/push failures when only non-`origin` remotes exist.</violation>
<violation number="2" location="samples/client/petstore/java/jersey3-oneOf-pojo/git_push.sh:48">
P2: Access token is embedded in the Git remote URL, risking plaintext secret exposure in `.git/config` and related tooling.</violation>
<violation number="3" location="samples/client/petstore/java/jersey3-oneOf-pojo/git_push.sh:57">
P2: `git push` failures can be masked because the script returns the pipeline/`grep` status instead of the push command status.</violation>
</file>
<file name="samples/client/petstore/java/jersey3-oneOf-pojo/src/main/java/org/openapitools/client/ApiClient.java">
<violation number="1" location="samples/client/petstore/java/jersey3-oneOf-pojo/src/main/java/org/openapitools/client/ApiClient.java:851">
P2: Form-urlencoded serialization overwrites accumulated parameters, causing only the last field to be sent.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Contributor
|
@Chhida I don't think the generated code will work. The inline oneOf complexifies the generation. This is simpler: The spring generator has an option For example: It generates: I would implement USE_DEDUCTION_FOR_ONE_OF_INTERFACES for the java generators:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #22209
PR checklist
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.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)Summary by cubic
Adds a
useOneOfPojooption to Java generators to emit real POJO classes for oneOf schemas instead of abstract wrapper models, fixing oneOf inheritance and serialization issues. Fixes #22209. Adds a Jersey3 sample and config to demonstrate the option.New Features
useOneOfPojo(default: false).updateModelForComposedSchema()to skip merging for oneOf and restore original vars; option handled inprocessOpts(); CLI option added; docs updated across Java generators.bin/configs/java-jersey3-oneOf-pojo.yamlandsamples/client/petstore/java/jersey3-oneOf-pojo/to validate output.Migration
--additional-properties useOneOfPojo=true(or set in config). No breaking changes by default.Written for commit 7830618. Summary will update on new commits.