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

Open
#988 1 comment 1 reaction 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
4.1k
Forks
436
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.