You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[REQ] Add @Generated annotation to EnumConverterConfiguration for JavaSpring generator #23923
Is your feature request related to a problem? Please describe.
When using the spring generator (JavaSpring), the supporting file EnumConverterConfiguration.java is generated without the @Generated annotation. All other generated files (models, API interfaces, delegate interfaces, etc.) are correctly annotated with @Generated via the generatedAnnotation partial. This inconsistency means tools that use @Generated to skip static analysis, formatting, or coverage checks (e.g., Checkstyle, JaCoCo, SonarQube) will incorrectly process EnumConverterConfiguration as hand-written code.
Describe the solution you'd like
Update modules/openapi-generator/src/main/resources/JavaSpring/converter.mustache to include:
The jakarta.annotation.Generated import (using {{javaxPackage}}):
import {{javaxPackage}}.annotation.Generated;
The {{>generatedAnnotation}} partial before the class declaration, consistent with pojo.mustache, api.mustache, etc.:
{{>generatedAnnotation}}
@Configuration(value = "{{configPackage}}.enumConverterConfiguration")
public class EnumConverterConfiguration {
Overriding converter.mustache locally in each project — works but requires every consumer to maintain a copy and track upstream changes manually.
Additional context
The issue affects at least the JavaSpring generator (spring generator name). Other generators with a similar converter.mustache (e.g., java-micronaut-server) may be affected too.
pojo.mustache, api.mustache, and apiDelegate.mustache all already use {{>generatedAnnotation}} as a reference for the correct pattern.
generatedAnnotation.mustache (the partial) already exists and handles the hideGenerationTimestamp flag correctly.
Why this matters: static analysis tools skip @Generated code
Tools like SonarQube, JaCoCo, Checkstyle, and SpotBugs have built-in support to automatically exclude classes annotated with @Generated from their analysis. This is the intended mechanism for distinguishing generated code from hand-written code.
Without @Generated on EnumConverterConfiguration, these tools treat it as regular source code, which leads to:
SonarQube: reports issues (code smells, coverage gaps) on code that developers cannot and should not modify.
JaCoCo: counts uncovered lines in EnumConverterConfiguration against the project's coverage threshold, potentially failing the build for code that is not hand-written.
Checkstyle / formatting tools: flag style violations in generated code, forcing projects to add explicit exclusion rules for this specific file.
Adding @Generated aligns EnumConverterConfiguration with all other generated files and allows these tools to correctly ignore it out of the box, without requiring per-project workarounds.
Activity
jorgerod commentedon Jun 2, 2026
Why this matters: static analysis tools skip
@GeneratedcodeTools like SonarQube, JaCoCo, Checkstyle, and SpotBugs have built-in support to automatically exclude classes annotated with
@Generatedfrom their analysis. This is the intended mechanism for distinguishing generated code from hand-written code.Without
@GeneratedonEnumConverterConfiguration, these tools treat it as regular source code, which leads to:EnumConverterConfigurationagainst the project's coverage threshold, potentially failing the build for code that is not hand-written.Adding
@GeneratedalignsEnumConverterConfigurationwith all other generated files and allows these tools to correctly ignore it out of the box, without requiring per-project workarounds.Chrimle commentedon Jul 2, 2026
Yep, known issue: #23832 #23863
It's a hassle to implement, due to how many java generators there are...