OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA] Generate duplicated Java file (with number sufix) with incorrect class name
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
Generates 2 classes with compilation errors.
- ExampleMYProperty.java and the class name is ExampleMYProperty
- ExampleMyproperty0.java and the class name is ExampleMyproperty.
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>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided mvn clean generate-sources reproduction with the Java generator and inspect the generated files and class names for the Example and Example_MYProperty schemas. Done means the generator produces compilable Java files with matching class and filename names, while the existing amyproperty case remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100