swagger-api / swagger-api/swagger-codegen

config "enumPropertyNaming" not working as expected

Open
#12,385 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Enum are generated without underscore

expected output

export enum ActionLogTypeEnum {
    REGIMEN_CHANGE = 'REGIMEN_CHANGE',
    INSTRUCTION_CHANGE = 'INSTRUCTION_CHANGE',
    INSTANT_CHECKUP_DELETE = 'INSTANT_CHECKUP_DELETE',
    INSTANT_CHECKUP_TYPE_CHANGED = 'INSTANT_CHECKUP_TYPE_CHANGED'
}

actual output

export enum ActionLogTypeEnum {
    REGIMENCHANGE = 'REGIMEN_CHANGE',
    INSTRUCTIONCHANGE = 'INSTRUCTION_CHANGE',
    INSTANTCHECKUPDELETE = 'INSTANT_CHECKUP_DELETE',
    INSTANTCHECKUPTYPECHANGED = 'INSTANT_CHECKUP_TYPE_CHANGED'
}

Yaml File

Swagger-codegen version

3.0.55

Swagger declaration file content or url
openapi: 3.0.3
info:
  title: Test Schema
  version: 0.0.1
paths: {}
components:
  schemas:
    ActionLog:
      type: object
      properties:
        type:
          type: string
          enum:
            - REGIMEN_CHANGE
            - INSTRUCTION_CHANGE
            - INSTANT_CHECKUP_DELETE
            - INSTANT_CHECKUP_TYPE_CHANGED
Command line used for generation

java -jar ./swagger-codegen-cli.jar generate -i ./test/test.schema.yaml -l typescript-axios -o ./test --additional-properties modelPropertyNaming=original enumPropertyNaming=original

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

Reproduce the issue with test/test.schema.yaml using the stated swagger-codegen-cli command and the typescript-axios generator. Then trace how enumPropertyNaming=original is handled for generated enum member names. Done means the output preserves underscores in the generated TypeScript enum members as shown in the expected output.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.