title: Nested property inheritance in OpenAPI Generator/Swagger Codegen
body: <p>I'm trying to generate Java models using a Swagger schema provided to me by a third-party company, but generation either fails or does not produce the objects I expect. I'm not sure if it's the generator or the schema that's the problem.</p>
  <p>Essentially, the schema has a parent object Pet with a property &quot;attributes,&quot; where &quot;attributes&quot; has a property &quot;size&quot;. The schema also has a child object Cat that &quot;inherits&quot; from Pet (references Pet in the 'allOf' statement) and itself has a property &quot;attributes&quot; with nested property &quot;whiskerCount&quot;.</p>
  <pre class="lang-yaml prettyprint-override"><code>Cat:
    allOf:
        - $ref: '#/definitions/Pet'
        - type: object
          properties:
            attributes:
              type: &quot;object&quot;
              properties:
                weight:
                  type: &quot;string&quot;
  Pet:
    type: &quot;object&quot;
    properties:
      attributes:
        type: &quot;object&quot;
        properties:
          whiskerCount:
            type: &quot;integer&quot;
            format: &quot;int64&quot;
  </code></pre>
  <p>When using the Swagger editor (2.0), the UI model shows the result that the company that provided me the schema is trying to achieve:</p>
  <pre><code>Cat {
      attributes  {
          whiskerCount    integer($int64)
          weight          string
  </code></pre>
  <p>However, when attempting to generate models, the results are:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Generator</th>
  <th>Result</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Swagger Codegen (2.2.1)</td>
  <td>Generation fails: <code>getAttributes() in Cat cannot override getAttributes() in Pet</code> (return types incompatible)</td>
  </tr>
  <tr>
  <td>OpenAPI Generator (4.3.1, 5.0.0, 5.1.0)</td>
  <td>Generation succeeds, but generates classes 'Cat.java', 'CatAllOf.java', 'CatAllOfAttributes.java', 'Pet.java', 'PetAttributes.java'. Cat#attributes (type CatAllOfAttributes) contains only 'whiskerCount' and Pet#attributes (type PetAttributes) contains only 'size')</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Is there a way to achieve a 'combined' Attributes object (member variable of Cat) that contains both fields whiskerCount and size?</p>