swagger-api / swagger-api/swagger-codegen

[typescript-angular] not generating enums as enum type

Open
#10,875 4 comments 5 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

I have an enum in my swagger scheme, but after generating the typescript-angular client with swagger codegen, the generated 'enum' looks like below:

image

The generator should use the typescript enum type instead of creating a custom object.

Swagger-codegen version

2.4.17

Swagger declaration file content or url

https://pastebin.com/h9MK0NEQ

Command line used for generation

java -jar swagger-codegen-cli.jar generate -i http://localhost:54371/swagger/v1/swagger.json -l typescript-angular -o .

Steps to reproduce

Generate angular-typescript client with the swagger declaration file

Related issues/PRs

/

Suggest a fix/enhancement

/

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

Start by running the supplied swagger-codegen CLI command with the linked Swagger declaration and the typescript-angular generator. Inspect the generated client model containing the enum and trace the generator templates or entry points responsible for its representation. Done means the generated output uses a TypeScript enum type and remains reproducible from the provided declaration.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.