swagger-api / swagger-api/swagger-codegen-generators

Property enumPropertyNaming is missing in swagger v3 generator options

Open
#1,172 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

In Swagger v2 there is a typescript language option to configure the enum name handling: enumPropertyNaming,
This options does not exist anymore in the v3 version.

My enum name contains an _ in the name which i want also have in the typescript enum name. That why i configure the
enumPropertyNaming=original

In Swagger v3 this _ will now be removed:

Example api json:

"components": {
  "schemas": {
      "Example": {
        "type": "string",
        "enum": [
          "CONST_NAME"
        ]
      }
   }
}

Actual:

export type Example = "CONST_NAME"
export const Example = {
    CONSTNAME: 'CONST_NAME' as Example
}

Expected (with enumPropertyNaming=original):

export type Example = "CONST_NAME"
export const Example = {
    CONST_NAME: 'CONST_NAME' as Example
}

See commit from v2 which adds this option: https://github.com/swagger-api/swagger-codegen/commit/a4e5eb732ae2d582013bfb75e1043bab54a19f04

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect the v2 change in commit a4e5eb732ae2d582013bfb75e1043bab54a19f04, then compare how v3 handles TypeScript generator options and enum names. Add support for enumPropertyNaming=original so underscores are retained in generated enum properties, and verify the output matches the issue's expected example.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.