OpenAPITools / OpenAPITools/openapi-generator

[REQ] [Java] Add annotation Generated in Enum

Open Beginner friendly
#23,832 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Within a Java/Quarkus project, I generate models from a YAML, using this openapi-generator-maven-plugin (version 7.22.0).
In POJOs, there's annotation @jakarta.annotation.Generated. But Enum don't have this one

My issue is with plugin ErrorProne, there's a flag available XepDisableWarningsInGeneratedCode, which allows us to ignore warnings triggered by generated code. ErrorProne.info
But since my generated Enums don't have this annotation, Warnings are triggered

I can add annotation @Generated in openapi-generator-maven-plugin with the additionalEnumTypeAnnotations

I'm wondering why generated Enum don't have this annotation by default, like POJOs ?

See there : https://github.com/OpenAPITools/openapi-generator/blob/fd651513978c5f2ac7028caee9c5caa841d0b6c1/modules/openapi-generator/src/main/resources/JavaSpring/enumClass.mustache for a correction, to use generatedAnnotation ? I'm not familiar with "mustache" language

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with modules/openapi-generator/src/main/resources/JavaSpring/enumClass.mustache and inspect how generatedAnnotation is used in the template. Generate a JavaSpring model containing an enum and verify that the resulting enum includes jakarta.annotation.Generated, while preserving the existing POJO behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.