acacode / acacode/swagger-typescript-api

Bug in enum keys generation: underscores should not be removed if enum value contains digits. E. g. for value `AMAZON_S3` generated key `AMAZONS3` is wrong

オープン
#988 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る
bug
主要言語
TypeScript
スター
4.1k
フォーク
436
PR マージ指標
30日以内にマージされた PR はありません

説明

For example, this enum definition

```json
[
//...
"foo.bar.StorageType": {
"description": "this enum contains available object storages",
"type": "string",
"default": "ORACLE_OBJECT_STORAGE",
"enum": [
"ORACLE_OBJECT_STORAGE",
"AMAZON_S3",
]
},
//...
]
```

is transformed into

```typescript
export enum FooBarStorageTypeDto {
ORACLE_OBJECT_STORAGE = "ORACLE_OBJECT_STORAGE",
AMAZONS3 = "AMAZON_S3",
}
```

Please notice `AMAZONS3`. The key should be `AMAZON_S3`, but the underscore is being removed.

It happens because of [this regexp](https://github.com/acacode/swagger-typescript-api/blob/main/src/type-name-formatter.ts#L35), `AMAZON_S3` doesn't match it. I guess the regexp should be changed in order to support names with digits.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。