-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
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
After upgrading to OpenAPI Generator 7.11.0, a regression has been introduced that affects custom generators extending SpringCodegen (info about custom generators).
When generating models, the import for org.springframework.lang.Nullable is not being added, even though the annotation is used in the generated code. This results in compilation errors out of the box.
This is a breaking change introduced in a minor version, which violates semantic versioning expectations. Custom generators that previously worked are now broken after upgrading, without any clear migration notes or warnings.
openapi-generator version
7.11.0
✅ Expected Behavior
Generated code should include the necessary import for org.springframework.lang.Nullable and compile without issues.
❌ Actual Behavior
The generated code uses @Nullable, but the import is missing, leading to compilation errors.
Steps to reproduce
- Create a custom generator that extends
org.openapitools.codegen.languages.SpringCodegen. - Generate model classes with nullable properties.
- Try to compile the generated output.
Workaround
As a temporary workaround, add this override method in your custom generator:
@Override
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
super.postProcessModelProperty(model, property);
model.imports.add("Nullable");
}