OpenAPITools / OpenAPITools/openapi-generator
[REQ] Enable to Set null to enum value
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.
Hello. We're using openapi-generator for defining our interface.
We want to allow null to enum values.
animal:
type: string
nullable: true
enum:
- "1"
- "2"
- null
x-enum-varnames:
- "CAT"
- "DOG"
- "HORSE"
generated code
enum class Animal(val value: kotlin.String) {
@JsonProperty("1") CAT("1"),
@JsonProperty("2") DOG("2"),
@JsonProperty("null") HORSE("null"),
}
Describe the solution you'd like
we want something like
enum class Animal(val value: kotlin.String) {
@JsonProperty("1") CAT("1"),
@JsonProperty("2") DOG("2"),
@JsonProperty(null) HORSE(null),
}
Describe alternatives you've considered
replace "null" to null by hand...
Additional context
If this feature can be supported, I am eager to make pull request
(however, I'm not sure where to fix by now...)
Thanks.
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 tracing how the OpenAPI schema's nullable enum is represented during Kotlin enum generation. Compare the requested generated Kotlin output with the current handling of the null enum value, then add coverage for the provided Animal schema and verify that the generated annotation and enum value preserve null rather than the string "null".
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, openapi
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100