Skip to content

[BUG] [JAVA] Inheritance: required param of child not correct #13158

@patpattypat

Description

@patpattypat
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions