Skip to content

[BUG][JAVA] Generated object has no properties of intermediate parents #9738

@abelan

Description

@abelan

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Version 4.3.1 generates inherited classes. So D extends C extends B extends A.
But there is no more inheritance as I understood.
So I expect that

  • D has properties of C, B, A (first, second, third, fourth)
  • C - B and A (first, second, third)

But they get properties of the root class A only

  • D: first, fourth
  • C: first, third

I'm able to fix it with to following markup

C:
  allOf:
    - $ref: '#/components/schemas/B'
    - type: object
      properties:
        third:
          type: string

but extra C[B]AllOf.java classes are generated.

openapi-generator version

5.1.1

OpenAPI declaration file content or url
openapi: 3.0.2
info:
  title: Example
  version: 0.0.1
servers:
  - url: https://myserver
paths:
  /go:
    post:
      tags:
        - GO
      operationId: go
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                shortObject:
                  $ref: '#/components/schemas/B'
                longObject:
                  $ref: '#/components/schemas/D'
      responses:
        200:
          description: OK
components:
  schemas:
    A:
      type: object
      properties:
        first:
          type: string
    B:
      allOf:
        - $ref: '#/components/schemas/A'
      type: object
      properties:
        second:
          type: string
    C:
      allOf:
        - $ref: '#/components/schemas/B'
      type: object
      properties:
        third:
          type: string
    D:
      allOf:
        - $ref: '#/components/schemas/C'
      type: object
      properties:
        fourth:
          type: string
Generation Details

Gradle Plugin
generatorName = 'spring'

Steps to reproduce

Run the gradle task with the given yaml

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