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] Generate duplicated Java file (with number sufix) with incorrect class name #20372

Open
miruritira opened this issue Dec 24, 2024 · 0 comments

Comments

@miruritira
Copy link

miruritira commented Dec 24, 2024

Description

Generates 2 classes with compilation errors.

  • ExampleMYProperty.java and the class name is ExampleMYProperty
  • ExampleMyproperty0.java and the class name is ExampleMyproperty.

imagen

The property name "myproperty" collides with the name of the schema component: "Example_MYProperty"
With another property name, for example "amyproperty" it will work and it will create 2 Java files with correct class name:

  • ExampleAmyproperty.java
  • ExampleMYProperty.java

In versions <=7.8.0 it only creates one Java file with compilation error, the class name has the first 'y' in lower case.
ExampleMYProperty.java -->class name ExampleMyproperty

openapi-generator version

7.10.0 openapi-generator-maven-plugin

OpenAPI declaration file content or url
{
    "openapi": "3.0.1",
    "info": {
        "title": "Issue test case",
        "version": "1.0"
    },
    "paths": {
        "/api/test": {
            "post": {
                "tags": ["Tag1"],
                "operationId": "testOperation",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "*/*": {
                                "schema": {
                                    "$ref": "#/components/schemas/Example"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "Example": {
                "type": "object",
                "properties": {
                    "myproperty": {
                        "nullable": true,
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/Example_MYProperty"
                            }
                        ]
                    }
                }
            },
            "Example_MYProperty": {
                "type": "object",
                "properties": {
                    "dcliteral": {
                        "type": "string",
                        "nullable": true
                    }
                }
            }
        }
    }
}
Generation Details
Steps to reproduce

mvn clean generate-sources

<plugin>
  <groupId>org.openapitools</groupId>
  <artifactId>openapi-generator-maven-plugin</artifactId>
  <version>7.10.0</version>
  <executions>
    <execution>
      <goals>
        <goal>generate</goal>
      </goals>
      <configuration>
        <inputSpec>...</inputSpec>
        <generatorName>java</generatorName>
        <configOptions>
          <delegatePattern>true</delegatePattern>
          <interfaceOnly>true</interfaceOnly>
        </configOptions>
      </configuration>
    </execution>
  </executions>
</plugin>
@miruritira miruritira changed the title [BUG][JAVA] Description [BUG][JAVA] Generate duplicated Java file (with number sufix) with incorrect class name Dec 24, 2024
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