Repository navigation
Conversation
A oneOf interface whose discriminator is an inline enum declared the getter but not the enum, while each implementor declared its own copy. The interface did not compile. The interface now declares the enum and the implementors reuse it. Fixes OpenAPITools#25398
There was a problem hiding this comment.
All reported issues were addressed across 15 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
|
@cpruijsen Thanks for this PR. As I'm only interested at a fix for java and Spring, your PR is probably simpler. You update AbstractJavaCodegen so the implementation should be valid for all java generators. |
|
Thanks! java/oneof_interface already includes |
Fixes #25398
A oneOf interface whose discriminator is an inline enum declared
PetTypeEnum getPetType()without declaringPetTypeEnum. Each implementor declared a separate nested enum. The interface did not compile, and the implementor enums could not satisfy its getter.The interface now declares the inline enum, and implementors reuse the inherited nested type.
Changes:
AbstractJavaCodegenkeeps interface-owned inline enums and clearsisEnumon interface properties collected from implementors. It also clears the flag on discriminator copies pushed into implementors. The [REQ] [Java] Allow excluding discriminator property from generated models #24769 implementor-owned case is unchanged. Groovy is excluded because it does not render Java oneOf interfaces.isEnumandisDiscriminatorare set. JAX-RS also renders the required Jackson, JSON-B, or XML imports.isInnerEnum, so copied properties retain their enum type and values afterisEnumis cleared.bugs/issue_25398.yaml. No new vendor extension is added.Implementation choice: shared Java post-processing covers every Java interface template. A Spring-only pass would be smaller but would leave the same defect in Java, JAX-RS Spec, and Micronaut. Repairing the pre-existing class-based oneOf hierarchy in native,
okhttp-gson, Jersey, and Helidon is outside this change.Checks:
checkstyle:check:BUILD SUCCESS.javac. JAX-RS also type-checks with JSON-B and XML.PetTypeEnumis missing.Dog.mdretain the enum type and values.PR checklist
Read the contribution guidelines.
Run the following to build the project and update samples:
(For Windows users, please run the script in WSL)
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.
I ran
./bin/generate-samples.sh ./bin/configs/*.yamland./bin/utils/export_docs_generators.shwith this change. Neither changed a committed file, so the PR has no sample changes.If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
@bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @martin-mfg @KannaKim (Java)
@cachescrubber @welshm @MelleD @atextor @manedev79 @javisst @borsch @banlevente (Java Spring)