OpenAPITools / OpenAPITools/openapi-generator
[BUG] [JAVA] Inheritance: required param of child not correct
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
If child defines a parameter as required but parent does not have it as required, it generates a new parameter for the child (name shadowing).
openapi-generator version
6.0.1 (using java)
Generation Details & Steps to reproduce
e.g. with a yaml similar to this:
parent:
properties:
param:
type: string
child:
allOf:
$ref: 'parent'
type: object
required:
param
Then the child class has its own attribute 'param' and does not inherit from parent (neither the attribute nor its getter and setter). Hence inheritance is not done properly.
Expected Behavior
I expect the child class to inherit the 'param' and its setter and getter from the parent.
Suggest a fix
I think the 'pojo.mustache' need the {{isInherited}} to call super in those cases.
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 by reproducing the issue with the YAML example and inspect the Java generator's pojo.mustache template, particularly the isInherited handling. Done means the child reuses the parent's param attribute, getter, and setter instead of generating shadowing members.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100