[BUG][JAVA] Deprecated properties only get @Deprecated on the getter (base, feign, native, microprofile)

Open Beginner friendly
#25,567 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Inf1mum is already working on this.

Since Nov 10, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
tooling

Research direction

Read the listed Java POJO templates: Java/pojo.mustache and the feign, native, and microprofile variants under Java/libraries; compare their deprecation handling with okhttp-gson. Then inspect JavaClientCodegenTest for the relevant generated-code tests. Done means deprecated properties annotate the field, getter, setter, and fluent setter in each listed template, with tests covering the generated output.

Written by the indexing model from the issue text.

Description

Issue: Bug
Description

If a property is marked deprecated: true, the Java client only puts @Deprecated on the getter.
The field, setter and fluent setter don't get it, so you only get a compiler warning when reading
the value, not when setting it:

private String name;                          // no @Deprecated

public Pet name(String name) { ... }          // no @Deprecated

@Deprecated
public String getName() { ... }

public void setName(String name) { ... }      // no @Deprecated

I'd expect all of them to be annotated, the way okhttp-gson does it since #15287 (#15286).
jersey2 and jersey3 do it too. These templates still don't:

  • Java/pojo.mustache (e.g. resttemplate, webclient)
  • Java/libraries/feign/pojo.mustache
  • Java/libraries/native/pojo.mustache
  • Java/libraries/microprofile/pojo.mustache

Checked with 7.27.0 and current master.

The same thing was reported for JavaSpring in #24704 (PRs #24705, #24762).

Question

Was there a reason these were left out of #15287, or did they just get missed? If it's the
latter, I'm happy to open a PR that does the same as #15287 for the templates above and adds
tests to JavaClientCodegenTest.

Dominant language
Java
Stars
26.9k
Forks
7.8k
Avg merge
2d 23m
Merged PRs (30d)
177

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

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.

More from OpenAPITools/openapi-generator

All issues in OpenAPITools/openapi-generator

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.