Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
5 of 6 tasks
JanLubenow opened this issue Jun 13, 2023 · 0 comments

Comments

@JanLubenow
Copy link
Contributor

JanLubenow commented Jun 13, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant