OpenAPITools / OpenAPITools/openapi-generator

How could I add custom annotation @Generator or other annotation to all class in Java

Open
#9,752 5 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

I want to add custom annotation to all classes that is generated by openapi. Something like @Generated so Jacoco can exclude those classes. Currently generator does support adding annotation to model classes but I want to add it all the classes. I do see @javax.annotation.Generated on all classes but the retention policy is SCOPE so jacoco is not able to exclude those classes from the report.
Is there any functionality like this additionalModelTypeAnnotations: '@lombok.Generated' that supports adding annotations to all classes?

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 by reviewing how additionalModelTypeAnnotations is handled and how @javax.annotation.Generated is emitted across generated classes. Compare model generation with the other generated class types and determine how a configurable annotation could apply to all of them. Done means the requested annotation is consistently emitted and Jacoco can exclude the generated classes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.