OpenAPITools / OpenAPITools/openapi-generator
[REQ][Java][Spring] Add "@Deprecated" annotation to enum value in java code if enum value is deprecated in contract
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
I would like to propose an improvement for the generated java sources based on the API contract.
I think it would be very interesting to give the possibility to add the @Deprecated annotation to an enum value.
Describe the solution you'd like
For this, you could add a new extension, e.g. x-deprecated and add the value to deprecated.
SaleBasePeriodType:
type: string
enum:
- ACCUMULATED_CAMPAIGN
- YESTERDAY
- FISCAL_YEAR
- LAST_FISCAL_YEAR
x-deprecated: # new custom extension
- ACCUMULATED_CAMPAIGN
Desired code:
public enum SaleBasePeriodTypeDTO {
@Deprecated // <- annotation added
ACCUMULATED_CAMPAIGN("ACCUMULATED_CAMPAIGN"),
YESTERDAY("YESTERDAY"),
FISCAL_YEAR("FISCAL_YEAR"),
LAST_FISCAL_YEAR("LAST_FISCAL_YEAR");
private String value;
SaleBasePeriodTypeDTO(String value) {
this.value = value;
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Java/Spring enum-generation entry point and how API contract extensions are read for enum values. Confirm the generated enum output for the proposed x-deprecated values, then identify or add the relevant generator tests; done means deprecated contract values receive @Deprecated while other values remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100