Skip to content

[BUG] [JAVA] Deduplication feature in 7.23 breaks existing code #24004

@pe-st

Description

@pe-st

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • 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

A schema with two structural identical properties is generated differently with 7.22 and 7.23

Might be related/introduced by #23856

                "schema": {
                  "type": "object",
                  "properties": {
                    "abc": {
                      "type": "object",
                      "description": "first container",
                      "properties": {
                        "result": {
                          "type": "string",
                          "description": "ABC Result"
                        }
                      }
                    },
                    "def": {
                      "type": "object",
                      "description": "second container",
                      "properties": {
                        "result": {
                          "type": "string",
                          "description": "DEF Result"
                        }
                      }
                    }
                  }
                }

7.22 generates basically this class

public class ApiGetDefaultResponse {
  private ApiGetDefaultResponseAbc abc;
  private ApiGetDefaultResponseDef def;

but 7.23 (or 7.24-snapshot) generates

public class ApiGetDefaultResponse {
  private ApiGetDefaultResponseAbc abc;
  private ApiGetDefaultResponseAbc def;

Note the field def is of type ApiGetDefaultResponseAbc which breaks code that expects ApiGetDefaultResponseDef

openapi-generator version

7.23 ; with 7.22 it works fine

OpenAPI declaration file content or url

https://raw.githubusercontent.com/pe-st/openapi-generator-deduplicate/refs/heads/main/src/main/resources/openapi.json

Generation Details

https://github.com/pe-st/openapi-generator-deduplicate contains a project with maven plugin configuration and Java code using the generated code, using the JAVA generator

Steps to reproduce

mvn package in the provided reproducer repository fails to compile when using 7.23 instead of 7.22

Related issues/PRs

#23856

Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions