OpenAPITools / OpenAPITools/openapi-generator

[REQ] Configurable default enum value name

Open
#20,667 0 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

Is your feature request related to a problem? Please describe.

I often use the enumUnknownDefaultCase option. However, I don't love the default name of the enum, which is unknown_default_open_api. Naming is hard, and any default is likely to make someone unhappy. Being able to change the value would be a good feature to allow users who want a different default enum value or users who have a name collision with the existing default (as unlikely as that is) to use a value they choose.

Describe the solution you'd like

I'd like to make the default enum value name configurable, but leave the existing default so that users who like the current default can continue using it without any breakage.

I am willing to contribute a patch myself for this.

My preferred solution would be to make the existing value settable, and provide a new config option to set it.

I would like to leave the existing default value as it is so that nothing breaks for anyone currently using the default value.

Describe alternatives you've considered

  1. Not allowing configuration, which I've ruled out because I'd like to change it in my use case.
  2. Providing a Kotlin-specific configuration value (as I primarily use the Kotlin generator), which I've ruled out because this seems like a generic enough concept to apply to all generators that support default enums

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 reading the existing value in modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java. Trace how generator configuration options reach the default-enum handling, then check generators that support default enums. Done means the current name remains the default while users can configure an alternative name without breaking existing users.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.