Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQ][Java][Spring] Add "@Deprecated" annotation to enum value in java code if enum value is deprecated in contract #19615

Open
jorgerod opened this issue Sep 18, 2024 · 0 comments

Comments

@jorgerod
Copy link
Contributor

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;
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant