Enum that are negatives(-) are generated with the same name as positives(+)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- openapi, typescript
Research direction
Look at the enum generation code, likely in a file handling enum extraction or name transformation. The issue shows that negative numbers in enums need to be parsed to include an underscore (e.g., '-1' becomes '_1') to avoid name collisions. Start by searching for 'enum' or 'generate' in the codebase, then run the reproduction steps to see the current output and test a fix.
Written by the indexing model from the issue text.
Description
Problem
When you have an enum with negatives(-) values and positive(+) values with the same number:

It produces an enum with the same name:

Possible Solution
For generating names in Enums function need to parse the "-" to a "_" character, it will generate something like this:

Steps to reproduce
- Create a swagger api with enums with a negative and a positive number (with the same number Ex: -1,1 or -2,2 or -3,3 or so on)
- Run the command:
npx swagger-typescript-api -p http://localhost/api-json --extract-enums - The generated enum will have the same name for both
-1 and 1
- Dominant language
- TypeScript
- Stars
- 4.1k
- Forks
- 436
- Avg merge
- 9d 7h
- Merged PRs (30d)
- 3
Contributor guide
No contributing guide indexed for this repository
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.
More from acacode/swagger-typescript-api
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
acacode/swagger-typescript-api#1821 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
acacode/swagger-typescript-api#1638 · 3 comments · 10 reactions ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
acacode/swagger-typescript-api#1237 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
acacode/swagger-typescript-api#1146 · 3 comments ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
acacode/swagger-typescript-api#988 · 1 comment · 1 reaction ·
All issues in acacode/swagger-typescript-api
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100