Skip to content

[BUG][JAVA] Model generated from allOf is unusable when combining $ref and inline schema (regression from 7.1.0) #17534

@mthmulders

Description

@mthmulders

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

In an OpenAPI specification where schema components use allOf to combine a $ref with inline properties, openapi-generator generates Java classes that

  • cannot be parsed from JSON that adheres to the schema
  • cannot be instantiated to construct values that would adhere to the schema
openapi-generator version

This issue popped up when Renovate suggested an upgrade from openapi-generator 7.1.0 to 7.2.0. I therefor believe it is a regression in 7.2.0.

OpenAPI declaration file content or url

Full spec included in the attached test-sdk.zip. I believe the relevant part is this:

    MyResponseType:
      type: object
      allOf:
        - $ref: "#/components/schemas/MyBaseType"
        - properties:
            someProperty:
              type: string
              nullable: true
              allOf:
                - $ref: "#/components/schemas/StringBaseType"
Generation Details
Steps to reproduce
  • Unpack the attached test-sdk.zip
  • Run the following commands inside the test-sdk directory:
     mvn clean
     mvn generate-sources -Dopenapi-generator.version=7.1.0 -DpackageName=v710
     mvn generate-sources -Dopenapi-generator.version=7.2.0 -DpackageName=v720
     mvn verify

This generates two OpenAPI client in the same output directory (one with v7.1.0, one with v7.2.0). The ExampleTest illustrates the problem with the code that gets generated by v7.2.0.

Related issues/PRs
Suggest a fix

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