OpenAPITools / OpenAPITools/openapi-generator
[REQ] Allow quotes string as enum paramter names, or ensure unique names
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.
using the typescript-fetch generator...
I am using Django Rest Framework to create my API. Its common practice to use an OrderingFilter to define fields and values that you specify to sort your results by.
order = OrderingFilter(
fields=(
("id", "id"),
("name", "name"),
("status", "status"),
)
)
the api then will expect the following values:
Available values : -id, -name, -status, id, name, status
The typescript-fetch generator will generate the following enum in typescript:
export enum ListOrderEnum {
Id = '-id',
Name = '-name',
Status = '-status',
Id = 'id',
Name = 'name',
Status = 'status'
}
The minus sign is lost in the enum property names ( creating duplicate names ). I need to manually rename the property names. I use quotes to properly rename them, for example: '-Status' = '-status'
Describe the solution you'd like
Add an option that will allow the enum parameter name to be quoted strings, or that otherwise preserves the '-' in some other way.
Describe alternatives you've considered
something like 'ensureUniqueParams' but 'enumUniquePropertyNaming' that otherwise renames duplicate values. The '-' sign's signaling that this is a descending order parameter in the sort function might be lost, but at least my code would compile.
I
Additional context
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 typescript-fetch generator code that derives enum property names, then reproduce the issue with enum values such as -id and id from the reported Django REST Framework example. Done means generated TypeScript enum members are valid and unique while preserving the distinction between ascending and descending values, with regression coverage for the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100