acacode / acacode/swagger-typescript-api

Enum that are negatives(-) are generated with the same name as positives(+)

未關閉
#502 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
4.1k
分支
436
PR 合併指標
30 天內沒有已合併 PR

描述

# Problem

When you have an enum with negatives(-) values and positive(+) values with the same number:

![image](https://user-images.githubusercontent.com/5687655/224488478-18aaac96-ee4f-4fc1-abb7-427bfb7b7f78.png)

It produces an enum with the same name:

![image](https://user-images.githubusercontent.com/5687655/224488449-f00e5d7b-9c36-45e8-a8fd-95590ad402b8.png)

# Possible Solution

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

![image](https://user-images.githubusercontent.com/5687655/224488558-99849afe-5842-42df-9ec8-8575d828cac0.png)

# 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`

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。