Skip to content

[BUG] [Java-Spring] Required-Fields-Constructor has wrong super call when using multiple inheritance layers #15825

@JanLubenow

Description

@JanLubenow

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

Given a model with multiple inheritance levels and required parameters on each level of inheritance, the super calls in the constructor has the wrong order.

Given the sample below without the fix:

//SubType extends IntermediateSubType
  public SubType(TypeEnum type, SchemaVersion schemaVersion, UUID id, Boolean oneBoolean, Boolean someBoolean, SomeEnum someEnum) {
    super(someBoolean, someEnum, oneBoolean, schemaVersion, id);
    this.type = type;
  }

...

  public IntermediateSubType(Boolean someBoolean, SomeEnum someEnum, SchemaVersion schemaVersion, UUID id, Boolean oneBoolean) {
    super(oneBoolean, schemaVersion, id);
    this.someBoolean = someBoolean;
    this.someEnum = someEnum;
  }
openapi-generator version

First occured in Openapi-Generator 6.5.0. Still in current master

OpenAPI declaration file content or url

https://github.com/JanLubenow/openapi-generator/blob/1d39efec7e3e9f6a09b23b40236211ce0cec9705/modules/openapi-generator/src/test/resources/bugs/issue_constructor-required-values-with-multiple-inheritance.yaml

Generation Details

See https://github.com/JanLubenow/openapi-generator/blob/1d39efec7e3e9f6a09b23b40236211ce0cec9705/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java#L394

Used generator: Spring
Library: Spring Boot

Steps to reproduce

Run linked testcase without bugfix in SpringCodeGen.java

Related issues/PRs

#15796 (but addresses other issues in this area)

Suggest a fix

see #15827

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