Bug Report Checklist
Description
Given the following openapi spec: https://github.com/bvschaik/openapi-nonexistent-class-reproducer/blob/main/spec.json
- One definition of catName as string in CatFields, with title "Given name"
- One Cat with a name property that references CatFields/catName
- One definition of dogName as string in DogFields, also with title "Given name"
- One Dog with a nickname property that references DogFields/dogName
The issue: starting from the OpenAPI generator 7.23.0, this generates a Java Dog class with a property nickname of type DogName. The DogName class is not generated:
public class Dog {
@JsonbProperty("nickname")
protected DogName nickname = null;
...
}
In 7.22.0 and lower, the Dog class just has a nickname property of String:
public class Dog {
@JsonbProperty("nickname")
protected String nickname;
...
}
Observations:
- If I change the title of either of the field definitions, the issue is not there.
- If I change the type of one of the fields to for example integer, the issue is not there.
Conclusion:
If there are two field definitions with the same type and the same title, the OpenAPI generator will generate code using non-existent classes for one of them.
openapi-generator version
Tested and breaks in: 7.23.0, 7.25.0, latest master
This is a regression: it works fine in 7.22.0
OpenAPI declaration file content or url
https://github.com/bvschaik/openapi-nonexistent-class-reproducer/blob/main/spec.json
Generation Details
Use any typed language (tested with Java, Kotlin):
java -jar openapi-generator.jar generate -g java -i https://raw.githubusercontent.com/bvschaik/openapi-nonexistent-class-reproducer/refs/heads/main/spec.json
Steps to reproduce
- Generate spec using command above
- Inspect the Cat and Dog classes - Dog has a property of type DogName, which doesn't exist
- Compile the code - fails
Related issues/PRs
Might be related to: #24004
Suggest a fix
Bug Report Checklist
Description
Given the following openapi spec: https://github.com/bvschaik/openapi-nonexistent-class-reproducer/blob/main/spec.json
The issue: starting from the OpenAPI generator 7.23.0, this generates a Java Dog class with a property nickname of type DogName. The DogName class is not generated:
In 7.22.0 and lower, the Dog class just has a nickname property of String:
Observations:
Conclusion:
If there are two field definitions with the same type and the same title, the OpenAPI generator will generate code using non-existent classes for one of them.
openapi-generator version
Tested and breaks in: 7.23.0, 7.25.0, latest master
This is a regression: it works fine in 7.22.0
OpenAPI declaration file content or url
https://github.com/bvschaik/openapi-nonexistent-class-reproducer/blob/main/spec.json
Generation Details
Use any typed language (tested with Java, Kotlin):
java -jar openapi-generator.jar generate -g java -i https://raw.githubusercontent.com/bvschaik/openapi-nonexistent-class-reproducer/refs/heads/main/spec.jsonSteps to reproduce
Related issues/PRs
Might be related to: #24004
Suggest a fix